RHEL上NIS网络信息服务配置实例讲解(3)

8、启动客户端进程,并测试NIS服务器

# 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"

#ypcat passwd
RedHat:$1$btyeQR8Z$TR0OkRrcrXYmgxY.MEN2R.:500:501::/home/redhat:/bin/bash
说明:redhat为手动建立的系统帐号

# ypmatch redhat passwd
redhat:$1$btyeQR8Z$TR0OkRrcrXYmgxY.MEN2R.:500:501::/home/redhat:/bin/bash

二、客户端的设定

1、设定NIS域名
#nisdomainname benet
#vi /etc/sysconfig/network
添加:
NISDOMAIN=benet
#vi /etc/rc.local
添加:
/sbin/nisdomainname benet

2、查看是否已经安装相应的rpm包ypbind和yptools,RHEL4默认已经安装
# rpm -qa |grep ^yp
ypbind-1.17.2-3
yp-tools-2.8-7

3、设置主配置文件/etc/yp.conf
#vi /etc/yp.conf
添加如下行:
domain benet server 192.168.0.16
其语法格式为:
domain NISDOMAIN server HOSTNAME
其中NISDOMAIN为你的NIS域名,HOSTNAME为你的NIS服务器名字,推荐使用IP;或者你也可以设置/etc/hosts文件,使用客户端能解析NIS Server的主机名称,此处则可以写作服务器的主机名;

4、设置/etc/nsswitch.conf文件

找到如下项:
passwd: files
shadow: files
group: files
#hosts: db files ldap nis dns
hosts: files dns

将其修改为:
passwd: files nis
shadow: files nis
group: files nis
#hosts: db files ldap nis dns
hosts: files nis dns

5、查看客户端portmap进程的启动状况,确定无误后启动其ypbind进程:

# service portmap status
portmap (pid 1774) is running...

# service ypbind start
Shutting down NIS services: [ OK ]
Binding to the NIS domain: [ OK ]
Listening for an NIS domain server.

将ypbind设置为开机自动启动
#chkconfig --level 2345 ypbind on

6、测试客户端的连接

# ypcat passwd
redhat:$1$btyeQR8Z$TR0OkRrcrXYmgxY.MEN2R.:500:501::/home/redhat:/bin/bash

# ypmatch redhat passwd
redhat:$1$btyeQR8Z$TR0OkRrcrXYmgxY.MEN2R.:500:501::/home/redhat:/bin/bash

# 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

8、在服务器添加测试用户
#userdd niSUSEr
#passwd nisuer
并使用如下命令重建maps数据库,其使用方法见服务端设定部分
# /usr/lib/yp/ypinit -m

三、重新启动客户端来测试结果

1、客户端登录:
# ssh -l nisuser 192.168.0.128
nisuser@192.168.0.128's 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
nisuser@192.168.0.128's password:
[nisuser@client ~]$ ls -a
. .. .bash_logout .bash_profile .bashrc .emacs .gtkrc .kde
[nisuser@client ~]$ ls /home
lost+found nisuser redhat

编辑/etc/fstab文件,使其开机能自动挂载
192.168.0.16:/home /home ext3 defaults 0 0

4、在客户端使用yppasswd命令修改个人密码

[nisuser@client ~]$ yppasswd
Changing NIS account information for nisuser on server.
Please enter old password: <----此处要输入旧密码
Changing NIS password for nisuser on server.
Please enter new password: <----新密码
Please retype new password: <----确认新密码
The NIS password has been changed on server. <----修改的确认信息

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wwyxps.html