Migration LDAP to PostgreSQL in Gluu Server 4.5
Instructions are applicable to VM based deployments only.
This document is a work in progress.
Before proceeding, make sure that you have the backup. In case of any failure, you can revert back and restart these steps.
Setup PostgreSQL
Install PostgreSQL server on your system (version should be at least 14.0) or any host that can be reached from the Gluu host.
Let’s install postgresql
with the following command:
sudo apt install postgresql postgresql-common
To create a database, user, and adjust privileges, 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
- Log in to the 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 the Gluu server and restart:
exit
gluu-serverd restart
After restarting, you should be able to log in to the server.