Chinaunix首页 | 论坛 | 博客
  • 博客访问: 101947611
  • 博文数量: 19283
  • 博客积分: 9968
  • 博客等级: 上将
  • 技术积分: 196062
  • 用 户 组: 普通用户
  • 注册时间: 2007-02-07 14:28
文章分类

全部博文(19283)

文章存档

2011年(1)

2009年(125)

2008年(19094)

2007年(63)

分类: LINUX

2008-05-05 16:37:26

 

NIS(Network Information Service)是一个为网络中所有的机器提供网络信息的系统,包括用户名、密码、主目录、组信息等。如果某个用户的用户名以及密码保存在了NIS密码数据库中,NIS允许此用户在网络当中的任何一台运行有NIS客户程序的机器上登陆。这使得整个网络看起来象一个独立系统,在所有的主机上有着相同的帐号。在Windows的AD(活动目录)中,这被称为“帐户漫游”。
NIS是由SUN公司开发的,所以最初被叫做Sun Yellow Page。另一方面,Yellow Pages是英国电信的商标,英国电信一直要求Sun更换这个名字。随着NIS被人们越来越广泛的使用,某些名称已与人们分不开了,所以YP一直以与NIS相关命令的前缀形式继续存在着,比如ypserv、ypbind等等。

NIS是一个客户机/服务器系统,下面我们来分别介绍NIS的服务器和NIS客户端的配置。

1、确定已经安装了ypser包。如果没有,请按以下方式安装。

#rpm -ivh ypserv-2.19-3.i386.rpm

2、确定ypserv,yppasswdd已经运行在相应的运行级别。

[root@ts3-142 ~]# chkconfig --list |grep yp
ypbind          0:off   1:off   2:on    3:on    4:on    5:on    6:off
yppasswdd       0:off   1:off   2:on    3:on    4:on    5:on    6:off
ypserv          0:off   1:off   2:on    3:on    4:on    5:on    6:off

ypserv是NIS server守护进程,yppasswdd是NIS password守护进程。
3、在/etc/sysconfig/network里插入一行:

[root@ts3-142 ~]# cat /etc/sysconfig/network
NETWORKING=yes
NETWORKING_IPV6=yes
HOSTNAME=localhost.localdomain
NISDOMAIN=turbolinux         //这就是我们定义的NIS域名

4、修改/var/yp/Makefile,找到all一行,确定要共享的资源。

all:  passwd group hosts rpc services netid protocols mail \
        # netgrp shadow publickey networks ethers bootparams printcap \
        # amd.home auto.master auto.home auto.local passwd.adjunct \
        # timezone locale netmasks

我只想为网络中的机器提供用户名和组信息,所以我只保留了passwd和group,其它的资源都去掉了。
5、建立并安装NIS database。

[root@ts3-142 ~]# /usr/lib/yp/ypinit -m

At this point, we have to construct a list of the hosts which will run NIS
servers.  ts3-142.ts.cn.tlan 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:  ts3-142.ts.cn.tlan
        next host to add:  
The current list of NIS servers looks like this:

ts3-142.ts.cn.tlan

Is this correct?  [y/n: y]  
We need a few minutes to build the databases...
Building /var/yp/turbolinux/ypservers...
Running /var/yp/Makefile...
gmake[1]: Entering directory `/var/yp/turbolinux'
Updating passwd.byname...
Updating passwd.byuid...
Updating group.byname...
Updating group.bygid...
gmake[1]: Leaving directory `/var/yp/turbolinux'

ts3-142.ts.cn.tlan has been set up as a NIS master server.

Now you can run ypinit -s ts3-142.ts.cn.tlan on all slave server.

6、重新启动yppasswdd进程。

[root@ts3-142 ~]# /etc/init.d/yppasswdd restart
Stopping YP passwd service:                                [  OK  ]
Starting YP passwd service:                                [  OK  ]

7、确定ypserv进程运行正常。

[root@ts3-142 ~]# ps aux|grep -i yp|grep -v grep
root      3554  0.0  0.1   1936   412 ?        S    02:09   0:00 rpc.yppasswdd
root      3581  0.0  0.2   1772   592 ?        S    02:11   0:00 ypserv

1、确认已经安装了这几个包:portmap,ypbind,yp-tools和authconfig。
2、确认客户端可以看到服务器上的portmap服务

[root@ts3-164 ~]# rpcinfo -p 172.16.78.142 
   program vers proto   port
    100000    2   tcp    111  portmapper
    100000    2   udp    111  portmapper
    100024    1   udp    983  status
    100024    1   tcp    986  status
    100009    1   udp    763  yppasswdd
    100004    2   udp    791  ypserv
    100004    1   udp    791  ypserv
    100004    2   tcp    794  ypserv
    100004    1   tcp    794  ypserv

3、将客户端跟NIS服务器绑定。 A)、编辑配置文件方法:
首先,将NIS服务器的主机名和IP地址在/etc/hosts里map。

[root@ts3-164 ~]# cat /etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1               localhost.localdomain localhost

172.16.78.142           nisserver

然后,编辑/etc/yp.conf

[root@ts3-164 ~]# cat /etc/yp.conf 
# /etc/yp.conf - ypbind configuration file
# Valid entries are
#
# domain NISDOMAIN server HOSTNAME
#       Use server HOSTNAME for the domain NISDOMAIN.
#
# domain NISDOMAIN broadcast
#       Use  broadcast  on  the local net for domain NISDOMAIN
#
# domain NISDOMAIN slp
#       Query local SLP server for ypserver supporting NISDOMAIN
#
# ypserver HOSTNAME
#       Use server HOSTNAME for the  local  domain.  The
#       IP-address of server must be listed in /etc/hosts.
#
# broadcast
#       If no server for the default domain is specified or
#       none of them is rechable, try a broadcast call to
#       find a server.
#
domain turbolinux server nisserver
domain turbolinux broadcast
domain turbolinux slp
ypserver nisserver
broadcast

最后,运行authconfig工具来绑定NIS。

[root@ts3-164 ~]# authconfig --update --enablenis
Stopping portmap:                                          [  OK  ]
Starting portmap:                                          [  OK  ]
Shutting down NIS services:                                [  OK  ]
Binding to the NIS domain:                                 [  OK  ]
Listening for an NIS domain server.

B)、用authconfig-tui工具。如图1、图2

图1

图2
这样,我们的NIS客户端也配置好了。

1、首先,在NIS服务器端创建新用户nisuser;然后用此帐号分别在NIS服务器和客户端上登陆,看是否能成功。结果是,nisuser只能在NIS服务器端登陆,而在NIS客户端无法登陆。
2、在服务器/var/yp目录下执行make命令,然后再在客户端用nisuser帐号登陆,是否可以成功登陆了呢?

[root@ts3-142 yp]# pwd
/var/yp
[root@ts3-142 yp]# make
gmake[1]: Entering directory `/var/yp/turbolinux'
Updating passwd.byname...
Updating passwd.byuid...
Updating group.byname...
Updating group.bygid...
gmake[1]: Leaving directory `/var/yp/turbolinux'
阅读(282) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~