Lesson 5 of 9 · 27m
Replication Topologies, Syncrepl, and Convergence
Design provider-consumer replication correctly, monitor contextCSN or replication agreements, and avoid split-brain write architectures.
Replication is where LDAP stops being a database exercise and becomes a distributed systems problem. I have seen two directory nodes both healthy, both responsive, both serving authentication — and diverging for six hours because one firewall rule changed. The service looked fine until a password reset worked in one data center and failed in the other.
Know who can write
The first design decision is write ownership. A classic provider-consumer topology accepts writes only on providers and replicates them to consumers. Multi-provider replication accepts writes in more than one place and therefore accepts conflict resolution complexity. Read-only consumers are operationally boring, which is exactly why they are attractive.
provider-a.example.org ──syncrepl──> consumer-a.example.org
provider-a.example.org ──syncrepl──> consumer-b.example.orgApplications should prefer local read replicas but write through a controlled endpoint. If writes can land anywhere, you are designing conflict handling whether you meant to or not.
OpenLDAP syncrepl is stateful and ordered
A consumer configuration might resemble:
olcSyncRepl:
rid=001
provider=ldaps://ldap-provider.sudosecurity.org
type=refreshAndPersist
retry="60 +"
searchbase="dc=sudosecurity,dc=org"
binddn="uid=replication,ou=services,dc=sudosecurity,dc=org"
credentials="use-a-vault-not-this-file"
starttls=criticalrefreshAndPersist performs an initial refresh and then stays connected for updates. The contextCSN values on each node tell you whether replication is converging:
ldapsearch -x -H ldaps://ldap-consumer.sudosecurity.org -D 'uid=readonly,ou=services,dc=sudosecurity,dc=org' -W -b 'dc=sudosecurity,dc=org' -s base '(objectClass=*)' contextCSNDo not only check that the process is running. A running consumer can be permanently stuck behind an ACL, certificate, or schema mismatch.
389ds uses replication agreements
389ds represents replication through agreements and exposes state through tooling:
dsconf -D 'cn=Directory Manager' ldap://ldap1 repl-agmt status --suffix 'dc=sudosecurity,dc=org' agreement-nameYou care about initialization state, last update time, replica generation, change sequence numbers, and consumer errors. The exact mechanics differ from OpenLDAP, but the operational question is identical: can a write performed now be observed everywhere clients may read it?
Lag is a security issue, not just performance
Password changes, lockouts, group revocation, and account disablement are replication-sensitive security events. If removing a user from cn=vpn-users takes ten minutes to reach a remote consumer, access persists for ten minutes. Measure replication delay and alert on thresholds tied to revocation risk, not only CPU use.
disable account -> provider write -> replication -> consumer visible -> app cache expiryThe total path includes application caches. A perfect directory can still lose the incident response battle to a 30-minute cache.
Replication failure modes to rehearse
Practice these before production rehearses them for you: certificate expiry, replication credential rotation, schema skew, disk-full consumer, network partition, clock skew, provider rebuild, and consumer reinitialization. Keep a documented command sequence for seeding or reinitializing a replica instead of improvising during an outage.
Field notes
- Matching
contextCSNis stronger evidence than matching process state, but understand topology-specific CSN formats before comparing blindly. - Replication binds need enough ACL access to read everything replicated; partial visibility causes partial replication.
- Never make geographically remote applications write to a local consumer unless the server explicitly supports chaining or referrals correctly.
- After restoring a provider from backup, evaluate whether consumers are ahead of it; replication topology decides whether they must be reinitialized.
Was this lesson helpful?