Linux 配置NFS


192.168.8.200 為服務端
192.168.8.202 為客戶端

找網絡組申請開通的端口如下:
TCP:111、2049、4046
UDP:4046


**********************
服務端、客戶端需要安裝的包
**********************
[root@rac1 nfstest]# rpm -qa | egrep "nfs|rpcbind"
nfs4-acl-tools-0.3.3-7.el6.x86_64
nfs-utils-lib-1.1.5-11.el6.x86_64
rpcbind-0.2.0-11.el6.x86_64
nfs-utils-1.2.3-64.el6.x86_64



********************
在服務端修改 /etc/exports,增加共享目錄   
********************

/nfstest 192.168.8.202(rw,sync,no_root_squash)
注:/nfstest 是准備共享的目錄,192.168.8.202是被允許掛接此共享linux客戶機的IP地址或主機名。



********************
在服務端啟動與停止NFS服務 
********************


/etc/rc.d/init.d/nfs stop 
/etc/rc.d/init.d/nfs start 


********************
在客戶端掛載nfs
********************

mkdir  /nfs  
mount -t nfs -o rw 192.168.8.200:/nfstest /nfs

********************
在客戶端掛載nfs測試讀寫
********************
若只有root用戶能寫,別的用戶不可寫,修改/nfs的權限為777即可




#############################################################################################################################
以下內容不建議做
#############################################################################################################################
********************
修改端口之前,查看啟用端口
********************
[root@rac1 nfstest]# rpcinfo -p rac1
   program vers proto   port  service
    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
    100024    1   udp   9130  status
    100024    1   tcp  62048  status
    100011    1   udp    875  rquotad
    100011    2   udp    875  rquotad
    100011    1   tcp    875  rquotad
    100011    2   tcp    875  rquotad
    100005    1   udp  55579  mountd
    100005    1   tcp  28829  mountd
    100005    2   udp  10625  mountd
    100005    2   tcp  11475  mountd
    100005    3   udp  60841  mountd
    100005    3   tcp  41411  mountd
    100003    2   tcp   2049  nfs
    100003    3   tcp   2049  nfs
    100003    4   tcp   2049  nfs
    100227    2   tcp   2049  nfs_acl
    100227    3   tcp   2049  nfs_acl
    100003    2   udp   2049  nfs
    100003    3   udp   2049  nfs
    100003    4   udp   2049  nfs
    100227    2   udp   2049  nfs_acl
    100227    3   udp   2049  nfs_acl
    100021    1   udp  52733  nlockmgr
    100021    3   udp  52733  nlockmgr
    100021    4   udp  52733  nlockmgr
    100021    1   tcp  17169  nlockmgr
    100021    3   tcp  17169  nlockmgr
    100021    4   tcp  17169  nlockmgr


*********************
修改nfs配置
*********************
vi /etc/sysconfig/nfs
增加以下內容
RQUOTAD_PORT=30001
LOCKD_TCPPORT=30002
LOCKD_UDPPORT=30002
MOUNTD_PORT=30003
STATD_PORT=30004


*********************
重新啟動nfs
*********************

/etc/rc.d/init.d/nfs stop 啟動NFS服務
/etc/rc.d/init.d/nfs start 停止NFS服務


*********************
再次查看啟動端口
*********************
root@rac1 nfstest]#  rpcinfo -p rac1
   program vers proto   port  service
    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
    100024    1   udp   9130  status
    100024    1   tcp  62048  status
    100011    1   udp  30001  rquotad
    100011    2   udp  30001  rquotad
    100011    1   tcp  30001  rquotad
    100011    2   tcp  30001  rquotad
    100005    1   udp  30003  mountd
    100005    1   tcp  30003  mountd
    100005    2   udp  30003  mountd
    100005    2   tcp  30003  mountd
    100005    3   udp  30003  mountd
    100005    3   tcp  30003  mountd
    100003    2   tcp   2049  nfs
    100003    3   tcp   2049  nfs
    100003    4   tcp   2049  nfs
    100227    2   tcp   2049  nfs_acl
    100227    3   tcp   2049  nfs_acl
    100003    2   udp   2049  nfs
    100003    3   udp   2049  nfs
    100003    4   udp   2049  nfs
    100227    2   udp   2049  nfs_acl
    100227    3   udp   2049  nfs_acl
    100021    1   udp  30002  nlockmgr
    100021    3   udp  30002  nlockmgr
    100021    4   udp  30002  nlockmgr
    100021    1   tcp  30002  nlockmgr
    100021    3   tcp  30002  nlockmgr
    100021    4   tcp  30002  nlockmgr

*********************
在防火牆設置允許端口
*********************
    
iptables -A INPUT -s 192.168.8.1 -p tcp --dport 111 -j ACCEPT           
iptables -A INPUT -s 192.168.8.1 -p udp --dport 111 -j ACCEPT           
iptables -A INPUT -s 192.168.8.1 -p tcp --dport 2049 -j ACCEPT          
iptables -A INPUT -s 192.168.8.1 -p udp --dport 2049 -j ACCEPT          
iptables -A INPUT -s 192.168.8.1 -p tcp --dport 30001:30004 -j ACCEPT   
iptables -A INPUT -s 192.168.8.1 -p udp --dport 30001:30004 -j ACCEPT   

 


免責聲明!

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



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