Debian下叢集構建之------NIS伺服器安裝配置
0 網路拓撲
nis server: 192.168.16.2 nis client: 192.163.16.3
1 伺服器端配置
添加測試使用者
$ sudo adduser nistest
軟體安裝
$ sudo aptitude update $ sudo aptitude install nis portmap
NIS 服務的控制
啟動
$ sudo /etc/init.d/nis start
停止
$ sudo /etc/init.d/nis stop
重啟
$ sudo /etc/init.d/nis restart
配置
1. 修改配製檔案 /etc/defaultdomain 內容如下, 設定 NIS 的域:
nis
2. 執行
$ sudo domainname nis
3. 修改設定檔 /etc/default/nis 確保有如下設定, 設定為 NIS 主伺服器
NISSERVER=master NISCLIENT=true
4. 重啟服務
/etc/init.d/nis restart Starting NIS services: ypserv yppasswdd ypxfrd ypbind
產生對應檔
使用者可以使用 make 命令初始化獨立伺服器,建立NIS映射表,檔案 /var/yp/Makefile 包含了建立資料庫的命令, 可以通過編輯Makefile指定系統準備分發哪些映射表。比如:
ALL = passwd group hosts rpc services netid protocols netgrp
使用 make 命令初始化獨立伺服器
$ cd /var/yp $ sudo make
測試
使用 ypwhich 命令測試與伺服器的串連情況
$ ypwhich 192.168.16.2
安全配製
在設定檔 /etc/ypserv.securenets 中,添加可以訪問的客戶機的ip位址範圍,比如允許 192.168.16.0/255.255.255.0 網路段的所有主機訪問
255.0.0.0 127.0.0.0 255.255.255.0 192.168.16.0
對應檔的存取控制
可以通過修改主設定檔: /etc/ypserv.conf 來設定對對應檔的存取權限.
設定檔的文法/格式
<設定項目>:<值><主機名稱/IP>:<網段名稱>:<資料庫類型>:<安全性> * 主機名稱/IP:通常可以這樣設定:192.168.16.0/255.255.255.0,表示192.168.16.0/24整個網段; * 網段名稱:通常設定為*即可; * 資料庫類型:可以使用 '*' 來表示所有類型; * 安全性:主要有三種參數: o none:可以無條件進入本機; o port:僅允許1024以下的連接埠進入; o deny:不允許其它使用者進入本機;
由於這次的目標比較簡單, 所以所有參數都使用預設設定:
# Host : Domain : Map : Security # # * : * : passwd.byname : port/mangle # * : * : passwd.byuid : port/mangle # This is the default - restrict access to the shadow password file, # allow access to all others. * : * : shadow.byname : port * : * : passwd.adjunct.byname : port * : * : * : none
2 用戶端配置
軟體安裝
$ sudo aptitude update$ sudo aptitude install nis portmap
配置
1. 修改設定檔 /etc/default/nis 確保有如下設定,配置為 NIS 用戶端
NISSERVER=falseNISCLIENT=true
2. 在設定檔 /etc/hosts 中添加 Server for NIS的記錄
192.168.16.2 nisserv
3. 修改 /etc/defaultdomain 內容如下, 設定 NIS 域
nis
4. 執行命令
$ sudo domainname nis
5. 修改設定檔 /etc/yp.conf, 加入如下內容, 指定索要使用的 Server for NIS
ypserver nisserv
或
ypserver 192.168.16.2
6. 確保設定檔 /etc/nsswitch.conf 中,passwd, group, shadow 和 netgroup 條目如下設定
passwd: compatgroup: compatshadow: compat
7. 在檔案 /etc/passwd 尾部加入
+:::::: (6個:)
8. 在檔案 /etc/shadow 尾部加入
+:::::::: (8個:)
9. 在檔案 /etc/group 尾部加入:
+::: (3個:)
用戶端測試
1. 使用 ypwhich 測試
$ ypwhichnisserv
2. 使用 yptest 測試
$ yptest
3. 使用 ypcat 測試
$ ypcat passwd
3 使用
在用戶端,使用伺服器端的測試使用者 nistest 使用者登入, 系統從 Server for NIS擷取 nistest 使用者的資訊, 登入成功:
debian login: nistestPassword:Linux debian 2.6.18-4-686 #1 SMP Mon Mar 26 17:17:36 UTC 2007 i686The programs included with the Debian GNU/Linux system are free software;the exact distribution terms for each program are described in theindividual files in /usr/share/doc/*/copyright.Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extentpermitted by applicable law.No directory, logging in with HOME=/nistest@debian:/$