[root@dlp ~]# yum -y install ypserv rpcbind # set NIS domain name [root@dlp ~]# ypdomainname srv.world [root@dlp ~]# echo "NISDOMAIN=srv.world" >> /etc/sysconfig/network [root@dlp ~]# vi /var/yp/securenets # add IP addresses you allow to access to NIS server 255.0.0.0 127.0.0.0 [root@dlp ~]# vi /etc/hosts # add server and clients' IP address for NIS database 10.0.0.30 dlp.srv.world dlp [root@dlp ~]# systemctl start rpcbind ypserv ypxfrd yppasswdd [root@dlp ~]# systemctl enable rpcbind ypserv ypxfrd yppasswdd # update NIS database [root@dlp ~]# /usr/lib64/yp/ypinit -m At this point, we have to construct a list of the hosts which will run NIS servers. dlp 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: dlp.srv.world next host to add: # Ctrl + D key The current list of NIS servers looks like this: dlp.srv.world Is this correct? [y/n: y] y # y key and Enter We need a few minutes to build the databases... Building /var/yp/srv.world/ypservers... Running /var/yp/Makefile... gmake[1]: Entering directory `/var/yp/srv.world' Updating passwd.byname... Updating passwd.byuid... Updating shadow.byname... 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/srv.world' dlp.srv.world has been set up as a NIS master server. Now you can run ypinit -s dlp on all slave server. |
If you added users in local server, apply them to NIS database, too [root@dlp ~]# cd /var/yp [root@dlp yp]# make |
[3] |
If Firewalld is running, it needs to allow NIS services or ports. Some services listen different ports when they restart, so fix ports for them and allow them by Firewalld. |
[root@dlp ~]# vi /etc/sysconfig/network # add to the end YPSERV_ARGS="-p 944" YPXFRD_ARGS="-p 945" [root@dlp ~]# vi /etc/sysconfig/yppasswdd # add like follows YPPASSWDD_ARGS="--port 946" [root@dlp ~]# systemctl restart rpcbind ypserv ypxfrd yppasswdd [root@dlp ~]# firewall-cmd --add-service=rpc-bind --permanent [root@dlp ~]# firewall-cmd --add-port=944/tcp --permanent [root@dlp ~]# firewall-cmd --add-port=944/udp --permanent [root@dlp ~]# firewall-cmd --add-port=945/tcp --permanent [root@dlp ~]# firewall-cmd --add-port=945/udp --permanent [root@dlp ~]# firewall-cmd --add-port=946/udp --permanent [root@dlp ~]# firewall-cmd --reload |
設定後測試
root@myhost:/volumes# ypwhich
192.168.1.77
root@myhost:/volumes# ypcat
Usage:
ypcat [-k] [-d domainname] [-t] mapname
ypcat -x
where
mapname may be either a mapname or a nickname for a map.
-t inhibits map nickname translation.
-k prints keys as well as values.
-x dumps the map nickname translation table.
root@myhost:/volumes# ypcat -x
NIS server,報錯"no such map in server's domain"
/etc/ypserv.conf配置文件中許可權設置。
參考 : server-word,鳥歌
留言列表