快捷搜索:   nginx

RHEL5 搭建 NIS 服务器

********* Server **************
[root@cuijj ~]# yum install ypserv yp-ols ypbind portmap
Loading "rhnplugin" plugin
Loading "security" plugin
This system is not registered with RHN.
RHN support will be disabled.
Setting up Install Process
Parsing package install arguments
Package ypserv - 2.19-3.i386 is already installed.
Package yp-tools - 2.9-0.1.i386 is already installed.
Package ypbind - 3:1.19-8.el5.i386 is already installed.
Package portmap - 4.0-65.2.2.1.i386 is already installed.
Nothing to do
[root@cuijj ~]# rpm -qa | grep yp
cryptsetup-luks-1.0.3-2.2.el5
ecryptfs-utils-41-1.el5
ypserv-2.19-3
libgcrypt-1.2.3-1
beecrypt-4.1.2-10.1.1
freetype-2.2.1-19.el5
m2crypto-0.16-6.el5.2
ypbind-1.19-8.el5
xorg-x11-fonts-truetype-7.1-2.1.el5
yp-tools-2.9-0.1
xorg-x11-fonts-Type1-7.1-2.1.el5
xorg-x11-drv-hyperpen-1.1.0-2
[root@cuijj ~]# rpm -qa | grep portmap
portmap-4.0-65.2.2.1
[root@cuijj ~]# vim /etc/ypserv.conf
----------------------------------------
dns: no
files: 30
slp_timeout: 3600
xfr_check_port: yes
----------------------------------------
[root@cuijj ~]# nisdomainname RHCE
[root@cuijj ~]# nisdomainname
RHCE
[root@cuijj ~]# vim /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.

/bin/nisdomainname RHCE
---------------------------------------
[root@cuijj ~]# vim /etc/sysconfig/network
---------------------------------------
NETWORKING=yes
NETWORKING_IPV6=yes
HOSTNAME=cuijj.com
NISDOMAIN=RHCE
---------------------------------------
[root@cuijj ~]# /usr/bin/yp/ypinit -m
-bash: /usr/bin/yp/ypinit: No such file or directory
[root@cuijj ~]# /usr/lib/yp/ypinit -m

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

cuijj.com

Is this correct? [y/n: y] y
We need a few minutes to build the databases...
Building /var/yp/RHCE/ypservers...
Running /var/yp/Makefile...
gmake[1]: Entering directory `/var/yp/RHCE'
Updating passwd.byname...
failed to send 'clear' to local ypserv: RPC: Program not registeredUpdating passwd.byuid...
failed to send 'clear' to local ypserv: RPC: Program not registeredUpdating group.byname...
failed to send 'clear' to local ypserv: RPC: Program not registeredUpdating group.bygid...
failed to send 'clear' to local ypserv: RPC: Program not registeredUpdating hosts.byname...
failed to send 'clear' to local ypserv: RPC: Program not registeredUpdating hosts.byaddr...
failed to send 'clear' to local ypserv: RPC: Program not registeredUpdating rpc.byname...
failed to send 'clear' to local ypserv: RPC: Program not registeredUpdating rpc.bynumber...
failed to send 'clear' to local ypserv: RPC: Program not registeredUpdating services.byname...
failed to send 'clear' to local ypserv: RPC: Program not registeredUpdating services.byservicename...
failed to send 'clear' to local ypserv: RPC: Program not registeredUpdating netid.byname...
failed to send 'clear' to local ypserv: RPC: Program not registeredUpdating protocols.bynumber...
failed to send 'clear' to local ypserv: RPC: Program not registeredUpdating protocols.byname...
failed to send 'clear' to local ypserv: RPC: Program not registeredUpdating mail.aliases...
failed to send 'clear' to local ypserv: RPC: Program not registeredgmake[1]: Leaving directory `/var/yp/RHCE'

cuijj.com has been set up as a NIS master server.

Now you can run ypinit -s cuijj.com on all slave server.
[root@cuijj ~]# /etc/init.d/ypserv restart
Stopping YP server services: [FAILED]
Starting YP server services: [ OK ]
[root@cuijj ~]# /etc/init.d/yppasswdd restart
Stopping YP passwd service: [FAILED]
Starting YP passwd service: [ OK ]
[root@cuijj ~]# vim /etc/sysconfig/network
----------------------------------
NETWORKING=yes
NETWORKING_IPV6=yes
HOSTNAME=cuijj.com
NISDOMAIN=RHCE
YPSERV_ARGS="-p 866"
YPXFRD_ARGS="-p 867"
----------------------------------
[root@cuijj ~]# service network restart
Shutting down interface eth0: [ OK ]
Shutting down loopback interface: [ OK ]
Bringing up loopback interface: [ OK ]
Bringing up interface eth0:
Determining IP information for eth0... done.
[ OK ]
[root@cuijj ~]# service ypserv restart
Stopping YP server services: [ OK ]
Starting YP server services: [ OK ]
[root@cuijj ~]# service ypxfrd restart
Stopping YP map server: [FAILED]
Starting YP map server: [ OK ]
[root@cuijj ~]# rpcinfo -p
   program vers proto   port
    100000    2   tcp    111 portmapper
    100000    2   udp    111 portmapper
    100024    1   udp    961 status
    100024    1   tcp    964 status
    100009    1   udp    960 yppasswdd
    100004    2   udp    866 ypserv
    100004    1   udp    866 ypserv
    100004    2   tcp    866 ypserv
    100004    1   tcp    866 ypserv
