centos6/7安装nfs-server

centos6/7安装nfs-server脚本

#!/bin/sh
set -e

#define vars
share_dir=${1:-/servyou/nfs_root}
ip_limit=${2:-*}

#judge centos6/7
if ! (uname -r |egrep "el6|el7" >/dev/null); then
    echo "current system not support!"
    exit 9
fi

#judge run user
if [ $UID -ne 0 ]; then
    echo "please execute script by root!"
    exit 9
fi

if ! (getent passwd weblogic >/dev/null); then
    echo "please add weblogic user!"
    exit 9
fi

#nfs-server install
yum -q install -y nfs-utils rpcbind

#create share_dir && configure
if [ ! -e ${share_dir} ]; then
    mkdir -p $share_dir  && echo "create share_root success!"
    chown -R weblogic: $share_dir
    chmod a+w $share_dir
fi

tee <<EOF >/etc/exports
${share_dir} ${ip_limit}(rw,sync,no_root_squash)
EOF

#start nfserver
if (uname -r |grep -q el7); then
    systemctl enable rpcbind --now && systemctl enable nfs --now
else
    service rpcbind restart
    service nfs restart
    chkconfig rpcbind on && chkconfig nfs on 
fi 

#testing
exportfs -rv  && showmount -e localhost

使用说明

2021年9月13日 18:45:04
使用环境:
centos6/7及基于此的发型系列
yum在线

使用限制:
weblogic作为挂在使用用户,cliet/server uid/gid 一致
执行账户root初始化nfs_server

脚本解读:
./install_nfs_server.sh  //default
./install_nfs_server.sh  nfs_root  ip_limit

参数说明
nfs_root:
nfs共享目录,权限weblogic,默认/servyou/nfs_root
ip_limit:
nfs-client ip访问控制,默认*不做控制  10.10.10.*   172.*

nfs-client使用需要安装nfs-utils
yum install -y nfs-utils

mount -t nfs 172.24.20.20:/opt/nfs_root /mnt   //remote mount
touch /mnt/sb && rm -rf /mnt/* 
umount /mnt

注意:
centos6/7默认添加weblogic的uid/gid不同会导致权限映射不出用户名
weblogic uid/gid 要一致才可以显示为用户名

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值