Reference:
http://linux.vbird.org/linux_server/0430nis.php#nis_server_master
http://paching.myweb.hinet.net/lesson15.htm
http://www.mattiasholm.com/?p=338
Server side:
1. vi /etc/sysconfig/network
NISDOMAIN=mynisdomain <==設定 NIS 領域名稱
YPSERV_ARGS="-p 1011" <==設定 NIS 每次都啟動在固定的埠口
2. /etc/ypserv.conf 用預設值即可
dns: no
files: 30
slp: no
slp_timeout: 3600
xfr_check_port: yes
* : * : shadow.byname : port
* : * : passwd.adjunct.byname : port
3. vi /etc/hosts 確定 master, slave NIS都在 hosts 裡面。
192.168.100.1 master
192.168.100.2 slave
4. vi /etc/sysconfig/yppasswdd
YPPASSWDD_ARGS="--port 1012"
5. start NIS service
/etc/init.d/ypserv start
/etc/init.d/yppasswdd start
chkconfig ypserv on
chkconfig yppasswdd on
6. check NIS service
rpcinfo -p localhost
program vers proto port service
100000 4 tcp 111 portmapper
100000 4 udp 111 portmapper
100004 2 udp 1011 ypserv
100004 1 udp 1011 ypserv
100004 2 tcp 1011 ypserv
100004 1 tcp 1011 ypserv
100009 1 udp 1012 yppasswdd
rpcinfo -u localhost ypserv
program 100004 version 1 ready and waiting
program 100004 version 2 ready and waiting
7. sync YP from master
/usr/lib64/yp/ypinit -s master
8. check slave DB in /var/yp/mynisdomain
Client side:
vi /etc/yp.conf
domain mynisdomain server master
domain mynisdomain server slave
2013/2/1 update:
Linux client automount doesn't work after reboot.
The client is bind to NIS slave. (run ypwhich to check)
Run ypcat auto.master getting error message "No such map auto.master. Reason: Internal NIS error".
The file auto.master isn't in NIS slave /var/yp/mynisdomain.
Solution:
1. Modify file auto.master in NIS master directory /etc. (The file time must be changed.)
2. cd /var/yp; make (This will push auto.master to NIS slave.)
3. run "service autofs restart" in client for automount.