网站策划书的基本内容,免费织梦导航网站模板下载,网站如何伪静态,合肥平台网站建设一、NIS定义 NIS#xff08;Network Information Service#xff0c;网络信息服务#xff09;也称YP(Yellow Pages)协议#xff0c;是一个提供目录服务的RPC(远程过程调用)应用服务。通过它#xff0c;就可以在网络上共享一个集中式的口令文件#xff0c;从而大大简化客… 一、NIS定义 NISNetwork Information Service网络信息服务也称YP(Yellow Pages)协议是一个提供目录服务的RPC(远程过程调用)应用服务。通过它就可以在网络上共享一个集中式的口令文件从而大大简化客户端用户对帐户和口令的维护工作。 二、实验环境 四台CentOS5.4服务器分别作用是 一台NIS Master Server 机器名rhce1.eryin.com IP地址192.168.1.83 一台NIS Slave Server 机器名称rhce2.eryin.com IP地址192.168.1.85 两台NIS Client 机器名称分别是rhce3.eryin.com和rhce4.eryin.com IP地址对应上面192.168.1.88、192.168.1.89 三、架设NIS Server的步骤 注意第三部分的操作是在两台NIS Server上操作的。 1、在NIS Server上安装所需的软件包 #yum install portmap ypserv 2、在NIS Server上设定NIS Domain名称 分别执行如下命令 #nisdomainname RHCE #vi /etc/sysconfig/network加入下面一行 NISDOMAINRHCE 3、设定要限制哪些电脑可以使用NIS Server #vi /var/yp/securenets输入以下内容 255.255.255.0 192.168.1.0 文件格式为 子网掩码 IP地址 上面的设定代表可以让192.168.1.0网段的所有服务器都可以使用NIS Server进行身份验证。 4、启动NIS Server所使用的服务和设置开机自动启动 #service ypserv start #service portmap start #service yppasswdd start #service ypxfrd start #chkconfig ypserv on #chkconfig portmap on #chkconfig yppasswdd on #chkconfig ypxfrd on 5、因为下面需要多个用户我们先创建好此操作只在Master Server上执行 #useradd -g 组 -u uid -d 自定义目录 nistest1 #useradd nistest2 #passwd nistest1 #passwd nistest2 四、配置主要的NIS Master Server 1、NIS Server里的用户资料库就是服务器里的文件内容转换而来的比如从/etc/passwd和/etc/shadow等转换过来的资料库就存放在 /var/yp/NIS Domain目录要转换的文件名称和类型就设定在/var/yp/Makefile文件里。假设我们要设定只验证用户密码和用户组可以在这个文件里设定。如下 #vi /etc/yp/Makefile i #只验证用户密码和用户组 NOPUSHtrue #如果没有Slave的情况下 MINUID500 #意思是只转UID为500以后的帐号之前都是系统帐号 MINGID500 #意思是只转GID为500以后的帐号之前都是系统帐号 2、建立NIS资料库建立之前确认/var/yp目录下没有/etc/sysconfig/network文件里设置的NISDOMAIN目录 #/usr/lib/yp/ypinit -m #m是指Master Server vi 3、重启所有ypserv使用的服务 #service ypserv restart #service portmap restart #service yppasswdd restart #service ypxfrd restart 五、配置备用的NIS Slave Server 1、所有Slave Server的清单都是设定在Master Server的/var/yp/ypservers这个文件里 2、当Master Server建立的资料库后在Slave Server执行如下指令 #/usr/lib/yp/ypinit -s masterIP或hosts #s是Slave Server的意思 3、如果Master Server更新了需重建NIS的资料库和复制给Slave Server 在Master Server里使用如下命令 #cd /var/yp; make 4、重启所有ypserv使用的服务 #service ypserv restart #service portmap restart #service yppasswdd restart #service ypxfrd restart 六、配置NIS Client 1、分别在两台NIS Client上安装所需的软件包即执行如下命令 #yum install portmap ypbind 2、执行authconfig命令指定使用NIS验证用户的方式 #authconfig --enablenis --update #authconfig --nisdomainRHCE --update #authconfig --nisserver192.168.1.83 --update 测试可以登陆了就行了上面写的是书面的步骤明天把整个过程中所有执行的命令全程文字记录发上来呵呵。 还有明天加上后面两章关于使用NIS验证用户后的用户根目录问题。 七、用NFS实现NIS Server与NIS Client用户目录同步 注意下面的NFS Server同时也包括NIS ServerNFS Client同时也包括NIS Client。 1、在四台服务器上全部安装NFS服务 #yum install nfs-utils 2、在NFS Server设置分享的目录 #vi /etc/exports #加入一行 /home 192.168.1.0/255.255.255.0(rw,sync) 3、在NFS Server上重启NFS服务 #service nfs restart 4、在两台NFS Client上查看NFS Server分享的目录 #showmount -e 192.168.1.83 5、在两台NFS Client上卸载原有的/home目录 #umount /home 6、在两台NFS Client上挂载NFS Server分享的目录 #mount 192.168.1.83:/home /home 7、在两台NFS Client上测试登陆nistest1和nistest2。 八、用Auto-Mount实现自动挂载和卸载NIS用户目录 1、在NFS Server创建实验用户和根目录 #mkdir /nishome #useradd -u 5001 -d /nishome/nis1 nis1 #useradd -u 5002 -d /nishome/nis2 nis2 #/usr/lib/yp/ypinit -m #重新生成用户资料库 #service ypserv restart #以下四行重新启动服务 #service portmap restart #service yppasswdd restart #service ypxfrd restart 2、在两台NFS Client上安装自动挂载程序 #yum install autofs 3、编辑自动挂载和卸载程序配置文件 #vi /etc/auto.master #加入一行 /home /etc/auto.nis –timeout60 #cp /etc/auto.misc /etc/auto.nis:wq #vi auto.nis #加入两行 nis1 -rw,soft,intr 192.168.1.83:/nishome/nis1 nis2 -rw,soft,intr 192.168.1.83:/nishome/nis2 为了以后更加方便或者只加入一行 * -rw.soft,intr 192.168.1.83:/nishome/ 4、重新启动autofs服务 #service autofs restart 5、在两台NFS Client上测试登陆nis1和nis2。 附一NIS服务器搭建过程全程记录 1、NIS Master Server192.168.1.83 [rootrhce1 ~]# yum install portmap [rootrhce1 ~]# yum install ypserv [rootrhce1 yp]# nisdomainname RHCE [rootrhce1 ~]# vi /etc/sysconfig/network NETWORKINGyes NETWORKING_IPV6no HOSTNAMErhce1.eryin.com GATEWAY192.168.1.254 #Add NISDOMAIN NISDOMAINRHCE “/etc/sysconfig/network” 5L, 96C written [rootrhce1 ~]# vi /var/yp/securenets 255.255.255.0 192.168.1.0 “/var/yp/securenets” [New] 1L, 28C written [rootrhce1 ~]# service ypserv start [rootrhce1 ~]# useradd nistest1 [rootrhce1 ~]# useradd nistest2 [rootrhce1 ~]# passwd nistest1 [rootrhce1 ~]# passwd nistest2 [rootrhce1 ~]# vi /var/yp/Makefile NOPUSHfalse MINUID500 MINGID500 “/var/yp/Makefile” 496L, 16670C written [rootrhce1 ~]# /usr/lib/yp/ypinit -m [rootrhce1 ~]# cd /var/yp/ [rootrhce1 yp]# ls Makefile RHCE securenets ypservers [rootrhce1 yp]# cd RHCE [rootrhce1 RHCE]# ls group.bygid hosts.byaddr mail.aliases passwd.byname protocols.byname rpc.byname services.byname ypservers group.byname hosts.byname netid.byname passwd.byuid protocols.bynumber rpc.bynumber services.byservicename [rootrhce1 yp]# vi ypservers rhce1.eryin.com rhce2.eryin.com “ypservers” 2L, 32C written [rootrhce1 yp]# vi /etc/hosts # Do not remove the following line, or various programs # that require network functionality will fail. 127.0.0.1 rhce1 localhost.localdomain localhost rhce1.eryin.com 192.168.1.85 rhce2 rhce2.eryin.com ::1 localhost6.localdomain6 localhost6 “/etc/hosts” 5L, 239C written [rootrhce1 yp]# service portmap start [rootrhce1 yp]# service ypserv start [rootrhce1 yp]# service yppasswdd start [rootrhce1 yp]# chkconfig portmap on [rootrhce1 yp]# chkconfig ypserv on [rootrhce1 yp]# chkconfig yppasswdd on [rootrhce1 yp]# rpcinfo -p 127.0.0.1 [rootrhce1 yp]# service ypserv restart [rootrhce1 yp]# /usr/lib/yp/ypinit -m [rootrhce1 yp]# service ypxfrd start [rootrhce1 yp]# chkconfig ypxfrd on 2、NIS Slave Server192.168.1.85 [rootrhce2 ~]# yum install portmap ypserv [rootrhce2 ~]# nisdomainname RHCE [rootrhce2 ~]# vi /etc/sysconfig/network NETWORKINGyes NETWORKING_IPV6no HOSTNAMErhce2.eryin.com GATEWAY192.168.1.254 NISDOMAINRHCE “/etc/sysconfig/network” 5L, 96C written [rootrhce2 ~]# vi /var/yp/securenets 255.255.255.0 192.168.1.0 “/var/yp/securenets” [New] 1L, 26C written [rootrhce2 ~]# vi /etc/hosts # Do not remove the following line, or various programs # that require network functionality will fail. 127.0.0.1 rhce2 localhost.localdomain localhost rhce2.eryin.com 192.168.1.83 rhce1 rhce1.eryin.com ::1 localhost6.localdomain6 localhost6 “/etc/hosts” 5L, 239C written [rootrhce2 ~]# service ypserv start [rootrhce2 ~]# service yppasswdd start [rootrhce2 ~]# service portmap start [rootrhce2 ~]# chkconfig ypserv on [rootrhce2 ~]# chkconfig yppasswdd on [rootrhce2 ~]# chkconfig portmap on [rootrhce2 ~]# /usr/lib/yp/ypinit -s rhce1 3、NIS Client 1192.168.1.88 [rootrhce3 ~]# yum install portmap ypbind [rootrhce4 ~]# vi /etc/hosts # Do not remove the following line, or various programs # that require network functionality will fail. 127.0.0.1 rhce4 localhost.localdomain localhost rhce4.eryin.com 192.168.1.83 rhce1 rhce1.eryin.com 192.168.1.85 rhce2 rhce2.eryin.com ::1 localhost6.localdomain6 localhost6 “/etc/hosts” 6L, 273C written [rootrhce3 ~]# authconfig –enablenis –update Stopping portmap: [ OK ] Starting portmap: [ OK ] Binding to the NIS domain: [ OK ] Listening for an NIS domain server.. [rootrhce3 ~]# authconfig –nisdomainRHCE –update Stopping portmap: [ OK ] Starting portmap: [ OK ] Shutting down NIS services: [ OK ] Binding to the NIS domain: [ OK ] Listening for an NIS domain server.. [rootrhce3 ~]# authconfig –nisserver192.168.1.83 –update Stopping portmap: [ OK ] Starting portmap: [ OK ] Shutting down NIS services: [ OK ] Binding to the NIS domain: [ OK ] Listening for an NIS domain server.. [rootrhce3 ~]# ls anaconda-ks.cfg install.log install.log.syslog [rootrhce3 ~]# ypwhich rhce1 [rootrhce3 ~]# exit logout Last login: Wed May 26 01:49:48 2010 [rootrhce3 ~]# su nistest1 bash-3.2$ pwd /root bash-3.2$ exit exit 4、NIS Client 2192.168.1.89 [rootrhce4 ~]# yum install portmap ypbind [rootrhce4 ~]# vi /etc/hosts # Do not remove the following line, or various programs # that require network functionality will fail. 127.0.0.1 rhce4 localhost.localdomain localhost rhce4.eryin.com 192.168.1.83 rhce1 rhce1.eryin.com 192.168.1.85 rhce2 rhce2.eryin.com ::1 localhost6.localdomain6 localhost6 “/etc/hosts” 6L, 273C written [rootrhce4 ~]# authconfig –enablenis –update [rootrhce4 ~]# authconfig –nisdomainRHCE –update Stopping portmap: [ OK ] Starting portmap: [ OK ] Shutting down NIS services: [ OK ] Binding to the NIS domain: [ OK ] Listening for an NIS domain server.. [rootrhce4 ~]# authconfig –nisserver192.168.1.83 –update Stopping portmap: [ OK ] Starting portmap: [ OK ] Shutting down NIS services: [ OK ] Binding to the NIS domain: [ OK ] Listening for an NIS domain server.. [rootrhce4 ~]# su nistest su: user nistest does not exist [rootrhce4 ~]# su nistest1 bash-3.2$ exit exit [rootrhce4 ~]# su nistest2 bash-3.2$ su nistest1 Password: bash-3.2$ exit exit bash-3.2$ exit exit 附二NFS服务器搭建和分享/home目录过程全程记录 1、NFS Server192.168.1.83 [rootrhce1 ~]# yum install nfs-utils [rootrhce1 ~]# vi /etc/exports /home 192.168.1.0/255.255.255.0(rw,sync) “/etc/exports” 1L, 41C written [rootrhce1 ~]# service nfs restart 2、NFS Client1192.168.1.88 [rootrhce3 ~]# yum install nfs-utils [rootrhce3 ~]# showmount -e 192.168.1.83 Export list for 192.168.1.83: /home 192.168.1.0/255.255.255.0 [rootrhce3 ~]# umount /home [rootrhce3 ~]# mount 192.168.1.83:/home /home [rootrhce3 ~]# su – nistest1 [nistest1rhce3 ~]$ touch test.txt [nistest1rhce3 ~]$ ls test.txt [nistest1rhce3 ~]$ echo $HOME /home/nistest1 3、NFS Client2192.168.1.89 [rootrhce4 ~]# yum install nfs-utils [rootrhce4 ~]# showmount -e 192.168.1.83 Export list for 192.168.1.83: /home 192.168.1.0/255.255.255.0 [rootrhce4 ~]# umount /home [rootrhce4 ~]# mount 192.168.1.83:/home /home [rootrhce4 ~]# su – nistest1 [nistest1rhce4 ~]$ ls test.txt [nistest1rhce4 ~]$ echo $HOME /home/nistest1 附三、用Auto-Mount实现自动挂载和卸载NIS用户目录全程文字记录 1、NFS Server192.168.1.83 [rootrhce1 home]# mkdir /nisname [rootrhce1 nishome]# chmod 1777 /nishome/ [rootrhce1 nisname]# useradd -u 5001 -d /nishome/nis1 nis1 [rootrhce1 nisname]# useradd -u 5002 -d /nishome/nis2 nis2 [rootrhce1 yp]# /usr/lib/yp/ypinit -m [rootrhce1 ~]# service ypserv restart [rootrhce1 ~]# service portmap restart [rootrhce1 ~]# service yppasswdd restart [rootrhce1 ~]# service ypxfrd restart [rootrhce1 yp]# su – nis1 [nis1rhce1 ~]$ pwd /nishome/nis1 [rootrhce1 nishome]# passwd nis1 [rootrhce1 nishome]# passwd nis2 [rootrhce1 nishome]# vi /etc/exports /nishome 192.168.1.0/255.255.255.0(rw,sync) [rootrhce1 nishome]# exportfs -r 2、NFS Client1192.168.1.88 [rootrhce3 home]# yum install autofs [rootrhce3 home]# vi /etc/auto.master /nishome /etc/auto.nis –timeout60 [rootrhce3 home]# cp /etc/auto.misc /etc/auto.nis [rootrhce3 home]# vi /etc/auto.nis nis1 -rw,soft,intr 192.168.1.83:/nishome/nis1 nis2 -rw,soft,intr 192.168.1.83:/nishome/nis2 [rootrhce3 home]# service autofs restart [rootrhce3 nishome]# su – nis1 [nis1rhce3 ~]$ exit 3、NFS Client2192.168.1.89 [rootrhce4 ~]# yum install autofs [rootrhce4 ~]# vi /etc/auto.master /nishome /etc/auto.nis –timeout60 [rootrhce4 ~]# cp /etc/auto.misc /etc/auto.nis [rootrhce4 ~]# vi /etc/auto.nis * -rw,soft,intr 192.168.1.83:/home/ [rootrhce4 ~]# service autofs restart [rootrhce4 ~]# su – nis2 [nis2rhce4 ~]$ exit 总结 服务端添加用户: 1.添加用户 useradd -u uid -d 指定路径 -g 组名 用户名 2./usr/lib64/yp/ypinit -m 更新库 3.重启所有服务 #service ypserv start #service portmap start #service yppasswdd start #service ypxfrd start 新客户端操作 1、分别在两台NIS Client上安装所需的软件包即执行如下命令 #yum install portmap ypbind 2、执行authconfig命令指定使用NIS验证用户的方式 #authconfig --enablenis --update #authconfig --nisdomainRHCE --update #authconfig --nisserver192.168.1.83 --update 转载于:https://blog.51cto.com/shitouququ/477780