Centos8搭建配置nis域服务详细步骤

作者:~槑~ 时间:2023-06-11 13:10:14 

NIS 简介

NIS,英文的全称是network information service,也叫yellow pages。在Linux中,NIS是一个基于RPC的client/server系统,需要使用 RPC 服务。

RPC即Remote Procedure Call Protocol(远程过程调用协议),RPCBIND用于取代旧版本中的portmap组件。简单说,RPCBIND就是为了将不同服务与对应的端口进行绑定,以便支持机器间的相互操作。

网络环境:

节点主机
node1(nis主服务器)192.168.10.222
node2(nis客户机)192.168.10.223

1.环境准备(两个节点都要)

关闭防火墙


systemctl stop firewalld
setenforce 0

添加主机名解析


vim /etc/hosts
192.168.10.222 node1
192.168.10.223 node2

2.nis主服务器配置

 下载软件包


yum -y install  rpcbind ypserv ypbind yp-tools

添加nis域名


[root@localhost ~]# nisdomainname skills.com
vim /etc/sysconfig/network
NISDOMAIN skills.com

开机自动挂载nis域名


[root@localhost ~]# vim /etc/rc.d/rc.local
touch /var/lock/subsys/local
/bin/nisdomainname skills.com
[root@localhost ~]# chmod 777 /etc/rc.d/rc.local

修改主配置文件限制权限


vim /etc/ypserv.conf
192.168.10.0/24:*:*:none   //给与该网段访问权限
192.168.10.222:*:*:none    //给与该本机访问权限
            :*:*:deny     //拒绝其他服务器

重启服务


systemctl restart yppasswdd rpcbind ypserv
systemctl enable  yppasswdd rpcbind ypserv

建立资料库


[root@localhost ~]# /usr/lib64/yp/ypinit -m

At this point, we have to construct a list of the hosts which will run NIS
servers.  localhost is in the list of NIS server hosts.  Please continue to add
the names for the other hosts, one per line.  When you are done with the
list, type a <control D>.
       next host to add:  localhost
       next host to add:  
The current list of NIS servers looks like this:

localhost

Is this correct?  [y/n: y]  y
We need a few minutes to build the databases...
Building /var/yp/skills.com/ypservers...
Running /var/yp/Makefile...
gmake[1]: Entering directory '/var/yp/skills.com'
Updating passwd.byname...
Updating passwd.byuid...
Updating group.byname...
Updating group.bygid...
Updating hosts.byname...
Updating hosts.byaddr...
Updating rpc.byname...
Updating rpc.bynumber...
Updating services.byname...
Updating services.byservicename...
Updating netid.byname...
Updating protocols.bynumber...
Updating protocols.byname...
Updating mail.aliases...
gmake[1]: Leaving directory '/var/yp/skills.com'

localhost has been set up as a NIS master server.

Now you can run ypinit -s localhost on all slave server.
[root@localhost ~]#

新建nis账户


useradd nis1 -p123
useradd nis2 -p123
当主机发生了更改就cd到/var/yp make
[root@localhost ~]# cd /var/yp/
[root@localhost yp]# make
gmake[1]: Entering directory '/var/yp/skills.com'
Updating passwd.byname...
Updating passwd.byuid...
Updating group.byname...
Updating group.bygid...
Updating netid.byname...
gmake[1]: Leaving directory '/var/yp/skills.com'
[root@localhost yp]#

重启服务


systemctl restart yppasswdd rpcbind ypserv
systemctl enable  yppasswdd rpcbind ypserv

3.nis客户端设置 

 下载软件包


yum -y install ypbind rpcbind yp-tools

添加nis域名


[root@localhost ~]# nisdomainname skills.com
vim /etc/sysconfig/network
NISDOMAIN skills.com

开机自动挂载nis域名


[root@localhost ~]# vim /etc/rc.d/rc.local
touch /var/lock/subsys/local
/bin/nisdomainname skills.com
[root@localhost ~]# chmod 777 /etc/rc.d/rc.local

编辑yp.conf文件,设置主服务。 


domain skills.com server 192.168.10.222

重启服务


systemctl restart ypbind rpcbind

 yptest查看是否加入成功


[root@localhost ~]# yptest
Test 1: domainname
Configured domainname is "skills.com"

Test 2: ypbind
Use Protocol V1: Used NIS server: 192.168.10.222
Use Protocol V2: Used NIS server: 192.168.10.222
Use Protocol V3:
ypbind_nconf:
       nc_netid: udp
       nc_semantics: 1
       nc_flag: 1
       nc_protofmly: 'inet'
       nc_proto: 'udp'
       nc_device: '-'
       nc_nlookups: 0
ypbind_svcaddr: 192.168.10.222:740
ypbind_servername: 192.168.10.222
ypbind_hi_vers: 2
ypbind_lo_vers: 2

Test 3: yp_match
WARNING: No such key in map (Map passwd.byname, key nobody)

Test 4: yp_first
nis1 nis1:123:1000:1000::/home/nis1:/bin/bash

Test 5: yp_next
nis2 nis2:123:1001:1001::/home/nis2:/bin/bash

Test 6: yp_master
localhost

Test 7: yp_order
1639387530

Test 8: yp_maplist
netid.byname
group.bygid
group.byname
passwd.byuid
passwd.byname
mail.aliases
protocols.byname
protocols.bynumber
services.byservicename
services.byname
rpc.bynumber
rpc.byname
hosts.byaddr
hosts.byname
ypservers

Test 9: yp_all
nis1 nis1:123:1000:1000::/home/nis1:/bin/bash
nis2 nis2:123:1001:1001::/home/nis2:/bin/bash
1 tests failed
[root@localhost ~]#

配置域用户登陆


[root@localhost ~]# authselect select nis --force
Backup stored at /var/lib/authselect/backups/2021-12-13-09-34-52.8NFKZD
Profile "nis" was selected.
The following nsswitch maps are overwritten by the profile:
- aliases
- automount
- ethers
- group
- hosts
- initgroups
- netgroup
- networks
- passwd
- protocols
- publickey
- rpc
- services
- shadow

Make sure that NIS service is configured and enabled. See NIS documentation for more information.

[root@localhost ~]#

主服务器配置nfs,将home目录共享。


[root@localhost yp]# vim /etx/exports
/home/ *(rw,sync)
[root@localhost yp]# exportfs -rv
exporting *:/home

客户端挂载主服务器home目录


systemctl restart nfs-server
[root@localhost ~]# mount 192.168.10.222:/home/ /home/
[root@localhost ~]# df
Filesystem           1K-blocks    Used Available Use% Mounted on
devtmpfs                379852       0    379852   0% /dev
tmpfs                   399816       0    399816   0% /dev/shm
tmpfs                   399816    5688    394128   2% /run
tmpfs                   399816       0    399816   0% /sys/fs/cgroup
/dev/mapper/cl-root   17811456 1615988  16195468  10% /
/dev/sda1              1038336  196688    841648  19% /boot
/dev/sr0               9046654 9046654         0 100% /media
tmpfs                    79960       0     79960   0% /run/user/0
192.168.10.222:/home  17811456 1644672  16166784  10% /home
[root@localhost ~]#

添加开机自动挂载主服务home目录。


vim /etc/fstab
192.168.10.222:/home    /home                   nfs     defaults        0 0
[root@localhost ~]# mount -a
[root@localhost ~]# df
Filesystem           1K-blocks    Used Available Use% Mounted on
devtmpfs                379852       0    379852   0% /dev
tmpfs                   399816       0    399816   0% /dev/shm
tmpfs                   399816    5688    394128   2% /run
tmpfs                   399816       0    399816   0% /sys/fs/cgroup
/dev/mapper/cl-root   17811456 1613680  16197776  10% /
/dev/sda1              1038336  196688    841648  19% /boot
/dev/sr0               9046654 9046654         0 100% /media
192.168.10.222:/home  17811456 1644544  16166912  10% /home
tmpfs                    79960       0     79960   0% /run/user/0
[root@localhost ~]#

到这nis配置完成。

来源:https://blog.csdn.net/qq_58462846/article/details/121897552

标签:Centos,nis
0
投稿

猜你喜欢

  • Apache 解决80端口占用问题

    2023-08-30 12:18:31
  • VMware中centos系统连接wifi的图文方法

    2022-01-06 04:53:58
  • CentOS 7中 Minimal 安装JDK 1.8的教程

    2023-05-11 12:01:14
  • eBay携微软推Daily Deals 可在线购折扣产品

    2009-11-26 13:31:00
  • Webmail攻防实战(5)

    2007-10-30 14:05:00
  • linux常用工具vi/vim的使用完整版

    2023-11-30 06:40:04
  • 报告称腾讯网游用户占中国网游用户总数44%

    2009-11-27 16:39:00
  • GG Adsense搜索联盟与传统搜索框的区别

    2008-08-08 12:58:00
  • 雅虎Logo的15年变迁之路 品牌的宣传之路

    2009-10-12 13:29:00
  • WordPress3.2.1测试版发布 修复部分兼容问题

    2011-07-13 19:34:43
  • 橙蓝绿三色风格助力垂直细分的SNS个性化发展

    2009-02-15 09:25:00
  • 站长怎么才能提高在Google的域名权重

    2008-05-30 13:07:00
  • 开发环境Ubuntu16安装以后的初始化设置

    2021-02-19 15:53:23
  • IIS网站的“护心甲”-实战SSL

    2007-11-14 13:13:00
  • 美国主机GoDaddy怎样使用htaccess管理PHP的扩展名

    2010-04-09 12:58:00
  • IIS6设置网站经常遇到的问题详解

    2009-09-10 13:03:00
  • 哥做的不是seo是ueo

    2009-08-22 17:23:00
  • 基于Linux的虚拟主机搭建

    2008-10-14 14:11:00
  • 上传漏洞解析-小韩网站编程安全系列二

    2007-07-13 10:08:00
  • 被忽视的Windows Server 2008十大功能

    2009-10-11 15:31:00
  • asp之家 网站运营 m.aspxhome.com