1. 程式人生 > >多機部署之NFS的安裝與配置

多機部署之NFS的安裝與配置

本文已在本人部落格https://www.nsxsg.com/archives/90首發

文章目錄

多機部署之NFS的安裝與配置

NFS即網路檔案系統,說的通俗一點就是網路共享檔案。它能夠讓不同的伺服器共享同一個資源,這個在叢集部署中普遍運用。

  1. 安裝nfs

    yum install -y nfs-utils
    yum install -y rpcbind #適用centos 6
    yum install -y portmap #適用centos 5
    
  2. 啟動NFS服務,一定要先啟動rpcbind,後啟動nfs

    /etc/init.d/rpcbind start
    /etc/init.d/nfs start
    
  3. 在資源伺服器(伺服器端)上配置NFS,修改 /etc/exports

    /data/httpd/www/public 客戶端ip(rw,sync,no_root_squash)
    /data/httpd/www/themes 客戶端ip(rw,sync,no_root_squash)
    /data/httpd/www/wap_themes 客戶端ip(rw,sync,no_root_squash)
    
    #修改好之後執行命令
    exportfs -rv
    

    檢視是否成功

    showmount -e 伺服器端ip
    Export list for
    伺服器端ip /data/httpd/www/public 客戶端ip /data/httpd/www/themes 客戶端ip /data/httpd/www/wap_themes 客戶端ip
  4. web伺服器(客戶端)掛載資源伺服器的資源

    mount 伺服器端ip:/data/httpd/www/public /data/httpd/www/public
    mount 伺服器端ip:/data/httpd/www/themes /data/httpd/www/themes
    mount 伺服器端ip:/data/httpd/www/wap_themes /data/httpd/www/wap_themes
    
  5. 防止重啟伺服器忘記掛載

    vi /etc/rc.local
    mount
    伺服器端ip:/data/httpd/www/public /data/httpd/www/public mount 伺服器端ip:/data/httpd/www/themes /data/httpd/www/themes mount 伺服器端ip:/data/httpd/www/wap_themes /data/httpd/www/wap_themes
  6. 重啟服務

    先啟動:service rpcbind start 再啟動:service nfs start
    先關閉:service nfs stop 再關閉:service rpcbind stop