码迷,mamicode.com
首页 > 系统相关 > 详细

Linux NIS server

时间:2015-01-30 17:53:57      阅读:221      评论:0      收藏:0      [点我收藏+]

标签:

NIS(Network Information Service)使用来在共享需要在网络上所有主机上使用的信息的。NIS起源是Sun Microsystems的Yellow Page,但YP已经注册公司,所以就取了NIS这个名字, NIS服务器管理账户信息,如果所有客户机都在域中,那么只需要一台NIS服务器储存用户就可以了,不需要每台机子都存放
软件安装
[root@alicia ~]# yum install ypserver
[root@alicia ~]# rpm -qa | grep yp
ypbind-1.19-12.el5_6.1
ypserv-2.19-10.el5_9.1
yp-tools-2.9-2.el5



设置域名
[root@alicia ~]# nisdomainname nis
[root@alicia ~]# vi /etc/sysconfig/network
  1 NETWORKING=yes
  2 NETWORKING_IPV6=yes
  3 HOSTNAME=alicia.net
  4 NISDOMAIN=nis



配置并启动守护进程
[root@alicia ~]# vi /etc/rc.d/rc.local 
  1 #!/bin/sh
  2 #
  3 # This script will be executed *after* all the other init scripts.
  4 # You can put your own initialization stuff in here if you don‘t
  5 # want to do the full Sys V style init stuff.
  6 
  7 touch /var/lock/subsys/local
  8 nisdomainname nis



配置访问权限
[root@alicia ~]# vi /etc/ypserv.conf 
 50 127.0.0.1/255.255.255.0    : *       : *                : none
 51 10.8.118.0/255.255.255.0    : *       : *                : none
 52 *                          : *        : *                : deny



增加测试用户
[root@alicia ~]# useradd nis
[root@alicia ~]# passwd nis
Changing password for user nis.
New UNIX password: 
BAD PASSWORD: it is based on a dictionary word
Retype new UNIX password: 
passwd: all authentication tokens updated successfully.



初始化NIS映射
[root@alicia ~]# service ypserv restart
Stopping YP server services:                               [FAILED]
Starting YP server services:                               [  OK  ]
[root@alicia ~]# /usr/lib/yp/ypinit -m 

At this point, we have to construct a list of the hosts which will run NIS
servers.  centos 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 <control D>.
        next host to add:  centos
        next host to add:  alicia.net
        next host to add:  alicia
        next host to add:  
The current list of NIS servers looks like this:

centos
alicia.net
alicia

Is this correct?  [y/n: y]  y
We need a few minutes to build the databases...
Building /var/yp/nis/ypservers...
Running /var/yp/Makefile...
gmake[1]: Entering directory `/var/yp/nis‘
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/nis‘

centos has been set up as a NIS master server.

Now you can run ypinit -s centos on all slave server.



启动服务
[root@alicia ~]# service ypserv restart
Stopping YP server services:                               [  OK  ]
Starting YP server services:                               [  OK  ]
[root@alicia ~]# service yppasswdd restart
Stopping YP passwd service:                                [FAILED]
Starting YP passwd service:                                [  OK  ]



client:
软件安装
[root@Samsun ~]# rpm -qa | grep yp
yp-tools-2.9-2.el5
ypbind-1.19-12.el5_6.1



nis设置
[root@Samsun ~]# nisdomainname nis
[root@Samsun ~]# vi /etc/sysconfig/network
NETWORKING=yes
NETWORKING_IPV6=yes
HOSTNAME=Samsun
NISDOMAIN=nis

[root@Samsun ~]# vi /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
domainname nis
~



设置hosts找到nis server
[root@Samsun ~]# vi /etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1               centos localhost.localdomain localhost Samsun Samsun.net
::1             localhost6.localdomain6 localhost6
10.8.118.100    alicia.net



修改客户端配置
[root@alicia ~]# vi /etc/yp.conf 

 22 ypserver alicia.net
 23 domain nis



修改认证文件
[root@alicia ~]# vi /etc/nsswitch.conf 

 28 # Example:
 29 #passwd:    db files nisplus nis
 30 #shadow:    db files nisplus nis
 31 #group:     db files nisplus nis
 32 
 33 passwd:     files nis
 34 shadow:     files nis
 35 group:      files nis



客户端服务启动
[root@alicia ~]# service ypbind restart
Shutting down NIS services:                                [FAILED]
Binding to the NIS domain:                                 [  OK  ]
Listening for an NIS domain server.



此时这个客户端就能够用nis/password这个用户去登录了,因为它已经加到域nis中,nis服务器上有这个用户,那它也可以用

Linux NIS server

标签:

原文地址:http://my.oschina.net/hding/blog/373723

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!