網站首頁 編程語言 正文
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
相關推薦
- 2022-08-30 python中Requests請求的安裝與常見用法_python
- 2022-11-14 C++中4種管理數據內存的方式總結_C 語言
- 2022-09-25 nginx平滑升級、nginx支持的kill信號
- 2022-06-23 QT實現簡單計算器功能_C 語言
- 2023-03-17 Docker部署Nginx并修改配置文件的兩種方式_docker
- 2023-03-20 C#如何刪除指定文件或文件夾_C#教程
- 2022-06-06 C++中隊列queue的用法實例詳解_C 語言
- 2022-09-21 Python安裝和配置uWSGI的詳細過程_python
- 最近更新
-
- window11 系統安裝 yarn
- 超詳細win安裝深度學習環境2025年最新版(
- Linux 中運行的top命令 怎么退出?
- MySQL 中decimal 的用法? 存儲小
- get 、set 、toString 方法的使
- @Resource和 @Autowired注解
- Java基礎操作-- 運算符,流程控制 Flo
- 1. Int 和Integer 的區別,Jav
- spring @retryable不生效的一種
- Spring Security之認證信息的處理
- Spring Security之認證過濾器
- Spring Security概述快速入門
- Spring Security之配置體系
- 【SpringBoot】SpringCache
- Spring Security之基于方法配置權
- redisson分布式鎖中waittime的設
- maven:解決release錯誤:Artif
- restTemplate使用總結
- Spring Security之安全異常處理
- MybatisPlus優雅實現加密?
- Spring ioc容器與Bean的生命周期。
- 【探索SpringCloud】服務發現-Nac
- Spring Security之基于HttpR
- Redis 底層數據結構-簡單動態字符串(SD
- arthas操作spring被代理目標對象命令
- Spring中的單例模式應用詳解
- 聊聊消息隊列,發送消息的4種方式
- bootspring第三方資源配置管理
- GIT同步修改后的遠程分支