CentOS 7快速安裝配置NFS服務


Server IP ADD:192.168.153.138
Client IP ADD:192.168.153.140
NFS Server安裝配置:
關閉selinux
vim /etc/selinux/config
#SELINUX=enforcing
#SELINUXTYPE=targeted
SELINUX=disabled     //新增部分
systemctl stop firewalld
systemctl disable firewalld
yum remove firewalls
yum install iptables-services
vi /etc/sysconfig/iptables
-A INPUT -p udp -s 192.168.153.140/32 -j ACCEPT    //新增兩條訪問策略
-A INPUT -p tcp -s 192.168.153.140/32 -j ACCEPT
:wq!
service start iptables
systemctl enable iptables

yum install nfs-utils -y //會連同rpcbind依賴包一起安裝。

/tmp/nfs 192.168.153.140(rw,sync,fsid=0,no_root_squash,no_all_squash,anonuid=501,anongid=501)

exportfs -r  //使配置生效

1./tmp/nfs  為共享目錄
2.192.168.153.140  //可以為一個網段或一個IP或多個IP
3.rw表示可讀寫,ro只讀;
4.sync表示同步模式,內存中數據時寫入磁盤;async表示不同步,把內存中數據定期寫入磁盤中。
5.no_root_squash:root用戶會對共享目錄擁有至高的權限控制,就像是對本機的目錄操作一樣,不安全,不建議使用;root_squash:root用戶對共享目錄的權限不高,只有普通用戶的權限,
6.all_squash:不管使用NFS用戶是誰,他的身份將會被限定成為一個指定的普通用戶身份;
7.anonuid/anongid:要和root_squash以及all_squash一同使用,同於指定使用NFS用戶限定后的uid和gid,前提本機的/etc/passwd中存在這個uid和gid。
8.fsid=0表示將/tmp/nfs整個目錄包裝成根目錄

nfs開機啟動服務
systemctl enable rpcbind
systemctl enable nfs-server

啟動nfs服務

systemctl start rpcbind
systemctl start nfs-server

確認NFS服務器啟動成功:
rpcinfo -p

查看service列中是否有nfs服務來確認NFS是否啟動
showmount -e 192.168.153.138     //在nfs server操作

NFS Client安裝配置
關閉selinux
vim /etc/selinux/config
#SELINUX=enforcing
#SELINUXTYPE=targeted
SELINUX=disabled     //新增部分
systemctl stop firewalld
systemctl disable firewalld
yum remove firewalls
yum install iptables-services
vi /etc/sysconfig/iptables
-A INPUT -p udp -s 192.168.153.138/32 -j ACCEPT    //新增兩條訪問策略
-A INPUT -p tcp -s 192.168.153.138/32 -j ACCEPT
:wq!
service start iptables
systemctl enable iptables

yum install nfs-utils -y //會連同rpcbind依賴包一起安裝。
systemctl enable rpcbind
systemctl start rpcbind
mkdir /tmp/nfs
mount -t nfs 192.168.153.138:/tmp/nfs /tmp/nfs/
vim /etc/fstab       //mount永久生效,重啟后mount不消失
192.168.153.138:/tmp/nfs  /tmp/nfs              nfs     nolock          0 0
:wq!

 


免責聲明!

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



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