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

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM