ldap 中的主从以提供者和消费者的名称命名。您没有指定您使用的是什么 ldap 服务器,所以我认为我们在谈论 openLDAP。
在旧的 openLDAP 配置中保存在 conf 文件中。如今,所有设置都存储在 ldap 服务器本身中。因此,您需要创建配置并将其注入 ldap 服务器,以便我们从创建这些文件开始。此指令将自动将所有条目复制到您的从服务器。
假设您的公司名称是 acme,域名是 com。并且您当前的 ldap 服务器管理员位于:cn=admin,dc=acme,dc=com
首先,我们需要创建一个 ldap 用户,该用户可以读取所有 ldap 条目以将其复制到消费者服务器。
创建文件“create_repl_user.ldif”
dn: cn=ldaps2,dc=acme,dc=com
objectClass: simpleSecurityObject
objectClass: organizationalRole
cn: ldaps2
description: LDAP server2 replicator
Run Code Online (Sandbox Code Playgroud)
其次,我们需要在主 ldap 服务器中启用提供者服务,并授予用户 ldaps2 对整个 ldap 服务器的读取访问权限。
创建文件“enable_sync_prov.ldif”
dn: olcDatabase={1}hdb,cn=config
changetype: modify
delete: olcAccess
olcAccess: {0}to attrs=userPassword,shadowLastChange
by self write
by anonymous auth
by dn="cn=admin,dc=acme,dc=com write
by * none
-
add: olcAccess
olcAccess: {0}to attrs=userPassword,shadowLastChange
by self write
by dn="cn=admin,dc=acme,dc=com" write
by dn="cn=ldaps2,dc=acme,dc=com" read
by anonymous auth
by * none
-
add: olcDbIndex
olcDbIndex: entryUUID eq
-
add: olcDbIndex
olcDbIndex: entryCSN eq
dn: cn=module{0},cn=config
changetype: modify
add: olcModuleLoad
olcModuleLoad: {1}syncprov
dn: olcOverlay=syncprov,olcDatabase={1}hdb,cn=config
changetype: add
objectClass: olcOverlayConfig
objectClass: olcSyncProvConfig
olcOverlay: {0}syncprov
olcSpCheckpoint: 100 10
olcSpSessionlog: 100
Run Code Online (Sandbox Code Playgroud)
第三:我们需要启用从指定服务器复制到我们的 ldap 使用者。创建文件 enable_sync_consumer.ldif 用您的主 ldap 服务器的 IP 替换行 provider="ldap://yourldapservername.com:389/" 。和 credentials=yourencryptedldap2spassword ,使用您为 ldap2s 用户决定的密码。
dn: cn=config
changetype: modify
replace: olcLogLevel
olcLogLevel: stats
dn: olcDatabase={1}hdb,cn=config
changetype: modify
delete: olcAccess
olcAccess: {0}to attrs=userPassword,shadowLastChange
by self write
by anonymous auth
by dn="cn=admin,dc=acme,dc=com" write
by * none
-
add: olcAccess
olcAccess: {0}to attrs=userPassword,shadowLastChange
by anonymous auth
by * none
-
delete: olcAccess
olcAccess: {2}to *
by self write
by dn="cn=admin,dc=acme,dc=com" write
by * read
-
add: olcAccess
olcAccess: {2}to *
by * read
-
replace: olcRootDN
olcRootDN: cn=manager
-
delete: olcRootPW
-
add: olcDbIndex
olcDbIndex: entryCSN eq
-
add: olcDbIndex
olcDbIndex: entryUUID eq
-
add: olcDbIndex
olcDbIndex: uid eq
-
add: olcDbIndex
olcDbIndex: cn eq
-
add: olcDbIndex
olcDbIndex: ou eq
-
add: olcDbIndex
olcDbIndex: dc eq
add: olcSyncrepl
olcSyncrepl: rid=123
provider="ldap://yourldapservername.com:389/"
type=refreshAndPersist
retry="60 30 300 +"
searchbase="dc=acme,dc=com"
bindmethod=simple
binddn="cn=ldaps2,dc=acme,dc=com"
credentials=yourencryptedldap2spassword
Run Code Online (Sandbox Code Playgroud)
现在我们已经创建了配置文件,我们需要将它们注入提供者和消费者服务器
在提供者服务器中创建复制用户:
run ldapadd -x -W -D cn=admin,dc=acme,dc=com -f create_repl_user.ldif
Run Code Online (Sandbox Code Playgroud)
启用提供者服务:
run ldapadd -x -W -D cn=admin,dc=acme,dc=com -f enable_sync_prov.ldif
Run Code Online (Sandbox Code Playgroud)
在消费者服务器中添加消费者同步设置:
run ldapadd -x -W -D cn=admin,dc=acme,dc=com -f enable_sync_consumer.ldif
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
34631 次 |
| 最近记录: |