这篇文章给大家分享的是有关Centos8如何搭建配置nis域服务的内容。小编觉得挺实用的,因此分享给大家做个参考,一起跟随小编过来看看吧。
NIS 简介
NIS,英文的全称是network information service,也叫yellow pages。在Linux中,NIS是一个基于RPC的client/server系统,需要使用 RPC 服务。
RPC即Remote Procedure Call Protocol(远程过程调用协议),RPCBIND用于取代旧版本中的portmap组件。简单说,RPCBIND就是为了将不同服务与对应的端口进行绑定,以便支持机器间的相互操作。
网络环境:
节点 | 主机 |
node1(nis主服务器) | 192.168.10.222 |
node2(nis客户机) | 192.168.10.223 |
1.环境准备(两个节点都要)
关闭防火墙
systemctl< /span > stop< /span > firewalld< /span > setenforce< /span > 0< /span >
添加主机名解析
vim< /span > /etc/hosts < /span > 192.168< /span >.10< /span >.222< /span > node1< /span > 192.168< /span >.10< /span >.223< /span > node2< /span >
2.nis主服务器配置
下载软件包
yum< /span > -y install rpcbind ypserv ypbind yp-tools
添加nis域名
[root@localhost ~] # nisdomainname skills.com vim /etc/sysconfig/network NISDOMAIN skills.com
开机自动挂载nis域名
[root@localhost ~< /span >] # vim /etc/rc.d/rc.local touch /var< /span >/lock< /span > /subsys/local /bin/nisdomainname skills.com [root@localhost ~< /span >] # chmod 777 /etc/rc.d/rc.local
修改主配置文件限制权限
vim< /span > /etc/ypserv .conf< /span > 192.168< /span >.10< /span >.0< /span > /24 :*:*:none< /span > // 给与该网段访问权限< /span > 192.168< /span >.10< /span >.222< /span >:*:*:none< /span > // 给与该本机访问权限< /span > :*:*:deny< /span > // 拒绝其他服务器< /span >
重启服务
systemctl restart yppasswdd rpcbind ypserv systemctl enable < /span > yppasswdd rpcbind ypserv
建立资料库
[root@localhost ~] # /usr/lib64/yp/ypinit -m At this point, we have to construct a list of the hosts which will run NIS servers. localhost 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< /span > the list< /span >, type < /span > a <control D>. next< /span > host to< /span > add< /span >: localhost next< /span > host to< /span > add< /span >: The current< /span > list< /span > of< /span > NIS servers looks like< /span > this: localhost Is< /span > this correct? [y /n : y] y We need a few minutes< /span > to< /span > build< /span > the databases... Building /var< /span > /yp/skills .com /ypservers ... Running /var< /span > /yp/Makefile ... gmake[1< /span >]: Entering directory< /span > '/var/yp/skills.com' < /span > 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< /span >]: Leaving directory< /span > '/var/yp/skills.com' < /span > localhost has been set < /span > up as< /span > a NIS master< /span > server. Now< /span > you can run ypinit -s localhost on< /span > all< /span > slave< /span > server. [root@localhost ~] #
新建nis账户
useradd nis1 -p123 useradd nis2 -p123 当主机发生了更改就 cd 到/var< /span > /yp make [root@localhost ~< /span >] # cd /var/yp/ [root@localhost yp< /span >] # make gmake[1< /span >]: Entering directory '/var/yp/skills.com' < /span > Updating passwd .byname... Updating passwd .byuid... Updating group< /span >.byname... Updating group< /span >.bygid... Updating netid.byname... gmake[1< /span >]: Leaving directory '/var/yp/skills.com' < /span > [root@localhost yp< /span >] #
重启服务
systemctl restart yppasswdd rpcbind ypserv systemctl enable < /span > yppasswdd rpcbind ypserv
3.nis客户端设置
下载软件包
yum< /span > -y install ypbind rpcbind yp-tools
添加nis域名
[root@localhost ~] # nisdomainname skills.com vim /etc/sysconfig/network NISDOMAIN skills.com
开机自动挂载nis域名
[root@localhost ~< /span >] # vim /etc/rc.d/rc.local touch /var< /span >/lock< /span > /subsys/local /bin/nisdomainname skills.com [root@localhost ~< /span >] # chmod 777 /etc/rc.d/rc.local
编辑yp.conf文件,设置主服务。
domain< /span > skills< /span >.com< /span > server< /span > 192.168< /span >.10< /span >.222< /span >
重启服务
systemctl< /span > restart ypbind rpcbind
yptest查看是否加入成功
[root@localhost ~] # yptest Test 1< /span >: domainname Configured domainname is "skills.com" < /span > Test 2< /span >: ypbind Use Protocol V1:< /span > Used NIS server:< /span > 192.168< /span >.10.222< /span > Use Protocol V2:< /span > Used NIS server:< /span > 192.168< /span >.10.222< /span > Use Protocol V3:< /span > ypbind_nconf:< /span > nc_netid:< /span > udp nc_semantics:< /span > 1< /span > nc_flag:< /span > 1< /span > nc_protofmly:< /span > 'inet' < /span > nc_proto:< /span > 'udp' < /span > nc_device:< /span > '-' < /span > nc_nlookups:< /span > 0< /span > ypbind_svcaddr:< /span > 192.168< /span >.10.222< /span >:< /span >740< /span > ypbind_servername:< /span > 192.168< /span >.10.222< /span > ypbind_hi_vers:< /span > 2< /span > ypbind_lo_vers:< /span > 2< /span > Test 3< /span >: yp_match WARNING:< /span > No such key in < /span > map (Map passwd .byname, key nobody) Test 4< /span >: yp_first nis1 nis1:< /span >123< /span >:< /span >1000< /span >:< /span >1000< /span >:< /span >: /home/nis1 < /span >: /bin/bash < /span > Test 5< /span >: yp_next nis2 nis2:< /span >123< /span >:< /span >1001< /span >:< /span >1001< /span >:< /span >: /home/nis2 < /span >: /bin/bash < /span > Test 6< /span >: yp_master localhost Test 7< /span >: yp_order 1639387530< /span > Test 8< /span >: yp_maplist netid.byname group.bygid group.byname passwd .byuid passwd .byname mail.aliases protocols.byname protocols.bynumber services.byservicename services.byname rpc.bynumber rpc.byname hosts.byaddr hosts.byname ypservers Test 9< /span >: yp_all nis1 nis1:< /span >123< /span >:< /span >1000< /span >:< /span >1000< /span >:< /span >: /home/nis1 < /span >: /bin/bash < /span > nis2 nis2:< /span >123< /span >:< /span >1001< /span >:< /span >1001< /span >:< /span >: /home/nis2 < /span >: /bin/bash < /span > 1< /span > tests failed [root@localhost ~] #
配置域用户登陆
[root@localhost ~] # authselect select nis --force Backup stored at /var/lib/authselect/backups/2021-12-13-09-34-52 .8NFKZD Profile "nis" was selected. The following nsswitch maps are overwritten by the profile: - < /span >aliases - < /span >automount - < /span >ethers - < /span >group - < /span >hosts - < /span >initgroups - < /span >netgroup - < /span >networks - < /span > passwd - < /span >protocols - < /span >publickey - < /span >rpc - < /span >services - < /span >shadow Make sure that NIS service is configured and enabled. See NIS documentation for more information. [root@localhost ~] #
主服务器配置nfs,将home目录共享。
[root@localhost yp] # vim /etx/exports /home/ *(rw, sync ) [root@localhost yp] # exportfs -rv exporting *: /home < /span >
客户端挂载主服务器home目录
systemctl< /span > restart< /span > nfs-server< /span > [root@localhost< /span > ~] # mount 192.168.10.222:/home/ /home/ [root@localhost< /span > ~] # df Filesystem< /span > 1K-blocks< /span > Used< /span > Available< /span > Use%< /span > Mounted< /span > on< /span > devtmpfs< /span > 379852< /span > 0< /span > 379852< /span > 0< /span >%< /span > /dev < /span > tmpfs< /span > 399816< /span > 0< /span > 399816< /span > 0< /span >%< /span > /dev/shm < /span > tmpfs< /span > 399816< /span > 5688< /span > 394128< /span > 2< /span >%< /span > /run < /span > tmpfs< /span > 399816< /span > 0< /span > 399816< /span > 0< /span >%< /span > /sys/fs/cgroup < /span > /dev/mapper/cl-root < /span > 17811456< /span > 1615988< /span > 16195468< /span > 10< /span >%< /span > /< /span > /dev/sda1 < /span > 1038336< /span > 196688< /span > 841648< /span > 19< /span >%< /span > /boot < /span > /dev/sr0 < /span > 9046654< /span > 9046654< /span > 0< /span > 100< /span >%< /span > /media < /span > tmpfs< /span > 79960< /span > 0< /span > 79960< /span > 0< /span >%< /span > /run/user/0 < /span > 192.168< /span >.10< /span >.222< /span >: /home < /span > 17811456< /span > 1644672< /span > 16166784< /span > 10< /span >%< /span > /home < /span > [root@localhost< /span > ~] #
添加开机自动挂载主服务home目录。
vim< /span > /etc/fstab < /span > 192.168< /span >.10< /span >.222< /span >: /home < /span > /home < /span > nfs< /span > defaults< /span > 0< /span > 0< /span > [root@localhost< /span > ~] # mount -a [root@localhost< /span > ~] # df Filesystem< /span > 1K-blocks< /span > Used< /span > Available< /span > Use%< /span > Mounted< /span > on< /span > devtmpfs< /span > 379852< /span > 0< /span > 379852< /span > 0< /span >%< /span > /dev < /span > tmpfs< /span > 399816< /span > 0< /span > 399816< /span > 0< /span >%< /span > /dev/shm < /span > tmpfs< /span > 399816< /span > 5688< /span > 394128< /span > 2< /span >%< /span > /run < /span > tmpfs< /span > 399816< /span > 0< /span > 399816< /span > 0< /span >%< /span > /sys/fs/cgroup < /span > /dev/mapper/cl-root < /span > 17811456< /span > 1613680< /span > 16197776< /span > 10< /span >%< /span > /< /span > /dev/sda1 < /span > 1038336< /span > 196688< /span > 841648< /span > 19< /span >%< /span > /boot < /span > /dev/sr0 < /span > 9046654< /span > 9046654< /span > 0< /span > 100< /span >%< /span > /media < /span > 192.168< /span >.10< /span >.222< /span >: /home < /span > 17811456< /span > 1644544< /span > 16166912< /span > 10< /span >%< /span > /home < /span > tmpfs< /span > 79960< /span > 0< /span > 79960< /span > 0< /span >%< /span > /run/user/0 < /span > [root@localhost< /span > ~] #
到这nis配置完成。
标签:服务,...,span,Updating,yp,nis,root,localhost,搭建 From: https://www.cnblogs.com/xxllx/p/17314187.html