Skip to content

Instantly share code, notes, and snippets.

@wangxianhe
Last active September 12, 2019 01:58
Show Gist options
  • Save wangxianhe/d26b1c8a08ea7f324543728ca3d28c24 to your computer and use it in GitHub Desktop.
Save wangxianhe/d26b1c8a08ea7f324543728ca3d28c24 to your computer and use it in GitHub Desktop.
CentOS7 NIS服务

在CentOS7上搭建NIS服务

NIS服务端

1、安装nis相关软件包

yum -y install ypserv
yum -y install ypbind
yum -y install yp-tools
yum -y install portreserve

2、设置NIS域名

举例域名设成:WANG [root@node1 ~]# cat /etc/sysconfig/network

Created by anaconda

NISDOMAIN=WANG

增加开机设置域名: vi /etc/rc.local 加入/bin/nisdomainname WANG 提醒:centos7的rc.local一定要能够执行:chmod +x /etc/rc.d/rc.local,否则重启后一直不生效。

3、启动相关服务

systemctrl start rpcbind systemctrl start ypserv systemctrl start yppasswdd

systemctl enable rpcbind systemctl enable ypserv systemctl enable yppasswdd

4、初始化数据库

/usr/lib64/yp/ypinit -m systemctrl restart ypserv 当账号信息有更新时,cd /var/yp,make一下。

NIS客户端

1、安装nis相关软件包

yum -y install ypbind
yum -y install yp-tools
yum -y install portreserve

2、加入NIS域

vi /etc/sysconfig/network 加入NISDOMAIN=WANG

vi /etc/rc.local 添加/bin/nisdomainname WANG

3、vi /etc/yp.conf

添加 domain WANG server node1

4、vi /etc/sysconfig/authconfig

  修改USENIS=yes
  
  执行命令:
  authconfig --enablenis --nisdomain=WANG --nisserver=node1 --enablemkhomedir --update

5、重启服务

systemctl restart rpcbind
systemctl restart ypbind

systemctl enable rpcbind
systemctl enable ypbind

若重启ypbind服务失败,可能是防火墙与selinux权限问题,若关闭仍然失败,应该是配置出现错误.

6、客户端检测

yptest
ypcat passwd 
有输出server端用户信息,即配置成功。

参考链接: http://www.178pt.com/32.html https://blog.csdn.net/dream_angel_z/article/details/44226055

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment