小編收到了很多消息都是關于Linux下的NIS服務器的架設,而對于Linux下NIS服務器的架設相信很多朋友們都不是非常的熟悉,那么我們現在就一起跟小編去看看Linux下怎么架設NIS服務器。
	  實驗環境:AS4最小化安裝
	  實驗目標:架設NIS服務器
	  NIS服務器IP192.168.1.10? hostname = crazylinux.nistest 該服務器下面有mike john2個賬號
	  NIS客戶機IP192.168.1.20
	  NIS初始配置:
	  首先配置NIS服務器:
	  1.檢查服務器是否安裝了下列包:portmap、ypserv、ypbind、yp-tools
	  ypserv在第一張安裝光盤中,
	  [root@crazylinux cdrom]# mount /media/cdrom/ 掛載
	  [root@crazylinux /]# rpm -ivh /media/cdrom/RedHat/RPMS/ypserv-2.13-5.i386.rpm
	  warning: /media/cdrom/RedHat/RPMS/ypserv-2.13-5.i386.rpm: V3 DSA signature: NOKEY, key ID db42a60e
	  Preparing...??????????????? ########################################### [100%]
	  1:ypserv???????????????? ########################################### [100%]
	  [root@crazylinux /]# rpm -qa | grep portmap
	  portmap-4.0-63
	  [root@crazylinux /]# rpm -qa | grep ^yp
	  yp-tools-2.8-7
	  ypserv-2.13-5
	  ypbind-1.17.2-3
	  2.設置time和time-udp服務的啟動狀態
	  [root@crazylinux /]# chkconfig --list | grep time? 默認設置
	  time-udp:?????? off
	  daytime-udp:??? off
	  daytime:??????? off
	  time:?? off
	  [root@crazylinux /]# chkconfig time on
	  [root@crazylinux /]# chkconfig time-udp on
	  [root@crazylinux /]# service xinetd restart
	  Stopping xinetd: [? OK? ]
	  Starting xinetd: [? OK? ]
	  3.建立NIS的域名
	  [root@crazylinux /]# nisdomainname nistest
	  [root@crazylinux /]# cat /etc/rc.d/rc.local
	  #!/bin/sh
	  #
	  # This script will be executed *after* all the other init scripts.
	  # You can put your own initialization stuff in here if you don't
	  # want to do the full Sys V style init stuff.
	  touch /var/lock/subsys/local
	  /bin/nisdomainname nistest? 添加這行使之開機運行
	  修改/etc/sysconfig/network文件,增加此行:NISDOMAIN=nistest
	  4.設置ypserv服務的配置文件
	  把下面這些添加到/etc/ypserv.conf最后
	  127.0.0.0/255.255.255.0??? : *?????? : *??????????????? : none
	  192.168.1.0/255.255.255.0? : *?????? : *??????????????? : none
	  *?????????????????????? : *?????? : *??????????????? : deny
	  [root@ crazylinux /]# touch /etc/netgroup
	  [root@crazylinux /]#hostname crazylinux.nistest
	  [root@crazylinux /]# cat /var/yp/securenets?? 需要自己建立
	  host 127.0.0.1
	  255.255.255.0?? 192.168.1.0
	  5.啟動相關服務:
	  #service portmap restart
	  [root@crazylinux /]# service portmap status
	  portmap (pid 1649) is running...
	  [root@crazylinux /]# service ypserv start
	  Starting YP server services: [? OK? ]
	  [root@crazylinux /]# service yppasswdd start
	  Starting YP passwd service: [? OK? ]
	  [root@crazylinux /]# chkconfig --level 35 ypserv on
	  [root@crazylinux /]# chkconfig --level 35 yppasswdd on? 設置開機自動運行
	  6.初始化NIS數據庫:
	  [root@crazylinux /]# useradd user1
	  [root@crazylinux /]# passwd user1
	  #/usr/lib/yp/ypinit –m
	  此時會詢問是否有其他NIS服務器,如果沒有,則可以直接按Ctrl+D結束,并重啟ypserv服務。
	  #service ypserv restart
	  #service yppasswdd restart
	  同時檢查進程是否正常運行以及信息是否正確:ps –aux | grep yp???? tail /var/log/message
	  以下進行客戶端上的配置:
	  1.確認安裝以下包: ypbind、yp-tools默認安裝了的
	  2.設置hosts文件
	  [root@localhost ~]# cat /etc/hosts
	  # Do not remove the following line, or various programs
	  # that require network functionality will fail.
	  127.0.0.1?????????????? localhost.localdomain localhost
	  192.168.1.10??????????? crazylinux??? NIS服務器的主機名
	  3.建立NIS域名
	  [root@crazylinux /]# nisdomainname nistest
	  [root@crazylinux /]# cat /etc/rc.d/rc.local
	  #!/bin/sh
	  #
	  # This script will be executed *after* all the other init scripts.
	  # You can put your own initialization stuff in here if you don't
	  # want to do the full Sys V style init stuff.
	  touch /var/lock/subsys/local
	  /bin/nisdomainname nistest? 添加這行使之開機運行
	  修改/etc/sysconfig/network文件,增加此行:NISDOMAIN=nistest
	  4.設置yp.conf
	  [root@localhost ~]# cat /etc/yp.conf
	  # generated by /sbin/dhclient-script
	  domain domain.org broadcast
	  domain? nistest???? 添加這句
	  ypserver crazylinux.nistest
	  在/etc/passwd最下面添加
	  +::::::
	  5.設置nsswitch.conf
	  vi? /etc/nsswitch.conf?? 修改為這樣
	  passwd:???? files nis nisplus
	  shadow:???? files nis nisplus
	  group:????? files nis nisplus
	  #hosts:???? db files nisplus nis dns
	  hosts:????? files nis dns
	  6.啟動ypbind服務程序
	  [root@localhost ~]# service portmap status
	  portmap (pid 1683) is running...
	  [root@localhost ~]# service? ypbind start
	  Binding to the NIS domain: [? OK? ]
	  Listening for an NIS domain server..
	  在NIS服務器中輸出NFS共享目錄
	  在nis服務器上
	  [root@localhost ~]# vi /etc/exports 添加
	  /home???? 192.168.1.0/24(rw,async,np_root_squash)
	  [root@localhost ~]#service nfs start
	  在NIS客戶機上
	  [root@localhost ~]#vi /etc/fstab
	  Crazylinux.nistest:/home/?????? /home???? nfs?? defaults?? 0???? 0
	  現在在客戶機中用服務器里面的帳號登陸? 嘿嘿? OK
	  上文中介紹的Linux下如何架設NIS服務器的內容你學會了嗎?linux系統還有更多豐富的功能和特性,可以幫助我們提高工作學習效率,有待朋友們多多發掘。