Chinaunix首页 | 论坛 | 博客
  • 博客访问: 104406
  • 博文数量: 28
  • 博客积分: 2010
  • 博客等级: 大尉
  • 技术积分: 300
  • 用 户 组: 普通用户
  • 注册时间: 2009-07-10 09:48
文章分类

全部博文(28)

文章存档

2010年(1)

2009年(27)

我的朋友

分类: LINUX

2009-08-10 16:27:33

一、NIS服务器的功能。
 
   NIS服务器的功能专门用来管理账号和密码的服务器,以提供其他linux主机需要用户和密码登陆时,就必须要到这部专门管理用户密码的主机来查寻使用者的帐号与密码。
   全称:Network Information Service 最早应该是称为 Sun Yellow Pages (简称 yp).
  
 NIS服务功能原理:
NIS Server (master/slave) 的运作原理∶
NIS Master 先将本身的帐号密码相关档案制作成为资料库档案以便快速传输和读写。
NIS Master 可以主动的告知 NIS slave server 来更新;
NIS slave 亦可主动的前往 NIS master server 取得更新后的资料库档案;
若有帐号密码的异动时,需要重新制作 database 与重新同步化 master/slave。
 NIS Client 有任何登入查询的需求时∶
NIS client 若有登入需求时,会先查询其本机的 /etc/passwd, /etc/shadow 等档案;
若在 NIS Client 本机找不到相关的帐号资料,才开始向整个 NIS 网域的主机广播查询;
每部 NIS server (不论 master/slave) 都可以回应,基本上是『先回应者优先』。
二、NIS服务器的设定。
 
1、检查是否安装如下四个rpm文件。
[root@linux etc]# rpm -qa |grep ^yp
ypbind-1.19-8.el5
ypserv-2.19-3
yp-tools-2.9-0.1
[root@linux etc]# rpm -qa |grep portmap
portmap-4.0-65.2.2.1
 
2、设定NIS域名称。
[root@linux ~]# nisdomainname zwtnis
[root@linux ~]# vi /etc/rc.d/rc.local
# 加入底下这一行,开机即启动NIS域名称
/bin/nisdomainname zwtnis
3、设定/etc/ypserv.conf文件
(一般都无需改变,不考虑安全的话,可以直接将最后一行改为
*                         : * : * : none)即可使用。
[root@linux ~]# vi /etc/ypserv.conf
dns: no
files: 30
# 预设会有 30 个资料库被读入记忆体当中。
slp: no
slp_timeout: 3600
# 这两个与 SLP 服务有关,因为我们仅使用单纯的 NIS ,所以不需要启动。
xfr_check_port: yes
# 这个与 master/slave 有关,将同步更新的资料库比对所使用的埠口,
# 放置于小于 1024 的埠口内。
# 底下则是设定限制用户端或 slave server 查询的权限,利用冒号隔成四部分,分别为∶
# [主机名称/IP] : [NIS网域名称] : [可用资料库名称] : [安全限制]

# [安全限制]      ∶包括没有限制 (none)、仅能使用 <1024 (port) 及拒绝 (deny)
# 一般来说,你可以依照我们的网域来设定成为底下的模样∶
127.0.0.0/255.255.255.0   : * : * : none
192.168.1.0/255.255.255.0 : * : * : none
*                         : * : * : deny
# 星号 (*) 代表任何资料都接受的意思。上面三行的意思是,开放 lo 内部介面、
# 开放内部 LAN 网域,且杜绝所有其他来源的 NIS 要求的意思。
# 万一上面这三行权限相关的设定无法让你的 NIS 顺利的生效时,
# 你可以先将上面三行注解,然后加入底下这一行∶
*                         : * : * : none
# 这样应该就能够让 NIS 顺利的连线了。
 
4、设定主机名称 (/etc/hosts)
[root@linux ~]# vi /etc/hosts
127.0.0.1 linux.yft.com
192.168.1.202   master.zwtnis
192.168.1.100   clinet.zwtnis
 
除了这个设定之外,有时候你可能需要设定 /etc/netgroup ,事实上,如果这个档案是空的的话,那么(代表著全部的主机、帐号与域名称都接受)的意思.
[root@linux ~]# touch /etc/netgroup
 
5、启动服务
[root@linux ~]# /etc/init.d/portmap start          # RPC服务
Starting portmap:                                          [  OK  ]
[root@linux ~]# /etc/init.d/ypserv start           #NIS服务
Starting YP server services:                               [  OK  ]
[root@linux ~]# /etc/init.d/yppasswdd start   # yppasswdd提供NIS用户端密码修改功能Starting YP passwd service:                                [  OK  ]

[root@linux ~]# rpcinfo -p localhost
   program vers proto   port
    100000    2   tcp    111  portmapper
    100000    2   udp    111  portmapper
    100024    1   udp    898  status
    100024    1   tcp    901  status
    100004    2   udp    912  ypserv
    100004    1   udp    912  ypserv
    100004    2   tcp    915  ypserv
    100004    1   tcp    915  ypserv
    100009    1   udp    921  yppasswdd

6、在完成以上的步骤后,我们就需要在NIS服务器主机上将用户账号和密码建立成资料库。
直接通过 /usr/lib/yp/ypinit 这个指令来操作。

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

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

linux.yft.com

 

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

linux.yft.com has been set up as a NIS master server.

Now you can run ypinit -s linux.yft.com on all slave server.

然后需要重新启动以下两个服务。

[root@linux ~]# /etc/init.d/ypserv restart
[root@linux ~]# /etc/init.d/yppasswdd restart

三、NIS客户端的设定。

1. 直接建立NIS域名称
[root@linux ~]# nisdomainname zwtnis

2. 开机立即启动此一NIS域名称
[root@linux ~]# vi /etc/rc.d/rc.local
# 加入底下这一行∶
/bin/nisdomainname zwtnis

3. 预设在启动 ypbind 时,设定 NIS 域名
[root@linux ~]# vi /etc/sysconfig/network
# 加入底下这一行∶
NISDOMAIN=zwtnis

[root@linux ~]# vi /etc/hosts
192.168.1.202  master.zwtnis
192.168.1.100  client.zwtnis

4、启动bind

[root@linux ~]#authconfig-tui进入图形界面设定即可

5、NISclinet端的一些命令

yptest, ypwhich, ypcat,yppasswd

 

 

 

 

 



 

阅读(975) | 评论(0) | 转发(0) |
0

上一篇:NFS服务器架设

下一篇:无主题。

给主人留下些什么吧!~~