Chinaunix首页 | 论坛 | 博客
  • 博客访问: 732279
  • 博文数量: 741
  • 博客积分: 6000
  • 博客等级: 准将
  • 技术积分: 4825
  • 用 户 组: 普通用户
  • 注册时间: 2008-09-18 11:18
文章分类

全部博文(741)

文章存档

2011年(1)

2008年(740)

我的朋友

分类:

2008-09-18 11:27:15

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.

这一步说明,文件中的数据被转化为表格后,已经被域的服务所支持。      
--------------------next---------------------
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+用户。      
--------------------next---------------------
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      
--------------------next---------------------
24.3 NIS+的命令介绍   
在配置了NIS+的各种服务器和主要表之后,接下来看一下如何利用NIS+来实现域的主机和资源的有效管理。本节将介绍一些常用的NIS+命令,它们是用于本地客户机系统NIS+设置显示的nisdefault命令;用于NIS+对象的访问权限设置的nischmod;用于对象查找和查询的nisls命令;用于NIS+表格内容显示、查看NIS+对象的细节的niscat命令。

24.3.1 nisdefaults命令
nisdefaults命令可以用来显示本地系统的当前设置及活动用户状态。该命令通常用于故障分析。下面就是nisdefaults命令的输出:

master% nisdefaults

Principal Name : topadmin.doc.com.

Domain Name : doc.com.

Host Name : rootmaster.doc.com.

Group Name : salesboss

Access Rights : ----rmcdr---r---

Time to live : 12:00:00:00:00

Search Path : doc.com

下面对输出进行解释:

 主用户是topadmin,属于NIS+域doc.com。

 基本域名为doc.com。

 本地系统的主机名为rootmaster.doc.com。

 用户topadmin的基本用户组为salesboss。

 生存期设置为12小时。

 搜索路径是doc.com。

 访问权限是所有者有rmcd(读、修改、创设、删除)的权限;组和所有认证用户有r(读)的权限。

24.3.2 nischmod命令
大家已经通过前面的介绍知道了NIS+命名空间的访问权限和NIS+委托者有四种授权类别,它们分别是rmcd和nogw。下面我们将通过一些例子来说明如何通过这些操作服和操作参数的组合来构成访问权限的字符串。

下面的命令将删除所有非认证用户(n)对于passwd表的修改(m)和创建(c)权限:

master1#nischmod n-cm passwd..org_dir

即使是非认证用户也需要有对passwd表的读权限,以便进行认证。为此,可以通过如下的命令来进行授权:

master1#nischmod n+r passwd.org_dir

为了将某个表的修改和创建的访问权限同时赋给当前用户(本例中为root)及其基本用户组,可以使用下面命令:

master1#nischmod og_cm passwd.org_dir

NIS+的访问权限字符串虽然容易记忆,但是,当我们需要同时对不同用户进行添加和删除某些权限的操作时,要想将它们同时组合到一个命令中就比较困难了,这与Solaris文件系统采用八进制代码来指定文件的绝对访问权限的情况有些不同。但我们也可以通过逗号将每个权限字符串隔开,从而构成一种组合权限字符串。下面的这个命令就采用了这种复杂的权限字符串,它在说明了这种权限字符串的组合方式的同时表明了这种权限字符串的含义解释是具有挑战性的:

maser1#nischmod o=rmcd,g=rmc,w=rm,n=r hosts.org_dir

该命令将下列权限分别赋予了四种不同的用户:

 所有者读、修改、创建和删除。

 用户组读和修改。

 world读和修改。

 nobody只读。

24.3.3 nisls命令
nisls命令是一种查找和查询命令,它可以提供对NIS+目录的查看功能。例如,为了查看所有用本地命名空间创建的NIS+目录,可以使用如下nisls命令:

master# nisls

doc.com.:

org_dir

groups_dir

还可以接着查看org_dir目录的内容,org_dir目录里有命名空间所建立的所有表:

master#nisls org_dir

org_dir.doc.com.:

auto_home

auto_master

bootparams

client_info

cred

ethers

group

hosts

mail_aliases

netgroup

netmasks

passwd

protocols

rpc

sendmailvars

services

timezone

在group目录中,除了包含一个我们早先创建的admin组(它包括所有管理员的列表)外,还有当前域中一些特殊的用户组,它们是依据特定的组织结构创建的:

master#nisls group_dir

group_dir.doc.com.:

admin

adverts

legal

media      
--------------------next---------------------
24.3.4 niscat命令
niscat命令可以用来获取域中对象的内容,主要包含在NIS+表中的数据。例如,我们可以利用如下的命令来列出域中的所有主机:

master#niscat –h hosts.org_dir

client1.doc.com client1 192.168.3.4

client2.doc.com client2 192.168.9.9

另外,也可以利用niscat命令来检查passwd表的内容:

master#niscat passwd.org_dir

root:uop5Jji7N1T56:0:1:Super-User:/:/bin/csh:9841::::::

daemon:NP:1:1::/::6445::::::

bin:NP:2:2::/usr/bin::6445::::::

listen:*LK*:37:4:Network Admin:/usr/net/nls::::::::

nobody:NP:60001:60001:Nobody:/::6445::::::

noaccess:NP:60002:60002:No Access User:/::6445::::::

guest:NP:14:300:Guest:/hd2/guest:/bin/csh:10658::::::

syscd:qkPu7IcquHRRY:120:10::/usr/syscd:/bin/csh:::::::

peifyAkTGOg/2TCY:819:800ei Fei:/home/peif:/bin/csh:10491::::::

接下来,可以通过再次使用niscat命令来查看这些用户都属于哪些组:

master#niscat group.org_dir

root::0:root

staff::1:client1,client2

bin::2:root,bin,daemon

sys:*:3:root,bin,sys,adm

adm::4:root,adm,daemon

uucp::5:root,uucp

mail::6:root

所有构成本地域的主机都可以根据它们的以太网地址来进行查看。这些查看数据是从ethers表中提取的,它们的显示结果如下所示:

master#niscat ethers.org_dir

1:4a:16:2f:13:b2 client1.doc.com

2f:13:b2:1:02:1e client2.doc.com

域中所定义的所有其他表都可以用niscat命令来查看。这里我们不再一一列举。      
--------------------next---------------------

阅读(198) | 评论(0) | 转发(0) |
0

上一篇:15

下一篇:欢迎阅读我的文章

给主人留下些什么吧!~~