
一、服务端操作
1、安装nfs并建立用户
yum -y install nfs* #检查安装情况 rpm -qa |grep nfs rpm -qa |grep rpcbind #新建用户 useradd -u 555 heat groupmod -g 556 heat
2、新建要共享的目录/duizhang
mkdir /duizhang
3、配置nfs
vim /etc/exports 输入如下内容: /duizhang 192.168.1.0/24(rw,sync,all_squash,anonuid=555,anongid=555) /duizhang是要共享目录 192.168.1.0/24是运行访问的ip段 all_squash:保证所有用户都能压缩成一个用户。 anonuid=555和anongid=555:指定每个用户下都有并且存在的。 rw 表示该主机对该共享目录有读写权限 sync 表示资料同步写入到内存与硬盘中
4、控制nfs,rpcbind起停
启动nfs systemctl start nfs 启动rpcbind systemctl start rpcbind 将nfs加入自启 systemctl enable nfs 将rpcbind加入自启 systemclt enable rpcbind 停止服务命令 systemctl stop rpcbind systemctl stop rpcbind.socket systemctl stop nfs
二、客户端操作
1、安装NFS程序
yum -y install nfs*
2、控制nfs、rpcbind起停
启动nfs systemctl start nfs 启动rpcbind systemctl start rpcbind 将nfs加入自启 systemctl enable nfs 将rpcbind加入自启 systemclt enable rpcbind 停止服务命令 systemctl stop rpcbind systemctl stop rpcbind.socket systemctl stop nfs
3、创建挂载目录
mkdir /duizhang
4、查看是否共享成功
#192.168.1.25是服务端ip showmount -e 192.168.1.25
5、网络挂载
mount -t nfs -o nolock 服务端IP:共享目录绝对路径 本地挂载目录
mount -t nfs -o nolock 192.168.1.25:/duizhang /duizhang
6、查看是否成功
df -Th
7、卸载网络磁盘
umount /duizhang 或 umount 192.168.1.25:/duizhang
8、开机自动挂载
sed -i '$amount -t nfs -o nolock 192.168.1.25:/duizhang /duizhang' /etc/rc.d/rc.local chmod +x /etc/rc.d/rc.local