📜 ⬆️ ⬇️

LDAP. Configuring a fault tolerant LDAP server

The Internet Engineering Task Force (IETF) In this article I will tell you about the 389 Directory Server (also known as Fedora Directory Server, also known as Redhat Directory Server). It so happened that the LDAP protocol is used to access the directory server. If you haven't worked with LDAP, I highly recommend reading the articles on Wikipedia ( here’s about directory services, and here’s about LDAP).

So, first, briefly, why use a directory service server at all (hereinafter referred to as the LDAP server). LDAP servers are mainly used for the centralized storage of user accounts, and everything connected with them. An LDAP server is a hierarchical database, which means you can store any data in it.

It would seem that the question is quite logical: why LDAP? What prevents to store accounts in MySQL or PostgreSQL? The answer is obvious - nothing =)
')
But over any RDBMS directory service has a number of advantages:



The choice of server directory service fell to 389 Directory Server. The history of this LDAP server is closely connected with the company Netscape (if you're interested, you can read the story here ).



Key features of this LDAP server:



After reviewing the capabilities of 389 Directory Server, let's take a closer look at its structure.

General Structure 389 Directory Server



389 DS consists of several components.



At first I wanted to write the theoretical and practical parts separately, but then it became clear that the first part would become too boring, and the second too dry. Therefore, immediately after the piece of theory there will be practical application.

So, the task. You need to configure a fault tolerant directory service. To do this, we will configure two servers, configure multimaster replication between them, and raise the moving IP address (pacemaker + openais).

image

If one of the servers becomes unavailable, the other will take over this IP and the service will continue to work.

image

After the server is restored, the data will be replicated to it and the IP address will switch back to LDAP00, or, depending on the cluster configuration, will remain on LDAP01.

image

On one server there can be several isolated ns-slapd instances with their own settings, schema, replication rules, etc. To be able to manage these instances from the management console, each server must have an Administration Server (hereinafter referred to as the admin server). The admin server itself needs one LDAP server instance, since it stores the run-time configuration there. By default, the admin server configuration is stored with user data, but I consider it unsafe, so we will have two instances on each server: one will contain the configuration for the admin server, and the second data. In such a scheme, in the event of a failure of one of the nodes, not only is the LDAP service operational, but also the ability to manage it.

For our directory service, we use two servers, ldap00 and ldap01. On each of them two instances of LDAP servers will be installed, one for the needs of admin servers, the second for our data.
The installation plan will be as follows:
  1. Installing the first server on ldap00;
  2. Setting up replication on ldap00;
  3. Install and configure the ldap instance on ldap01;
  4. Installing the admin server on ldap01;
  5. Install and configure ldap instances to store user data.


Installing the first server on ldap00



Finished rpm are collected in the EPEL repository for Centos, RHEL and Fedora Core. If you have one of these systems, connect the EPEL repository and perform the installation via yum.

We use SLES, so we had to build all the packages for this system in our OpenSUSE Build Service. If you have debian / ubuntu, read this document.

Along with 389 DS is a set of perl scripts that are used to install server instances.

Here are some of them:



First, run dsktune:

ldap00: ~ # dsktune
389 Directory Server system tuning analysis version 10-AUGUST-2007.

NOTICE: System is x86_64-unknown-linux2.6.27.42-0.1-xen (1 processor).

NOTICE: The net.ipv4.tcp_keepalive_time is set to 7200000 milliseconds
(120 minutes). This may cause temporary server congestion from lost
client connections.

WARNING: There are only 1024 file descriptors (hard limit) available, which
limit the number of simultaneous connections.

WARNING: There are only 1024 file descriptors (soft limit) available, which
limit the number of simultaneous connections.


The utility wrote about the system parameters that need to be tweaked. In my case, it is net.ipv4.tcp_keepalive_time and the limit of open files.

tcp_keepalive_time is the time from the last packet sent to the first keepalive parcel. With a large value, if the client is "dead", the connection will remain open for a long time (120 minutes by default). Set this value to 10 minutes.

echo 600 > /proc/sys/net/ipv4/tcp_keepalive_time

Add to /etc/sysctl.conf:

net.ipv4.tcp_keepalive_time = 600

To increase the limit of open files, add to /etc/security/limits.conf:

* - nofile 8192

run dsktune again and make sure that everything is ready for installation.

Now run the setup-ds-admin.pl script
We will be asked if we want to install 389 Directory and Administration Server, if we agree with the license, run dsktune again and, finally, the installation type selection menu appears.

Choose a setup type:

1. Express
Allows you to set up the servers using the most
common options and pre-defined defaults. Useful for quick
evaluation of the products.

2. Typical
Allows you to specify common defaults and options.

3. Custom
Allows you to specify more advanced options. This is
recommended for experienced server administrators only.

To accept the default shown in brackets, press the Enter key.

Choose a setup type [2]:


Select the third item (we are experienced server administrators =)

Further it will be offered to specify FQDN and a name / group from which (oops) the LDAP server will be started.

Configuration directory server, enter 'no' to
be prompted to set up one.

Do you want to register this software with an existing
configuration directory server? [no]:


Here we are asked if we want to use an existing directory server to save information about the server. Since this is our first server, we answer No.

Next come the admin server questions: administrator ID, password, Administration Domain, and leave the answers to them by default (except for the password).

Then you will need to specify which port will listen to the LDAP server. We agreed that this is an instance that stores only the configuration for the admin server, so we transfer it to port 6389. Next we specify the Directory server identifier. Let's call our instance config-instance. We answer the question about the suffix of the root tree by default, there will be no root tree in this instance, so you can delete it later.

Then we will have a question about the Directory Manager DN.

Directory Manager is a user with root privileges in the LDAP server. Each instance has its own local directory manager.

Next are questions about the password to the Directory Manager, whether we want to put examples of entries in our root suffix and whether we want to fill our new instance with some data, ask for the port name, IP address and username from which the admin server will work . After that, the last time they ask for confirmation and start the installation.

Setting up replication on ldap00



To connect to the server, you need to install and run the 389-console management console.

image

As the Adminstration URL, you need to enter the admin server address and the port you specified during installation.

Next we get to the server control panel. We now have only one instance, choose it.

image

From the management console, remove the suffix dc = edu, dc = scalaxy, dc = local

image

We have only one suffix left and the base in which the configuration data for the admin server is located.

Now a little theory about the principles of replication.

Two types of servers are involved in replication, supplier and consumer.

A supplier is a server that copies a replica to another server.

Server supplier duties:

The supplier server must always be available, since the record is made only on this server, and then replicated to other routes.

If the connection with the supplier server is lost, then writing to the directory will become impossible.

consumer is a server that stores a replica from another server. In the case of multimaster replication, the two servers are both supplier and consumer.

consumer must:

Each supplier server has its own changelog, which stores information about all changes that have occurred on the replica.

The supplier server repeats these changes on each consumer server.

Now that we’re a bit theoretical, you can set up a multimaster instance replication with a configuration.

Keeping changelog changes is disabled by default, it is enabled in the Replication tab. Changelog is enabled for all databases simultaneously.

Further we include replication for the NetscapeRoot base. You must specify Replica ID and Supplier DNs.

Supplier DN is the name of the user who is allowed to replicate on the LDAP server. This user must be created on all LDAP servers that participate in multimaster replication.

The fastest way to do this is through the ldapmodify utility. This utility allows you to modify data in LDAP online or take commands from the ldif file.

ldapmodify -h 127.0.0.1 -p 6389 -x -D "cn=root" -W
Enter LDAP Password:
dn: cn=replication manager,cn=config
changetype: add
objectClass: inetorgperson
objectClass: person
objectClass: top
objectClass: organizationalPerson
cn: replication manager
sn: RM
userPassword: <password>
passwordExpirationTime: 20380119031407Z


The answer should be
adding new entry "cn=replication manager,cn=config"

So we got:

image

Immediately create a Replication Agreement for the second server. In the context menu for the base NetscapeRoot, select the New Replication Agreement and fill in the same way:

image

We will be warned that the connection to the server is impossible (since it is not there yet), we reach the last item, set Do not initialize consumer .

Installing and configuring the ldap instance on ldap01



Now you need to configure a second LDAP server. With him a little different, because The admin server installation should already occur in the installed LDAP server and we will perform the initial configuration from the console using the ldapmodify utility (which is a good thing if the task is to figure out how this directory server works).

First, on the second server, using the setup-ds.pl script, you need to create an instance that is not managed by the admin server.

Answers to script questions are similar to the previous ones.

After installing the LDAP server, connect to it via ldapmodify and configure it.

Connection is approximately as follows:

ldapmodify -h 127.0.0.1 -p 6389 -D "cn=root" -W

1) Enable the changelog :

