在OpenLDAP 2.6.4版本中,要实现主从同步并使用SSL双向认证,可以按照以下步骤操作:

  1. 在主服务和从服务上都安装OpenLDAP软件,并将主服务配置为主服务器,从服务配置为从服务器。

  2. 在主服务器上创建SSL证书和私钥,并将它们复制到从服务器上。

  3. 在主服务器的slapd.conf文件中添加以下配置:

TLSCACertificateFile /path/to/ca-certificate-file
TLSCertificateFile /path/to/server-certificate-file
TLSCertificateKeyFile /path/to/server-private-key-file
TLSCipherSuite HIGH:MEDIUM:-SSLv2:-SSLv3:-TLSv1:-TLSv1.1:+TLSv1.2

其中,TLSCACertificateFile是CA证书,TLSCertificateFile是服务器证书,TLSCertificateKeyFile是服务器私钥,TLSCipherSuite是SSL密码套件。

  1. 在从服务器的slapd.conf文件中添加以下配置:
syncrepl rid=001
    provider=ldap://master.example.com:389
    type=refreshAndPersist
    retry="60 10 300 3"
    searchbase="dc=example,dc=com"
    bindmethod=simple
    binddn="cn=replicator,dc=example,dc=com"
    credentials="password"
    attrs="*,+"
    schemachecking=on
    network-timeout=10
    timeout=5
    starttls=critical
    tls_reqcert=demand
    tls_cacertfile=/path/to/ca-certificate-file
    tls_certfile=/path/to/server-certificate-file
    tls_keyfile=/path/to/server-private-key-file
    tls_cipher_suite=HIGH:MEDIUM:-SSLv2:-SSLv3:-TLSv1:-TLSv1.1:+TLSv1.2

其中,syncrepl是同步复制的配置,provider是主服务器的地址和端口号,type是同步模式,retry是重试策略,searchbase是搜索根目录,binddn和credentials是用于绑定主服务器的用户名和密码,attrs是要同步的属性,schemachecking是启用模式检查,network-timeout和timeout是网络超时和超时时间,starttls是要求使用SSL/TLS连接,tls_reqcert是要求检查对方证书,tls_cacertfile是CA证书,tls_certfile是服务器证书,tls_keyfile是服务器私钥,tls_cipher_suite是SSL密码套件。

  1. 在主服务器上启用同步复制:
ldapadd -x -D "cn=config" -w password -f syncprov.ldif
ldapadd -x -D "cn=config" -w password -f accesslog.ldif
  1. 在从服务器上启用同步复制:
ldapadd -x -D "cn=config" -w password -f syncprov.ldif
ldapadd -x -D "cn=config" -w password -f accesslog.ldif
  1. 在主服务器上创建同步用户:
dn: cn=replicator,dc=example,dc=com
objectClass: simpleSecurityObject
objectClass: organizationalRole
cn: replicator
userPassword: {SSHA}password

其中,cn是用户名,userPassword是加密后的密码。

  1. 在从服务器上测试同步:
ldapsearch -x -D "cn=replicator,dc=example,dc=com" -w password -b "dc=example,dc=com" -s sub "(objectClass=*)"

如果一切正常,就可以在主服务器上添加、修改或删除条目,然后在从服务器上查看同步是否成功。

openldap 264版本在主服务开启SSL双向认证认证的情况下怎么实现主从同步

原文地址: https://www.cveoy.top/t/topic/MOB 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录