搭建NIS服务器

搭建NIS服务器

作者:LAMP小白  点击:2009  发布日期:2013-04-17 23:39:00  返回列表

服务器

安装服务器端
yum install ypserv

设置NIS域和启动的端口
[root@mio_U2 dvd]# vi /etc/sysconfig/network
NETWORKING=yes
NETWORKING_IPV6=no
HOSTNAME=mio_U2
NISDOMAIN=mio
YPSERV_ARGS="-p 1011"

设置NIS配置文件
[root@mio_U2 dvd]# vi /etc/ypserv.conf
#
# ypserv.conf In this file you can set certain options for the NIS server,
# and you can deny or restrict access to certain maps based
# on the originating host.
#
# See ypserv.conf(5) for a description of the syntax.
#

# Some options for ypserv. This things are all not needed, if
# you have a Linux net.

# Should we do DNS lookups for hosts not found in the hosts table ?
# This option is ignored in the moment.
dns: no

# How many map file handles should be cached ?
files: 30

# Should we register ypserv with SLP ?
slp: no
# After how many seconds we should re-register ypserv with SLP ?
slp_timeout: 3600

# xfr requests are only allowed from ports < 1024
xfr_check_port: yes

# The following, when uncommented, will give you shadow like passwords.
# Note that it will not work if you have slave NIS servers in your
# network that do not run the same server as you.

# Host : Domain : Map : Security
#
# * : * : passwd.byname : port
# * : * : passwd.byuid : port
127.0.0.1/32 : * : * : none
192.168.0.1/24 : * : * : none

设置host
[root@mio_U2 dvd]# vi /etc/host
192.168.1.202 mio_U2
192.168.1.203 mio_U3

设置yppasswdd
[root@mio_U2 dvd]# vi /etc/sysconfig/yppasswdd
# The passwd and shadow files are located under the specified
# directory path. rpc.yppasswdd will use these files, not /etc/passwd
# and /etc/shadow.
#ETCDIR=/etc

# This options tells rpc.yppasswdd to use a different source file
# instead of /etc/passwd
# You can't mix usage of this with ETCDIR
#PASSWDFILE=/etc/passwd

# This options tells rpc.yppasswdd to use a different source file
# instead of /etc/passwd.
# You can't mix usage of this with ETCDIR
#SHADOWFILE=/etc/shadow

# Additional arguments passed to yppasswd
YPPASSWDD_ARGS="--port 1012"

启动NIS
[root@mio_U2 dvd]# /etc/init.d/ypserv start
Setting NIS domain name mio: [ OK ]
Starting YP server services: [ OK ]
[root@mio_U2 dvd]# /etc/init.d/yppasswdd start
Starting YP passwd service: [ OK ]
[root@mio_U2 dvd]# chkconfig ypserv on
[root@mio_U2 dvd]# chkconfig yppasswdd on


检测NIS

[root@mio_U2 dvd]# rpcinfo -p localhost
program vers proto port
100000 2 tcp 111 portmapper
100000 2 udp 111 portmapper
100024 1 udp 624 status
100024 1 tcp 627 status
100004 2 udp 1011 ypserv
100004 1 udp 1011 ypserv
100004 2 tcp 1011 ypserv
100004 1 tcp 1011 ypserv
100009 1 udp 1012 yppasswdd

建立NIS数据库

[root@mio_U2 dvd]# /usr/lib/yp/ypinit -m

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

mio_U2

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

mio_U2 has been set up as a NIS master server.

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

客户端

设置NIS登陆
setup

挂载用户home目录
[root@mio_U3 /]# mount -t nfs 192.168.1.202:/miohome /miohome



上一篇:RHEL 5使用光盘YUM源 下一篇:快递查询API
0