Linux_NIS+NFS+Autofs

目录

前言

NIS+NFS+Autofs可以实现,网络用户的集中管理。

NIS

NIS(网络信息服务)管理用户的帐号信息,是集中控制几个系统管理数据库的网络用品。NIS简化了UNIX和LINUX桌面客户的管理工作客户端利用它可以使用中心服务器的管理文件。桌面系统的用户无需建立他们自己的/etc/passwd,他们只简单的使用维护在NIS服务器的文件即可。NIS是一个客户机/服务器系统,ypbind是定义NIS服务器的客户端进程。一旦确定了服务器位置,客户机绑定到了服务器上,所以客户端的住处查询都发往服务器。ypserv是回答客户端查询的服务器进程。

NFS

NFS(Network File System网络文件系统)网络共享用户帐号的home目录。它允许网络中的计算机之间通过TCP/IP网络共享资源。在NFS的应用中,本地NFS的客户端应用可以透明地读写位于远端NFS服务器上的文件,就像访问本地文件一样。

Autofs

Autofs(自动挂载服务)在用户登录的同时,自动触发挂载用户home目录
mount指令是用来挂载文件系统的,可以在系统启动的时候挂载也可以在系统启动后挂载。对于本地固定设备,如硬盘可以使用mount挂载。而光盘、软盘、NFS、SMB等文件系统具有动态性,即需要的时候才有必要挂载。我们一般不能及时知道NFS共享和SMB什么时候可以挂载,而autofs服务能够及时挂载动态加载的文件系统。免去我们手动载在麻烦。
原理:Autofs与Mount/Umount的不同之处在于,它是一种看守程序。如果它检测到用户正试图访问一个尚未挂接的文件系统,它就会自动检测该文件系统,如果存在,那么Autofs会自动将其挂接。另一方面,如果它检测到某个已挂接的文件系统在一段时间内没有被使用,那么Autofs会自动将其卸载。因此一旦运行了Autofs后,用户就不再需要手动完成文件系统的挂接和卸载。

搭建NIS+NFS+Autofs

集中式用户管理+网络文件系统+自动挂载

Setup NNA environment

Setup ServerSite

step1. Install ypserv

yuminstall ypserv   #NIS service

step2. Setup the hostname
vim /etc/sysconfig/network

HOSTNAME=master.nice.com
 NISDOMAIN=nice.com

Commands:

hostname master.nice.com
bash

step3.
vim /etc/hosts

192.168.0.1 master.nice.com nice.com
192.168.0.2 node.nice.com

step4. Start service ypserv

/etc/init.d/ypservstart

step5. Stop iptables,SElinux,NetworkManager service
step6. Create local user and add user to Database.
vim /var/yp/Makefile

/usr/lib64/yp/ypinit-m

step7. Share the directory to client by NFS Service, realize login NIS user at the same time mount the source share directory to goal directory.
For example: Server share /home directory to clientPort by NFS and mount the source share /home directory to client /home/* when login NIS user in the client.

vim /exports (in NFS Server)

/home192.168.0.0/24(rw)
      #/home  --> share dir absolute URL
      #192.168.0.0/24  --> share clientPort IP
      #(rw)  --> client owned permission

step8. Start the NFS service

service nfs restart#or 
exportfs -r

step9. Check the usable share NFS directory in the clientPort

showmount-e ServerIP #can check in serverPort and clientPort.
#or 
exportfs -v #only check in the serverPort

Setup client

step1.
vim /etc/hosts

192.168.0.1 master.nice.com nice.com
192.168.0.2 node.nice.com

step2. Edit the hostname
vim /etc/sysconfig/metwork

HOSTNAME=node.nice.com

Commands:

hostname node.nice.com
bash

step3. Setup the autofs
vim /etc/auto.master

/home    /etc/auto.home

vim /etc/auto.home

*ServerPortIP:/home/&

step4. Start autofs

service autofs restart
su - userName#Check the autofs server whether successfully.

相关阅读:

原文地址:https://www.cnblogs.com/hzcya1995/p/13310976.html