配置nfs文件共享

配置nfs文件共享
服务端:192.168.10.100
客户端:192.168.8.88
一、服务端配置:
1、如果没有安装的话执行
yum    install   nfs-utils    -y
 
2、启动服务
centos6
/etc/init.d/rpcbind start 先启动rpcbind服务
/etc/init.d/nfs start 再启动nfs服务
 
centos7
systemctl start rpcbind 先启动rpcbind服务
systemctl start nfs 再启动nfs服务
3、设置开机启动
centos6
chkconfig --level 35  nfs on         nfs服务开机启动
chkconfig --level 35 rpcbind on    rpcbind服务开机启动
chkconfig --list nfs                 查看nfs开机启动列表
chkconfig --list rpcbind             查看rbcbind开机启动列表
 
centos 7
systemctl enable rpcbind 先启动rpcbind服务
systemctl enable nfs  启动nfs服务
 
4.创建同步文件夹
mkdir -p /var/www/html/img
chown -R nfsnobody:nfsnobody /var/www/html/img 更改所属组
 
5.编辑nfs挂载权限配置文件
vi /etc/exports
/var/www/html/img 10.168.8.88(rw,sync,all_squash,insecure)
/var/www/html/img 客户端1IP(rw,sync,all_squash,insecure)
5.设置nfs端口
vi  /etc/sysconfig/nfs
MOUNTD_PORT="4002"
STATD_PORT="4003"
LOCKD_TCPPORT="4004"
LOCKD_UDPPORT="4004"
6.停止nfs服务
systemctl stop nfs-server
systemctl stop rpcbind
 
启动nfs服务
systemctl start nfs-server
systemctl start rpcbind
 
7、查看使用的nfs端口
rpcinfo -p

二、客户端配置192.168.8.88:
1、如果没有安装的话执行
yum    install   nfs-utils    -y
2.创建同步文件夹
mkdir -p /var/www/html/img
3.服务端路径与本地路径挂载
mount -t nfs 192.168.10.100:/var/www/html/img /var/www/html/img
开机自动挂载:
如果服务端或客户端的服务器重启之后需要手动挂载,我们可以加入到开机自动挂载
在客户端/etc/fstab里添加
#192.168.10.100:/var/www/html/img /var/www/html/img     nfs  defaults,_rnetdev  1  1
192.168.10.100:/var/www/html/img /var/www/html/img     nfs  defaults  0  0
备注:第1个1表示备份文件系统,第2个1表示从/分区的顺序开始fsck磁盘检测,0表示不检测。
_rnetdev  表示主机无法挂载直接跳过,避免无法挂载主机无法启动

三、报错与异常
 1、exportfs -rv 重新加载配置文件
1.mount后服务器使用ls df等命令出现卡顿,在服务端进行了挂载操作。
取消挂载目录使用 umount /var/www
如果提示device busy 使用umount -l  /var/www/ 命令。
2.网段绑定问题
如果需要绑定一个网段下的机器,服务端设置/etc/exports ip修改为类似10.10.0.0/16

猜你喜欢

转载自www.cnblogs.com/zgyw/p/12327372.html