Networking Guide
Chapter 7, Configuring the Network Information Service (NIS)

Changing the master NIS server

Changing the master NIS server

You may need to change your master server, for example, if you rearrange server configuration or the master server host is removed from service. Any server in the NIS domain can become the new master server because each one has all active maps. However, because the old NIS master's name is contained in the existing map, you can neither use an existing copy at the new master nor send a copy there with ypxfr. Rather, you must re-create these maps by running ypmake (or make) on the new master server to associate the new server listing with each map.

The old master server must be running NIS to complete this procedure. This is because nonmaster servers consult their own copies of maps, which include the name of the old master server, when they receive a map transfer request originating from yppush on the master. New maps with the new master server listing must come from the old master server for the maps to be incorporated on slave and copy-only servers. Therefore, if the old master is not available when you change master servers, you must rebuild your entire NIS system from scratch.


CAUTION: Changing master servers is a major reconfiguration of your network and should not be undertaken unless absolutely necessary. Make sure you understand the procedure thoroughly and back up your network configuration files before you begin.

The procedures described here assume that the new master is running SCO NIS. Other implementations of NIS configure servers in a different way; consult the documentation for your version of NIS before changing master servers.


To change NIS master servers, follow these steps:

  1. Log into the new master server in multiuser mode.

  2. Copy the /etc/passwd.yp file from the old master. If this file is not available, you must re-create distributed accounts manually. If you have modified the /etc/yp/ypmake or /etc/yp/Makefile file, you must also copy it from the old master.

  3. Run the following commands to rebuild the maps:

    cd /etc/yp
    rm *.time
    ypmake NOPUSH=1

    By removing the timestamp files, you force the maps to be rebuilt regardless of prior modifications. The NOPUSH option to ypmake prevents maps from being pushed to other servers until you have completed this entire procedure.

  4. If the map only exists as a ndbm database, you can remake it on the new master by unassembling an existing copy from any NIS server and running the unassembled version back through makedbm. For example, enter:

    cd /etc/yp
    ypcat -k mymap | ./makedbm - domain_name/mymap

  5. Log into the old master server.

  6. Copy the new maps from the new master server with the following command:

    /etc/yp/ypxfr -h new_master -f mapname

    This command must be run on the old master for every current NIS map. The -h option forces ypxfr to transfer the map from the new master; the -f option forces the transfer even if the contents of the old and new maps are the same.

  7. Propagate the new maps from the old master server by running the following command on the old master server:

    /etc/yp/yppush mapname

    This command must be run on the old master for every current NIS map. When this is completed, all nonmaster servers will have received maps that include the new master listing.

  8. If you are removing the old master server from NIS service, edit the ypservers map on the new master server following the instructions in ``Removing an NIS server from the server list''.
You can automate the map transfer procedure on the old master server using shell scripts and other tools. For example, the following shell script automatically completes steps 6 and 7:
   \:
   MAPS=`oawk '{print $1 ; }' /etc/yp/YP_MAP_X_LATE`
   for map in $MAPS; do
   echo moving $map
   ypxfr -h new_master -f $map
   yppush $map
   done
Make sure your /etc/yp/YP_MAP_X_LATE file is current before running this command; for more information, refer to ``NIS maps''.

See also: