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

yum install 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/ypserv start

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)

/home    192.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.
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
要在Linux上配置NIS(Network Information Service),请按照以下步骤进行操作: 1. 安装 NIS 服务器软件: ```shell sudo apt install ypserv ``` 2. 配置 NIS 服务器: - 编辑 `/etc/default/nis` 文件,并确保 `NISSERVER` 变量设置为 `true`: ```shell sudo nano /etc/default/nis ``` ```plaintext NISSERVER=true ``` - 编辑 `/etc/ypserv.securenets` 文件,指定允许访问 NIS 服务器的子网段。例如,允许本地子网访问: ```shell sudo nano /etc/ypserv.securenets ``` ```plaintext 255.255.255.0 192.168.0.0 ``` 3. 配置 NIS 客户端: - 编辑 `/etc/yp.conf` 文件,添加 NIS 服务器的 IP 地址或主机名: ```shell sudo nano /etc/yp.conf ``` ```plaintext domain your_domain_name server your_server_ip_or_hostname ``` - 编辑 `/etc/nsswitch.conf` 文件,将相应的数据库切换到 NIS。例如,将 passwd 和 shadow 切换到 NIS: ```shell sudo nano /etc/nsswitch.conf ``` ```plaintext passwd: nis [NOTFOUND=return] files shadow: nis [NOTFOUND=return] files ``` 4. 启动 NIS 服务: ```shell sudo service ypserv start ``` 5. 设置 NIS 客户端: ```shell sudo ypbind -broadcast ``` 6. 检查 NIS 配置: - 检查 NIS 服务器是否正在运行: ```shell sudo service ypserv status ``` - 检查 NIS 客户端是否已成功绑定到 NIS 服务器: ```shell ypwhich ``` - 检查 NIS 数据库是否可用: ```shell ypcat passwd ``` 配置完成后,您的 Linux 系统将使用 NIS 来获取用户和组信息。请根据您的网络环境和需求进行适当的配置。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值