二、配置slave
1)编辑/etc/hosts文件,添加NIS域中提供NIS服务的主机即master和slave)
# vi /etc/hosts
添加如下内容
192.168.0.10   nisa      nisa.nistest.com

2)配置NIS域名为
# domainname nistest.com
# domainname > /etc/defaultdomain

3)替换/etc/nsswitch.conf文件,先备份,后替换
# cp /etc/nsswitch.conf /etc/nsswitch.conf.orig
# cp /etc/nsswitch.nis /etc/nsswitch.conf

4)运行ypinit -c,将nisb先配置成为客户端机
# ypinit -c
...
next host to add:  nisa
next host to add:  nisb
next host to add:  ^DCtrl+D)
The current list of yp servers looks like this:
nisa
nisb
Is this correct?  [y/n: y]  y
如果配置master时没有将nisb添加进去,在这里会看不到nisb机器,需要到master上重新运行# ypinit -m,添加nisb后再到nisb上运行# ypinit -c。

5)启动NIS服务守护进程
# /usr/lib/netsvc/yp/ypstart

6)检查是否已绑定到nisa上
# ypwhich
nisa

7)运行ypinit -s,将nisb配置为slave
# ypinit -s nisa
...
Do you want this procedure to quit on non-fatal errors? [y/n: n]  y
...
开始传送map文件)
nisb's nis data base has been set up
without any errors.

8)重启NIS服务守护进程
# /usr/lib/netsvc/yp/ypsttop
# /usr/lib/netsvc/yp/ypstart

9)检查slaver状态
# ypwhich -m
会显示NIS域中所有map的名字以及提供这些map的主机)
# ypcat -k ypservers
nisb
nisa


三、配置client
1)编辑/etc/hosts文件,添加NIS域中提供NIS服务的主机即master和slave)
# vi /etc/hosts
添加如下内容
192.168.0.10   nisa      nisa.nistest.com
192.168.0.11   nisb      nisb.nistest.com

2)配置NIS域名为
# domainname nistest.com
# domainname > /etc/defaultdomain

3)替换/etc/nsswitch.conf文件,先备份,后替换
# cp /etc/nsswitch.conf /etc/nsswitch.conf.orig
# cp /etc/nsswitch.nis /etc/nsswitch.conf

4)运行ypinit -c,将nisc配置为client
# ypinit -c
...
next host to add:  nisa
next host to add:  nisb
next host to add:  ^DCtrl+D)
The current list of yp servers looks like this:
nisa
nisb
Is this correct?  [y/n: y]  y

5)启动NIS服务守护进程
# /usr/lib/netsvc/yp/ypstart

6)检查slaver状态
# ypwhich -m
会显示NIS域中所有map的名字以及提供这些map的主机)

至此,全部配置完毕。这个时候就可以在nisc上用testuser用户登录测试配置是否成功,看看能否实现自动挂接home目录。还可以在nisamaster)上停掉NIS服务# /usr/lib/netsvc/yp/ypstop),然后在niscclient)上用testuser登录,测试能否自动切换到nisbslave)提供NIS服务。

  1. 在RHEL 5中配置NIS服务器端及客户端
  2. RHEL上NIS网络信息服务配置实例讲解
  3. RHEL5.1主/从NIS服务器配置及测试 


相关内容