- 論壇徽章:
- 0
|
24.2 NIS+的設(shè)置
設(shè)置NIS+服務(wù)有兩種方法:一種是使用腳本來設(shè)置NIS+服務(wù);另一種就是直接使用NIS+命令來設(shè)置。腳本也是用一些NIS+命令寫成的,它定制了典型的幾種NIS+服務(wù)的設(shè)置方法。由于使用NIS+命令比較復(fù)雜,使用腳本方法設(shè)置NIS+服務(wù)是一種明智的做法。不過,在定制服務(wù)方面,還需要直接使用命令來做。本書限于篇幅,只介紹腳本的方法,對需要定制服務(wù)的讀者,可到docs.sun.com網(wǎng)站查找相關(guān)資料。
在本節(jié)中,我們將進(jìn)行一個(gè)NIS+服務(wù)的完整配置。在這個(gè)過程中,將討論主服務(wù)器的建立、NIS+表的創(chuàng)建、客戶機(jī)和服務(wù)器的配置,以及其他域的設(shè)置。
24.2.1 建立一個(gè)根域服務(wù)器
創(chuàng)建NIS+命名空間的第一步是為新的域創(chuàng)建一個(gè)根域的主服務(wù)器。比如我們要建立一個(gè)根域?yàn)镈oc.Com.的根域服務(wù)器?梢赃M(jìn)行下列步驟:
(1)在超級用戶的環(huán)境變量中設(shè)置PATH時(shí)加入/usr/lib/nis目錄。
(2)(這步是可選的)默認(rèn)系統(tǒng)使用192位DES算法來加密,現(xiàn)在使用下面的命令可以改為640位DES加密:
nisauthconf dh640-0 des
(3)下面這個(gè)命令是超級用戶設(shè)置主服務(wù)器用的,-r選項(xiàng)是指根服務(wù)器將被選定,-d選項(xiàng)是指定域名。
master1# nisserver -r -d doc.com.
This script sets up this machine “master1” as a NIS+ root master
server for domain doc.com.
Domain name : doc.com.
NIS+ group : admin.doc.com.
NIS (YP) compatibility : OFF
Security level : 2=DES
Is this information correct? (type ’y’ to accept, ’n’ to change)
(4)如果信息顯示的正確,請鍵入“y”。
Is this information correct? (type ’y’ to accept, ’n’’ to change)
y
This script will set up your machine as a root master server for
domain doc.com. without NIS compatibility at security level 2.
Use "nisclient -r" to restore your current network service environment.
Do you want to continue? (type ‘y’ to continue, ‘n’ to exit the script)
(5)鍵入“y”,繼續(xù)進(jìn)行NIS+設(shè)置。
Do you want to continue? (type ’y’ to continue, ’n’ to exit the script)
y
setting up domain information “doc.com.” ...
setting up switch information ...
running nisinit ...
This machine is in the doc.com. NIS+ domain.
Setting up root server ...
All done.
starting root server at security level 0 to create credentials...
running nissetup ...
(creating standard directories & tables)
org_dir.doc.com. created
Enter login password:
(6)寫入本計(jì)算機(jī)的root用戶的口令。本例子中計(jì)算機(jī)名為“master1”。
Wrote secret key into /etc/.rootkey
setting NIS+ group to admin.doc.com. ...
restarting root server at security level 2 ...
This system is now configured as a root server for domain doc.com.
You can now populate the standard NIS+ tables by using the
nispopulate or /usr/lib/nis/nisaddent commands.
現(xiàn)在,根域的主服務(wù)器已經(jīng)設(shè)置完成了。下面該填充NIS+的標(biāo)準(zhǔn)表格了。
24.2.2 創(chuàng)建表格
在master1服務(wù)器上為Doc.Com.域創(chuàng)建了根域服務(wù)器之后,下一步的工作就是創(chuàng)建NIS+表,為此,需要使用nispopulate命令。
標(biāo)準(zhǔn)的NIS+表格有:auto_master, auto_home, ethers, group, hosts, networks, passwd, protocols, services, rpc, netmasks, bootparams, netgroup和aliases。
在創(chuàng)建NIS+表格之前需要做下面兩件事:
(1)啟動(dòng)根域主服務(wù)器。
# svcadm enable network/rpc/nisplus:default
(2)為了安全起見,將/etc目錄下的網(wǎng)絡(luò)和用戶配置文件都拷貝到另一目錄,然后從這個(gè)目錄進(jìn)行數(shù)據(jù)轉(zhuǎn)換工作。本例中拷貝到/etc/nis+file目錄。
創(chuàng)建NIS+表格的基本步驟如下:
(1)如果從文件中將數(shù)據(jù)移到NIS+表格中,使用下面命令。
master1# nispopulate -F -p /nis+files -d doc.com.
NIS+ domain name : doc.com.
Directory Path : /nis+files
Is this information correct? (type ’y’ to accept, ’n’ to change)
其中-F選項(xiàng)的意思是數(shù)據(jù)來源于文件;-p指明文件位置;-d選項(xiàng)指明NIS+域的名字。還要注意必須以root賬戶執(zhí)行這個(gè)命令。
(2)如果顯示信息正確,請鍵入“y”。
Is this information correct?
(type ’y’ to accept, ’n’ to change)
y
This script will populate the following NIS+ tables for domain doc.com. from
the files in /nis+files: auto_master auto_home ethers group hosts networks
passwd protocols services rpc netmasks bootparams netgroup aliases shadow
**WARNING: Interrupting this script after choosing to continue may leave
the tables only partially populated. This script does not do any automatic
recovery or cleanup.
Do you want to continue? (type ’y’ to continue, ’n’ to exit this script)
(3)如果顯示信息正確,請鍵入“y”。
Do you want to continue? (type ’y’ to continue, ’n’ to exit this script)
y
populating auto_master table from file /nis+files/auto_master
... auto_master table done.
populating auto_home table from file /nis+files/auto_home
... auto_home table done.
Credentials have been added for the entries in the hosts and passwd table(s).
Each entry was given a default network password (also known as a Secure-
RPC password). This password is: nisplus
Use this password when the nisclient script requests the network password.
Done!
請記住Secure-RPC password,在本例中為nisplus,在下面設(shè)置客戶機(jī)的時(shí)候需要用到這個(gè)口令。
現(xiàn)在所有數(shù)據(jù)都被轉(zhuǎn)移過來了。
(4)使用下面命令來檢查這個(gè)域。
master1# nisping -C doc.com.
Checkpointing replicas serving directory doc.com.
Master server is master1.doc.com.
Last update occurred at date
Master server is master1.doc.com.
checkpoint scheduled on master1.doc.com.
這一步說明,文件中的數(shù)據(jù)被轉(zhuǎn)化為表格后,已經(jīng)被域的服務(wù)所支持。
24.2.3 建立客戶機(jī)
因?yàn)楦虻闹鞣⻊?wù)器也是該域的客戶機(jī),所以就沒有必要在主服務(wù)器上建立客戶機(jī)了。我們現(xiàn)在要做的是在另一臺計(jì)算機(jī)上建立客戶機(jī)。
我們同樣使用腳本命令來完成客戶機(jī)的設(shè)置。
(1)如果服務(wù)的加密是使用640位DES,客戶機(jī)也需要是640位DES加密。
#nisauthconf dh640dh-0 des
(2)使用下面命令來初始化客戶機(jī)的設(shè)置。
client1# nisclient -i -d doc.com. -h master1
Initializing client client1 for domain “doc.com.”.
Once initialization is done, you will need to reboot your machine.
Do you want to continue? (type ’y’ to continue, ’n’ to exit this script)
其中,-i選項(xiàng)是初始化設(shè)置客戶機(jī);-d是接NIS+的域名;-h是接NIS+主域服務(wù)器的主機(jī)名。
(3)鍵入“y”后,接著鍵入主域服務(wù)器的IP地址。
Do you want to continue? (type ’y’ to continue, ’n’ to exit this script)
y
Type server master1’s IP address:
(4)鍵入正確的IP地址后按回車鍵。
Type server master1’s IP address: 123.123.123.123
setting up the domain information...
setting up the name service switch information...
At the prompt below, type the network password (also known as the
Secure-RPC password) that you obtained either from your administrator or
from running the nispopulate script.
Please enter the Secure-RPC password for root:
(5)鍵入“Secure-RPC”口令,還記得建立NIS+表格時(shí)設(shè)定為“nisplus”嗎?
(6)接著鍵入本機(jī)的root口令。
Please enter the login password for root:
Wrote secret key into /etc/.rootkey
Your network password has been changed to your login one.
Your network and login passwords are now the same.
Client initialization completed!!
Please reboot your machine for changes to take effect.
(7)最后重新啟動(dòng)客戶機(jī)。
NIS+的客戶機(jī)在名為client1的計(jì)算機(jī)上已經(jīng)建立起來了。下面我們需要在這個(gè)客戶機(jī)上添加一個(gè)用戶。
(1)在client計(jì)算機(jī)上建立一個(gè)普通用戶,以這個(gè)普通用戶登錄到Soalris系統(tǒng)中,運(yùn)行下面命令:
user1prompt% nisclient -u
At the prompt below, type the network password (also known as the
Secure-RPC password) that you obtained either from your administrator
or from running the nispopulate script.
Please enter the Secure-RPC password for user1:
(2)輸入Secure-RPC口令后,就創(chuàng)建了普通的NIS+用戶。
24.2.4 建立服務(wù)器
在創(chuàng)建了根域服務(wù)器之后,我們還希望為每個(gè)子域創(chuàng)建新的主服務(wù)器。比如前面我們介紹的根域Doc.Com.有個(gè)子域Sales.Doc.Com.,那么如何建立Sales.Doc.Com.子域的主服務(wù)器呢?答案是我們必須首先從根域主服務(wù)器來創(chuàng)建客戶機(jī),然后再將它們轉(zhuǎn)為根域的復(fù)制服務(wù)器,隨后將它們修改為子域的非根主服務(wù)器。
下面我們將用實(shí)例來說明,這個(gè)例子將分四個(gè)部分,它們分別是:
建立主服務(wù)器的復(fù)制服務(wù)器;
將復(fù)制服務(wù)器轉(zhuǎn)為子域主服務(wù)器;
為子域主服務(wù)器建立NIS+表格;
建立子域主服務(wù)器的復(fù)制服務(wù)器。
由于上一節(jié)已經(jīng)建立了客戶機(jī),我們就在客戶機(jī)的基礎(chǔ)上進(jìn)行。
第一部分,在客戶機(jī)client1上建立根域主服務(wù)器的復(fù)制服務(wù)器。
(1)首先應(yīng)該在客戶機(jī)client1上啟動(dòng)NIS+服務(wù)。
client1# svcadm enable /network/rpc/nisplus:default
(2)在根域主服務(wù)器上,使用下面命令將client1服務(wù)器變成根域服務(wù)器的復(fù)制服務(wù)器。
master1# nisserver -R -d doc.com. -h client1
This script sets up a NIS+ replica server for domain doc.com.
Domain name: :doc.com.
NIS+ server : :client1
Is this information correct? (type ’y’ to accept, ’n’ to change)
-R 建立復(fù)制服務(wù)器。
-d 指定根域。
-h 復(fù)制服務(wù)器的名字。
(3)鍵入“y”,繼續(xù)。
Is this information correct? (type ’y’ to accept, ’n’ to change)
y
This script will set up machine “client1” as an NIS+ replica server for domain
doc.com. without NIS compatibility. The NIS+ server daemon, rpc.nisd, must
be running on client1 with the proper options to serve this domain.
Do you want to continue? (type ’y’ to continue, ’n’ to exit this script)
(4)鍵入“y”,繼續(xù)。
Is this information correct? (type ’y’ to continue, ’n’ to exit this script)
y
The system client1 is now configured as a replica server for domain doc.com..
The NIS+ server daemon, rpc.nisd, must be running on client1 with the proper
options to serve this domain. ...
通過上面的步驟,就在客戶機(jī)client1上建立根域主服務(wù)器的復(fù)制服務(wù)器。
下面進(jìn)行第二部分,將復(fù)制服務(wù)器轉(zhuǎn)為子域主服務(wù)器。步驟如下:
(1)在根域主服務(wù)器上,使用下面命令將client1服務(wù)器轉(zhuǎn)為Sales.Doc.Com子域的主服務(wù)器。
master1# nisserver -M -d sales.doc.com. -h client1
This script sets up a non-root NIS+ master server for domain sales.doc.com.
Domain name : sales.doc.com.
NIS+ server : client1
NIS+ group : admin.sales.doc.com.
NIS (YP) compatibility : OFF
Security level : 2=DES
Is this information correct? (type ’y’ to accept, ’n’ to change)
(2)鍵入“y”,繼續(xù)。
Is this information correct?
(type ’y’ to accept, ’n’ to change) y
This script sets up machine “client1” as an NIS+ non-root master
server for domain sales.doc.com.
Do you want to continue? (type ’y’ to continue, ’n’ to exit this script)
(3)鍵入“y”,繼續(xù)。
Do you want to continue? (type ’y’ to continue, ’n’to exit this script)
y
running nissetup ...
org_dir.sales.doc.com. created
groups_dir.sales.doc.com. created
...
...
setting NIS+ group admin.sales.doc.com. ...
The system client1 is now configured as a non-root server for
domain sales.doc.com.
You can now populate the standard NIS+ tables by using the
nispopulate or /usr/lib/nis/nisaddent commands.
第三部分,為子域主服務(wù)器建立NIS+表格。
使用下面命令,具體過程請參考24.2.2節(jié)中建立表格的過程。
client1# nispopulate -F -p /nis+files -d sales.doc.com.
第四部分,建立子域主服務(wù)器的復(fù)制服務(wù)器。
使用下面命令,具體過程請參考第一部分建立主域主服務(wù)器的復(fù)制服務(wù)器的過程。
Client1# nisserver -R -d sales.doc.com. -h client2 |
|