Ldap高效数据同步- MirrorMode双主复制模式配置详解(下)
#作者:朱雷
上篇:《Ldap高效数据同步- MirrorMode双主复制模式配置详解(上)》
链接: link
文章目录
- 三、配置Mirror复制类型
- 3.3. 在ldap-0上增加test2用户
- 3.4. 在ldap-1上查看
- 3.5. 在ldap-1上增加test4用户
- 3.7. 最终两台LDAP数据情况
- 四、总结
三、配置Mirror复制类型
3.3. 在ldap-0上增加test2用户
[root@ldap-0 openldap]# cat test2_user.ldif
#dn: ou=oa,dc=zltest,dc=com
#ou: oa
#objectclass: organizationalUnit
dn: cn=test2,ou=oa,dc=zltest,dc=com
ou: oa
cn: test2
sn: test2
mail: test2@zltest.com
objectclass: inetOrgPerson
objectclass: organizationalPerson
userPassword:: e1NTSEF9eTZZVktFUmMraG0vcFZYTkVVbzBFcDJyZlQ0MWxUM1g=[root@ldap-0 openldap]# ldapadd -x -D 'cn=admin,dc=zltest,dc=com' -W -f test2_user.ldif
Enter LDAP Password:
adding new entry "cn=test2,ou=oa,dc=zltest,dc=com"
3.4. 在ldap-1上查看
[root@ldap-1 openldap]# ldapsearch -x -b 'dc=zltest,dc=com' '(cn=test2)'
# extended LDIF
#
# LDAPv3
# base <dc=zltest,dc=com> with scope subtree
# filter: (cn=test2)
# requesting: ALL
## test2, oa, zltest.com
dn: cn=test2,ou=oa,dc=zltest,dc=com
ou: oa
cn: test2
sn: test2
mail: test2@zltest.com
objectClass: inetOrgPerson
objectClass: organizationalPerson
userPassword:: e1NTSEF9eTZZVktFUmMraG0vcFZYTkVVbzBFcDJyZlQ0MWxUM1g=# search result
search: 2
result: 0 Success# numResponses: 2
# numEntries: 1
3.5. 在ldap-1上增加test4用户
[root@ldap-1 openldap]# ldapadd -x -D 'cn=admin,dc=zltest,dc=com' -W -f test4_user.ldif
Enter LDAP Password:
adding new entry "cn=test4,ou=oa,dc=zltest,dc=com"
3.6. 在ldap-0上查看用户同步
[root@ldap-0 openldap]# ldapsearch -x -b 'dc=zltest,dc=com' '(cn=test4)'
# extended LDIF
#
# LDAPv3
# base <dc=zltest,dc=com> with scope subtree
# filter: (cn=test4)
# requesting: ALL
## test4, oa, zltest.com
dn: cn=test4,ou=oa,dc=zltest,dc=com
ou: oa
cn: test4
sn: test4
mail: test4@zltest.com
objectClass: inetOrgPerson
objectClass: organizationalPerson
userPassword:: e1NTSEF9eTZZVktFUmMraG0vcFZYTkVVbzBFcDJyZlQ0MWxUM1g=# search result
search: 2
result: 0 Success# numResponses: 2
# numEntries: 1
3.7. 最终两台LDAP数据情况
可以看到数据是保持一致的。
四、总结
MirrorMode双主同步复制机制可以实现两端服务器同时实现读写,且数据会相互同步最终保持一致性。同时还提供高可用性,在MirrorMode模式下两台服务器互为主备模式对外同时提供服务,前端使用负载均衡器(如: HAProxy、Nginx等)将请求定位到双主的任一台服务器。
本文从MirrorMode的原理介绍,到具体的安装部署,再到实际的数据操作验证,最终实现了MirrorMode模式的功能,读者可以按照本文操作步骤独自配置执行并实现和本文一致的结果。