NIS搭配NFS
在不使用NFS做搭配的时候你会发现一个问题,就是没有宿主目录,这很正常,因为user1的宿主目录在服务器端的 /home下。在客户端登录的时候不可能会有对应的宿主目录。
服务器端:
- 添加三个账号用于测试
mkdir /rhome
useradd -u 2001 -d /rhome/user1 user1 ; echo "123" | passwd --stdin user1
useradd -u 2002 -d /rhome/user2 user2 ; echo "123" | passwd --stdin user2
useradd -u 2003 -d /rhome/user3 user3 ; echo "123" | passwd --stdin user3
- 配置NFS
vi /etc/exprots
/rhome 10.10.10.0/24(rw,no_root_squash)
启动systemctl restart rpcbind nfs
客户端:
mkdir /rhome
mount -t nfs 10.10.10.2:/rhome /rhome
配置脚本
服务端
#!/bin/bash
sed -i "7s/enforcing/disabled/g" /etc/selinux/config
setenforce 0
systemctl stop firewalld
systemctl disable firewalld
yum -y install yp-tools ypserv rpcbind
echo 'NISDOMAIN=netskills.com
YPSERV_ARGS="-p 1011"' >> /etc/sysconfig/network
sed -i "17s/$/\"--port 1012\"/g" /etc/sysconfig/yppasswdd
systemctl start ypserv yppasswdd
mkdir /rhome
useradd -u 2001 -d /rhome/user1 user1 ; echo "123" | passwd --stdin user1
useradd -u 2002 -d /rhome/user2 user2 ; echo "123" | passwd --stdin user2
useradd -u 2003 -d /rhome/user3 user3 ; echo "123" | passwd --stdin user3
yum -y install nfs-utils
echo "/rhome 10.10.10.0/24(rw,no_root_squash)" >> /etc/exports
systemctl start ypserv yppasswdd nfs
systemctl enable ypserv yppasswdd nfs
/lib64/yp/ypinit -m
客户端
#!/bin/bash
sed -i "7s/enforcing/disabled/g" /etc/selinux/config
setenforce 0
systemctl stop firewalld
systemctl disable firewalld
yum -y install ypbind yp-tools mount*
echo "NISDOMAIN=netskills.com" >> /etc/sysconfig/network
sed -i "19s/no/yes/g" /etc/sysconfig/authconfig
echo "domain netskills.com server 10.10.10.2" >> /etc/yp.conf
sed -i "33s/$/ nis/g" /etc/nsswitch.conf
sed -i "34s/$/ nis/g" /etc/nsswitch.conf
sed -i "35s/$/ nis/g" /etc/nsswitch.conf
sed -i "39s/$/ nis/g" /etc/nsswitch.conf
systemctl start ypbind rpcbind
systemctl enable ypbind rpcbind
mkdir /rhome
mount -t nfs 10.10.10.2:/rhome /rhome