Operating System - HP-UX
1846764 Members
5859 Online
110256 Solutions
New Discussion

Re: NIS Command/Script help.

 
joe_91
Super Advisor

NIS Command/Script help.

Hi There:

I am installing a fileset on a hp-ux 11.0 box which would have to go and check the box on which it is installed and then pick out the master and the slave servers from that.(I have one master and 3 slaves) What would be the best way to accomplish this. ypwhich returns tha master name. But how would i extract the master and all the slave names out of a NIS box. Please Help.

Thanks
Joe.
8 REPLIES 8
A. Clay Stephenson
Acclaimed Contributor

Re: NIS Command/Script help.

You are probably looking for ypcat -k ypservers.
If it ain't broke, I can fix that.
S.K. Chan
Honored Contributor

Re: NIS Command/Script help.

On NIS client I don;t think you can do this but on an NIS slave or NIS master box, I use this method whenever I add additional NIS slaves to the domain. The same method can be used to find out the list of hostnames that were your NIS slaves and masters.
On NIS master or slave (assuming your NIS domain name is "engr")
# cd /var/yp/engr
# makedbm -u ypservers > /tmp/nis-list
Take a look at the file /tmp/nis-list, at the last line it should say ..
YP_MASTER_NAME
and all the other lines before that shows the list of master and slaves. Extract it accordingly.
S.K. Chan
Honored Contributor

Re: NIS Command/Script help.

Silly me .. yes ..
# ypcat -k ypservers
but I'm not sure how to distinguish which is the master server.
joe_91
Super Advisor

Re: NIS Command/Script help.

Hi :

Thanks Clay. But yes, how do i identify the master and the slave from that list. Please advise.

Thanks
Joe.
D. Jackson_1
Honored Contributor

Re: NIS Command/Script help.

You could try to do it this way:
ypcat -k ypservers


donald
daffy
buggs

remsh donald "cat /etc/rc.config.d/namesrvs" |egrep "SLAVE|MASTER"

This will tell you which one is what.
slave = 1
master = 0


HTH
D. Jackson_1
Honored Contributor

Re: NIS Command/Script help.

You could try to do it this way:
ypcat -k ypservers


donald
daffy
buggs

remsh donald "cat /etc/rc.config.d/namesrvs" |egrep "SLAVE|MASTER"

This will tell you which one is what.
slave = 1
master = 0

Donald is a slave.

HTH
A. Clay Stephenson
Acclaimed Contributor

Re: NIS Command/Script help.

You can use ypcat -k ypservers to identify the slave servers;

MASTER=$(ypwhich -m ypservers)
echo "Master NIS Server is ${MASTER}"
If it ain't broke, I can fix that.
Niraj Kumar Verma
Trusted Contributor

Re: NIS Command/Script help.

Hey try this

# rpcinfo -p |grep ypserv

if you get the ypserv running on the server that means the server is a NIS Master server.

you can have a small script to check this on the

# ypcat -k ypserves

result

-Niraj
Niraj.Verma@philips.com