一:简介
NIS服务即Network Information Services网络信息服务。由SUN开发。基于RPC设计,采用C/S模式。NIS早期命名为黄页(yellow pages),简称YP.NIS的主要功能是对主机账号系统等系统信息
提供集中的管理。
软件包的安装:
portmap
NIS是与NFS一样依赖于RPC的服务,通常这个软件包系统默认都会安装。
yp-tools
提供NIS相关指令查寻功能,通常默认会安装。
ypbind
提供NIS Client 设定档,通常默认会安装。
ypserv
提供NIS Server 设定档。
二:案例
1.服务器端
安装软件包
[root@localhost ~]# mkdir /mnt/cdrom
[root@localhost ~]# mount /dev/cdrom /mnt/cdrom
mount: block device /dev/cdrom is write-protected, mounting read-only
[root@localhost ~]# cd /mnt/cdrom/Server/
[root@localhost Server]# rpm -ivh yp
ypbind-1.19-12.el5.i386.rpm ypserv-2.19-5.el5.i386.rpm
yp-tools-2.9-0.1.i386.rpm
[root@localhost Server]# rpm -ivh ypserv-2.19-5.el5.i386.rpm
warning: ypserv-2.19-5.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
Preparing...
########################################### [100%]
1:ypserv ########################################### [100%]
启动服务
[root@localhost Server]# service ypserv start
[root@localhost Server]# chkconfig ypserv on
[root@localhost Server]# service yppasswdd start
启动 YP 口令服务:
[确定]
[root@localhost Server]# chkconfig yppasswdd on
[root@localhost Server]# cd /var/yp/
[root@localhost yp]# vim Makefile
all: passwd group hosts \
编辑域环境
[root@localhost yp]# vim /etc/sysconfig/network
NISDOMAIN=rhce
产生域
[root@localhost yp]# /usr/lib/yp/ypinit -m
At this point, we have to construct a list of the hosts which will run NIS
servers. localhost.localdomain 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: localhost.localdomain
next host to add:
The current list of NIS servers looks like this:
localhost.localdomain
Is this correct? [y/n: y] y
[root@localhost yp]# ll
总计 44
drwxr-xr-x 2 root root 4096 2009-04-15 binding
-rw-r--r-- 1 root root 16635 08-19 19:55 Makefile
-rw-r--r-- 1 root root
185 2006-07-13 nicknames
drwxr-xr-x 2 root root 4096 08-19 20:04 rhce
-rw-r--r-- 1 root root
22 08-19 20:04 ypservers
建立帐号,导入账号库
[root@localhost ~]# useradd user3
[root@localhost ~]# passwd user3
Changing password for user user3.
New UNIX password:
BAD PASSWORD: it is WAY too short
Retype new UNIX password:
passwd: all authentication tokens updated successfully.
[root@localhost ~]# cd /var/yp/
[root@localhost yp]# make
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...
gmake[1]: Leaving directory `/var/yp/rhce'
客户端配置
测试
2.设置手动挂载, 共享服务器端用户家目录
[root@localhost ~]# vim /etc/exports
/home 192.168.20.0/24(rw,sync)
[root@localhost yp]# service nfs restart
关闭 NFS mountd:
[确定]
关闭 NFS 守护进程:
[确定]
关闭 NFS quotas:
[确定]
关闭 NFS 服务:
[确定]
启动 NFS 服务:
[确定]
关掉 NFS 配额:
[确定]
启动 NFS 守护进程:
[确定]
启动 NFS mountd:
[确定]
[root@localhost yp]# chkconfig nfs on
导入共享清单
[root@localhost yp]# exportfs -rv
exporting 192.168.20.0/24:/home
客户端导入查看共享清单
客户端登录测试
3.为提高服务器可用性设置自动挂载
删除手动挂载
服务器端配置
[root@localhost yp]# vim /etc/exports
/nishome 192.168.20.0/24(rw,sync)
3、导出共享清单
[root@localhost yp]# exportfs -rv
exporting 192.168.20.0/24:/nishome
[root@localhost yp]# mkdir /nishome
[root@localhost yp]# useradd -d /nishome/user10 user10
[root@localhost yp]# passwd user10
Changing password for user user10.
New UNIX password:
BAD PASSWORD: it is WAY too short
Retype new UNIX password:
passwd: all authentication tokens updated successfully.
刷新账号库
cd /var/yp
[root@localhost yp]# make
重启服务
[root@localhost yp]# service nfs restart
关闭 NFS mountd:
[确定]
关闭 NFS 守护进程:
[确定]
关闭 NFS quotas:
[确定]
关闭 NFS 服务:
[确定]
启动 NFS 服务:
[确定]
关掉 NFS 配额:
[确定]
启动 NFS 守护进程:
[确定]
启动 NFS mountd:
[确定]
客户端配置
[root@localhost ~]# vim /etc/auto.master
10 /nishome
/etc/auto.qq --timeout=60
[root@localhost ~]# cp /etc/auto.misc /etc/auto.qq
[root@localhost ~]# vim /etc/auto.qq
*
-ro,soft,intr 192.168.20.10:/nishome/&
[root@localhost ~]# mkdir /nishome
[root@localhost ~]# chmod o+wt /nishome/
[root@localhost ~]# service autofs restart
停止 automount:
[确定]
启动 automount:
[确定]
客户端登录测试: