最近看了一些nis服务相关的资料,主要是对帐户进行一些管理,现在准备简单的总结。
1.环境准备
1.1环境拓扑图
环境拓扑
1.2安装软件包
[root@master ~]# yum install -y ypserv yp-tools ypbind rpcbind
2.服务器端配置
2.1在/etc/sysconfig/network加入如下两行:
NISDOMAIN=longining.com YPSERV_ARGS="-p 1011"
2.2在/etc/hosts加入记录
172.16.100.80 master 192.168.4.44 master
2.3在/etc/ypserv.conf加入如下内容
192.168.4.0/255.255.255.0 :* :* :none
2.4将/etc/sysconfig/yppasswdd修改如下
YPPASSWDD_ARGS="--port 1012"
2.5启动服务
[root@master ~]# /etc/init.d/ypserv start 启动 YP 服务器的服务: [确定] [root@master ~]# /etc/init.d/yppasswdd start 启动 YP 口令服务: [确定]
2.6查看端口是否1101、1102
[root@master ~]# rpcinfo -p localhost program vers proto port service 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
2.7将帐号转换成数据库
[root@master ~]# /usr/lib/yp/ypinit -m At this point, we have to construct a list of the hosts which will run NIS servers. master 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: master next host to add: The current list of NIS servers looks like this: master Is this correct? [y/n: y] y We need a few minutes to build the databases... Building /var/yp/master/ypservers... Running /var/yp/Makefile... gmake[1]: Entering directory `/var/yp/master' 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/master' master has been set up as a NIS master server. Now you can run ypinit -s master on all slave server.
3.客户端设置
3.1安装包
[root@Nodes01 ~]# yum install -y ypbind yp-tools
3.2设置客户端
作用setup图形设置快速方便
[root@Nodes01 ~]# setup
图01
图02
图03
Starting rpcbind: [ OK ]
4.nis应用-nfs案例
4.1nfs服务器端配置
查看挂载情况
[root@master data01]# df -h 文件系统 容量 已用 可用 已用%% 挂载点 /dev/sda2 5.5G 3.9G 1.4G 74% / tmpfs 122M 0 122M 0% /dev/shm /dev/sda1 146M 45M 94M 33% /boot /dev/sda5 9.7G 730M 8.5G 8% /opt /dev/sdc 504M 78M 402M 17% /data01
创建目录
[root@master data01]# mkdir customer [root@master data01]# chown tom:tom customer
更改nfs配置文件
在/etc/exports中加入如下内容
/data01/customer/ *(rw)
使配置生效
[root@master data01]# exportfs -ra
4.4客户端测试
挂载目录
[root@Nodes01 ~]# mount -t nfs 192.168.4.44:/data01/customer /data/
切换用户
[root@Nodes01 data]# su tom
检验是否能创建目录
bash-4.1$ cd /data/ bash-4.1$ mkdir ShenZhenTV bash-4.1$ ls -al total 12 drwxr-xr-x 3 tom tom 4096 Aug 17 2013 . dr-xr-xr-x. 26 root root 4096 Jul 11 01:19 .. drwxr-xr-x 2 tom tom 4096 Aug 17 2013 ShenZhenTV
注:客户端是没有创建tom用户,是应用nis服务。
到此,nis服务配置完成,虽然简单,开卷有益。