Windows XP Windows 7 Windows 2003 Windows Vista Windows 綜合教學 Linux 系統教學
Windows 10 Windows 8 Windows 2008 Windows NT Windows Server 電腦軟體教學
您现在的位置: Windows教程網 >> Windows教程 >  >> Linux 系統教學 >> Linux 教學

CentOS/RHEL 5 快速搭建 NFS 文件共享服務圖文教程

編輯:Linux 教學

環境準備

  • Server: 192.168.1.1 (RedHat AS 5)
  • Client: 192.168.1.2
  • 軟件包: nfs-utils-1.0.9-16.el5.i386.rpm

服務端配置步驟

  1. 安裝軟件包:
    rpm -qa | grep nfs  # 檢查
    rpm -ivh nfs-utils-1.0.9-16.el5.i386.rpm  # 未裝則安裝
  2. 配置導出目錄 (/etc/exports):
    /junlong 192.168.1.0/24(rw,sync,no_root_squash)
  3. 創建目錄並授權:
    mkdir /junlong
    chmod 755 /junlong
  4. 關閉 SELinux 與防火牆(測試環境):
    setenforce 0
    sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
    service iptables stop
    chkconfig iptables off
  5. 啟動服務(順序關鍵):
    service portmap start
    service nfs start
    service nfslock start
    chkconfig portmap on
    chkconfig nfs on
    chkconfig nfslock on
  6. 驗證導出:
    showmount -e 192.168.1.1

客戶端掛載驗證

mkdir -p /mnt/junlong
mount -t nfs 192.168.1.1:/junlong /mnt/junlong
ls -l /mnt/junlong  # 應看到服務端創建的測試文件夾

生產環境建議

  • 啟用 sec=krb5p 加密傳輸
  • 配置 /etc/idmapd.conf 統一 UID/GID 映射
  • 使用 autofs 實現按需自動掛載
  • 防火牆僅放行 111/2049 端口,綁定具體客戶端 IP
Copyright © Windows教程網 All Rights Reserved