{"repo": "atoposyz/atoposyz.github.io", "files": {"public/nis_ubuntu.html": {"cb5893b569f230065fe91ceeb1bee461076c1c12": {"t": 1785594973.9400144, "n": 112841, "h": "5e369f10debfe72f", "c": "\n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n Ubuntu 22.04配置NIS服务_ubuntu nis-CSDN博客 \n \n \n \n \n \n \n \n \n \t\n \n \n
\n \n \n \n
\n
\n
\n
\n
\n
\n
\n

Ubuntu 22.04配置NIS服务

\n
\n
\n
\n \"\" \n
\n \"\" \n dawei.wang \n \"\" \n 于 2024-08-28 16:02:11 发布 \n
\n \"\" \n 阅读量1k \n \"\" \"\" 收藏 2 \n
\n \"\" \n \"\" \n 点赞数 3 \n
\n
\n
\n
\n
\n
\n 分类专栏: \n # Ubuntu \n 文章标签: \n ubuntu \n linux \n 运维 \n
\n
\n
\n
\n
\n 版权声明:本文为博主原创文章,遵循\n CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。 \n
\n \n
\n
\n
\n 版权 \n
\n
\n
\n
\n
\n
\n
\n \n \n
\n \n \n \n

说明:
  ubuntu 22.04 nis服务搭建。

\n

服务端配置

\n

查看系统版本

\n
$ cat /etc/os-release \nPRETTY_NAME=\"Ubuntu 22.04.4 LTS\"\nNAME=\"Ubuntu\"\nVERSION_ID=\"22.04\"\nVERSION=\"22.04.4 LTS (Jammy Jellyfish)\"\nVERSION_CODENAME=jammy\nID=ubuntu\nID_LIKE=debian\nHOME_URL=\"https://www.ubuntu.com/\"\nSUPPORT_URL=\"https://help.ubuntu.com/\"\nBUG_REPORT_URL=\"https://bugs.launchpad.net/ubuntu/\"\nPRIVACY_POLICY_URL=\"https://www.ubuntu.com/legal/terms-and-policies/privacy-policy\"\nUBUNTU_CODENAME=jammy\n
\n

安装NIS服务端

\n
$ sudo apt update\n$ sudo apt install -y ypserv\nReading package lists... Done\nBuilding dependency tree... Done\nReading state information... Done\nThe following packages were automatically installed and are no longer required:\n  libwpe-1.0-1 libwpebackend-fdo-1.0-1\nUse 'sudo apt autoremove' to remove them.\nThe following additional packages will be installed:\n  libnss-nis make nscd rpcbind yp-tools ypbind-mt\nSuggested packages:\n  make-doc krb5-kdc\nThe following NEW packages will be installed:\n  libnss-nis make nscd rpcbind yp-tools ypbind-mt ypserv\n0 upgraded, 7 newly installed, 0 to remove and 28 not upgraded.\nNeed to get 525 kB of archives.\nAfter this operation, 1,964 kB of additional disk space will be used.\nGet:1 https://mirrors.tuna.tsinghua.edu.cn/ubuntu jammy/main amd64 rpcbind amd64 1.2.6-2build1 [46.6 kB]\nGet:2 https://mirrors.tuna.tsinghua.edu.cn/ubuntu jammy/main amd64 libnss-nis amd64 3.1-0ubuntu6 [27.3 kB]\nGet:3 https://mirrors.tuna.tsinghua.edu.cn/ubuntu jammy/main amd64 make amd64 4.3-4.1build1 [180 kB]\nGet:4 https://mirrors.tuna.tsinghua.edu.cn/ubuntu jammy-updates/universe amd64 nscd amd64 2.35-0ubuntu3.8 [83.3 kB]\nGet:5 https://mirrors.tuna.tsinghua.edu.cn/ubuntu jammy/universe amd64 ypbind-mt amd64 2.7.2-2 [33.4 kB]\nGet:6 https://mirrors.tuna.tsinghua.edu.cn/ubuntu jammy/universe amd64 yp-tools amd64 4.2.3-3 [50.3 kB]\nGet:7 https://mirrors.tuna.tsinghua.edu.cn/ubuntu jammy/universe amd64 ypserv amd64 4.1-2 [104 kB]\n# 安装ypserv同时安装了rpcbind、libnss-nis、make、nscd、ypbind-mt、yp-tools、ypserv;这些都不需要额外安装了。\n\n$ sudo vim /etc/sysctl.conf \nkernel.domainname = aic.test.ai\t\t# 这里给nis域名\n\n$ sudo reboot\t\t# 重启系统\n$ nisdomainname \t# 查看一下nis域名\naic.test.ai\n\n$ sudo vim /etc/defaultdomain\naic.test.ai\n\n$ sudo vim /var/yp/Makefile\n# ALL =   passwd group hosts rpc services netid protocols netgrp\nALL =   passwd group hosts netgrp\t\t# 这里根据需求修改nis域管理服务\n\n/usr/lib/yp/ypinit -m\n\nAt this point, we have to construct a list of the hosts which will run NIS\nservers.  mlc09 is in the list of NIS server hosts.  Please continue to add\nthe names for the other hosts, one per line.  When you are done with the\nlist, type a <control D>.\n        next host to add:  mlc09\n        next host to add:  \nThe current list of NIS servers looks like this:\n\nmlc09\n\nIs this correct?  [y/n: y]  y\nWe need a few minutes to build the databases...\nBuilding /var/yp/aic.test.ai/ypservers...\nRunning /var/yp/Makefile...\ngmake[1]: Entering directory '/var/yp/aic.test.ai'\nUpdating passwd.byname...\nfailed to send 'clear' to local ypserv: RPC: Program not registeredUpdating passwd.byuid...\nfailed to send 'clear' to local ypserv: RPC: Program not registeredUpdating group.byname...\nfailed to send 'clear' to local ypserv: RPC: Program not registeredUpdating group.bygid...\nfailed to send 'clear' to local ypserv: RPC: Program not registeredUpdating hosts.byname...\nfailed to send 'clear' to local ypserv: RPC: Program not registeredUpdating hosts.byaddr...\nfailed to send 'clear' to local ypserv: RPC: Program not registeredUpdating netgroup...\nfailed to send 'clear' to local ypserv: RPC: Program not registeredUpdating netgroup.byhost...\nfailed to send 'clear' to local ypserv: RPC: Program not registeredUpdating netgroup.byuser...\nfailed to send 'clear' to local ypserv: RPC: Program not registeredUpdating shadow.byname...\nfailed to send 'clear' to local ypserv: RPC: Program not registeredgmake[1]: Leaving directory '/var/yp/aic.test.ai'\n\nmlc09 has been set up as a NIS master server.\n\nNow you can run ypinit -s mlc09 on all slave server.\n
\n

配置服务启动

\n
cat /lib/systemd/system/ypserv.service \n[Unit]\nDescription=NIS/YP (Network Information Service) Server\nRequires=rpcbind.service\nAfter=network.target rpcbind.service \nBefore=ypbind.service\n\n[Service]\nType=forking\nPIDFile=/run/ypserv.pid\nEnvironment=YPSERVARGS=\nEnvironmentFile=-/etc/default/nis\nExecStartPre=/bin/domainname -F /etc/defaultdomain\nExecStart=/usr/sbin/ypserv $YPSERVARGS\n\n[Install]\nWantedBy=multi-user.target\n
\n

为了方便管理可以自定义服务端端口:856;也可以使用默认端口

\n
$ sudo vim /lib/systemd/system/ypserv.service\nEnvironment=YPSERVARGS=\"-p 856\"\n
\n

添加到开机启动并启动服务

\n
$ sudo systemctl enable ypserv --now\n$ sudo lsof -i |grep ypserv\nypserv    3148            root    5u  IPv4  93227      0t0  UDP *:856 \nypserv    3148            root    6u  IPv4  93232      0t0  TCP *:856 (LISTEN)\nypserv    3148            root    7u  IPv6  93237      0t0  UDP *:857 \nypserv    3148            root    8u  IPv6  93240      0t0  TCP *:857 (LISTEN)\n
\n

同样yppasswd服务,修改端口号:858;也可以使用默认端口

\n
cat /lib/systemd/system/yppasswdd.service\n[Unit]\nDescription=NIS Users Passwords Change Server\nRequires=rpcbind.service\nWants=network-online.target\nAfter=network-online.target rpcbind.service\n\n[Service]\nType=forking\nPIDFile=/run/yppasswdd.pid\nEnvironment=YPPASSWDDARGS= YPCHANGEOK=chsh YPPWDDIR=/etc\nEnvironmentFile=-/etc/default/nis\nExecStartPre=/bin/domainname -F /etc/defaultdomain\nExecStart=/usr/sbin/rpc.yppasswdd -D $YPPWDDIR -e $YPCHANGEOK $YPPASSWDDARGS\n\n[Install]\nWantedBy=multi-user.target\n\n$ sudo vim /lib/systemd/system/yppasswdd.service\nEnvironment=YPPASSWDDARGS=\"-p 858\" YPCHANGEOK=chsh YPPWDDIR=/etc\n
\n

添加到开机启动并启动服务

\n
$ sudo systemctl enable yppasswdd --now\n$ sudo lsof -i | grep yppas\nrpc.yppas 3240            root    5u  IPv4  16980      0t0  UDP *:858 \nrpc.yppas 3240            root    6u  IPv4  16983      0t0  TCP *:858 (LISTEN)\nrpc.yppas 3240            root    7u  IPv6  16986      0t0  UDP *:859 \nrpc.yppas 3240            root    8u  IPv6  16989      0t0  TCP *:859 (LISTEN)\n
\n

客户端配置

\n
$ sudo apt install -y ypbind-mt \nReading package lists... Done\nBuilding dependency tree... Done\nReading state information... Done\nThe following additional packages will be installed:\n  libnss-nis nscd rpcbind yp-tools\nThe following NEW packages will be installed:\n  libnss-nis nscd rpcbind yp-tools ypbind-mt\n0 upgraded, 5 newly installed, 0 to remove and 80 not upgraded.\nNeed to get 241 kB of archives.\nAfter this operation, 1,081 kB of additional disk space will be used.\nGet:1 https://mirrors.tuna.tsinghua.edu.cn/ubuntu jammy/main amd64 rpcbind amd64 1.2.6-2build1 [46.6 kB]\nGet:2 https://mirrors.tuna.tsinghua.edu.cn/ubuntu jammy/main amd64 libnss-nis amd64 3.1-0ubuntu6 [27.3 kB]\nGet:3 https://mirrors.tuna.tsinghua.edu.cn/ubuntu jammy-updates/universe amd64 nscd amd64 2.35-0ubuntu3.8 [83.3 kB]\nGet:4 https://mirrors.tuna.tsinghua.edu.cn/ubuntu jammy/universe amd64 ypbind-mt amd64 2.7.2-2 [33.4 kB]\nGet:5 https://mirrors.tuna.tsinghua.edu.cn/ubuntu jammy/universe amd64 yp-tools amd64 4.2.3-3 [50.3 kB]\n\n$ sudo vim /etc/defaultdomain\naic.test.ai\n\n$ sudo vim /etc/yp.conf\ndomain aic.test.ai server 192.168.13.68\n\n$ sudo systemctl enable ypbind --now\n\n$ sudo vim /etc/nsswitch.conf\npasswd:         files systemd nis\ngroup:          files systemd nis\nshadow:         files nis\ngshadow:        files\n\nhosts:          files nis mdns4_minimal [NOTFOUND=return] dns\nnetworks:       files\n\nprotocols:      db files\nservices:       db files\nethers:         db files\nrpc:            db files\n\nnetgroup:       nis\n
\n

小结:
  配置前需要先安装NFS服务并将home目录挂载到nis client服务器。

\n
\n \n \n
\n
\n
\n
\n
\n
\n
\n \n
\n 确定要放弃本次机会? \n
\n 福利倒计时 \n
\n \n : \n \n : \n \n
\n
\n

立减 ¥

\n 普通VIP年卡可用 \n
\n 立即使用 \n
\n
\n
\n
\n
\n \n
\n 关注 \n \n
\n
\n
\n \n
\n
\n
\n 专栏目录 \n
\n
\n
\n
\n \n
\n
\n
\n
\n 0 条评论 \n
\n
\n 写评论 \n
\n
\n
\n \n \n \n \n
\n \n
\n
\n \n
\n
\n \n
\n
\n
\n
\n
\n
\n
\n
\n 评论 \n \n
\n
\n
\n
\n \n
\n
\n \n
\n \n
\n
\n 成就一亿技术人! \n
\n
\n 拼手气红包\n 6.0元 \n
\n
\n
\n
\n
\n 还能输入1000个字符 \n
\n
\n   \n
\n
\n
\n \"红包\" \n 添加红包 \n
\n
\n \"表情包\" \n 插入表情 \n
\n
\n
\n
\n
\n \"表情包\" \n 代码片 \n
\n \n
\n
\n
\n \n \n \n \n \n
\n
\n
\n
\n
\n
\n
\n
\n
\n  条评论被折叠 \n 查看 \n
\n
\n
\n
\n
\n
\n
\n
\n \"\"被折叠的 \n  条评论 \n 为什么被折叠? \n 到【灌水乐园】发言 \n
\n
\n \n
\n
\n
\n
\n
\n 添加红包 \n \n
\n
\n
\n \n
\n \n \n
\n

请填写红包祝福语或标题

\n
\n
\n \n
\n \n 个 \n
\n

红包个数最小为10个

\n
\n
\n \n
\n \n 元 \n
\n

红包金额最低5元

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

抵扣说明:

\n

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

\n
\n
\n
\n
\n \"\"余额充值 \n
\n
\n \n
\n
\n \n \n \n"}}}}