Chinaunix首页 | 论坛 | 博客
  • 博客访问: 487782
  • 博文数量: 82
  • 博客积分: 3003
  • 博客等级: 中校
  • 技术积分: 1285
  • 用 户 组: 普通用户
  • 注册时间: 2007-09-11 15:27
文章分类

全部博文(82)

文章存档

2011年(1)

2010年(5)

2009年(63)

2008年(13)

我的朋友

分类: LINUX

2010-01-03 21:46:43

Red Hat Directory Server配置

Author: Jaylin Zhou


配置yum源:

RHEL5u4ISORHDSISO里的RPM包拷贝到/media/REPO目录下,并执行下面命令,# createrepo /media

# vi /etc/yum.repos.d/jaylin.repo

[rhds]

name=rhds

baseurl=file:///media

enable=1

gpgcheck=0


安装RHDS相关的包:

# yum install *redhat-ds*

redhat-ds i386 8.0.0-1.4.el5dsrv rhds 3.3 k

redhat-ds-admin i386 8.0.0-4.el5dsrv rhds 353 k

redhat-ds-base i386 8.0.0-12.el5dsrv rhds 1.6 M

redhat-ds-base-devel i386 8.0.0-12.el5dsrv rhds 23 k

redhat-ds-console noarch 8.0.0-11.el5dsrv rhds 1.4 M

Installing for dependencies:

adminutil i386 1.1.5-1.el5dsrv rhds 66 k

cyrus-sasl-gssapi i386 2.1.22-5.el5 rhds 28 k

cyrus-sasl-md5 i386 2.1.22-5.el5 rhds 45 k

idm-console-framework noarch 1.1.0-7.el5idm rhds 1.0 M

jss i386 4.2.4-41.el5idm rhds 648 k

ldapjdk i386 4.18-2jpp.3.el5 rhds 783 k

libicu i386 3.6-5.11.4 rhds 5.2 M

lm_sensors i386 2.10.7-4.el5 rhds 513 k

mod_nss i386 1.0.3-8.el5 rhds 81 k

mozldap-tools i386 6.0.5-1.el5 rhds 139 k

perl-Mozilla-LDAP i386 1.5.2-4.el5 rhds 180 k

redhat-admin-console noarch 8.0.0-11.el5dsrv rhds 233 k

redhat-idm-console i386 1.0.0-16.el5idm rhds 73 k


# rpm -ivh java-1.5.0-ibm-1.5.0.8-1jpp.2.el4.i386.rpm

提供DS图形配置环境。


安装openldapopenldap-serversopenldap-clients包。


下面开始正式配置DS

我的hostnameserver.jaylin.com

[root@server ~]# setup-ds-admin.pl


==============================================================================

This program will set up the Red Hat Directory and Administration Servers.


It is recommended that you have "root" privilege to set up the software.

Tips for using this program:

- Press "Enter" to choose the default and go to the next screen

- Type "Control-B" then "Enter" to go back to the previous screen

- Type "Control-C" to cancel the setup program


Would you like to continue with set up? [yes]: yes


==============================================================================

BY SETTING UP AND USING THIS SOFTWARE YOU ARE CONSENTING TO BE BOUND BY

AND ARE BECOMING A PARTY TO THE AGREEMENT FOUND IN THE

LICENSE.TXT FILE. IF YOU DO NOT AGREE TO ALL OF THE TERMS

OF THIS AGREEMENT, PLEASE DO NOT SET UP OR USE THIS SOFTWARE.


Do you agree to the license terms? [no]: yes


==============================================================================

Your system has been scanned for potential problems, missing patches,

etc. The following output is a report of the items found that need to

be addressed before running this software in a production

environment.


Red Hat Directory Server system tuning analysis version 10-AUGUST-2007.


NOTICE : System is i686-unknown-linux2.6.18-164.el5 (1 processor).


ERROR : Only 122MB of physical memory is available on the system. 256MB is the

recommended minimum. 1024MB is recommended for best performance on large production system.


NOTICE : The net.ipv4.tcp_keepalive_time is set to 7200000 milliseconds

(120 minutes). This may cause temporary server congestion from lost

client connections.


WARNING: There are only 1024 file descriptors (hard limit) available, which

limit the number of simultaneous connections.


WARNING: There are only 1024 file descriptors (soft limit) available, which

limit the number of simultaneous connections.


ERROR : The above errors MUST be corrected before proceeding.


Would you like to continue? [no]: yes


==============================================================================

Choose a setup type:


1. Express

Allows you to quickly set up the servers using the most

common options and pre-defined defaults. Useful for quick

evaluation of the products.


2. Typical

Allows you to specify common defaults and options.


3. Custom

Allows you to specify more advanced options. This is

recommended for experienced server administrators only.


To accept the default shown in brackets, press the Enter key.


Choose a setup type [2]: 2


==============================================================================

Enter the fully qualified domain name of the computer

on which you're setting up server software. Using the form

.

Example: eros.example.com.


To accept the default shown in brackets, press the Enter key.


Computer name [server.jaylin.com]: server.jaylin.com


==============================================================================

The servers must run as a specific user in a specific group.

It is strongly recommended that this user should have no privileges

on the computer (i.e. a non-root user). The setup procedure

will give this user/group some permissions in specific paths/files

to perform server-specific operations.


If you have not yet created a user and group for the servers,

create this user and group using your native operating

system utilities.


System User [nobody]: nobody

System Group [nobody]: nobody

==============================================================================

Server information is stored in the configuration directory server.

This information is used by the console and administration server to

configure and manage your servers. If you have already set up a

configuration directory server, you should register any servers you

set up or create with the configuration server. To do so, the

following information about the configuration server is required: the

fully qualified host name of the form

.(e.g. hostname.example.com), the port number

(default 389), the suffix, the DN and password of a user having

permission to write the configuration information, usually the

configuration directory administrator, and if you are using security

(TLS/SSL). If you are using TLS/SSL, specify the TLS/SSL (LDAPS) port

number (default 636) instead of the regular LDAP port number, and

provide the CA certificate (in PEM/ASCII format).


If you do not yet have a configuration directory server, enter 'No' to

be prompted to set up one.


Do you want to register this software with an existing

configuration directory server? [no]: no


==============================================================================

Please enter the administrator ID for the configuration directory

server. This is the ID typically used to log in to the console. You

will also be prompted for the password.


Configuration directory server

administrator ID [admin]: admin

Password: redhat

Password (confirm): redhat


==============================================================================

The information stored in the configuration directory server can be

separated into different Administration Domains. If you are managing

multiple software releases at the same time, or managing information

about multiple domains, you may use the Administration Domain to keep

them separate.


If you are not using administrative domains, press Enter to select the

default. Otherwise, enter some descriptive, unique name for the

administration domain, such as the name of the organization

responsible for managing the domain.


Administration Domain [jaylin.com]: jaylin.com


==============================================================================

The standard directory server network port number is 389. However, if

you are not logged as the superuser, or port 389 is in use, the

default value will be a random unused port number greater than 1024.

If you want to use port 389, make sure that you are logged in as the

superuser, that port 389 is not in use.


Directory server network port [389]: 389


==============================================================================

Each instance of a directory server requires a unique identifier.

This identifier is used to name the various

instance specific files and directories in the file system,

as well as for other uses as a server instance identifier.


Directory server identifier [server]: server


==============================================================================

The suffix is the root of your directory tree. The suffix must be a valid DN.

It is recommended that you use the dc=domaincomponent suffix convention.

For example, if your domain is example.com,

you should use dc=example,dc=com for your suffix.

Setup will create this initial suffix for you,

but you may have more than one suffix.

Use the directory server utilities to create additional suffixes.


Suffix [dc=jaylin, dc=com]: dc=jaylin, dc=com


==============================================================================

Certain directory server operations require an administrative user.

This user is referred to as the Directory Manager and typically has a

bind Distinguished Name (DN) of cn=Directory Manager.

You will also be prompted for the password for this user. The password must

be at least 8 characters long, and contain no spaces.


Directory Manager DN [cn=Directory Manager]: cn=”Directory Manager”

Password: 12345678

Password (confirm): 12345678


==============================================================================

The Administration Server is separate from any of your web or application

servers since it listens to a different port and access to it is

restricted.


Pick a port number between 1024 and 65535 to run your Administration

Server on. You should NOT use a port number which you plan to

run a web or application server on, rather, select a number which you

will remember and which will not be used for anything else.


Administration port [9830]: 9830

==============================================================================

The interactive phase is complete. The script will now set up your

servers. Enter No or go Back if you want to change something.


Are you ready to set up your servers? [yes]: yes

Creating directory server . . .

Your new DS instance 'server' was successfully created.

Creating the configuration directory server . . .

Beginning Admin Server creation . . .

Creating Admin Server files and directories . . .

Updating adm.conf . . .

Updating admpw . . .

Registering admin server with the configuration directory server . . .

Updating adm.conf with information from configuration directory server . . .

