Skip to content

Instantly share code, notes, and snippets.

@imShakil
Last active October 10, 2024 10:38
Show Gist options
  • Save imShakil/694a0769ebcf679ea63e94e47692103f to your computer and use it in GitHub Desktop.
Save imShakil/694a0769ebcf679ea63e94e47692103f to your computer and use it in GitHub Desktop.
[WIP] ldap to pgsql migration in Gluu CE 4.5

Migration LDAP to PostgreSQL in Gluu Server (4.5) [WIP]

Before procceding, make sure that you have the backup. In case any failure, you can revert back and restart these steps. Let's start:

Setup PostgreSQL

Install postgresql server on your system (version should be at least 14.0) or any host that can be reachable from gluu host.

Let's install postgresql with the following command:

sudo apt install postgresql postgresql-common

To crate database, user and adjust previleges, connect to postgresql server by command sudo su - postgres -c 'psql'

Execute the following sql commands one-by-one:

CREATE DATABASE gluudb;
CREATE USER gluu WITH PASSWORD 'YourPassword';
GRANT ALL PRIVILEGES ON DATABASE gluudb TO gluu;
ALTER DATABASE gluudb OWNER TO gluu;

Let's add the following line at the beginning of /etc/postgresql/14/main/pg_hba.conf:

host    gluudb    gluu    0.0.0.0/0    md5

and restart postgresql:

systemctl restart postgresql.service

Migrate

  • Login into gluu server and install python3-ldap:
gluu-serverd login
apt install python3-ldap
  • Download the migration script:
wget https://raw.githubusercontent.com/GluuFederation/community-edition-setup/refs/heads/master/tools/ldap_to_rdbm/ldap2rdbm.py -O /install/community-edition-setup/ldap2rdbm.py
  • Download and extract the community-edition-repo:
wget https://github.com/GluuFederation/community-edition-setup/archive/refs/heads/master.zip -O community-edition-setup.zip && unzip community-edition-setup.zip
  • Replace with updated files in /install/community-edition-setup/ directory:
rsync -av community-edition-setup-master/ /install/community-edition-setup/
  • Now let's run the migration:
cd /install/community-edition-setup/
python3 ldap2rdbm.py -rdbm-type="pgsql" -rdbm-user="gluu" -rdbm-password="YourPassword" -rdbm-db="gluudb" -rdbm-host="localhost" -rdbm-port="5432"

Restart Server

If everything goes well, you should see this line at the end after running the migration script:

Please disable opendj and restart container

Let's disable opendj:

/opt/opendj/bin/stop-ds

systemctl disable opendj.service

Finally, exit from gluu server and restart:

exit
gluu-serverd restart

After restart, you should be able to login into the server.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment