Linux服务器文件同步(NFS服务)

服务器:

服务端:10.26.68.245

客户端:10.26.32.14

一、服务端配置:

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.26.32.14(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 stop nfs-server systemctl stop rpcbind 7、查看使用的nfs端口 rpcinfo -p
 100000    4   tcp    111  portmapper
    100000    3   tcp    111  portmapper
    100000    2   tcp    111  portmapper
    100000    4   udp    111  portmapper
    100000    3   udp    111  portmapper
    100000    2   udp    111  portmapper
    100005    1   udp   4002  mountd
    100005    1   tcp   4002  mountd
    100005    2   udp   4002  mountd
    100005    2   tcp   4002  mountd
    100005    3   udp   4002  mountd
    100005    3   tcp   4002  mountd
    100024    1   udp   4003  status
    100024    1   tcp   4003  status
    100003    3   tcp   2049  nfs
    100003    4   tcp   2049  nfs
    100227    3   tcp   2049  nfs_acl
    100003    3   udp   2049  nfs
    100003    4   udp   2049  nfs
    100227    3   udp   2049  nfs_acl
    100021    1   udp  45989  nlockmgr
    100021    3   udp  45989  nlockmgr
    100021    4   udp  45989  nlockmgr
    100021    1   tcp  43094  nlockmgr
    100021    3   tcp  43094  nlockmgr
    100021    4   tcp  43094  nlockmgr


二、客户端配置10.26.32.14:

1.服务端路径与本地路径挂载
mount -t nfs 10.26.68.245:/var/www/html/img /var/www/html/img

三、报错与异常

 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

 

posted @ 2018-05-09 14:34  codeforu2  阅读(1828)  评论(0编辑  收藏  举报