NIS服务器同时也是它们自己的NIS客户端,所以你需要编辑NIS客户端配置文件/etc/yp.conf,将其记录域的NIS服务器同时也是主机。
# vi /etc/yp.conf
添加:
ypserver 127.0.0.1
5、启动rpc、ypserv、yppasswdd等进程
# service portmap start
Starting portmap: [ OK ]
# rpcinfo -p localhost
program vers proto port
100000 2 tcp 111 portmapper
100000 2 udp 111 portmapper
100024 1 udp 32768 status
100024 1 tcp 32768 status
# service ypserv start
Starting YP server services: [ OK ]
# rpcinfo -u localhost ypserv
program 100004 version 1 ready and waiting
program 100004 version 2 ready and waiting
#
service yppasswdd start
Starting YP passwd service: [ OK ]
# rpcinfo -u localhost yppasswdd
program 100009 version 1 ready and waiting
# rpcinfo -p localhost
program vers proto port
100000 2 tcp 111 portmapper
100000 2 udp 111 portmapper
100024 1 udp 32768 status
100024 1 tcp 32768 status
100004 2 udp 613 ypserv
100004 1 udp 613 ypserv
100004 2 tcp 616 ypserv
100004 1 tcp 616 ypserv
100009 1 udp 628 yppasswdd
6、初始化NIS域
接下来使用 ypinit 命令去创立域maps文件
# /usr/lib/yp/ypinit -m
At this point, we have to construct a list of the hosts which will run NIS
servers. server.mshome.net 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 .
next host to add: server.mshome.net
next host to add:
The current list of NIS servers looks like this:
server
Is this correct? [y/n: y] y
We need a few minutes to build the databases...
Building /var/yp/benet/ypservers...
Running /var/yp/Makefile...
gmake[1]: Entering directory `/var/yp/benet'
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/benet'
server has been set up as a NIS master server.
Now you can run ypinit -s server on all slave server.
# service ypbind start
Binding to the NIS domain: [ OK ]
Listening for an NIS domain server..
[root@server ~]# yptest
Test 1: domainname
Configured domainname is "benet"
Test 2: ypbind
Used NIS server: 192.168.0.16
………………
………………
# ypwhich -x
Use "ethers" for map "ethers.byname"
Use "aliases" for map "mail.aliases"
Use "services" for map "services.byname"
Use "protocols" for map "protocols.bynumber"
Use "hosts" for map "hosts.byname"
Use "networks" for map "networks.byaddr"
Use "group" for map "group.byname"
Use "passwd" for map "passwd.byname"
# ypwhich -x
Use "ethers" for map "ethers.byname"
Use "aliases" for map "mail.aliases"
Use "services" for map "services.byname"
Use "protocols" for map "protocols.bynumber"
Use "hosts" for map "hosts.byname"
Use "networks" for map "networks.byaddr"
Use "group" for map "group.byname"
Use "passwd" for map "passwd.byname"
# ypcat hosts
192.168.0.16 server
127.0.0.1 localhost.localdomain localhost
7、配置客户端在启动时登录到NIS域
# vi /etc/sysconfig/authconfig
找到如下行:
USENIS=no
修改为:
USENIS=yes
1、客户端登录:
# ssh -l nisuser 192.168.0.128
[email=nisuser@192.168.0.128's]nisuser@192.168.0.128's[/email]
password:
Last login: Wed Jul 11 17:59:14 2007 from server
Could not chdir to home directory /home/nisuser: No such file or directory
-bash-3.00$
2、在服务端输出/home目录,以使得客户端漫游配置文件:
# vi /etc/exports
/home 192.168.0.0/24(rw,no_root_squash,async)
启动nfs服务:
# service nfs start
Starting NFS services: [ OK ]
Starting NFS quotas: [ OK ]
Starting NFS daemon: [ OK ]
Starting NFS mountd: [ OK ]
设置其开机自动启动
# chkconfig --level 2345 nfs on
3、客户端的设定
以root用户登录客户端,挂载服务端的/home目录至本机的/home目录,而后测试使用nisuser用户登录
# ssh -l nisuser 192.168.0.128
[email=nisuser@192.168.0.128's]nisuser@192.168.0.128's[/email]
password:
[nisuser@client ~]$ ls -a
. .. .bash_logout .bash_profile .bashrc .emacs .gtkrc .kde
[nisuser@client ~]$ ls /home
lost+found nisuser redhat
[nisuser@client ~]$ yppasswd
Changing NIS account information for nisuser on server.
Please enter old password:
The NIS password has been changed on server.
四、添加一台从服务器
1、编辑/etc/hosts文件,添加如下两行(非必要步骤)
192.168.0.16 server
192.168.0.228 Linux