CentOS7安裝配置NFS,防火牆配置

本文屬於轉載,原作者也不知道同不同意。。。爲了方便找記錄一下,原作者博客
https://blog.csdn.net/w171066/article/details/52934862

安裝 nfs 會同時自動安裝rpcbind

yum -y install nfs-utils

配置端口nfs除了主程序端口2049和rpcbind的端口111是固定以外,還會使用一些隨機端口 可以在/etc/sysconfig/nfs 文件中配置將這些端口固定

LOCKD_TCPPORT=32803
LOCKD_UDPPORT=32769
MOUNTD_PORT=892
RQUOTAD_PORT=875
STATD_PORT=662
STATD_OUTGOING_PORT=2020

打開端口 CentOS7 使用的是 firewalld.使用可以參考
https://www.cnblogs.com/wuliwawa/p/11944112.html
首先打開 111 和 2049 端口

firewall-cmd  --permanent    --add-port=111/tcp
firewall-cmd  --permanent    --add-port=111/udp
firewall-cmd  --permanent    --add-port=2049/tcp
firewall-cmd  --permanent    --add-port=2049/udp

再將上面nfs文件中配置的端口打開

firewall-cmd  --permanent    --add-port 32803/tcp
firewall-cmd  --permanent    --add-port 32769/udp

firewall-cmd  --permanent    --add-port 892/tcp
firewall-cmd  --permanent    --add-port 892/udp

firewall-cmd  --permanent    --add-port 875/tcp
firewall-cmd  --permanent    --add-port 875/udp

firewall-cmd  --permanent    --add-port 662/tcp
firewall-cmd  --permanent    --add-port 662/udp

重新載入防火牆

firewall-cmd --reload

查看已開放端口

firewall-cmd	--zone=public --list-ports

設置共享目錄 如 /export/primary
編輯 /etc/exports 文件

vi /etc/exports

加上如下內容

/export/primary *(rw,async,no_root_squash,no_subtree_check)
  • 表示所有IP都可以訪問, rw可進行讀寫操作 。其它參數意思 可以自己查一查,本人也不甚瞭解。

重啓 rpcbind和nfs 服務。

systemctl	restart rpcbind
systemctl restart nfs

查看nfs 綁定的端口

rpcinfo -p
[root@bride2 ~]# rpcinfo -p
   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
    100005    1   udp    892  mountd
    100005    1   tcp    892  mountd
    100005    2   udp    892  mountd
    100005    2   tcp    892  mountd
    100005    3   udp    892  mountd
    100005    3   tcp    892  mountd
    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  32769  nlockmgr
    100021    3   udp  32769  nlockmgr
    100021    4   udp  32769  nlockmgr
    100021    1   tcp  32803  nlockmgr
    100021    3   tcp  32803  nlockmgr
    100021    4   tcp  32803  nlockmgr

其它 主機可以查看 掛載該共享點,假設該共享點IP192.168.199.61

其它主機 (假設是CentOS7系統,也安裝了 nfs-utils)

查看 192.168.199.61 的共享

showmount -e 192.168.199.61

掛載 該共享

mount -t nfs 192.168.199.61:/export/primary /mnt/primary
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章