您的位置:首页 > 运维架构 > Linux

Centos5.6安装并部署LDAP服务

2011-11-17 15:24 459 查看
LDAP是轻量目录访问协议,英文全称是Lightweight Directory Access Protocol,一般都简称为LDAP。它是基于X.500标准的,但是简单多了并且可以根据需要定制。与X.500不同,LDAP支持TCP/IP,这对访问Internet是必须的。LDAP的核心规范在RFC中都有定义,所有与LDAP相关的RFC都可以在LDAPman RFC网页中找到。简单说来,LDAP是一个得到关于人或者资源的集中、静态数据的快速方式。

1、CentOS上yum方式安装openldap

查看有没下面4个相关的openldap包;

Shell脚本代码

[root@RDCenter125 yzwei]# rpm -qa|grep openldap

openldap-servers-2.3.27-8.el5_2.4

openldap-devel-2.3.27-8.el5_2.4

openldap-clients-2.3.27-8.el5_2.4

openldap-2.3.27-8.el5_2.4

[root@RDCenter125 yzwei]# rpm -qa|grep openldap

openldap-servers-2.3.27-8.el5_2.4

openldap-devel-2.3.27-8.el5_2.4

openldap-clients-2.3.27-8.el5_2.4

openldap-2.3.27-8.el5_2.4

没有的话通过下面命令安装;

Java代码

[root@RDCenter125 yzwei]# yum install openldap openldap-servers openldap-clients openldap-devel

base 100% |=========================| 1.1 kB 00:00

updates 100% |=========================| 951 B 00:00

addons 100% |=========================| 951 B 00:00

extras 100% |=========================| 1.1 kB 00:00

Setting up Install Process

Parsing package install arguments

。。。。。。

[root@RDCenter125 yzwei]#

[root@RDCenter125 yzwei]# yum install openldap openldap-servers openldap-clients openldap-devel

base 100% |=========================| 1.1 kB 00:00

updates 100% |=========================| 951 B 00:00

addons 100% |=========================| 951 B 00:00

extras 100% |=========================| 1.1 kB 00:00

Setting up Install Process

Parsing package install arguments

。。。。。。

[root@RDCenter125 yzwei]#

yum命令一个好处就是解决了大部分的包依赖关联,不用自己去安装,比如openldap默认存储的数据放在bdb中,这些包我们不用关心就帮我们安装好啦!yum方式安装的openldap命令在”/usr/bin”,”/usr/sbin”目录下,

如:

/usr/bin/ldapsearch

/usr/bin/ldapadd

/usr/sbin/slapadd

/usr/sbin/slapdel

2、ldap配置

修改slapd.conf配置文件, 主要修改部分如下;

配置脚本代码

database bdb

suffix “dc=chinahcn,dc=com” #修改domain信息

rootdn “cn=Manager,dc=chinahcn,dc=com” #修改domain信息

# Cleartext passwords, especially for the rootdn, should

# be avoided. See slappasswd(8) and slapd.conf(5) for details.

# Use of strong authentication encouraged.

# rootpw secret

# rootpw {crypt}ijFYNcSNctBYg

rootpw secret #打开密码保护

建立ldap到bdb的连接,并启动ldap;

Shell脚本代码

[root@RDCenter125 yzwei]# cp /etc/openldap/DB_CONFIG.example /var/lib/ldap/DB_CONFIG

[root@RDCenter125 yzwei]#

[root@RDCenter125 yzwei]# service ldap start

Checking configuration files for slapd: config file testing succeeded

[ OK ]

Starting slapd: [ OK ]

[root@RDCenter125 yzwei]# cp /etc/openldap/DB_CONFIG.example /var/lib/ldap/DB_CONFIG

[root@RDCenter125 yzwei]#

[root@RDCenter125 yzwei]# service ldap start

Checking configuration files for slapd: config file testing succeeded

[ OK ]

Starting slapd: [ OK ]

3、ldap数据导入

先停掉ldap服务,然后导入用户数据(数据在附件压缩包中).

Shell脚本代码

[root@RDCenter125 data]# service ldap stop

……

[root@RDCenter125 data]# slapadd -v -l root-unit.ldif

……

[root@RDCenter125 data]# slapadd -v -l users.ldif

……

[root@RDCenter125 data]# service ldap stop

……

[root@RDCenter125 data]# slapadd -v -l root-unit.ldif

……

[root@RDCenter125 data]# slapadd -v -l users.ldif

……

ldap的数据默认放在”/var/lib/ldap”目录下,通过root账户运行slapadd命令添加的数据产生的文件属性属于root用户root组,但是service启动ldap是用ldap用户启动的,所以需要把这些文件的属性修改一下。下面这句脚本代码非常重要,否则数据只能读不能修改删除,血的教训。

Shell脚本代码

[root@RDCenter125 data]# chown -R ldap.ldap /var/lib/ldap/

[root@RDCenter125 data]# service ldap start

……

[root@RDCenter125 data]# chown -R ldap.ldap /var/lib/ldap/

[root@RDCenter125 data]# service ldap start

……

至此服务器端ldap完成,服务器端占用的端口默认是389。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: