2010年11月8日 星期一

NIS server



1.相關套件:
yp-tools-2.9-1.el5       //server,client都須裝
ypbind-1.19-12.el5        //server,client都須裝
ypserv.i386 0:2.19-5.el5        //server須裝

2.相關檔案與目錄:
/etc/ypserv.conf
/etc/hosts
/etc/sysconfig/network
/var/yp/
/etc/nsswitch.conf         //client
/etc/yp.conf              //client

3.環境設定:
Server:     //由於設定nis不能使用ip,崓稱解析須正常
設定Nisdomainame:
# nisdomainname marcus
#vim /etc/sysconfig/network     //為了開機生效,加入
NISDOMAIN=marcus

#vim /etc/hosts      //加入
127.0.0.1     ......................    master.marcus     //讓本機名稱解析正常
140.137.215.238     master.marcus
192.168.213.112     client.marcus       //client端資料
Client:      //設定正確的nis主機名稱與IP
#vim /etc/hosts    //加入名稱解析
127.0.0.1   .......................   client.marcus
192.168.213.100     master.marcus

4.NIS設定:
#vim /etc/ypserv.conf      //將最後一行註解與空白取消
*                        : *       : *                : none

#/etc/init.d/ypserv restart      //啟動服務
# /etc/init.d/yppasswdd restart       //啟動密碼服務

# rpcinfo -p     //確認是否正常啟動
    100004    2   udp    716  ypserv
    100004    1   udp    716  ypserv
    100004    2   tcp    719  ypserv
    100004    1   tcp    719  ypserv
    100009    1   udp    728  yppasswdd

# /usr/lib/yp/ypinit -m    //建立nis map檔(資料庫格式),將server帳號資料放到/var/yp/marcus 下
                                 //做完後帳號有修改要重做一次,yppasswd可以改密碼
At this point, we have to construct a list of the hosts which will run NIS
servers.  a238.snpy.org 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:  a238.snpy.org
        next host to add:  master.marcus      //輸入網域名稱
        next host to add:          //可在加另一個網域,用ctrl+D來離開
The current list of NIS servers looks like this:

a238.snpy.org
master.marcus

Is this correct?  [y/n: y]  y
We need a few minutes to build the databases...
Building /var/yp/marcus/ypservers...
Running /var/yp/Makefile...
gmake[1]: Entering directory `/var/yp/marcus'
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/marcus'

a238.snpy.org has been set up as a NIS master server.

Now you can run ypinit -s a238.snpy.org on all slave server.

# ypcat -h localhost passwd.byname    //可檢查是否正常運作,會show出帳號資料

*注意防火牆iptables規則
5測試:
在client 端用ypcat測試:
# ypcat -h master.marcus passwd.byname   //看有無server端帳號資料
#setup  --> 認證設定  -->  勾選"使用NIS"      //如果使用DHCP取得IP,
網域名稱:marcus                                           //須注意DHCP srv在dhcpd.conf中有沒設定正確nisdomain
伺服器:192.168.213.100
#cat /etc/yp.conf
domain a238 server 192.168.213.100

#cat /etc/nsswitch.conf
passwd:     files nis
shadow:     files nis
group:      files nis

hosts:      files nis dns
...

*如果有問題可能開機後不能登入,就只能用single user mode來修正
*重開機後,nisdomainname設定可能會失效,可在/etc/rc.local加上
/bin/nisdomainname marcus

沒有留言:

張貼留言