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 Atul Kumar

Leave a Comment:

5 comments
Geetha says December 4, 2008

Hi Shanker

Could you please throw some light on
‘What is LDAP server’? and
‘Where do we use in real environment’?

Rgds
Appsdba

Reply
Atul Kumar says December 4, 2008

AppsDBA,

LDAP is (protocol) Light weight Directory Access Protocol to access Direcory server which is nothing but kind of phone directory.

Directory Server is also called as LDAP server which usually stores user, group or any enterprise entity like pcs, networks, table, chair or just anything.

Main difference between LDAP server and database (which also can be used repository of LDAP server) is that entry in Database is stored in tabular format where as it is in tree like structure in LDAP server.

LDAP server is mainly for queries and example of ldap server is OID (Oracle Internet Directory) from Oracle, iPlanet from Sun or LDAP from fedora or Open ldap (open source ldap server)

Reply
Geetha says December 7, 2008

Thankyou Atul.

Rgds
Appsdba

Reply
rohitpatel9999 says June 18, 2009

Please explain the best way to backup OID entries – so it can be used to restore in case of disaster or if rebuilding server.

(need to use scripts to automize backup. ldifwrite does not help as ODS password need to be entered manually)

Thanks

Reply
Atul Kumar says June 19, 2009

@Rohit,
You have two option

1. In script, define variable for password (and store password) use ldifwrite and pass on ODS password in script via variable (Need good scripting skills)

2. LDAP repository (for OID) is database so use hot/cold backup of database (which contains OID entry) and restore database in case of disaster

Reply
Add Your Reply

Not found