dn: cn=changelog5,cn=config
changetype: add
objectclass: top
objectclass: extensibleObject
cn: changelog5
nsslapd-changelogdir: /var/lib/dirsrv/slapd-ldap01/changelogdb


changelogdir should point to a directory with the name of your instance.

2) add user replication manager :

dn: cn=replication manager,cn=config
changetype: add
objectClass: inetorgperson
objectClass: person
objectClass: top
objectClass: organizationalPerson
cn: replication manager
sn: RM
userPassword: <passowrd>
passwordExpirationTime: 20380119031407Z


20380119031407Z means that the password is not limited.

3) Create the netscaperoot suffix:

dn: cn="o=netscaperoot",cn=mapping tree,cn=config
changetype: add
objectclass: top
objectclass: extensibleObject
objectclass: nsMappingTree
nsslapd-state: backend
nsslapd-backend: NetscapeRoot
cn: "o=netscaperoot"


4) Create a base for the netscaperoot suffix:

dn: cn=NetscapeRoot,cn=ldbm database,cn=plugins,cn=config
changetype: add
objectclass: extensibleObject
objectclass: nsBackendInstance
nsslapd-suffix: o=netscaperoot


By the way, the default 389 DS for storing directory entries uses a modified version of the non-relational database Berkeley DB. If you wish, you can read more here .

