原创NIS 服务器搭建 加客户端配置

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

在这里我不需要多说什么,希望大家能够相互多多交流哈!
操作开始~~~~~~
NIS服务器的配置
1、安装服务器软件
检查Linux的服务器是否有NIS服务器端软件:ypserv
[root@rhel ~]# rpm -qa | grep yp
如果没有需要安装,将Linux安装光盘放入光驱:或者YUM 进行安装
[root@test Server]# yum install yp*
warning: ypserv-2.13-14.i386.rpm: V3 DSA signature: NOKEY, key ID db42a60e Preparing... ########################################### [100%] 1:ypserv ########################################### [100%]
环境:
NIS服务器 RHEL 5 IP地址10.6.0.127
NIS客户机 RHEL 5 IP地址10.6.0.156
1、设置NIS域名
听上去要建立域名,注意这个和DNS域是一点关系斗都没有的,这里所谓的NIS域名就像的电脑网络中的工作组一样,只有当NIS客户机都属于一个NIS域的时候,NIS服务器才有权对其管理的能力。

我们建立一个域名:
在NIS服务器上(10.6.0.127),执行一下命令:
[root@rhel ~]# nisdomainname <==建立一个域名:
[root@rhel ~]# vi /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=rhel
NISDOMAIN= <==增加这一行,也就是我们刚才建立的域
2、配置NIS服务的配置文件
这个文件位于/etc目录下
执行以下命令:
[root@rhel ~]# 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.0/255.255.255.0 : * : * : none
# * 设置NIS客户机的网段,也就是其他Linux服务器所在的网段,并允许访问NIS服务器10.6.0.0/255.255.255.0 : * : * : none
# *设置其他的Linux服务器都会被NIS服务器拒绝
* : * : * : deny
# Not everybody should see the shadow passwords, not secure, since
# under MSDOG everbody is root and can access ports < 1024 !!!
* : * : shadow.byname : port
* : * : passwd.adjunct.byname : port
# If you comment out the next rule, ypserv and rpc.ypxfrd will
# look for YP_SECURE and YP_AUTHDES in the maps. This will make
# the security check a little bit slower, but you only have to
# change the keys on the master server, not the configuration files
# on each NIS server.
# If you have maps with YP_SECURE or YP_AUTHDES, you should create
# a rule for them above, that's much faster.
# * : * : * : none
设置完成以后保存退出。

以上设置的是NIS服务器中数据库的访问策略,如果需要更高的安全性,还可以根据需要配置NIS客户机的访问控制。

(其实这个可以去做不做也可以省的麻烦)
这个时候需要配置/etc/yp/securenets文件:
这个文件需要手工建立:
[root@rhel yp]# touch securenets
[root@rhel yp]# vi securenets
增加以下内容:
host 127.0.0.1
255.255.255.0 10.6.0.0
# *主机记录以host开头,后面跟上IP地址,这里设置可以让本机访问,如果需要增加其他的服务器访问,可以继续增加:host 192.168.3.100。

# *如果是一个网段,必须注意子网掩码在前,网段地址在后。

这个时候基本上就配置完成了。

3、启动NIS服务器
[root@rhel yp]# service portmap restart
Stopping portmap: [ OK ]
Starting portmap: [ OK ]
[root@rhel yp]# service ypserv restart
Stopping YP server services: [FAILED]
Starting YP server services: [ OK ]
[root@rhel yp]# service yppasswdd restart
Stopping YP passwd service: [FAILED] Starting YP passwd service: [ OK ]
如果需要开机执行这些命令,执行以下命令:
[root@rhel yp]# chkconfig --list | grep yp
ypserv 0:off 1:0ff 2:off 3:off 4:off 5:off 6:off ypxfrd 0:off 1:off 2:off 3:off 4:off 5:off 6:off yppasswdd 0:off 1:off 2:off 3:off 4:off 5:off 6:off ypbind 0:off 1:off 2:off 3:off 4:off 5:off 6:off [root@rhel yp]# chkconfig --level 35 ypserv on
[root@rhel yp]# chkconfig --level 35 yppasswdd on
[root@rhel yp]# chkconfig --list | grep yp
ypserv 0:off 1:off 2:off 3:on 4:off 5:on 6:off ypxfrd 0:off 1:off 2:off 3:off 4:off 5:off 6:off yppasswdd 0:off 1:off 2:off 3:on 4:off 5:on 6:off ypbind 0:off 1:off 2:off 3:off 4:off 5:off 6:off
这样就可以了:
4、构建NIS数据库
执行以下命名就可以了:
[root@rhel yp]# /usr/lib/yp/ypinit -m
At this point, we have to construct a list of the hosts which will run NIS servers. rhel 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:
next host to add: <===这里按CTRL+D
The current list of NIS servers looks like this:
rhel
Is this correct? [y/n: y] y <===输入y
We need a few minutes to build the databases...
Building /var/yp//ypservers...
Running /var/yp/Makefile...
gmake[1]: Entering directory `/var/yp/' 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/' rhel has been set up as a NIS master server.
Now you can run ypinit -s rhel on all slave server. 这样,数据库就建立好了。

接下来配置NIS客户端
注意客户端必须有ypbind和yp-tools两个软件包。

我们在NIS客户机上(10.6.0.156)上可以查看安装的软件包:[root@linux5 ~]# rpm -qa | grep yp
ypbind-1.19-8.el5
libgcrypt-1.2.3-1
beecrypt-4.1.2-10.1.1
freetype-2.2.1-19.el5
m2crypto-0.16-6.el5.1
cryptsetup-luks-1.0.3-2.2.el5
yp-tools-2.9-0.1
[root@linux5 ~]# nisdomainname <==建立一个域名: [root@linux5 ~]# vi /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=rhel
NISDOMAIN= <==增加这一行,也就是我们刚才建立的域 执行命令:
[root@linux5 ~]# authconfig-tui
1,出现下图:选择Use nis
2,添加你之前的NIS server
如果成功如下图显示
这样NIS客户机就配置完成了
测试一下:
[root@linux5 ~]# ypwhich
显示NIS服务器的名称。

我们在服务器上增加新用户:Rlogin,然后使用这个新用户登录客户机:
NIS服务器 RHEL 5 IP地址 10.6.0.127
NIS客户机 RHEL 5 IP地址 10.6.0.156
[root@test home]# mkdir nishome
[root@test home]# useradd -d /home/nishome/Rlogin Rlogin
增加了新用户后,必须更新数据库:再次执行以下命令:
[root@test Server]# /usr/lib/yp/ypinit -m
然后使用这个用户在客户机上登录:
[root@test ~]# su Rlogin
bash-3.1$
bash-3.1$ e
提示登录成功了,但是没有用户 Rlogin的家目录,也就是/home/Rlogin这个目录。

到这里,我们的NIS服务器就算成功了,
不过没有宿主目录,后面还需要将NIS服务器上的/home目录要分别挂载到每台NIS客户机的/home目录,这样每个用户登录后,才会找到自己的家目录。

其实你也可以用把服务器端上的home 挂载到客户端
所以我们接着做NFS+NIS+Autofs客户端配置
1,进行编辑auto.master
[root@test ~]# vi /etc/auto.master
# $Id: auto.master,v 1.4 2005/01/04 14:36:54 raven Exp $
# Sample auto.master file
# This is an automounter map and it has the following format
# key [ -mount-options-separated-by-comma ] location
# For details of the format look at autofs(5).
/misc /etc/auto.misc
/net -hosts
/home/nishome /etc/auto.nisuser
# Include central master map if it can be found using
# nsswitch sources.
# Note that if there are entries for /net or /misc (as
# above) in the included master map any keys that are the
# same will not be seen as the first read key seen takes
# precedence.
+auto.master
保存退出
2,把/etc/auto.misc 复制一份,并重命名为auto.nisuse
cp /etc/auto.misc /etc/auto.nisuser
vim /etc/auto.nisuser
# This is an automounter map and it has the following format
# key [ -mount-options-separated-by-comma ] location
# Details may be found in the autofs(5) manpage
cd -fstype=iso9660,ro,nosuid,nodev :/dev/cdrom
# the following entries are samples to pique your imagination
#linux -ro,soft,intr :/pub/linux
#boot -fstype=ext2 :/dev/hda1
#floppy -fstype=auto :/dev/fd0
#floppy -fstype=ext2 :/dev/fd0
#e2floppy -fstype=ext2 :/dev/fd0
#jaz -fstype=ext2 :/dev/sdc1
#removable -fstype=ext2 :/dev/hdd
* -rw.soft,inir 10.6.0.127:/home/nishome & "/etc/auto.nisuser" 18L, 619C written
[root@test ~]# service netfs restart
Mounting other filesystems: [ OK ]
[root@test ~]# service portmap restart
Stopping portmap: [ OK ]
Starting portmap: [ OK ]
[root@test ~]# service autofs restart
Stopping automount: [ OK ]
Starting automount: [ OK ]
测试:
[root@test home]# su – Rlogin
[Rlogin@ ~]
正常登陆OK ~~~~收工周末愉快!!!。

相关文档
最新文档