mikadonic-03-NIS+NFS+Autofs

01 NIS-server

1.准备工作
vim /etc/hosts
172.25.0.101 storage-1.example.com
172.25.0.100 storage-2.example.com

useradd nis-user1
useradd nis-user2
passwd nis-user1
passwd nis-user2

2.安装软件
yum install ypserv -y

3.设置NIS域名
add the line:
DefaultDependencies=no
in the [Unit] section of /usr/lib/systemd/system/rhel-domainname.service
and then simply:
systemctl enable rhel-domainname
systemctl restart rhel-domainname
vim /etc/sysconfig/network
NISDOMAIN=rhce
source /etc/sysconfig/network

4.固定NIS端口
vim /etc/sysconfig/network
YPSERV_ARGS="-p 834"
source /etc/sysconfig/network

5.启动服务
systemctl enable ypserv.service
systemctl start ypserv.service

6.初始化nis数据库
/usr/lib64/yp/ypinit -m

7.防火墙设置
firewall-cmd --add-service=rpc-bind --permanent
firewall-cmd --add-port=834/tcp --permanent
firewall-cmd --add-port=834/udp --permanent
firewall-cmd --reload

 

02 NIS-client

1.安装软件
yum install ypbind -y

2.加入NIS域
authconfig-tui

3.启动服务
systemctl enable ypbind
systemctl restart ypbind

4.初步验证
getent passwd nis-user1
getent passwd nis-user2

5.进一步验证用户登录
su - nis-user1
su - nis-user2

6.进一步验证域名解析
vim /etc/nsswitch.conf
line39:
hosts: nis files dns
ping storage-1.example.com 可以正常ping通

vim /etc/nsswitch.conf
line39:
hosts: files dns
ping storage-1.example.com 无法ping通

03 NFS-server-share home directory

1.共享server0端用户家目录
vim /etc/exports
/home *(rw,sync)

2.启动服务
systemctl enable nfs-server.service
systemctl restart nfs-server.service

3.设置防火墙
firewall-cmd --add-service=nfs-server --permanent
firewall-cmd --add-service=mountd --permanent
firewall-cmd --reload

04 NFS-client

1.查看server0端的NFS共享
showmount -e 172.25.0.11

2.挂载server0端NFS共享
vim /etc/fstab
172.25.0.11:/home /home nfs defaults 0 0
mount -a

3.NIS+NFS验证
su - nis-user1
su - nis-user2

05 Autofs-server

1.安装软件
yum install autofs -y

2.配置autofs
主配置文件
touch /etc/auto.master.d/home.autofs
vim /etc/auto.master.d/home.autofs
/home /etc/auto.home

辅配置文件
touch /etc/auto.home
vim /etc/auto.home
* -rw,sync 172.25.0.11:/home/&

3.重启服务
systemctl enable autofs.service
systemctl restart autofs.service

4.验证autofs自动挂载
su - nis-user1
su - nis-user2
mount

 

posted @ 2018-01-13 16:41  mikadonic  阅读(140)  评论(0编辑  收藏  举报