本文整理在 NIS 環境下,以 Solaris 為伺服器,並讓 Solaris 與 Linux 客戶端實現 auto_home 與 autofs 的完整設定(slaver server 部分為網上參考補充)。管理域為 testdomain,master 為 SUN-2(10.1.100.2)、slave 為 SUN-1(10.1.100.1)。
設定域名 domainname testdomain 並寫入 /etc/defaultdomain,編輯 /etc/hosts、/etc/auto_home(內容如 SUN-2:/export/home/&),touch 建立 ethers、bootparams、netgroup、netmasks 等檔,再執行 ypinit -m 加入 master 與 slave 主機,最後 /usr/lib/netsvc/yp/ypstart 啟動,用 ypwhich -m 驗證。可透過修改 /var/yp/Makefile 的 DIR 變數改變來源目錄。
Solaris 客戶端編輯 hosts、設域名、ypinit -c 輸入伺服器清單後啟動 ypstart。Linux 客戶端則確認 ypbind 已安裝並用 ntsysv 勾選,設定 /etc/yp.conf(domain 與 ypserver)、/etc/sysconfig/network(NISDOMAIN)、/etc/nsswitch.conf(passwd/shadow/group 加 nis),並在 /etc/passwd 末尾加入 +::::::,重啟 ypbind 即可。
Solaris 端修改 /var/yp/Makefile 加入 auto.master、auto.home 等 map(注意 TAB 與空格的區分),執行 make 產生資料庫。Linux 端確認 autofs 服務運行,於 /etc/auto.master 加入 /home /etc/auto.home --timeout=60,並在 auto.home 寫入 * test:/export/home/&,重啟 autofs 與 ypbind。
注意:Linux 的 NFS 共享設定檔是 /etc/exports、開機掛載檔是 /etc/fstab;Solaris 則分別是 /etc/dfs/dfstab 與 /etc/vfstab。