- Prerequisites
- Downloading and Compiling OpenHalo
- Server Configuration
- Environment Variables Setup
- Security and Permissions
- Database Initialization
- OpenHalo/PostgreSQL Configuration
- MySQL Extension Activation
- Architecture Overview
- Final Verification
- Troubleshooting Tips
- Logging
- Stopping and Restarting OpenHalo
- Creating Additional Users
- Loading a PostgreSQL Database into OpenHalo
- Loading a MySQL Database into OpenHalo
- Backup and Restore
- Updating OpenHalo
You need a Linux environment (for example, WSL on Windows, Ubuntu, or a Linux-based Chromebook).
Open a terminal, update your system, and install the required build tools for OpenHalo:
sudo apt-get update
sudo apt install build-essential gcc g++ make cmake autoconf uuid-dev libicu-dev zlib1g-dev libreadline-dev -yNote: libicu-dev provides Unicode support, libreadline-dev enables command-line editing in psql, and uuid-dev is used for unique IDs in OpenHalo.
This installs a C compiler and necessary libraries for OpenHalo.
Make sure you have Git installed to clone the OpenHalo repository:
sudo apt install gitYou also need to have the MySQL client installed. Here’s how to install it:
sudo apt install mysql-client-core-8.0You may also need the PostgreSQL client to test connections independently of pg_ctl:
sudo apt install postgresql-clientNote for beginners: On some systems (Mac, Chromebook, or restricted Linux accounts), you may need to use sudo with more commands if you encounter "permission denied" errors.
Clone the OpenHalo repository from GitHub:
git clone https://github.com/HaloTech-Co-Ltd/openHalo.gitThe files are cloned to your computer. Now, go into the repository directory and prepare the compilation:
cd openHalo
./configure --prefix=/home/halo/openhalo/1.0 --enable-debug --with-uuid=ossp --with-icu CFLAGS=-O2Explanation: This checks your system for necessary libraries and creates Makefiles. Errors will be logged in config.log.
Compile and install OpenHalo:
make && make installTo compile additional modules, navigate to the contrib directory:
cd contrib
make && make installCreate the halo group with ID 1000:
groupadd -g 1000 haloTip: If ID 1000 is already used, pick another number (for example, 1500).
Add the halo user to this group:
useradd -u 1000 -g halo haloCheck that the user and group were created:
id haloExpected output:
uid=1000(halo) gid=1000(halo) groups=1000(halo)Note: OpenHalo should run as halo to avoid permission issues. For extra security, you can lock halo from SSH login.
Switch to the halo user:
su - haloIf prompted for a password, create one first with:
sudo passwd haloCreate a persistent directory for sockets.
Since /var/run is cleared on each reboot, we need to create a systemd configuration to recreate the directory automatically.
Switch to the root user:
exitCreate a tmpfiles configuration:
sudo nano /etc/tmpfiles.d/openhalo.confAdd this line:
d /var/run/openhalo 0755 halo halo -
Save and exit: Ctrl+O, Enter, Ctrl+X.
Apply the configuration immediately:
sudo systemd-tmpfiles --createThis will:
- Create
/var/run/openhalowith permissions 755 - Set owner to
halo:halo - Recreate it automatically at each system boot
Verify the directory was created:
ls -ld /var/run/openhaloYou should see:
drwxr-xr-x 2 halo halo 40 Oct 16 10:00 /var/run/openhalo
Now, switch again to the halo user:
su - haloSet the environment variables so that the shell knows where OpenHalo binaries and data are located, and where to find libraries.
Edit the file:
nano ~/.bashrcAdd the following lines:
export HALO_HOME=/home/halo/openhalo/1.0 # OpenHalo binaries and libraries
export PGDATA=/home/halo/ohdata # PostgreSQL data directory
export PATH=$HALO_HOME/bin:$PATH # Add OpenHalo binaries to PATH
export LD_LIBRARY_PATH=$HALO_HOME/lib:$LD_LIBRARY_PATH # Add OpenHalo libs
export PGHOST=/var/run/openhalo # PostgreSQL socket location
alias pg_ctl='/home/halo/openhalo/1.0/bin/pg_ctl -D /home/halo/ohdata'Save and exit: Ctrl+O, Enter, Ctrl+X.
Apply the changes:
. ~/.bashrcInstall direnv if not already installed:
sudo apt install direnvActivate direnv in your shell:
echo 'eval "$(direnv hook bash)"' >> ~/.bashrc
source ~/.bashrcCreate a .envrc file in the OpenHalo directory:
cd /home/halo/openhalo/1.0
nano .envrcAdd the same environment variable lines as above:
export HALO_HOME=/home/halo/openhalo/1.0 # OpenHalo binaries and libraries
export PGDATA=/home/halo/ohdata # PostgreSQL data directory
export PATH=$HALO_HOME/bin:$PATH # Add OpenHalo binaries to PATH
export LD_LIBRARY_PATH=$HALO_HOME/lib:$LD_LIBRARY_PATH # Add OpenHalo libs
export PGHOST=/var/run/openhalo # PostgreSQL socket location
alias pg_ctl='/home/halo/openhalo/1.0/bin/pg_ctl -D /home/halo/ohdata'Allow direnv to load the file:
direnv allowNote for beginners: With direnv, every time you enter this directory, variables and aliases are applied automatically. They are removed when you leave the directory.
echo $PATH
echo $PGDATA
which pg_ctlNote: If you encounter "permission denied" errors, try prepending sudo to commands that interact with system directories.
Never run OpenHalo as root except for installation or system commands.
Ensure proper ownership and permissions on data directories:
chown -R halo:halo /home/halo/ohdata
chmod 700 /home/halo/ohdataInitialize the database:
pg_ctl init -D $PGDATAExplanation: Creates necessary system tables and directories for PostgreSQL.
Check status, start, stop, or restart the server:
pg_ctl status
pg_ctl start
pg_ctl restart
pg_ctl stopWarning: Existing data in $PGDATA will be overwritten.
Edit the postgresql.conf file:
nano $PGDATA/postgresql.confAdd or modify the following lines:
listen_addresses = '*' # Listen on all IP addresses
port = 5432 # Default PostgreSQL port
database_compat_mode = 'mysql' # Enable MySQL compatibility mode
mysql.listener_on = true # Enable MySQL listener
mysql.port = 3306 # MySQL-compatible portSave and exit: Ctrl+O, Enter, Ctrl+X.
Edit pg_hba.conf:
nano $PGDATA/pg_hba.confAdd or modify the following lines:
# IPv4 local connections:
host all all 127.0.0.1/32 trust # Local IPv4 connections without password (useful for internal scripts)
host all all 0.0.0.0/0 scram-sha-256 # IPv4 connections from any IP with SCRAM-SHA-256 authenticationSave and exit: Ctrl+O, Enter, Ctrl+X.
Restart the server (or start it if not yet running):
pg_ctl restartCheck status:
pg_ctl statusTip: Ensure firewall allows ports 5432 and 3306.
Connect to PostgreSQL:
psql -p 5432Create the MySQL extension:
CREATE EXTENSION aux_mysql CASCADE;Create a MySQL-compatible user:
SET password_encryption = 'caching_sha2_password'; # Recommended for MySQL 8.0+ for stronger security. For older clients, use 'mysql_native_password'.
CREATE USER test PASSWORD 'test';
SELECT * FROM pg_shadow WHERE usename='test';Security note: This is an example. Change the password in production for better security.
Exit PostgreSQL:
\qTest MySQL connection:
mysql -P 3306 -h 127.0.0.1Exit MySQL:
\qHere are some tests to understand how the link between MySQL and PostgreSQL works:
Here’s a simplified diagram showing how OpenHalo interacts with PostgreSQL and MySQL:
+----------------+
| OpenHalo |
+----------------+
| |
| |
v v
+----------------+ +----------------+
| PostgreSQL | | MySQL |
| Port: 5432 | | Port: 3306 |
| Stores data | | MySQL Extension|
+----------------+ +----------------+Explanation:
- OpenHalo acts as a middleware and can interact with both databases.
- PostgreSQL (5432) holds the main data.
- MySQL (3306) is used through OpenHalo’s MySQL extension for compatibility and MySQL queries.
Check if PostgreSQL listens on 5432 and MySQL on 3306:
pg_ctl status
ss -tlnp | grep 5432 # sudo may be required to see all processes
ss -tlnp | grep 3306permission deniederrors → make sure you are using thehalouser and check folder permissions.- Port already in use → check with:
ss -tlnp | grep 5432
ss -tlnp | grep 3306- MySQL extension not found → make sure
aux_mysqlis compiled and installed correctly. - Logs can help diagnose issues (see below).
OpenHalo/PostgreSQL logs can help debug issues. By default, logs are stored in $PGDATA.
To monitor logs in real time:
tail -f $PGDATA/logfileYou can also configure logging in postgresql.conf:
logging_collector = on
log_directory = 'pg_log'
log_filename = 'openhalo-%Y-%m-%d.log'Stop PostgreSQL/OpenHalo at the end of a session:
pg_ctl stopVerify the server is no longer listening:
pg_ctl status
ss -tlnp | grep 5432
ss -tlnp | grep 3306For the next session, switch to the halo user:
su - haloReload environment variables if using ~/.bashrc:
. ~/.bashrcIf using direnv, just navigate to the OpenHalo directory.
Start the server and check status:
pg_ctl start
pg_ctl statusAccess PostgreSQL:
psql -p 5432Access MySQL:
mysql -P 3306 -h 127.0.0.1 Create additional MySQL-compatible users in PostgreSQL:
psql -p 5432
SET password_encryption = 'caching_sha2_password';
CREATE USER username PASSWORD 'your_password'; # Modify as needed
CREATE DATABASE projectdb OWNER username; # Modify as needed
\q
mysql -P 3306 -h 127.0.0.1 -uusername -p # Modify as usernameTip: Assign privileges using GRANT ALL PRIVILEGES ON DATABASE projectdb TO username;
psql -p 5432 -U halo -d postgres -f path/to/backup.sqlmysql -P 3306 -h 127.0.0.1 -utest -p < path/to/backup.sql # Password is the one used for the MySQL user (test in this example)Tip for beginners: If you get permission errors, try using sudo for MySQL commands.
It is recommended to backup your databases before making major changes:
- PostgreSQL backup
pg_dump -U halo -F c -b -v -f /home/halo/backup/openhalo_backup.pgsql postgres- MySQL backup
mysqldump -P 3306 -h 127.0.0.1 -utest -p your_database > /home/halo/backup/mysql_backup.sqlTo restore, simply use:
- PostgreSQL restore
pg_restore -U halo -d postgres /home/halo/backup/openhalo_backup.pgsql- MySQL restore
mysql -P 3306 -h 127.0.0.1 -utest -p your_database < /home/halo/backup/mysql_backup.sqlStop server before updating:
pg_ctl stopTo update OpenHalo to the latest version from GitHub:
cd /home/halo/openhalo
git pull
./configure --prefix=/home/halo/openhalo/1.0 --enable-debug --with-uuid=ossp --with-icu CFLAGS=-O2
make && make install