CentOS-7.4 NIS与NFS配置

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
  • 配置NFSvi /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

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

黑色蒲G英~

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值