5) Create a root o = NetScapeRoot :

dn: o=NetscapeRoot
changetype: add
objectClass: organization
objectClass: top
o: NetscapeRoot


6) Allow replication for o = netscaperoot:

dn: cn=replica,cn="o=netscaperoot", cn=mapping tree, cn=config
changetype: add
objectClass: nsDS5Replica
objectClass: top
nsDS5ReplicaId: 2
nsDS5ReplicaRoot: o=netscaperoot
cn: replica
nsDS5Flags: 1
nsDS5ReplicaBindDN: cn=replication manager,cn=config
nsds5ReplicaChangeCount: 0
nsds5ReplicaPurgeDelay: 604800
nsDS5ReplicaType: 3


Do not forget to change nsDS5ReplicaId to your server number ( nsDS5ReplicaType - type of replication, 3 - multimaster).

At this stage, we already have configured one-way replication from ldap00 to ldap01.

The final step will be:

7) Configure replication from ldap01 to ldap00:

dn: cn=Multimaster replication, cn=replica, cn="o=netscaperoot", cn=mapping
tree, cn=config
changetype: add
objectClass: top
objectClass: nsDS5ReplicationAgreement
cn: Multimaster replication
description: replication for netscaperoot
nsDS5ReplicaBindDN: cn=replication manager,cn=config
nsDS5ReplicaBindMethod: SIMPLE
nsds5replicaChangesSentSinceStartup:
nsDS5ReplicaCredentials: <password>
nsDS5ReplicaHost: ldap00.edu.scalaxy.local
nsDS5ReplicaPort: 6389
nsDS5ReplicaRoot: o=netscaperoot
nsDS5ReplicaTransportInfo: LDAP
nsds5replicaUpdateInProgress: FALSE


nsDS5ReplicaBindDN - the name of the user on whose behalf replication will be performed
nsDS5ReplicaCredentials - password

8) Initial initiation of replication from ldap00 to ldap01:

On the first server, execute this command:
dn: cn=Multimaster replication,cn=replica,cn="o=netscaperoot",cn=mapping tree,cn=config
changetype: modify
replace: nsds5beginreplicarefresh
nsds5beginreplicarefresh: start


This command replicates data from ldap00 to ldap01, this operation is required, and the server on the second server is now empty o = netscaperoot.

Now we have fully replicated directories with admin server configuration.

Installing admin server on ldap01



You need to raise the admin server on the second server. Run the register-ds-admin.pl script

When we are prompted to specify the Configuration directory server URL , enter the LDAP URL of the second server ldap: //ldap01.edu.scalaxy.local: 6389 / o = NetscapeRoot

Further configuration is trivial, follow the instructions of the script.

Installing and configuring ldap instances to store user data



Now you can connect via the management console to any admin server.

On each of the servers in the Server Group we create a new LDAP server instance, this will be the LDAP server in which we will store our data.

image

We configure multimaster replication between two instances by the same principle (now you can configure replication through both the GUI and the console).

Congratulations! You have configured a failsafe directory service! Next, you need to configure openais + pacemaker to eliminate downtime in the service.

Documentation used:
directory.fedoraproject.org/wiki/Documentation
www.redhat.com/docs/manuals/dir-server

Source: https://habr.com/ru/post/86090/


All Articles