环境介绍
LDAP Server端:
hostname:pnode11
IPaddr:192.168.56.220
LDAP Client端:
hostname:pnode12
IPaddr: 192.168.56.221
安装LDAP相关的软件包
1、首先配置本地yum源,请参考我的nis服务搭建过程。
2、在server、client端分别安装以下软件包
yum install openldap*
rpm -qa|grep openldap
LDAP server端配置
1、首先cd /etc/openldap目录下执行以下操作:
rm -rf /etc/openldap/slapd.d/*
cp /usr/share/openldap-servers/slapd.conf.obsolete /etc/openldap/slapd.conf
执行完之后可以看到如下文件
certs check_password.conf ldap.conf schema slapd.conf slapd.d
2、创建LDAP管理员密码
[root@pnode11 migrationtools]# slappasswd
New password:
Re-enter new password:
{SSHA}32+hyGI4lJkUzi+cQ+RejqFNVLTBqWMq
输入两次密码之后请保存生成的密文。
3、修改slapd.conf文件
主要修改cn、dc、rootpw的内容,rootpw为上一步生成的密文。
database monitor
access to *
by dn.exact="gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth" read
by dn.exact="cn=Manager,dc=zhilong.com" read
by * none
#######################################################################
# database definitions
#######################################################################
database bdb
suffix "dc=zhilong.com"
checkpoint 1024 15
rootdn "cn=Manager,dc=zhilong.com"
# 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 {SSHA}d2aAB5GOxLnj0d2/F7Tq6gK8vGqsMKFQ
**这里rootpw后面必须是连个Tab隔开,否则后面执行命令会报错!**
4、创建数据库文件
从模板复制产生的数据库文件
cp /usr/share/openldap-servers/DB_CONFIG.example /var/lib/ldap/DB_CONFIG
设置目录权限
chown -R ldap:ldap /etc/openldap
chown -R ldap:ldap /var/lib/ldap
测试配置文件是否正确
[root@pnode11 migrationtools]# slaptest -f /etc/openldap/slapd.conf -F /etc/openldap/slapd.d
config file testing succeeded
5、启动LDAP服务
chown -R ldap:ldap /var/lib/ldap
service slapd start
chkconfig slapd on
启动之后我们会在/var/lib/ldap路径下看到一些数据库文件
[root@pnode11 slapd.d]# ll /var/lib/ldap/
total 11724
-rw-r–r– 1 ldap ldap 4096 Dec 23 16:42 alock
-rw——- 1 ldap ldap 8192 Dec 23 14:35 cn.bdb
-rw——- 1 ldap ldap 24576 Dec 23 16:42 __db.001
-rw——- 1 ldap ldap 9093120 Dec