1创建用户及NIS用户主目录
建议在NIS服务器上建立独立的目录存放NIS帐号信息,如果保持默认设置则客户端挂载NIS主目录到/home目录时会覆盖原有用户主目录而导致其他异常错误;
我们现在建立/nishome存放NIS用户的主目录并使用useradd -d将NIS帐号的主目录指向/nishome,如果己有帐号可以使用usermod -d变更主目录。
1 [root@master /]# mkdir nishome
2 [root@master /]# mkdir nishome/nisuser1
3 [root@master /]# usermod-d /nishome/nisuser1/ nisuser1
4 [root@master /]# useradd-d /nishome/nisuser2 nisuser2
5 [root@master /]# ls nishome/
6 nisuser1 nisuser2
2重新生成NIS数据库并重启ypserv和yppasswd服务
# /usr/lib/yp/ypinit -m
# service ypserv restart
# service yppasswdd restart
3共享用户主目录
1 # vim /etc/exports
2 /nishome/nisuser1 (rw)
3 /nishome/nisuser2 (rw)
4重启NFS服务
1 [root@master /]# service nfs restart
2 Shutting down NFS mountd: [ OK ]
3 Shutting down NFS daemon: [ OK ]
4 Shutting down NFS quotas: [ OK ]
5 Shutting down NFS services: [ OK ]
6 Starting NFS services: [ OK ]
7 Starting NFS quotas: [ OK ]
8 Starting NFS daemon: [ OK ]
9 Starting NFS mountd: [ OK ]
10 Stopping RPC idmapd: [ OK ]
11 Starting RPC idmapd: [ OK ]
二、客户端配置NIS验证及Autofs
1检测主/从NIS服务器相应服务是否正常开启
1 [root@client01 ~]# rpcinfo -p masterabcnis
2 program vers proto port
3 100000 2 tcp 111 portmapper
4 100000 2 udp 111 portmapper
5 100024 1 udp 952 status
6 100024 1 tcp 955 status
7 100004 2 udp 682 ypserv
8 100004 1 udp 682 ypserv
9 100004 2 tcp 685 ypserv
10 1000041 tcp 685 ypserv
11 1000091 udp 699 yppasswdd
12 1000111 udp 781 rquotad
13 1000112 udp 781 rquotad
14 1000111 tcp 784 rquotad
15 1000112 tcp 784 rquotad
16 1000032 udp 2049 nfs
17 1000033 udp 2049 nfs
18 1000034 udp 2049 nfs
19 1000211 udp 49642 nlockmgr
20 1000213 udp 49642 nlockmgr
21 1000214 udp 49642 nlockmgr
22 1000032 tcp 2049 nfs
23 1000033 tcp 2049 nfs
24 1000034 tcp 2049 nfs
25 1000211 tcp 57392 nlockmgr
26 1000213 tcp 57392 nlockmgr
27 1000214 tcp 57392 nlockmgr
28 1000051 udp 796 mountd
29 1000051 tcp 799 mountd
30 1000052 udp 796 mountd
31 1000052 tcp 799 mountd
32 1000053 udp 796 mountd
33 1000053 tcp 799 mountd
2Authconfig启用NIS验证
执行setup(或者authconfig-tui命令)
3修改Autofs主配置文件
1 vim /etc/automaster
2 # Sample automaster file
3 # This is an automounter map and it has thefollowing format
4 # key [ -mount-options-separated-by-comma ]location
5 # For details of the format look at autofs(5)
6 #/misc /etc/automisc
7 # NOTE: mounts done from a hosts map will bemounted with the
8 # "nosuid" and"nodev" options unless the "suid" and "dev"
9 # options are explicitlygiven
10 #
11 /net -hosts
12 /nishome /etc/autonishome
13 #nishome是客户端要挂载的目录;autonishome是Autofs客户端配置文件;
14 # Include centralmaster map if it can be found using
15 # nsswitch sources
16 # Note that ifthere are entries for /net or /misc (as
17 # above) in theincluded master map any keys that are th
18 # same will not beseen as the first read key seen takes
19 # precedence
20 +automaster
4创建NIS自动挂载配置文件
1 [root@client01 ~]# touch /etc/autonishome
2
3 [root@client01 ~]# vim /etc/autonishome
4 -fstype=nfs masterabcnis:/nishome/&
5 # Autofs挂载目录支持通配符 ;
6 # 网络路径中的用户名使用 & 表示;
5重启Autofs服务
# service autofs restart
可以看到重启Autofs服务后客户端自动创建了/nishome目录!
三、客户端测试
注意如果使用su命令在NIS客户端切换到NIS用户时,在第一次可能会报无法定位到用户家目录的错误,没有关系,退出第二次再使用时就会正常。
1 [root@client01 ~]# su nisuser1
2 [nisuser1@client01 root]$ pwd
3 /root
4 [nisuser1@client01 root]$ cd
5 [nisuser1@client01 nisuser1]$ pwd
6 /nishome/nisuser1
7 [nisuser1@client01 nisuser1]$
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)