Sun Microsystems, Inc.
spacerspacer
spacer www.sun.com docs.sun.com |
spacer
black dot
 
 
9.  Administering NIS (Tasks) Updating and Modifying Existing Maps Modifying Default Maps  Previous   Contents   Next 
   
 

Using makedbm to Modify a Non-Default Map

There are two different methods for using makedbm to modify maps if you do not have an input file:

  • Redirect the makedbm -u output to a temporary file, modify the file, then use the modified file as input to makedbm.

  • Have the output of makedbm -u operated on within a pipeline that feeds into makedbm. This is appropriate if you can update the disassembled map with either awk, sed, or a cat append.

Creating New Maps from Text Files

Assume that a text file /var/yp/mymap.asc was created with an editor or a shell script on the master. You want to create an NIS map from this file and locate it in the homedomain subdirectory. To do this, type the following on the master server.

# cd /var/yp # makedbm mymap.asc homedomain/mymap

The mymap map now exists on the master server in the directory homedomain. To distribute the new map to slave servers run ypxfr.

Adding Entries to a File-Based Map

Adding entries to mymap is simple. First, you must modify the text file /var/yp/mymap.asc. If you modify the actual dbm files without modifying the corresponding text file, the modifications are lost. Then run makedbm as shown above.

Creating Maps From Standard Input

When no original text file exists, create the NIS map from the keyboard by typing input to makedbm, as shown below (end with Control-D).

ypmaster# cd /var/yp

ypmaster# ypmaster# makedbm - homedomain/mymapkey1 value1 key2 value2 key3 value3

Modifying Maps Made From Standard Input

If you later need to modify the map, you can use makedbm to disassemble the map and create a temporary text intermediate file. To disassemble the map and create a temporary file, type the following.

% cd /var/yp

% makedbm -u homedomain/mymap > mymap.temp

The resulting temporary file mymap.temp has one entry per line. You can edit this file as needed, using any text editor.

To update the map, give the name of the modified temporary file to makedbm by typing the following.

% makedbm mymap.temp homedomain/mymap

% rm mymap.temp

Then propagate the map to the slave servers, by becoming root and typing the following.

# yppush mymap

The preceding paragraphs explained how to use makedbm to create maps; however, almost everything you actually have to do can be done by ypinit and Makefile unless you add nondefault maps to the database or change the set of NIS servers after the system is already up and running.

Whether you use the Makefile in /var/yp or some other procedure the goal is the same. Anew pair of well-formed dbm files must end up in the maps directory on the master server.

Adding a Slave Server

After NIS is running, you might need to create an NIS slave server that you did not include in the initial list given to ypinit.

To add a NIS slave server:

How to Add a Slave Server

  1. Log in to the master server as a superuser.

  2. Change to the NIS domain directory.

    # cd /var/yp/domainname

  3. Disassemble the ypservers file.

    # makedbm -u ypservers >/tmp/temp_file

    The makedbm command converts ypservers from ndbm format to a temporary ASCII file /tmp/temp_file.

  4. Edit the /tmp/temp_file file using a text editor. Add the name of the new slave server to the list of servers. Then save and close the file.

  5. Run the makedbm command with temp_file as the input file and ypservers as the output file.

    # makedbm /tmp/temp_file ypservers

    makedbm then converts ypservers back into ndbm format.

  6. Verify that the ypservers map is correct (since there is no ASCII file for ypservers) by typing the following on the slave.

    slave3# makedbm -u ypservers

    The makedbm command displays each entry in ypservers on your screen.


    Note - If a machine name is not in ypservers, it will not receive updates to the map files because yppush consults this map for the list of slave servers.


  7. Set up the new slave server's NIS domain directory by copying the NIS map set from the master server.

    To do this, become superuser on the new NIS slave and run the ypinit and ypbind commands.

    slave3# cd /var/yp

    slave3# ypinit -c list of servers

    slave3# /usr/lib/netsvc/yp/ypbind

  8. Initialize this machine as a slave.

    slave3# /usr/sbin/ypinit -s ypmaster

    where ypmaster is the machine name of the existing NIS master server.

  9. Run ypstop to stop the machine running as an NIS client.

    # /usr/lib/netsvc/yp/ypstop

  10. Run ypstart to start NIS slave service.

    # /usr/lib/netsvc/yp/ypstart

 
 
 
  Previous   Contents   Next