- 论坛徽章:
- 0
|
24.2 NIS+的设置
设置NIS+服务有两种方法:一种是使用脚本来设置NIS+服务;另一种就是直接使用NIS+命令来设置。脚本也是用一些NIS+命令写成的,它定制了典型的几种NIS+服务的设置方法。由于使用NIS+命令比较复杂,使用脚本方法设置NIS+服务是一种明智的做法。不过,在定制服务方面,还需要直接使用命令来做。本书限于篇幅,只介绍脚本的方法,对需要定制服务的读者,可到docs.sun.com网站查找相关资料。
在本节中,我们将进行一个NIS+服务的完整配置。在这个过程中,将讨论主服务器的建立、NIS+表的创建、客户机和服务器的配置,以及其他域的设置。
24.2.1 建立一个根域服务器
创建NIS+命名空间的第一步是为新的域创建一个根域的主服务器。比如我们要建立一个根域为Doc.Com.的根域服务器。可以进行下列步骤:
(1)在超级用户的环境变量中设置PATH时加入/usr/lib/nis目录。
(2)(这步是可选的)默认系统使用192位DES算法来加密,现在使用下面的命令可以改为640位DES加密:
nisauthconf dh640-0 des
(3)下面这个命令是超级用户设置主服务器用的,-r选项是指根服务器将被选定,-d选项是指定域名。
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”,继续进行NIS+设置。
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)写入本计算机的root用户的口令。本例子中计算机名为“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.
现在,根域的主服务器已经设置完成了。下面该填充NIS+的标准表格了。
24.2.2 创建表格
在master1服务器上为Doc.Com.域创建了根域服务器之后,下一步的工作就是创建NIS+表,为此,需要使用nispopulate命令。
标准的NIS+表格有:auto_master, auto_home, ethers, group, hosts, networks, passwd, protocols, services, rpc, netmasks, bootparams, netgroup和aliases。
在创建NIS+表格之前需要做下面两件事:
(1)启动根域主服务器。
# svcadm enable network/rpc/nisplus:default
(2)为了安全起见,将/etc目录下的网络和用户配置文件都拷贝到另一目录,然后从这个目录进行数据转换工作。本例中拷贝到/etc/nis+file目录。
创建NIS+表格的基本步骤如下:
(1)如果从文件中将数据移到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选项的意思是数据来源于文件;-p指明文件位置;-d选项指明NIS+域的名字。还要注意必须以root账户执行这个命令。
(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,在下面设置客户机的时候需要用到这个口令。
现在所有数据都被转移过来了。
(4)使用下面命令来检查这个域。
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.
这一步说明,文件中的数据被转化为表格后,已经被域的服务所支持。
24.2.3 建立客户机
因为根域的主服务器也是该域的客户机,所以就没有必要在主服务器上建立客户机了。我们现在要做的是在另一台计算机上建立客户机。
我们同样使用脚本命令来完成客户机的设置。
(1)如果服务的加密是使用640位DES,客户机也需要是640位DES加密。
#nisauthconf dh640dh-0 des
(2)使用下面命令来初始化客户机的设置。
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选项是初始化设置客户机;-d是接NIS+的域名;-h是接NIS+主域服务器的主机名。
(3)键入“y”后,接着键入主域服务器的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+表格时设定为“nisplus”吗?
(6)接着键入本机的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)最后重新启动客户机。
NIS+的客户机在名为client1的计算机上已经建立起来了。下面我们需要在这个客户机上添加一个用户。
(1)在client计算机上建立一个普通用户,以这个普通用户登录到Soalris系统中,运行下面命令:
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口令后,就创建了普通的NIS+用户。
24.2.4 建立服务器
在创建了根域服务器之后,我们还希望为每个子域创建新的主服务器。比如前面我们介绍的根域Doc.Com.有个子域Sales.Doc.Com.,那么如何建立Sales.Doc.Com.子域的主服务器呢?答案是我们必须首先从根域主服务器来创建客户机,然后再将它们转为根域的复制服务器,随后将它们修改为子域的非根主服务器。
下面我们将用实例来说明,这个例子将分四个部分,它们分别是:
建立主服务器的复制服务器;
将复制服务器转为子域主服务器;
为子域主服务器建立NIS+表格;
建立子域主服务器的复制服务器。
由于上一节已经建立了客户机,我们就在客户机的基础上进行。
第一部分,在客户机client1上建立根域主服务器的复制服务器。
(1)首先应该在客户机client1上启动NIS+服务。
client1# svcadm enable /network/rpc/nisplus:default
(2)在根域主服务器上,使用下面命令将client1服务器变成根域服务器的复制服务器。
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 建立复制服务器。
-d 指定根域。
-h 复制服务器的名字。
(3)键入“y”,继续。
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”,继续。
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. ...
通过上面的步骤,就在客户机client1上建立根域主服务器的复制服务器。
下面进行第二部分,将复制服务器转为子域主服务器。步骤如下:
(1)在根域主服务器上,使用下面命令将client1服务器转为Sales.Doc.Com子域的主服务器。
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”,继续。
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”,继续。
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.
第三部分,为子域主服务器建立NIS+表格。
使用下面命令,具体过程请参考24.2.2节中建立表格的过程。
client1# nispopulate -F -p /nis+files -d sales.doc.com.
第四部分,建立子域主服务器的复制服务器。
使用下面命令,具体过程请参考第一部分建立主域主服务器的复制服务器的过程。
Client1# nisserver -R -d sales.doc.com. -h client2 |
|