Skip to content

Instantly share code, notes, and snippets.

@imShakil
Last active November 20, 2024 05:13
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, Execute the following sql commands one-by-one:

sudo -i -u postgres psql -c "CREATE DATABASE gluudb;"
sudo -i -u postgres psql -c "CREATE USER gluu WITH PASSWORD 'YourPassword';" 
sudo -i -u postgres psql -c "GRANT ALL PRIVILEGES ON DATABASE gluudb TO gluu;"
sudo -i -u postgres psql -c "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

If you face trouble finding pg_hba.conf file location, run the following command:

 sudo -i -u postgres psql -c "SHOW hba_file;"

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/gluu4/refs/heads/4.5/community-edition-setup/tools/ldap_to_rdbm/ldap2rdbm.py -O /install/community-edition-setup/ldap2rdbm.py
  • Download community-edition-setup, And Sync with /install/community-edition-setup files:
git clone --sparse --filter=blob:none --depth=1 https://github.com/GluuFederation/gluu4
cd gluu4
git sparse-checkout add community-edition-setup
rsync -av community-edition-setup/ /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