01 NIS-server
1.准备工作
vim /etc/hosts172.25.0.101 storage-1.example.com172.25.0.100 storage-2.example.comuseradd nis-user1
useradd nis-user2passwd nis-user1passwd nis-user22.安装软件
yum install ypserv -y3.设置NIS域名
add the line:DefaultDependencies=noin the [Unit] section of /usr/lib/systemd/system/rhel-domainname.serviceand then simply:systemctl enable rhel-domainnamesystemctl restart rhel-domainnamevim /etc/sysconfig/networkNISDOMAIN=rhcesource /etc/sysconfig/network4.固定NIS端口
vim /etc/sysconfig/networkYPSERV_ARGS="-p 834"source /etc/sysconfig/network5.启动服务
systemctl enable ypserv.servicesystemctl start ypserv.service6.初始化nis数据库
/usr/lib64/yp/ypinit -m7.防火墙设置
firewall-cmd --add-service=rpc-bind --permanentfirewall-cmd --add-port=834/tcp --permanentfirewall-cmd --add-port=834/udp --permanentfirewall-cmd --reload
02 NIS-client
1.安装软件
yum install ypbind -y2.加入NIS域
authconfig-tui3.启动服务
systemctl enable ypbindsystemctl restart ypbind4.初步验证
getent passwd nis-user1getent passwd nis-user25.进一步验证用户登录
su - nis-user1su - nis-user26.进一步验证域名解析
vim /etc/nsswitch.confline39:hosts: nis files dnsping storage-1.example.com 可以正常ping通vim /etc/nsswitch.conf
line39:hosts: files dnsping storage-1.example.com 无法ping通03 NFS-server-share home directory
1.共享server0端用户家目录
vim /etc/exports/home *(rw,sync)2.启动服务
systemctl enable nfs-server.servicesystemctl restart nfs-server.service3.设置防火墙
firewall-cmd --add-service=nfs-server --permanentfirewall-cmd --add-service=mountd --permanentfirewall-cmd --reload04 NFS-client
1.查看server0端的NFS共享
showmount -e 172.25.0.112.挂载server0端NFS共享
vim /etc/fstab172.25.0.11:/home /home nfs defaults 0 0mount -a3.NIS+NFS验证
su - nis-user1su - nis-user205 Autofs-server
1.安装软件
yum install autofs -y2.配置autofs
主配置文件touch /etc/auto.master.d/home.autofsvim /etc/auto.master.d/home.autofs/home /etc/auto.home辅配置文件
touch /etc/auto.homevim /etc/auto.home* -rw,sync 172.25.0.11:/home/&3.重启服务
systemctl enable autofs.servicesystemctl restart autofs.service4.验证autofs自动挂载
su - nis-user1su - nis-user2mount