LDAP Installation and Migration

 

How to Migrate LDAP server to another machine with same architecture?

The following article explains simple way to install and migrate LDAP server.

I have taken two machines (host1.example.com and host2.example.com) with Oracle Enterprise Linux 4, as it is available free.  Host1 machine is already installed and running with LDAP server and now we need to work on host2.example.com machine. See that each machine configured with FQDN.

Now login to host2.example.com and perform the following tasks.

Installation:

Check whether the fedora-ds (fedora directory service) is installed or not.

#

rpm -qi fedora-ds

Install fedora-ds using yum  or rpm.  If you want to use rpm to install, download the fedora-ds package.

#

yum install fedora-ds

Or

#

wget -c http://directory.fedoraproject.org/download/fedora-ds-1.0.4-1.RHEL4.i386.opt.rpm

#

rpm -ivh  fedora-ds-1.0.4-1.RHEL4.i386.opt.rpm

After successful installation of fedora-ds package goto the /opt/fedora-ds directory.

#

cd /opt/fedora-ds

#

 ./setup/setup

Select all the defaults and you just need to provide the admin and Directory Manager passwords.

Or

You can use the custom installation file

#

./setup/setup  -s –f /PATH OF FILE/sample.inf

A sample .inf file is listed below

[General]
FullMachineName=   host2.example.com
SuiteSpotUserID=   nobody
ServerRoot=        /usr/lib/fedora-ds
[slapd]
ServerPort=        389
ServerIdentifier=  myhost
Suffix=   dc=host2,dc=example,dc=com
RootDN=   cn=Directory Manager
RootDNPwd=   password

After the installation, start the server.


#

cd /opt/fedora-ds/slapd-`hostname –a`

#

./start-slapd


To test the basic operation of the server, use the ldapsearch command:


#

/usr/bin/ldapsearch -x [-h <your host>] [-p <your port>] -s base -b “” “objectclass=*”  (syntax)



Migration of LDAP:


To migrate the ldap to new server you need to take the backup of schema(structure of ldap database)  and database.

Login to host1.example.com


Schema backup:

#

cd /opt/fedora-ds/slapd-`hostname –a`/


You can take the backup of schema in two ways.



One is through ldapsearch

 #

ldapsearch -b cn=schema -L “(objectclass=*)” > schema.ldif

Copy the file to /tmp of host2

Other way is to copy the schema folder  from the host1 to  host2


#

scp –r /opt/fedora-ds/slapd-`hostname –a`/config/sch* \host2.example.com: /opt/fedora-ds/slapd-`hostname –a`/config/.



Database backup :

#

/opt/fedora-ds/slapd-`hostname –a`

#

./db2ldif -s “dc=example,dc=com” -s “o=NetscapeRoot”  \-a /tmp/example-ldapRootDSE-`date +%m%d%y-%I%M%S`.ldif


Copy the backup file to /tmp of host2 server .

Schema and Database restoration :

Note that this server should be in running state.


#

cd /opt/fedora-ds/slapd-`hostname –a`/


#

./ldif2ldap “cn=Directory Manager”  manager /tmp/schema.ldif ( ignore this step, if you have copied schema directory to host2)


#

./ldif2ldap “cn=Directory Manager”  manager \/tmp/example-ldapRootDSE-xxxx.ldif


Syntax:

./ldif2ldap “cn=Directory Manager”  <password> /PATH OF BACKUPFILE



Now you will find the same data on both servers.


    

About the Author Masroof Ahmad

Leave a Comment:

5 comments
Add Your Reply