ldap主从同步

ldap主从同步

一、安装ldap从服务器

安装步骤同ldap主服务器相同

  1. 主从同步配置
  1. Ldap主服务器

导出原用户,格式为ldif,并将其传输到ldap从服务器

# ldapsearch -x -H ldap://127.0.0.1 -b 'dc=taobao,dc=com' > wdd.ldif

# yum -y install openssh-clients

# scp wdd.ldif 192.168.131.140:/root

  1. ldap从服务器

# ldapadd -x -D "cn=admin,dc=taobao,dc=com" -W -f /root/wdd.ldif

  1. 停止ldap主服务器,修改配置文件

# service slapd stop

# vim /etc/openldap/slapd.conf

replica host=192.168.131.140:389

binddn="cn=admin,dc=taobao,dc=com"

bindmethod=simple

credentials=123456 #密码

replogfile /var/lib/ldap/openldap-master-replog

# chown -R ldap:ldap /var/lib/ldap/

  1. 从服务器,修改其配置文件

# vim /etc/openldap/slapd.conf

updatedn "cn=admin,dc=taobao,dc=com"

updateref ldap://192.168.131.138:389 #ldap主服务器地址

# /etc/init.d/slapd restart

  1. 启动ldap主服务器

# /etc/init.d/slapd start

  1. 查看ldap用户
  2. Ldap主服务器操作

#ldapsearch -LLL -x -H ldap://192.168.131.138 -b 'dc=taobao,dc=com'| grep uid=

#ldapsearch -LLL -x -H ldap://192.168.131.140 -b 'dc=taobao,dc=com'| grep uid=

  1. 删除ldapuser1用户

#ldapdelete -x -D "cn=admin,dc=taobao,dc=com" -W "uid=ldapuser1,ou=People,dc=taobao,dc=com"

  1. 再次进行查询ldap主服务器

#ldapsearch -LLL -x -H ldap://192.168.131.138 -b 'dc=taobao,dc=com'| grep uid=

  1. 再次查询ldap从服务器,发现ldapuser1用户也没有了

#ldapsearch -LLL -x -H ldap://192.168.131.140 -b 'dc=taobao,dc=com'| grep uid=

posted @ 2015-11-17 21:18  【风语】  阅读(4634)  评论(0编辑  收藏  举报