nis服务实现用户帐号管理同步

mac2022-08-12  22

配置NIS服务器,在server端操作可以使所有client端的用户帐号同步

测试为两台centos7,server端192.168.52.137     client端192.168.52.140

前置条件:

关闭防火墙

关闭selinux

配置nis server端

1、安装需要的软件包:

yum -y install ypserv rpcbind

 

2、设置nis域名:

[root@spgpu ~]# ypdomainname   srv.world [root@spgpu ~]# echo "NISDOMAIN=srv.world" >> /etc/sysconfig/network

3、添加允许访问NIS服务器的IP地址

 

 根据自己的环境添加

[root@spgpu ~]# cat /var/yp/securenets 255.255.255.0  192.168.52.0         

255.0.0.0 127.0.0.0       

 

4、添加服务和客户端解析:

ip地址      主机名和域名的结合       主机名

 

 

 5、启动相关服务并设置成开机自启:

[root@spgpu ~]# systemctl start rpcbind ypserv ypxfrd yppasswdd [root@spgpu ~]# systemctl enable rpcbind ypserv ypxfrd yppasswdd

6、更新nis数据库:

[root@spgpu ~]# /usr/lib64/yp/ypinit -m

At this point, we have to construct a list of the hosts which will run NIS servers. spgpu.srv.world 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>.      这里输入:Ctrl + D next host to add: spgpu.srv.world next host to add: The current list of NIS servers looks like this:

spgpu.srv.world

Is this correct? [y/n: y] y     这里输入:y 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 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'

spgpu.srv.world has been set up as a NIS master server.

Now you can run ypinit -s spgpu.srv.world on all slave server.

7、检测server服务是否正常:

rpcinfo -u 主机名 ypserv

[root@spgpu ~]# rpcinfo -u spgpu ypserv program 100004 version 1 ready and waiting program 100004 version 2 ready and waiting

提示:如果防火墙正在运行,固定nis服务端口,并开放端口:

[root@spgpu ~]# vi /etc/sysconfig/network

# 添加到最后

YPSERV_ARGS="-p 944" YPXFRD_ARGS="-p 945"

[root@spgpu ~]# vi /etc/sysconfig/yppasswdd

# add like follows

YPPASSWDD_ARGS="--port 946"

[root@spgpu ~]# systemctl restart rpcbind ypserv ypxfrd yppasswdd

[root@spgpu ~]# firewall-cmd --add-service=rpc-bind --permanent

[root@spgpu ~]# firewall-cmd --add-port=944/tcp --permanent

[root@spgpu ~]# firewall-cmd --add-port=944/udp --permanent

[root@spgpu ~]# firewall-cmd --add-port=945/tcp --permanent

[root@spgpu ~]# firewall-cmd --add-port=945/udp --permanent

[root@spgpu ~]# firewall-cmd --add-port=946/udp --permanent

[root@spgpu ~]# firewall-cmd --reload

 

 

配置nis客户端

1、安装相关的软件包:

[root@spgpu01 ~]# yum -y install ypbind rpcbind

2、设置nis域名:

[root@spgpu01 ~]# ypdomainname   srv.world [root@spgpu01 ~]# echo "NISDOMAIN=srv.world" >> /etc/sysconfig/network

3、添加服务和客户端解析:

ip地址      主机名和域名的结合       主机名

 

 

4、更新nis服务器:

authconfig \ --enablenis \ --nisdomain=srv.world \ --nisserver=spgpu.srv.world \     这里填写 nis  server域名 --enablemkhomedir \ --update

5、启动相关服务并设置成开机自启:

[root@spgpu01 ~]# systemctl start rpcbind ypbind [root@spgpu01 ~]# systemctl enable rpcbind ypbind

到此client端设置完成!

在server端创建用户,修改用户密码之后需要执行一个命令才可以同步到所有的客户端下

make -C /var/yp

因为没做home目录共享!client不会自动创建用户家目录,但是用户是已经同步创建好了。

所以需要在client端需要su -用户   才会创建用户的家目录!

可以通nfs共享server的home目录到client端这样自动创建家目录。

在client也可以修改server端创建用户的密码:yppasswd  用户名

[root@spgpu01 ~]# yppasswd qwer Changing NIS account information for qwer on spgpu.szsp.cn. Please enter root password:                          这里输入本机的root密码 Changing NIS password for qwer on spgpu.szsp.cn. Please enter new password: Please retype new password:

The NIS password has been changed on spgpu.szsp.cn.

最新回复(0)