Managing NFS and NIS, 2nd Edition - Mike Eisler [30]
nobody:NP:60001:60001:Nobody:/:
listen:*LK*:37:4:Network Admin:/usr/net/nls:
daemon:NP:1:1::/:
nuucp:NP:9:9:uucp Admin:/var/spool/uucppublic:/usr/lib/uucp/uucico
uucp:NP:5:5:uucp Admin:/usr/lib/uucp:
sys:NP:3:3::/:
bin:NP:2:2::/usr/bin:
adm:NP:4:4:Admin:/var/adm:
lp:NP:71:8:Line Printer Admin:/usr/spool/lp:
stern:aSuxcvmyerjDM:6445::::::
mre:96wqktpdmrkjsE:6445::::::
You are now ready to add new slave servers or to set up NIS clients. Note that NIS must be running on a master server before you can proceed.
Installing NIS slave servers
As with a master server, you must establish the domain name and the /etc/hosts file with the IP addresses of all the slaves and the master:
newslave# domainname bedrock
newslave# domainname > /etc/defaultdomain
Edit /etc/hosts to add master and slaves
When you initialize a new slave server, it transfers the data from the master server's map files and builds its own copies of the maps. No ASCII source files are used to build the NIS maps on a slave server — only the information already in the master server's maps. If the slave has information in ASCII configuration files that belongs in the NIS maps, make sure the master NIS server has a copy of this data before beginning the NIS installation. For example, having password file entries only on an NIS slave server will not add them to the NIS passwd map. The map source files on the master server must contain all map information, since it is the only host that constructs map files from their sources.
The slave will need to act as an NIS client in order get initial copies of the maps from the server. Thus you must first set up the slave as a client:
newslave# /usr/sbin/ypinit -c
You will be prompted for a list of NIS servers. You should start with the name of the local host (in this example, newslave), followed by the name of the master (in this example, newmaster), followed by the remaining slave servers, in order of physical proximity.
Now check to see if your slave was already acting as an NIS client already. If so, use ypstop to terminate it:
newslave# ps -ef | grep ypbind
newslave# /usr/lib/netsvc/yp/ypstop
Now start ypbind:
newslave# /usr/lib/netsvc/yp/ypstart
Slave servers are also initialized using ypinit. Instead of specifying the -m option, use -s and the name of the NIS master server:
newslave# /usr/sbin/ypinit -s newmaster
Now you need to start the ypserv daemon:
newslave# /usr/lib/netsvc/yp/ypstop
newslave# /usr/lib/netsvc/yp/ypstart
Finally, set up nsswitch.conf to use NIS:
newslave# cp /etc/nsswitch.nis /etc/nsswitch.conf
Adding slave servers later
In general, it is a good idea to initialize your NIS slave servers as soon as possible after building the master server, so that there are no inconsistencies between the ypservers map and the hosts that are really running NIS. Once the initial installation is complete, though, you can add slave servers at any time. If you add an NIS slave server that was not listed in the ypservers map, you must add its hostname to this map so that it receives NIS map updates.
To edit ypservers, dump out its old contents with ypcat, add the new slave server name, and rebuild the map using makedbm. This procedure must be done on the NIS master server:
master# ypcat -k ypservers > /tmp/ypservers
Edit /tmp/ypservers to add new server name
master# cd /var/yp
master# cat /tmp/ypservers | makedbm - /var/yp/`domainname`/ypservers
Once you've changed the master ypservers map on the new slave, you must follow the steps described in Section 3.2.3 in this chapter.
Enabling NIS on client hosts
Once you have one or more NIS servers running ypserv, you can set up NIS clients that query them. Make sure you do not enable NIS on any clients until you have at least one NIS server up and running. If no servers are available, the host that attempts to run as an NIS client will hang.
To enable NIS on a client host, first set up the nsswitch.conf file:
newclient# cp /etc/nsswitch.nis /etc/nsswitch.conf
Set up the domain name:
newclient# domainname bedrock