目標:nfs服務器配置nfs服務,客戶端將nfs共享的目錄掛載到網站服務的根目錄下,
環境準備:兩臺linux虛擬機(192.168.1.11,192.168.1.12)
192.168.1.11 服務器端配置
[root@nfs ~]# yum -y install nfs-utils
[root@nfs ~]# mkdir /web_share
[root@nfs ~]# vim /etc/exports
/web_share 192.168.1.0/24(rw,no_root_squash)
[root@nfs ~]# echo nihao > /web_share/index.html
[root@nfs ~]# systemctl restart rpcbind
[root@nfs ~]# systemctl enable rpcbind
[root@nfs ~]# systemctl restart nfs
[root@nfs ~]# systemctl enable nfs
NFS使用的是隨機埠,每次啟動NFS都需要將自己的隨機埠注冊到rpcbind服務,這樣客戶端訪問NFS時先到rpcbind查詢埠資訊,得到埠資訊后再訪問NFS服務,
192.168.1.12 客戶端配置
[root@web1 ~]# yum -y install nfs-utils
[root@web1 ~]# yum -y install httpd
[root@web1 ~]# echo "192.168.2.11:/web_share/ /var/www/html/ nfs defaults 0 0" >> /etc/fstab
[root@web1 ~]# mount -a
[root@web1 ~]# systemctl restart httpd
[root@web1 ~]# curl 192.168.1.12
nihao
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/232545.html
標籤:其他
