公司要求搭配NIS和NFS服务器统一管理账号及资源共享,在RedHat 6.1 64位服务器上安装NIS和NFS服务配置如下:
在配置之前请关闭iptables,或者是添加规则使得nfs服务可通过防火墙:
service iptables stop
or
iptables -I INPUT -p tcp --dport 111 -j ACCEPT
iptables -I INPUT -p udp --dport 111 -j ACCEPT
iptables -I INPUT -p tcp --dport 2049 -j ACCEPT
iptables -I INPUT -p udp --dport 2049 -j ACCEPT
service iptables save
NIS Server端配置:
1、安装ypserv服务:yum -y install ypserv yp-tools ypbind
2、启用ypserv服务:service ypserv start
3、开机启动ypserv服务:chkconfig ypserv on
4、编辑network文件:vim /etc/sysconfig/network,在最后面添加一行:
NISDOMAIN=example.com
编辑hosts文件:vim /etc/hosts 添加客户端IP、客户端主机名。
5、编辑sercurenets,默认没有此文件)添加监听域:
vim /var/yp/sercurenets
255.255.255.255 127.0.0.1
255.255.255.0 192.168.89.0
6、重启nis服务: service ypserv restart
7、创建nis用户的专用目录:mkdir /home/rhome
8、创建nis账户,家目录为/home/rhome/*
useradd -d /home/rhome/test1 test1
useradd -d /home/rhome/test2 test2
echo "123456" | passwd test1 --stdin
echo "123456" | passwd test2 --stdin
9、编辑nis服务配置文件:vim /var/yp/Makefile
简单的nis服务只须共享passwd、group、hosts即可,把行
all: passwd group hosts 后面的参数另起一行前面加上#号注释。
10、编辑/etc/yp.conf配置文件,添加:domain example.com server 192.168.89.254
11、建立资料库:/usr/lib64/yp/ypinit -m(注:此命令必须用全路径,32位系统全路径为/usr/lib/yp/ypinit),此时会提示输入next host add,按ctrl+d 退出后按 y 键确认,系统会开始建立资料库。可通过查看/var/yp/ 目录确认。
若以后NIS服务器新添加了账号,必须使用此命令来更新资料库,NIS客户端才能识别新加的账号。
12、启用yppasswdd服务(此服务允许nis用户通过nisclient端自行更改密码:
service yppwasswdd start
NIS Client端配置:
1、查看ypbind服务是否安装,若未安装刚可以通过yum安装。
rpm -qa|grep ypbind
yum -y install ypbind
2、配置nis client端:在图形界面中使用system-config-authentication
在“User Account configuration”出选择“NIS”,填入相应的NIS 域名和服务器IP信息,点击Apply应用后,系统会自动启动nis client服务。
在终端界面中可使用setup命令,验证工具--使用NIS、使用MD5密码和shadow密码--填写NIS服务器IP。
3、编辑yp.conf配置文件,添加:domain example.com server 192.168.89.254
NFS Server端配置:
1、查看是否安装NFS服务,若未安装,则可以通过yum安装
rpm -qa |grep nfs
yum -y install nfs
2、配置NFS共享配置文件:vim /etc/exports
添加此行语句:/home/rhome 192.168.89.0(rw,sync)
3、启动nfs服务:service nfs start
4、开机启动nfs服务:chkconfig nfs on
NFS Client配置:
1、查看是否安装autofs,若未安装,则可以通过yum安装
rpm -qa | grep autofs
yum -y install autofs
2、编辑配置文件:vim /etc/auto.master
添加以下语句:
/home/rhome /etc/home.nfs
3、编辑/etc/home.nfs:
* 192.168.89.254:/home/rhome/&
4、重新启动autofs服务:service autofs reload
5、开机启动autofs服务:chkconfig autofs on
此时可在nis客户端通过su - test1 可使用test1来登录客户端,通过df -h可查看当前nis客户端已自动挂载NFS服务器的/home/rhome目录到本机的/home/rhome。
转载于:https://blog.51cto.com/kwokchivu/727845