Install Openldap From Source And Configure Multi-Master Replication
Install Openldap From Source And Configure Multi-Master ReplicationAuthor: Nitin Bhadauria Going forward to my previous document on setting up a Qmail Server with Openldap, I am now sharing a doc on how we can set up an Openldap in multi-master replication mode. So If you want more than one ldap-server for redundancy here we go:
1 Preliminary NoteIn this tutorial I will use two demo servers, just to make steps simple, But you can replicate the same setup on more then two servers.
server1.example.com: IP address 192.168.0.100 Because we will run all the steps from this tutorial with root privileges, you can either pretend all commands in this tutorial with the string sudo, or we become root right now by typing: sudo su Two servers should be able to resolve the other systems' hostnames. If this cannot be done through DNS, you should edit the /etc/hosts file so that it looks as follows on all three systems: vi /etc/hosts 127.0.0.1 localhost.localdomain localhost 192.168.0.100 server1.example.com server1 192.168.0.101 server2.example.com server2
2 Prerequisitesa. Before compiling we will install some dependencies: yum install libacl-devel libblkid-devel gnutls-devel readline-devel python-devel autoconf gcc-c++ gcc glibc-devel glibc-headers kernel-headers libgomp libstdc++-devel openssl-devel e2fsprogs-devel keyutils-libs-devel krb5-devel libselinux-devel libsepol-devel libtool-ltdl-devel b. Before installing Openldap we need to install latest Oracle Berkeley DB. wget http://download.oracle.com/berkeley-db/db-4.7.25.tar.gz
3 Install Openldapa. install the OpenLDAP server from source: wget ftp://ftp.openldap.org/pub/OpenLDAP/openldap-release/openldap-2.4.26.tgz Try to start the service and check it started without any error. To make sure we are good to go. /usr/local/openldap/libexec/slapd -d 5 Note: Press "ctrl + c" to exit. Now we will follow the same steps to install the Openldap on other server.
4 Configure Multi-Master ReplicationNow we will configure the replication although i will include most of the important configuration just to make sure that the configuration are in correct order (which is important because you can’t just put any line anywhere in file). On server1 (192.168.0.100): vi /usr/local/openldap/etc/openldap/slapd.conf pidfile /usr/local/openldap/var/run/slapd.pid
argsfile /usr/local/openldap/var/run/slapd.args
# Load the required modules
moduleload syncprov.la
moduleload accesslog.la
moduleload back_bdb.la
#Define the server ID.
serverID 1
# Make sure you change below configuration as your need
database bdb
suffix " dc=example,dc=com "
rootdn "cn=ldadmin,dc=example,dc=com "
rootpw {SSHA}MxGntcb+QdYimYqbly7IOCY2ZJ0SxqCZ # Generate password using "slappasswd"
directory /usr/local/openldap/var/openldap-data
# These are basic performances configuration required
checkpoint 10240 720 # check point whenever 10M data bytes written or 24Hr has elapsed whichever occurs first
cachesize 50000 # LDAP maintains 50,000 entries in memory
# These configurations are to set the default database parameters
dbconfig set_cachesize 0 524288000 1 # Set the database in memory cache size to 500 MB, Tuning this value can greatly effect your database performance.
dbconfig set_lk_max_locks 3000
dbconfig set_lk_max_objects 1500
dbconfig set_lk_max_lockers 1500
dbconfig set_lg_regionmax 262144
dbconfig set_lg_bsize 2097152
# Replication configuration, only things you may have to change here are provider, binddn, credentials and searchbase.
syncrepl rid=001
provider=ldap://server2.example.com:389
binddn="cn=ldadmin,dc=example,dc=com "
bindmethod=simple
credentials=secret
searchbase=" dc=example,dc=com "
type=refreshAndPersis
interval=00:00:00:10
retry="5 5 300 5"
timeout=1
index objectClass eq
#Rest replication configuration goes to end of the file.
mirrormode TRUE
overlay syncprov
syncprov-nopresent TRUE
syncprov-reloadhint TRUE
syncprov-checkpoint 1000 60
Now configure server2 (192.168.0.101): vi /usr/local/openldap/etc/openldap/slapd.conf pidfile /usr/local/openldap/var/run/slapd.pid
argsfile /usr/local/openldap/var/run/slapd.args
moduleload syncprov.la
moduleload accesslog.la
moduleload back_bdb.la
serverID 1
database bdb
suffix " dc=example,dc=com "
rootdn "cn=ldadmin,dc=example,dc=com "
rootpw {SSHA}MxGntcb+QdYimYqbly7IOCY2ZJ0SxqCZ # Generate password using “slappasswd”
directory /usr/local/openldap/var/openldap-data
checkpoint 10240 720
cachesize 50000
dbconfig set_cachesize 0 524288000 1
dbconfig set_lk_max_locks 3000
dbconfig set_lk_max_objects 1500
dbconfig set_lk_max_lockers 1500
dbconfig set_lg_regionmax 262144
dbconfig set_lg_bsize 2097152
syncrepl rid=002
provider=ldap://server1.example.com:389
binddn="cn=ldadmin,dc=example,dc=com "
bindmethod=simple
credentials=secret
searchbase="dc=example,dc=com "
type=refreshAndPersist
interval=00:00:00:10
retry="5 5 300 5"
timeout=1
index objectClass eq
mirrormode TRUE
overlay syncprov
syncprov-nopresent TRUE
syncprov-reloadhint TRUE
syncprov-checkpoint 1000 60
5 Configure Startup Script FileFirst create an account to run ldap service: groupadd ldap As openldap didn't include any scripts in package we will create one: vi /etc/init.d/ldap #!/bin/bash You may have to make some aditional directory required: mkdir -p /usr/local/openldap/var/{run,lock/subsys} Now, make this script executable and change its default permissions: chmod 700 /etc/init.d/ldap Start your OpenLDAP Server manually with the following command: /etc/init.d/ldap start
6 MigrationOnly follow these steps if you are setting replication on already running Openldap server: a. First copy all the schema used in your running setup, I would suggest sync the whole directory. rsync -av /usr/local/openldap/etc/openldap/schema root@server2:/usr/local/openldap/etc/openldap/schema Now remember to include the these schema in your configuration: vi /usr/local/openldap/etc/openldap/slapd.conf include /usr/local/openldap/etc/openldap/schema/core.schema include /usr/local/openldap/etc/openldap/schema/cosine.schema include /usr/local/openldap/etc/openldap/schema/inetorgperson.schema include /usr/local/openldap/etc/openldap/schema/nis.schema include /usr/local/openldap/etc/openldap/schema/qmail.schema b. Now import all the data from server1 to server2. on server1: ldapsearch -x -b 'dc=example,dc=com' > master.ldif on server2: ldapmodify -cvx -D'cn=ldadmin,dc=example,dc=com' -W -f /root/master.ldif Enter LDAP Password: Now restart Ldap service simultaneously on both servers: /etc/init.d/ldap restart
7 Configure Qmail And IMAP To Use Both serversNow we will edit a qmail control file to define multiple ldap servers: vi /var/qmail/control/ldapserver server1.example.com:389 server2.example.com:389 And courier-auth configuration to make imap use both the servers: vi /etc/courier/authldaprc LDAP_URI ldap://server1.example.com, ldap://server2.example.com Now just restart the services and all should be good :) I will be publishing a doc to configure replication over SSL very soon...
|



Recent comments
21 hours 38 min ago
1 day 4 hours ago
1 day 8 hours ago
1 day 9 hours ago
1 day 18 hours ago
2 days 3 hours ago
2 days 4 hours ago
2 days 8 hours ago
2 days 12 hours ago
2 days 12 hours ago