Tuesday, July 27, 2010

Step by step to configure NIS in RHEL5


1: pre-setting up
NIS domain name: linuxcream
NIS master server IP100.0.0.1,hostname:master.linuxcream   /* create user01 in master server
NIS slave server  IP100.0.0.2,hostname: slave.linuxcream
NIS client side IP100.0.0.3,  hostname: client.linuxcream
2: setting up
a: install all needed package
———————————————————————————————–
[root@localhost ~]# yum install portmap ypserv ypbind yp-tools
[root@localhost ~]# rpm -qa | grep ^yp

ypbind-1.19-11.el5
ypserv-2.19-5.el5
yp-tools-2.9-0.1
[root@localhost ~]# rpm -qa | grep portmap
portmap-4.0-65.2.2.1
———————————————————————————————–
b: setting up NIS domain name
———————————————————————————————————————–
[root@localhost ~]# nisdomainname linuxcream
[root@localhost ~]# echo “/bin/nisdomainname linuxcream” >> /etc/rc.d/rc.local
[root@localhost ~]# echo “NISDOMAIN=linuxcream” >> /etc/sysconfig/network
———————————————————————————————————————–
/bin/nisdomainname linuxcream            /*  start when turn on server
add NISDOMAIN=linuxcream in /etc/sysconfig/network               /*auto set nis domain when start sevices
c: configure ypserv
——————————————————————————————————
[root@linuxcream /]# vi /etc/ypserv.conf
/* only allow 127.0.0.0/255.0.0.0 and 100.0.0.0/255.0.0.0 access,
127.0.0.0/255.0.0.0    :  *  :  *  :  none
100.0.0.0/255.0.0.0        :  *  :  *  :  none
*                              :  *  :  *  :  deny
[root@localhost ~]# cat /var/yp/securenets    /*created  by user
host 127.0.0.1
255.0.0.0 100.0.0.0
———————————————————————————————————-
d: configure /etc/hosts and create /etc/netgroup
——————————————————————————
[root@localhost ~]# touch /etc/netgroup
[root@localhost ~]# vi /etc/hosts
127.0.0.1        localhost.localdomain localhost
::1             localhost6.localdomain6 localhost6
100.0.0.1       master.linuxcream
100.0.0.2       slave.linuxcream
100.0.0.3       client.linuxcream
———————————————————————————–
e: setting NIS datalist:
———————————————————————————–
[root@localhost ~]# useradd user01
[root@localhost ~]# passwd user01
Changing password for user user01.
New UNIX password:
BAD PASSWORD: it is WAY too short
Retype new UNIX password:
passwd: all authentication tokens updated successfully.
[root@localhost ~]# /usr/lib/yp/ypinit –m
At this point, we have to construct a list of the hosts which will run NIS
servers.  master.linuxcream is in the list of NIS server hosts.  Please continue to add
the names for the other hosts, one per line.  When you are done with the
list, type a .                                   /*  type ctrl+D =enter
next host to add:  master.linuxcream
next host to add:
The current list of NIS servers looks like this:
master.linuxcream
Is this correct?  [y/n: y]  y
We need a few minutes to build the databases…
Building /var/yp/linuxcream/ypservers…
Running /var/yp/Makefile…
gmake[1]: Entering directory `/var/yp/linuxcream’
Updating passwd.byname…
failed to send ‘clear’ to local ypserv: RPC: Port mapper failureUpdating passwd.byuid…
failed to send ‘clear’ to local ypserv: RPC: Port mapper failureUpdating group.byname…
failed to send ‘clear’ to local ypserv: RPC: Port mapper failureUpdating group.bygid…
failed to send ‘clear’ to local ypserv: RPC: Port mapper failureUpdating hosts.byname…
failed to send ‘clear’ to local ypserv: RPC: Port mapper failureUpdating hosts.byaddr…
failed to send ‘clear’ to local ypserv: RPC: Port mapper failureUpdating rpc.byname…
failed to send ‘clear’ to local ypserv: RPC: Port mapper failureUpdating rpc.bynumber…
failed to send ‘clear’ to local ypserv: RPC: Port mapper failureUpdating services.byname…
failed to send ‘clear’ to local ypserv: RPC: Port mapper failureUpdating services.byservicename…
failed to send ‘clear’ to local ypserv: RPC: Port mapper failureUpdating netid.byname…
failed to send ‘clear’ to local ypserv: RPC: Port mapper failureUpdating protocols.bynumber…
failed to send ‘clear’ to local ypserv: RPC: Port mapper failureUpdating protocols.byname…
failed to send ‘clear’ to local ypserv: RPC: Port mapper failureUpdating mail.aliases…
failed to send ‘clear’ to local ypserv: RPC: Port mapper failuregmake[1]: Leaving directory `/var/yp/linuxcream’
master.linuxcream has been set up as a NIS master server.
Now you can run ypinit -s master.linuxcream on all slave server.
——————————————————————————————————————————————–
f:start services
——————————————————————————————————-
[root@localhost ~]# service portmap restart
stop portmap:[OK]
starportmap:[OK]
[root@localhost ~]# service ypserv restart
Stop YP services:[Failure]
Start YP services:[OK]
[root@localhost ~]# service yppasswd restart
yppasswd: unrecognised services
[root@localhost ~]# service yppasswdd restart
Stop  YP services:[Failure]
Start YP services:[OK]
[root@localhost ~]# chkconfig –level 35 portmap on
[root@localhost ~]# chkconfig –level 35 ypserv on
[root@localhost ~]# chkconfig –level 35 yppasswdd on
[root@localhost ~]# ps –aux | grep yp
[root@localhost ~]# tail /var/log/message
—————————————————————————————————
7.configure for slave server
————————————————————–
[root@linuxcream /]# vim /var/yp/Makefile
NOPUSH=true   /* around line 23
NOPUSH=false   /* update for slave server from master server
[root@localhost ~]# cat /var/yp/ypservers    /*  add 
nis slave
master.linuxcream
slave.linuxcream
[root@localhost ~]# service ypxfrd restart  /* allow slave server connect to ypxfrd for updating
Stop YP services:[failure]
Start YP services:[OK]
/* allow slave server to master server database
[root@crazylinux]# yppush -h slave.linuxcream passwd.*
—————————————————————————————————-

Configure NIS salve server (same with master server configure)
1:check package including portmap、ypserv、ypbind、yp-tools
—————————————————————————————————-
[root@localhost ~]# yum install portmap ypbind yp-tools ypserv
[root@localhost ~]# rpm -qa | grep ^yp
ypbind-1.19-11.el5
yp-tools-2.9-0.1
ypserv-2.19-5.el5
[root@localhost ~]# rpm -qa | grep portmap
portmap-4.0-65.2.2.1
2.create nis domain name
[root@localhost ~]# 
nisdomainname linuxcream
[root@localhost ~]# echo “/bin/
nisdomainname linuxcream” >> /etc/rc.d/rc.local
[root@localhost ~]# echo “NISDOMAIN=crazylinux” >> /etc/sysconfig/network
3. configure ypserv
[root@linuxcream /]# vi /etc/ypserv.conf           /* add from bottom line
127.0.0.0/255.0.0.0    :  *  :  *  :  none
100.0.0.0/255.0.0.0        :  *  :  *  :  none
*                              :  *  :  *  :  deny
[root@localhost ~]# cat /var/yp/securenets
host 127.0.0.1
255.0.0.0 100.0.0.0
4.set /etc/hosts and create /etc/netgroup
[root@linuxcream /]#vi /etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1               localhost.localdomain localhost
100.0.0.1               master.linuxcream
100.0.0.2               slave.linuxcream
100.0.0.3               client.linuxcream
[root@linuxcream /]# touch /etc/netgroup
5.Start services
[root@crazylinux /]#service portmap restart
[root@crazylinux /]# service ypserv start
[root@crazylinux /]#/usr/lib/yp/ypinit -s master.crazylinux
[root@crazylinux /]# ypcat -h localhost passwd.byname       //check if work
[root@crazylinux /]#vi /etc/crontab             /add from bottom line
20 * * * * root /usr/lib/yp/ypxfr_1perhour
40 6 * * * root /usr/lib/yp/ypxfr_2perday
55 6,18 * * * root /usr/lib/yp/ypxfr_2perday
[root@linuxcream /]# vi /usr/lib/yp/ypxfr_1perhour
$YPBINDIR/ypxfr $map /*change to
$YPBINDIR/ypxfr $map –h master.linuxcream
[root@linuxcream /]#service ypbind restart
—————————————————————————————————-
Configure for client side:
1:check  ypbind、yp-tools  package
[root@localhost ~]# yum install portmap ypbind yp-tools
[root@localhost ~]# rpm -qa | grep ^yp
ypbind-1.19-11.el5
yp-tools-2.9-0.1
[root@localhost ~]# rpm -qa | grep portmap
portmap-4.0-65.2.2.1
2.create NIS domain name
[root@localhost ~]# 
nisdomainname linuxcream
[root@localhost ~]# echo “/bin/
nisdomainname linuxcream” >> /etc/rc.d/rc.local
[root@localhost ~]# echo “NISDOMAIN=linuxcream” >> /etc/sysconfig/network
3.set /etc/hosts and /etc/netgroup
[root@linuxcream /]#vi /etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1               localhost.localdomain localhost
100.0.0.1               master.linuxcream
100.0.0.2               slave.linuxcream
100.0.0.3               client.linuxcream
[root@crazylinux /]# touch /etc/netgroup
4.configure nsswitch.conf
[root@linuxcream /]# vi /etc/nsswitch.conf
passwd:     files 
nis nisplus
shadow:     files 
nis nisplus
group:      files 
nis nisplus
hosts:      files 
nis dns
5.set /etc/sysconfig/authconfig
[root@linuxcream /]# vi /etc/sysconfig/authconfig
USENIS=no–>yes
6.set /etc/yp.conf
[root@localhost ~]# cat /etc/yp.conf
domain linuxcream server master.linuxcream  /* line 4
domain linuxcream server slave.linuxcream
7.start ypbind
[root@localhost ~]# service portmap status
portmap (pid 1683) is running…
[root@localhost ~]# service  ypbind start
Binding to the NIS domain: [  OK  ]
Listening for an NIS domain server..
set nis server
[root@localhost ~]# vi /etc/exports
/home        100.0.0.0/8(rw,async,np_root_squash)
[root@localhost ~]#service nfs start
set nis client
[root@localhost ~]#vi /etc/fstab
master.linuxcream:/home/        /home        nfs        defaults        0        0
testing……