Updating the configuration for the httpd engine . . .

Starting admin server . . .

The admin server was successfully started.

Admin server was successfully created, configured, and started.

Exiting . . .

Log file is '/tmp/setuptEkdxi.log'


其中“[]”里和后面输入相同的地方直接回车就可以了。


成功之后会生成/etc/dirsrv/slapd-server/ /var/lib/dirsrv/slapd-server/目录,前者是存放DS配置的,后者是存放数据库的。

其中slapd-xxxxxx是和上面的“Directory server identifier”一致的。


查看下面的两个进程是否正常运行:

[root@server home]# /etc/init.d/dirsrv status

dirsrv server (pid 5478) is running...

[root@server home]# /etc/init.d/dirsrv-admin status

dirsrv-admin (pid 5562) is running...


下面进入图形界面配置:

# redhat-idm-consol





选中”Directory Server”之后点击右上角的”Open”


添加一个用户:

记住”User ID”,这里是jzhou


# setup——>Authentication configuration——>Use LDAP

DN要和开始生成DS时设定的一致,一般是将主机的FQDN中除去主机名之后的每个字段设置为一个dc,多个dc之间用逗号分割。

[root@server ~]# getent passwd | grep jzhou

jzhou:*:1001:1001:jaylin zhou:1001:

或者:

[root@server ~]# ldapsearch -x | grep jzhou

# jzhou, People, jaylin.com

dn: uid=jzhou,ou=People, dc=jaylin, dc=com

uid: jzhou

可以看到刚才添加的用户了。


[root@server ~]# ssh jzhou@localhost

The authenticity of host 'localhost (127.0.0.1)' can't be established.

RSA key fingerprint is ec:7a:b5:71:14:93:1a:7a:4f:e0:01:34:44:33:9a:3b.

Are you sure you want to continue connecting (yes/no)? yes

Warning: Permanently added 'localhost' (RSA) to the list of known hosts.

jzhou@localhost's password:

Permission denied, please try again.

jzhou@localhost's password:

登录不了,这是为什么呢?

原来是setup——>Authentication configuration——>Use LDAP Authentication选项没有选中。

选中后再次验证,

[root@server ~]# ssh jzhou@localhost

jzhou@localhost's password:

Last login: Thu Dec 17 17:28:09 2009 from client.jaylin.com

Could not chdir to home directory 1001: No such file or directory

-sh-3.2$

我们可以发现/etc/passwd文件里根本没有jzhou这个用户,之所以可以验证成功,是因为LDAP验证的。

/etc/nsswitch.conf文件里已经和从前不同了:

passwd: files ldap

shadow: files ldap

group: files ldap



继续实验。进入下面的目录,里面有很多脚本,这些脚本有不同的功能,添加不同的文件到LDAP,使用不同的脚本文件。

[root@server migration]# pwd

/usr/share/openldap/migration

其中migrate_common.ph文件文这些perl脚本的头文件,定义了一些全局的东西,首先修改这个文件里的下面两行:

# Default DNS domain

$DEFAULT_MAIL_DOMAIN = "padl.com";——>“jaylin.com”

# Default base

$DEFAULT_BASE = "dc=padl,dc=com"; ——>“dc=jaylin,dc=com”


[root@server migration]# sh migrate_all_online.sh

Enter the X.500 naming context you wish to import into: [dc=jaylin,dc=com] Enter

Enter the hostname of your LDAP server [ldap]: server

Enter the manager DN: [cn=manager,dc=jaylin,dc=com]: cn="Directory Manager"

Enter the credentials to bind with: 12345678

Do you wish to generate a DUAConfigProfile [yes|no]? yes


Importing into dc=jaylin,dc=com...


Creating naming context entries...

Creating DUAConfigProfile entry...

Migrating groups...

Migrating hosts...

Migrating networks...

Migrating users...

Migrating protocols...

Migrating rpcs...

Migrating services...

Migrating netgroups...

Migrating netgroups (by user)...

sh: /etc/netgroup: No such file or directory

Migrating netgroups (by host)...

sh: /etc/netgroup: No such file or directory

adding new entry "dc=jaylin,dc=com"

ldapadd: Already exists (68)


Importing into LDAP...

adding new entry "ou=Hosts,dc=jaylin,dc=com"


adding new entry "ou=Rpc,dc=jaylin,dc=com"


adding new entry "ou=Services,dc=jaylin,dc=com"

adding new entry "nisMapName=netgroup.byuser,dc=jaylin,dc=com"


adding new entry "ou=Mounts,dc=jaylin,dc=com"


