yp-tools-2.14-3.el7.x86_64.rpmypbind-1.37.1-7.el7.x86_64.rpm
/etc/sysconfig/network:加入 NIS 的域名
/etc/hosts:至少需要有各个 NIS 服务器的 IP 与主机名对应;
/etc/yp.conf:这个则是 ypbind 的主要配置文件,里面主要设定NIS 服务器所在 /etc/sysconfig/authconfig:规范账号登入时的允许认证机制;
/etc/pam.d/system-auth :因为账号通常由 PAM 模块所管理, 所以必须要在 PAM 模块内加入 NIS 的支持才行! /etc/nsswitch.conf :设定账号密码与相关信息的查询顺序,默认是先找 /etc/passwd 再找 NIS 数据库;
2.3.1 设置NIS域名
设置 NIS 的域名,新增如下内容: 临时设置:
[python] view plain copy print?在CODE上查看代码片派生到我的代码片 [root@node0 nis]# nisdomainname hikuss 永久设置:
[root@node0 nis]# cat /etc/sysconfig/network
[python] view plain copy print?在CODE上查看代码片派生到我的代码片 # Created by anaconda NISDOMAIN=hikuss
YPSERV_ARGS=\
2.3.2 设置hosts
设定IP地址与主机名的对应关系/etc/hosts,新增如下内容
[python] view plain copy print?在CODE上查看代码片派生到我的代码片 [root@node0 nis]# cat /etc/hosts
192.168.192.90 node0 192.168.192.91 node1 192.168.192.92 node2
2.3.3 设施ypbind连接server-方法1 2.3.3.1 账户信息的读取顺序 配置账户信息的读取顺序
[python] view plain copy print?在CODE上查看代码片派生到我的代码片 [root@node2 nis]# vim /etc/nsswitch.conf …
passwd: files nis sss shadow: files nis sss group: files nis sss …
hosts: files nis dns …
[root@node2 nis]#
2.3.3.2 配置/etc/yp.conf
配置/etc/yp.conf,最后添加如下两行代码:
[python] view plain copy print?在CODE上查看代码片派生到我的代码片 domain hikuss server node0 domain hikuss server node1 ypserver node0 ypserver node1
2.3.3.3 设置账号登入认证机制 登入时的允许认证机制
[python] view plain copy print?在CODE上查看代码片派生到我的代码片 [root@node2 nis]# grep NIS/etc/sysconfig/authconfig USENIS=yes
2.3.3.4 设置PAM授权
修改文件/etc/pam.d/system-auth,增加nis
[python] view plain copy print?在CODE上查看代码片派生到我的代码片 …
password sufficient pam_unix.so md5shadow nis nullok try_first_passuse_authtok …
2.3.4 设施ypbind连接server-方法2
[python] view plain copy print?在CODE上查看代码片派生到我的代码片 [root@node1 nis]#setup
1. 第一步:选择authentication
2.3.5 启动及开机启动 启动如下命令:
[python] view plain copy print?在CODE上查看代码片派生到我的代码片 [root@node0 nis]# systemctlstart rpcbind [root@node0 nis]# systemctlstart ypbind [root@node0 nis]#
设置开机启动
[python] view plain copy print?在CODE上查看代码片派生到我的代码片 [root@node2 nis]# systemctlenable ypbind Created symlink from/etc/systemd/system/multi-user.target.wants/ypbind.service to /usr/lib/systemd/system/ypbind.service. [root@node0 nis]# systemctlenable rpcbind Created symlink from/etc/systemd/system/sockets.target.wants/rpcbind.socket to/usr/lib/systemd/system/rpcbind.socket. [root@node0 nis]#
2.4 Client测试 2.4.1 yptest
yptest用来测试 server 端和 client 端能否正常通讯 #如果配置成功,会返回成功的结果 #如果返回fail,则根据提示进行排查
[python] view plain copy print?在CODE上查看代码片派生到我的代码片 [root@node2 nis]# yptest Test 1: domainname
Configured domainname is \
Test 2: ypbind
Used NIS server: node0
Test 3: yp_match
WARNING: No such key in map (Map passwd.byname, keynobody)
Test 4: yp_first
cephceph:$1$X9Z9IOh1$QJtLqBSk75qIf/h3oaRBO0:1000:1000:ceph:/home/ceph:/bin/bash
Test 5: yp_next …
Test 6: yp_master node0
Test 7: yp_order 1478832908
Test 8: yp_maplist …
Test 9: yp_all …
1 tests failed
[root@node2 nis]#
从这个测试当中可能发现一些错误,就是在 Test 3 出现的那个警告信息啦。只是说没有该数据库而已~ 该错误是可以忽略的。
重点在第 9 个步骤 yp_all 必须要有列出你 NIS server 上头的所有帐户信息,如果有出现账号相关数据的话,那么应该就算验证成功了!
2.4.2 ypwhich
ypwhich用来查看资料库映射数据 1. 查看NIS domain
[python] view plain copy print?在CODE上查看代码片派生到我的代码片 [root@node2 nis]# ypwhich node0
[root@node2 nis]#
2. 查看数据库映射
[python] view plain copy print?在CODE上查看代码片派生到我的代码片 [root@node2 nis]# ypwhich -x
Use \ for map \ Use \ for map \ Use \ for map \ Use \ Use \
Use \ for map \ Use \
Use \ for map \ [root@node2 nis]#
2.4.3 ypcat
利用ypcat读取数据库内容
[python] view plain copy print?在CODE上查看代码片派生到我的代码片 [root@node2 nis]# ypcat -?
Usage: ypcat [-kt] [-d domain] [-h hostname]mapname | -x ypcat - print values of all keys in a NIS database
-ddomain Use 'domain' instead of thedefault domain
-hhostname Query ypserv on 'hostname'instead the current one -k Display map keys
-t Inhibits map nickname translation
-x Display the map nickname translationtable -?,--help Give this help list
--usage Give a short usagemessage --version Print program version [root@node2 nis]#
1. 查看数据库映射
[python] view plain copy print?在CODE上查看代码片派生到我的代码片 [root@node2 nis]# ypcat -x
Use \ for map \ Use \ for map \ Use \ for map \ Use \ Use \
Use \ for map \ Use \
Use \ for map \ [root@node2 nis]#
2. 查看数据库映射ypcat -k
[python] view plain copy print?在CODE上查看代码片派生到我的代码片 [root@node2 nis]# ypcat -k passwd
cephceph:$1$X9Z9IOh1$QJtLqBSk75qIf/h3oaRBO0:1000:1000:ceph:/home/ceph:/bin/bash nisuser1nisuser1:$1$2e4n/ePv$xnfaSHSSUZhApRpjHn1Lw.:1001:1001::/home/nisuser1:/bin/bash nisuser2
nisuser2:$1$NBitWXE9$43ezdKoamgw0ze8PnIOtT/:1002:1002::/home/nisuser2:/bin/bash nisuser3nisuser3:$1$GUtQO.zB$38oGHfzgWGYG84cKa7bkZ0:1003:1003::/home/nisuser3:/bin/bash
nisuser4nisuser4:$1$nc3FDwqx$aKhlazecXTmDSmGciCBkG1:1004:1004::/home/nisuser4:/bin/bash
nisuser5nisuser5:$1$krWvFybT$yUwL3dCDVz0qp5Sg7wifX1:1005:1005::/home/nisuser5:/bin/bash
[root@node2 nis]#