⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 0430nis.htm

📁 鸟哥LINUX 学习课本
💻 HTM
📖 第 1 页 / 共 5 页
字号:
<br>请留意的是,底下的设定都是在 Client 端喔!不要在主机端作这些设定了!^_^<br> <ol><li><b><font color="#000099">启动 portmap 并设定开机时启动:</font></b></li><br>不论是 RPC Server 还是 RPC Client ,反正只要是 RPC 的相关服务要应用,就一定要有portmap 的辅助才行!所以,启动并设定开机时启动吧!<table bgcolor="#000000" border="1" cols="1" width="550"><tbody><tr><td><font size="-1" face="SimSun"><font color="#ffffff">[root@clientroot]# </font><font color="#ffff00">/etc/rc.d/init.d/portmap start</font></font><br><font size="-1" face="SimSun"><font color="#ffffff">[root@clientroot]#</font><font color="#ffff00"> netstat -tl</font></font><br><font size="-1" color="#ffffff" face="SimSun">Active Internetconnections (only servers)</font><br><font size="-1" color="#ffffff" face="SimSun">Proto Recv-QSend-Q Local Address&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Foreign Address&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; State</font><br><font size="-1" face="SimSun"><font color="#ffffff">tcp&#160;&#160;&#160;&#160;&#160;&#160;&#160;0&#160;&#160;&#160;&#160;&#160; 0 *:</font><font color="#ffffcc">sunrpc</font><font color="#ffffff">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;*:*&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;LISTEN</font></font><br><font size="-1" color="#ff6666" face="SimSun">如果看到 sunrpc的话,就表示启动成功了!</font><br><font size="-1" face="SimSun"><font color="#ffffff">[root@testroot]# </font><font color="#ffff00">chkconfig --level 35 portmap on</font></font><br><font size="-1" color="#ff6666" face="SimSun">上面这一行在设定portmap 在 run-level 为 3, 5 的时候就开机时启动!</font></td></tr></tbody></table>很简单吧!这样 portmap 就启动了!<br><b><font color="#000099"> </font></b><li><b><font color="#000099">设定 NIS Server 的 IP 对应主机名称:</font></b></li><br>请看上面 Server 设定之前的假设,我的 NIS Server 的 IP 与主机名称记录在Client 端的 /etc/hosts 上面:<table bgcolor="#000000" border="1" cols="1" width="550"><tbody><tr><td><font size="-1" face="SimSun"><font color="#ffffff">[root@clientroot]#</font><font color="#ffff00"> vi /etc/hosts</font></font><br><font size="-1" color="#ff6666" face="SimSun"># 要有底下这一行喔!</font><br><font size="-1" color="#ffff00" face="SimSun">192.168.10.30server.cluster</font></td></tr></tbody></table> <li><b><font color="#000099">设定 NIS 的 domain 与 NIS 的主机:</font></b></li><br>NIS Server 与 Client 的 NIS domain 一定要相同,所以我们必须要花一点时间来将这个咚咚搞定:<table bgcolor="#000000" border="1" cols="1" width="550"><tbody><tr><td><font size="-1" color="#ffffcc" face="SimSun">1. 建立 NISdomain name:</font><br><font size="-1" face="SimSun"><font color="#ffffff">[root@clientroot]#</font><font color="#ffff00"> nisdomainname cluster</font></font><br><font size="-1" face="SimSun"><font color="#ffffff">[root@clientroot]# </font><font color="#ffff00">vi /etc/rc.d/rc.local</font></font><br><font size="-1" color="#ff6666" face="SimSun"># 加入底下这一行:</font><br><font size="-1" color="#ffff00" face="SimSun">/bin/nisdomainnamecluster</font><br><font size="-1" face="SimSun"><font color="#ffffff">[root@clientroot]# </font><font color="#ffff00">vi /etc/sysconfig/network</font></font><br><font size="-1" color="#ff6666" face="SimSun"># 加入底下这一行:</font><br><font size="-1" color="#ffff00" face="SimSun">NISDOMAIN=cluster</font><br><font size="-1" color="#ffffff" face="SimSun"> </font><br><font size="-1" color="#ffffcc" face="SimSun">2. 建立 NIS查寻的主机名称</font><br><font size="-1" face="SimSun"><font color="#ffffff">[root@clientroot]#</font><font color="#ffff00"> vi /etc/yp.conf</font></font><br><font size="-1" color="#ff6666" face="SimSun"># 加入这两行:</font><br><font size="-1" color="#ffff00" face="SimSun">domain cluster</font><br><font size="-1" color="#ffff00" face="SimSun">ypserver server.cluster</font><br><font size="-1" color="#ff6666" face="SimSun"># 还是要记得,那个cluster 是你的 NIS 的 domain ,至于 server.cluster&#160;</font><br><font size="-1" color="#ff6666" face="SimSun"># 则是 NISServer 的主机名称,我这里是使用内部私有 IP ,所以名称可以随便</font><br><font size="-1" color="#ff6666" face="SimSun"># 我喜欢来选择的喔!</font></td></tr></tbody></table> <li><b><font color="#000099">修改密码验证的方式:</font></b></li><br>密码验证的方式是一定要修改的,不然你的系统怎么知道要去哪里使用什么方式查寻账号、密码数据呢?!所以您至少需要更改两个档案喔!<table bgcolor="#000000" border="1" cols="1" width="550"><tbody><tr><td><font size="-1" color="#ffffcc" face="SimSun">1. 密码文件的修改:</font><br><font size="-1" face="SimSun"><font color="#ffffff">[root@clientroot]#</font><font color="#ffff00"> vi /etc/passwd</font></font><br><font size="-1" color="#ff6666" face="SimSun"># 还记得这个档案吗?这个档案总共有七个字段,而每个字段都以分号『:』隔开,</font><br><font size="-1" color="#ff6666" face="SimSun"># 相关的信息请参考基础学习篇里面的账号管理章节。由于我们要将数据</font><br><font size="-1" color="#ff6666" face="SimSun"># 设定以 NISServer 的数据库来验证,因此,</font><br><font size="-1" color="#ff6666" face="SimSun"># 在这个档案的最后面加入这一行:</font><br><font size="-1" color="#ffff00" face="SimSun">+::::::</font><br><font size="-1" color="#ffffcc" face="SimSun"># 注意喔!在+ 之后连续加六个『 : 』,并且中间没有空格符!</font><br><font size="-1" color="#ffffcc" face="SimSun"> </font><br><font size="-1" color="#ffffcc" face="SimSun">2. 查寻密码的程序:</font><br><font size="-1" color="#ff6666" face="SimSun"># 因为我们有很多方式来查寻密码,需要修改/etc/nsswitch.conf 这个档案才行</font><br><font size="-1" face="SimSun"><font color="#ffffff">[root@clientroot]# </font><font color="#ffff00">vi /etc/nsswitch.conf</font></font><br><font size="-1" color="#ff6666" face="SimSun"># 找到相关的参数,并改成底下这样:</font><br><font size="-1" color="#ffff00" face="SimSun">passwd:&#160;&#160;&#160;&#160;files nis nisplus</font><br><font size="-1" color="#ffff00" face="SimSun">shadow:&#160;&#160;&#160;&#160;files nis nisplus</font><br><font size="-1" color="#ffff00" face="SimSun">group:&#160;&#160;&#160;&#160;&#160;files nis nisplus</font><br><font size="-1" color="#ffff00" face="SimSun">hosts:&#160;&#160;&#160;&#160;&#160;files nis dns</font><br><font size="-1" color="#ff6666" face="SimSun"># 这个档案在设定一些信息的查寻程序!那个files 指的是本机的相关档案,</font><br><font size="-1" color="#ff6666" face="SimSun"># 至于 nis则是透过 NIS 来进行查寻,至于 nisplus 则是 NIS+ 这是比较新</font><br><font size="-1" color="#ff6666" face="SimSun"># 版的 NIS啦!不过,官方网站上面说,目前这个发展的计划已经暂停了!</font><br><font size="-1" color="#ff6666" face="SimSun"># 1. passwd:就是使用者相关信息查寻,分别为 /etc/passwd, nis 与 nisplus</font><br><font size="-1" color="#ff6666" face="SimSun"># 2. shadow:就是使用者密码的查寻, /etc/shadow, nis 及 nisplus</font><br><font size="-1" color="#ff6666" face="SimSun"># 3. group:&#160;就是使用者的群组信息查寻, /etc/group, nis 及 nisplus</font><br><font size="-1" color="#ff6666" face="SimSun"># 4. hosts:&#160;就是主机名称与IP对应的查寻,/etc/hosts, nis 及 /etc/resolv.conf</font></td></tr></tbody></table> <li><b><font color="#000099">启动 ypbind 与设定开机启动:</font></b></li><br>这样几乎就设定完成了!而我们前面说过, NIS Client 也需要启动 ypbind这个 daemon 的,所以就给他启动吧!<table bgcolor="#000000" border="1" cols="1" width="550"><tbody><tr><td><font size="-1" color="#ffffcc" face="SimSun">1. 直接手动启动ypbind 吧:</font><br><font size="-1" face="SimSun"><font color="#ffffff">[root@clientroot]#</font><font color="#ffff00"> /etc/rc.d/init.d/ypbind start</font></font><br><font size="-1" face="SimSun"><font color="#ffffff">[root@clientroot]#</font><font color="#ffff00"> rpcinfo -p localhost</font></font><br><font size="-1" color="#ffffff" face="SimSun">&#160;&#160;program vers proto&#160;&#160; port</font><br><font size="-1" color="#ffffff" face="SimSun">&#160;&#160;&#160;100000&#160;&#160;&#160; 2&#160;&#160; tcp&#160;&#160;&#160; 111&#160;portmapper</font><br><font size="-1" color="#ffffff" face="SimSun">&#160;&#160;&#160;100000&#160;&#160;&#160; 2&#160;&#160; udp&#160;&#160;&#160; 111&#160;portmapper</font><br><font size="-1" color="#ffffff" face="SimSun">&#160;&#160;&#160;100007&#160;&#160;&#160; 2&#160;&#160; udp&#160;&#160;&#160; 735&#160;ypbind</font><br><font size="-1" color="#ffffff" face="SimSun">&#160;&#160;&#160;100007&#160;&#160;&#160; 1&#160;&#160; udp&#160;&#160;&#160; 735&#160;ypbind</font><br><font size="-1" color="#ffffff" face="SimSun">&#160;&#160;&#160;100007&#160;&#160;&#160; 2&#160;&#160; tcp&#160;&#160;&#160; 738&#160;ypbind</font><br><font size="-1" color="#ffffff" face="SimSun">&#160;&#160;&#160;100007&#160;&#160;&#160; 1&#160;&#160; tcp&#160;&#160;&#160; 738&#160;ypbind</font><br><font size="-1" color="#ff6666" face="SimSun"># 至少要有上面几个信息才是对的喔!不过,需要记得的是,那个port number</font><br><font size="-1" color="#ff6666" face="SimSun"># 是系统随机启动的,所以port number 每次都会不太一样啊!</font><br><font size="-1" color="#ff6666" face="SimSun"># 记得要经常用rpcinfo 去检查一下 RPC Server 相关的服务才行!</font><br><font size="-1" color="#ffffcc" face="SimSun"> </font><br><font size="-1" color="#ffffcc" face="SimSun">2. 设定开机时启动:</font><br><font size="-1" face="SimSun"><font color="#ffffff">[root@clientroot]#</font><font color="#ffff00"> chkconfig --level 35 ypbind on</font></font></td></tr></tbody></table>&nbsp;</ol>基本上,上面的动作就已经设定好了一部 NIS Client 主机了!而且已经可以跑啰!不过,我们毕竟不知道到底目前我们的NIS Client 主机使用的 NIS Server 主机里面的哪些数据,并且如何去确认我们的数据库与设定值都没有问题呢?!呵呵!所以底下我们就来谈一谈那个yp-tools 提供的相关好用的工具程序来检验啰!<br> <br><hr width="100%"><a name="client_yp_tools"></a><font size="+1" color="#000099">NICClient 端检验 NIS 设定:yptest, ypwhich, ypcat</font><br> <br>设定好了 NIS Client 之后,先以 netstat 与 rpcinfo 检验一下是否成功的启动之后,接下来就是要测试到底我们的NIS Client 与 NIS Server 之间沟通的情况如何了!此时就需要使用到 NIS 提供的yp-tools 这个套件,里面的几个小小的执行程序来动作了:<br> <ul><li><font color="#000066" face="SimSun">yptest :主要在测试 yp 的设定内容、数据库内容等等所有NIS 相关的资料测试;</font></li><li><font color="#000066" face="SimSun">ypwhich:主要在测试 NIS Client与 Server 之间沟通的数据库 (database) 到底是哪几个档案;</font></li><li><font color="#000066" face="SimSun">ypcat&#160; :主要在取得 NISServer 上面的使用者密码信息!</font></li></ul> <br>分别谈一谈每个程序的用途与说明吧!<br> <ul><hr width="100%"><a name="client_yp_tools_yptest"></a>yptest<table bgcolor="#000000" border="1" cols="1" width="550"><tbody><tr><td><font size="-1" face="SimSun"><font color="#ffffff">[root@clientroot]# </font><font color="#ffff00">yptest</font></font><br><font size="-1" color="#ffffff" face="SimSun">Test 1: domainname</font><br><font size="-1" color="#ffffff" face="SimSun">Configureddomainname is "cluster"</font><p><font size="-1" color="#ffffff" face="SimSun">Test 2: ypbind</font><br><font size="-1" color="#ffffff" face="SimSun">Used NIS server:server.cluster</font><br><font size="-1" color="#ffffff" face="SimSun">....</font><br><font size="-1" color="#ffffff" face="SimSun">....</font><br><font size="-1" color="#ffffff" face="SimSun">Test 8: yp_maplist</font>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -