好程序員雲計算學習路線分享:關於NFShtml
項目名稱: 爲集羣中的 Web Server 配置後端存儲linux
NFS:Network File System 網絡文件系統,Unix系統之間共享文件的一種協議程序員
NFS 的客戶端主要爲Linuxweb
支持多節點同時掛載以及併發寫入vim
========================================================後端
nas 192.168.122.59centos
web1 192.168.122.85網絡
web2 192.168.122.166併發
web3 192.168.122.111學習
nas web1 web2 web3
# sed -ri '/^SELINUX=/cSELINUX=disabled' /etc/selinux/config
# setenforce 0
centos6
# iptables -F
# service iptables save
centos7
# systemctl stop firewalld
# systemctl disable firewalld
# vim /etc/hosts [可選]
192.168.122.59 nas
192.168.122.85 web1
192.168.122.166 web2
192.168.122.111 web3
NFS
1.安裝軟件
yum -y install nfs-utils(主包提供文件系統)
yum -y install rpcbind(提供rpc協議)
2.啓動服務------>這兩個服務必須同時啓用
systemctl start nfs
systemctl start rpcbind
1、nas(存儲端)
[root@nas ~]# yum -y install nfs-utils
[root@nas ~]# mkdir /webdata //存儲網站代碼!
[root@nas ~]# echo "nfs test..." > /webdata/index.html
[root@nas ~]# vim /etc/exports
/webdata 192.168.122.0/24(rw,sync,no_root_squash) //不壓制root(當client端使用root掛載時,也有root權限) 掛載是root ,一樣保持root權限
[root@nas ~]# systemctl start nfs-server
[root@nas ~]# systemctl enable nfs-server
[root@nas ~]# exportfs -v
/webdata 192.168.122.0/24(rw,wdelay,no_root_squash,no_subtree_check,sec=sys,rw,secure,no_root_squash,no_all_squash)
his
2、web1 web2 web3 客戶端
以web1爲例:
[root@web1 ~]# yum -y install nfs-utils httpd
[root@web1 ~]# systemctl start httpd
[root@web1 ~]# systemctl enable httpd
httpd
1. 查看存儲端共享 [可選]
[root@web1 ~]# showmount -e nas
Export list for nas:
/webdata 192.168.122.0/24
ps -ef | grep nfs
2. 手動掛載 [可選]
[root@web1 ~]# mount -t nfs nas:/webdata /var/www/html/
[root@web1 ~]# umount /var/www/html/
3. 自動掛載到網站主目錄
[root@web1 ~]# vim /etc/fstab
nas:/webdata /var/www/html nfs defaults 0 0
[root@web1 ~]# mount -a
4. 查看掛載
[root@web1 ~]# df
nas:/webdata 7923136 692416 6821568 10% /var/www/html
[root@web1 ~]# ls /var/www/html/
index.html
5. web2 web3同上
3、測試網站訪問
# firefox 192.168.122.85
# firefox 192.168.122.111
# firefox 192.168.122.166