600100069    1   udp    867 fypxfrd
600100069    1   tcp    867 fypxfrd
[root@cuijj ~]# mkdir /nishome
[root@cuijj ~]# useradd -d /nishome/nisuser nisuser
[root@cuijj ~]# /usr/lib/yp/ypinit -m

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

cuijj.com

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

cuijj.com has been set up as a NIS master server.

Now you can run ypinit -s cuijj.com on all slave server.
[root@cuijj ~]# vim /etc/exports
----------------------------------
/tmp    *(ro,sync)
/data   *(ro,sync)
/home   192.168.0.0/255.255.255.0(rw,sync)
/nishome/nisuser *(rw,sync)
----------------------------------
[root@cuijj ~]# service nfs restart
Shutting down NFS mountd: [FAILED]
Shutting down NFS daemon: [FAILED]
Shutting down NFS services: [FAILED]
Starting NFS services: [ OK ]
Starting NFS quotas: [ OK ]
Starting NFS daemon: [ OK ]
Starting NFS mountd: [ OK ]
[root@cuijj ~]# vim /etc/auto.master
--------------------------------
/misc   /etc/auto.misc
/nishome /etc/auto.home // nishome is the dictory for guest to mount ; auto.home is the guest setting file for autofs
--------------------------------
[root@cuijj ~]# vim /etc/auto.home
--------------------------------------------
*       -fstype=nfs     192.168.148.128:/nishome/&
--------------------------------------------
[root@cuijj ~]# service autofs restart
Stopping automount: [ OK ]
Starting automount: [ OK ]
[root@cuijj ~]# chkconfig --level 3 ypserv on

---------------------------- OK -----------------------------

************** Client ******************
1.安装所需软件:
[root@cuijj ~]# yum install ypbind yp-tools

2.加入NIS域:
[root@cuijj ~]# nisdomainname RHCE
[root@cuijj ~]# vim /etc/sysconfig/network
------------
NISDOMAIN=RHCE
------------
[root@cuijj ~]# vim /etc/rc.d/rc.local
------------
/bin/nisdomainname RHCE
------------

3.修改hosts文件:
[root@cuijj ~]# vim /etc/hosts
---------------
192.168.148.128 cuijj
---------------

4.修改密码验证方式:
[root@cuijj ~]# vim /etc/nsswitch.conf
---------------
passwd:      files cuijj
shadow:     files cuijj
group:       files cuijj

#hosts:     db files nisplus nis dns
hosts:      files nis dns
---------------

5.修改/etc/yp.conf文件:
---------------
domain RHCE
ypserver cuijj
---------------

6.重新启动ypbind服务:
[root@cuijj ~]# /etc/rc.d/init.d/ypbind start
注意客户端一定要开启111端口,可以用 rpcinfo -p localhost 进行查看

7.设置ypbind服务开机运行:
[root@cuijj ~]# chkconfig --level 35 ypbind on

8.客户端检测:
yptest: 测试数据库内容等所有与NIS有关的资料
ypwhich: 测试NIS客户端与之间通信使用的哪些数据库文件
ypcat: 可以查看NIS服务器上使用者的账号信息,也可以查看NIS服务器上的/etc/hosts文件记录哪些主机信息

9.修改用户密码:
yppasswd
密码长度不能少于6位,另外yppasswd还能自动更新NIS数据库中的内容

-------------------------- OK -----------------------------

*********** TroubleShooting ************
1.客户端无法查询NIS信息:
(1).域名设置错误:使用nisdomainname查询,如果有问题,进入配置文件修改,并开启ypbind服务
(2).检查与NIS服务器的连通性,并检查yp.conf是否添加了特定的NIS服务器,并且该主机出现异常,改为广播形式,重新尝试访问。

2.添加新的数据无法生效:
(1).主服务器没有更新数据库:重新生成数据库文件:ypinit -m
(2).从服务器没有同步数据:检测NIS从服务器的设置是否正确,并保证其与NIS主服务器的连通性

顶(0)
踩(0)

您可能还会对下面的文章感兴趣:

最新评论