NIS服务端配置

NIS服务安装

[root@localhost /]mount /dev/hdc /hdc

[root@localhost /]cd /hdc/Server/

[root@localhost Server]rpm ivh ypserv-2.13-5.i386.rpm

[root@localhost Server]cd /

[root@localhost /]

设置timetime-udp的启动状态

[root@localhost /]chkconfig time on

[root@localhost /]chkconfig time-udp on

[root@localhost /]service xinetd restart

NIS服务器主机中建立NIS域名

[root@localhost /]nisdomainname nistest

[root@localhost /]echo '/bin/nisdomainname nistest' >> /etc/rc.d/rc.local

[root@localhost /]echo 'NISDOMAIN=nistest' >> /etc/sysconfig/network

NIS主配置文件

[root@localhost /]vi /etc/ypserv.conf

127.0.0.0/255.255.255.0     : *       : *    : none

192.168.1.0/255.255.255.0   : *       : *    : none

*                           : *       : *    : deny

//每一行配置文件都是由三个“:”分成四个部分

在配置文件中添加两行

127.0.0.0/255.0.0.0             :*          :*          :none

192.168.0.0/255.255.255.0       :*          :*          :none

启动NIS服务器

//NIS服务器需要portmap服务的支持,并且需要启动ypservyppasswdd两个服务

[root@localhost /]service portmap start

[root@localhost /]service ypsery start

[root@localhost /]service yppasswdd start

[root@localhost /]useradd nis               //创建用户方便验证

[root@localhost /]passwd nis                //配置密码

构建NIS数据库

[root@localhost /]/usr/lib/yp/ypinit –m

 

下面完成客户端的配置

设置hosts文件

[root@locaohost /]echo ‘192.168.0.1 LinServ’  >> /etc/rc.d/rc.local

建立NIS域名

[root@locaohost /]nisdomainname nistest

[root@locaohost /]echo '/bin/nisdomainname nistest' >> /etc/rc.d/rc.local

[root@locaohost /]echo 'NISDOMAIN=nistest' >> /etc/sysconfig/network

设置yp.conf配置文件

[root@locaohost /]echo 'domain nistest server LinServ' >> /etc/yp.conf

设置nsswitch.conf文件

passwd:     files nis

shadow:     files nis

group:      files nis

hosts:      files nis dns

启动ypbind服务

[root@locaohost /]service portmap status

[root@locaohost /]service ypbind start

测试NIS服务器

1Yptest命令可对NIS服务器进行自动测试

[root@localhost /]yptest

2ywhich命令可显示NIS客户机所是哟那个的NIS服务器的主机名称和数据库文件列表

[root@localhost /]ypwhich

[root@localhost /]ypwhich –x

3ypcat命令显示数据库文件列表和制定数据库的内容

[root@localhost /]ypcat –x

[root@localhost /]ypcat passwd

当用户从客户端登陆时会发现没有宿主目录,所以说得在NIS服务器上做NFS服务。

NIS服务器中将“/home”目录输出为NFS共享目录

exports文件中设置NFS共享目录

/home           *(rw)

启动NFS服务器

[root@localhost /]service nfs start

在所有NIS客户机中挂载NIS服务器主机中的“/home”目录

    fstabl文件中添加NFS文件系统挂载记录

    LinServ:/home/      /home   nfs default 0 0

    使用mount命令挂载“/home”目录

    [root@localhost /]mount /home

 

 

 

现在就可以试着从客户端登陆了。

本文出自 “ 你的支持,我的动力” 博客,请务必保留此出处 http://coolcup.blog.51cto.com/484305/163620