2011-11-11日更新服务器架设部分内容!
网络信息服务(NIS)是集中控制几个系统管理数据库的网络用品。NIS简化了UNIX和LINUX桌面客户的管理工作,客户端利用它可以使用中心服务器的管理文件。桌面系统的用户无需建立他们自己的/etc/passwd,他们只简单的使用维护在NIS服务器的文件即可。 
一、概述:
1、相关服务:ypserv(NIS服务器端),ypbind(NIS客户端),yppasswdd(修改密码时,NIS客户端与NIS服务器端之前通过这个服务来通信)
2、相关端口:portmap :111,因为NIS、NFS 都是依赖于portmap服务
3、相关包:ypserv(NIS服务器必需的),ypbind(NIS客户端必需的,默认已安装),yp-tools(NIS的常用工具,默认已安装
二、服务端的的配置:
1、安装ypserv服务相关的包。 如果没有搭建YUM源则查看http://iminmin.blog.51cto.com/689308/162666,第二部分搭建光盘YUM源
Yum list |grep ypserv
Yum install ypserv.i386
2、建立一个Nis专用用户目录文件夹:
mkdir /home/nishome
3、建立一个NIS用户:(可以使用该方式建立多个用户)
useradd -d  /home/nishome/user1  user1
4、编辑/etc/sysconfig/network为NIS服务器指定NIS域名:
-------------------------------------------
[root@localhost Server]# vim /etc/sysconfig/network
NETWORKING=yes
NETWORKING_IPV6=no
HOSTNAME=localhost.localdomain
NISDOMAIN= example.com
-------------------------------------------
5、运行:nisdomainname example.com //这里的域名和上面=号后面的一样!加入域example.com
-------------------------------------------
[root@localhost Server]# nisdomainname
(none)
[root@localhost Server]# nisdomainname example.com 
[root@localhost Server]# nisdomainname
example.com 
-------------------------------------------
6、编辑/etc/rc.d/rc.local,每次开机自动运行步骤五的命令,加入example.com域;
-------------------------------------------
[root@localhost Server]# vim /etc/rc.d/rc.local
#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.

touch /var/lock/subsys/local
/bin/nisdomainname example.com  //把这句加入最后一行。
----------------------------------------------------
7、启动ypserv服务:
----------------------------------------------------
[root@client Server]# service ypserv restart
停止 YP 服务器的服务:                                     [失败]
启动 YP 服务器的服务:                                     [确定]
----------------------------------------------------
8、生成NIS 用户数据库:/usr/lib/yp/ypinit -m(该服务器上的所有用户名都将用作客户端身份认证)
----------------------------------------------------
[root@localhost Server]# /usr/lib/yp/ypinit -m

At this point, we have to construct a list of the hosts which will run NIS
servers.  localhost.localdomain is in the list of NIS server hosts.  Please coninue to add
the names for the other hosts, one per line.  When you are done with the
list, type a <control D>.
        next host to add:  localhost.localdomain
        next host to add:                                              //这里直接按Ctrl+D
The current list of NIS servers looks like this:

localhost.localdomain

Is this correct?  [y/n: y]  y
We need a few minutes to build the databases...
Building /var/yp/rhce.org/ypservers...
Running /var/yp/Makefile...
gmake[1]: Entering directory `/var/yp/rhce.org'
Updating passwd.byname...
Updating passwd.byuid...
Updating group.byname...
Updating group.bygid...
Updating hosts.byname...
Updating hosts.byaddr...
Updating rpc.byname...
Updating rpc.bynumber...
Updating services.byname...
Updating services.byservicename...
Updating netid.byname...
Updating protocols.bynumber...
Updating protocols.byname...
Updating mail.aliases...
gmake[1]: Leaving directory `/var/yp/rhce.org'

localhost.localdomain has been set up as a NIS master server.

Now you can run ypinit -s localhost.localdomain on all slave server.
----------------------------------------------------
备注:提示输入NIS服务器主机名,有多个可以输入多个,按Y确认。
配置完以上命令后在/var/yp下检查有没有生成一个NIS域名命名的文件,这是NIS用户数据库,如果没有则删除该目录下的’”(none)”目录,再重新生成数据库。
8、重启相关服务:
Service ypserv restart
Chkconfig ypserv on
9、使用NFS共享NIS用户家目录:
Vim /etc/exports
加入内容:/home/nishome 192.168.1.88.*(rw)

二、客户端的配置:
1、检查ypbind 和yptools是否安装:
----------------------------------------------------
[root@localhost ~]# rpm -qa|grep ^yp
yp-tools-2.9-0.1
ypbind-1.19-12.el5
----------------------------------------------------
2、Setsebool -P allow_ypbind=1(防止由于Selinux造成的问题)
3、客户端加入NIS域:
输入system-config-authentication
选择:启用NIS支持,点击“配置NIS”;输入NIS域,及NIS服务器Ip地址