adding new entry "ou=Networks,dc=jaylin,dc=com"


adding new entry "ou=People,dc=jaylin,dc=com"

ldapadd: Already exists (68)


/usr/bin/ldapadd: returned non-zero exit status: saving failed LDIF to /tmp/nis.ldif.BZ7140


[root@server migration]# perl migrate_hosts.pl /etc/hosts > /tmp/hosts.ldif

[root@server migration]# ldapadd -x -f /tmp/hosts.ldif -D cn="Directory Manager" -w 12345678

adding new entry "cn=localhost.localdomain,ou=Hosts,dc=jaylin,dc=com"


adding new entry "cn=localhost6.localdomain6,ou=Hosts,dc=jaylin,dc=com"


adding new entry "cn=server.jaylin.com,ou=Hosts,dc=jaylin,dc=com"


adding new entry "cn=client.jaylin.com,ou=Hosts,dc=jaylin,dc=com"


[root@server migration]# ldapsearch -x | grep Hosts

# Hosts, jaylin.com

dn: ou=Hosts,dc=jaylin,dc=com

ou: Hosts

# localhost.localdomain, Hosts, jaylin.com

dn: cn=localhost.localdomain,ou=Hosts,dc=jaylin,dc=com

# localhost6.localdomain6, Hosts, jaylin.com

dn: cn=localhost6.localdomain6,ou=Hosts,dc=jaylin,dc=com

# server.jaylin.com, Hosts, jaylin.com

dn: cn=server.jaylin.com,ou=Hosts,dc=jaylin,dc=com

# client.jaylin.com, Hosts, jaylin.com

dn: cn=client.jaylin.com,ou=Hosts,dc=jaylin,dc=com

LDAP里已经添加了/etc/hosts文件里的内容。


我们下面做一个实验,

/etc/auto.master里添加一行:

/nfs /etc/auto.master

/etc/auto.nfs里添加一行:

aaa -fstype=nfs 192.168.56.101:/data


[root@server migration]# perl migrate_automount.pl /etc/auto.master > /tmp/master.ldif

[root@server migration]# ldapadd -x -f /tmp/master.ldif -D cn="Directory Manager" -w 12345678

adding new entry "nisMapName=auto.master,dc=jaylin,dc=com"


adding new entry "cn=/misc,nisMapName=auto.master,dc=jaylin,dc=com"


adding new entry "cn=/nfs,nisMapName=auto.master,dc=jaylin,dc=com"


adding new entry "cn=/net,nisMapName=auto.master,dc=jaylin,dc=com"


adding new entry "cn=/net,nisMapName=auto.master,dc=jaylin,dc=com"

ldapadd: Already exists (68)


[root@server migration]# ldapsearch -x | grep nfs

# /nfs, auto.master, jaylin.com

dn: cn=/nfs,nisMapName=auto.master,dc=jaylin,dc=com

cn: /nfs

nisMapEntry: /etc/auto.nfs


[root@server migration]# perl migrate_automount.pl /etc/auto.nfs > /tmp/nfs.ldif

[root@server migration]# ldapadd -x -f /tmp/nfs.ldif -D cn="Directory Manager" -w 12345678

adding new entry "nisMapName=auto.nfs,dc=jaylin,dc=com"


adding new entry "cn=aaa,nisMapName=auto.nfs,dc=jaylin,dc=com"


[root@server migration]# ldapsearch -x | grep aaa

# aaa, auto.nfs, jaylin.com

dn: cn=aaa,nisMapName=auto.nfs,dc=jaylin,dc=com

cn: aaa


修改/etc/nsswitch.conf文件里的下面一行:

automount: ldap ——>删除了ldap前面的files


重启autofs服务。

[root@server migration]# showmount -e 192.168.56.101

Export list for 192.168.56.101:

/data *


[root@server /]# cd /nfs/aaa

[root@server aaa]# mount | grep data

192.168.56.101:/data on /nfs/aaa type nfs (rw,addr=192.168.56.101)


这就说明是使用了LDAP验证的。



客户端配置:

# system-config-authentication

或者


指定ServerDNIP

图形界面配置会做一下几个动作:

1.修改/etc/nsswitch.conf文件,在认证的后面加上ldap

2.修改/etc/pam.d/system-auth文件里下面的一句:

password sufficient pam_ldap.so use_authtok

3./etc/ldap.conf文件里添加下面的内容:

base dc=jaylin,dc=com

uri ldap://192.168.56.102

4.修改/etc/sysconfig/authconfig文件里的

USELDAP=yes




阅读(4494) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~