On this page |
Overview ¶
The HQueue farm uses SQLite for its database backend. SQLite is lightweight and portable but not scalable. It is unsuitable for high concurrency as it limits writing to only one writer at a time. HQueue provides the option to change the database backend to more performant database engines, MySQL and PostgreSQL.
Note
SQLite is sufficient for most HQueue farms. Switching to MySQL or PostgreSQL is beneficial only for large farms where freezes and slowdowns are noticeable in the HQueue web interface.
Note
Switching the database backend to MySQL or PostgreSQL does not migrate the data from the existing SQLite database. Job, client, group and resource information will be lost, however, the new database will automatically repopulate with client information when the HQueue clients ping the server.
Switching to MySQL ¶
Prerequisites ¶
The HQueue server requires the following
-
MySQL and the database management tool MySQL Workbench on the HQueue server.
-
The mysqlclient Python package.
This must be installed into the HQueue server installation
Linux
In a terminal, run:
sudo /opt/hqueue/bin/pip3 install mysqlclient
Mac
In a terminal, run:
sudo /Library/HQueueServer/Frameworkds/Python.framework/Versions/X.Y/bin/pip3 install mysqlclient
Windows
In a Windows command prompt terminal, run as administrator:
cd C:/HQueueServer/pythonXY/Scripts pip3.exe install mysqlclient
Note
You may need to install the
pkg-config
andlibmysqlclient-dev
packages before installingmysqlclient
.
Setup Instructions ¶
-
Stop the HQueue Server.
See the FAQs for instructions on how to stop the server.
-
Access the MySQL database shell.
In a terminal or Windows command prompt, run:
mysql -u root -p
-
Create the HQueue database.
In the MySQL database shell, run:
mysql> CREATE DATABASE hqueue;
The database should be visible in MySQL Workbench.
-
Create a database user account. (optional)
Note
Skip this step if you already have a database user account that you want to connect to the HQueue database with.
In the MySQL database shell, run:
mysql> CREATE USER '<username>'@'localhost' IDENTIFIED BY '<password>';
where
<username>
and<password>
are the new user account’s username and password respectively. -
Grant HQueue database access to the database user account.
In the MySQL database shell, run:
mysql> GRANT ALL ON hqueue.* TO '<username>'@'localhost';
where
<username>
is the database user account. -
Configure the HQueue server to connect to the MySQL database.
Edit the HQueue server configuration file,
hqserver.ini
in a text editor and add the following to the end of the file:[database] engine = django.db.backends.mysql name = hqueue user = <username> password = <password>
where
<username>
and<password>
are the user credentials required to connect to the MySQL database.See HQueue Configuration for further details on the database configuration options.
-
Create the HQueue database tables.
Linux
In a terminal, run:
cd /opt/hqueue sudo ./bin/python3 ./hqserver/manage.py migrate
Mac
In a terminal, run:
cd /Library/HQueueServer sudo ./Frameworks/Python.framework/Versions/X.Y/bin/python3 ./hqserver/manage.py migrate
Windows
In a Windows command prompt terminal, run as administrator:
cd C:/HQueueServer pythonXY/bin/pythonX.Y.exe hqserver/manage.py migrate
-
Restart the HQueue Server.
See the FAQs for instructions on how to start the server.
Switching to PostgreSQL ¶
Prerequisites ¶
The HQueue server requires the following
-
PostgreSQL and the database management tool pgAdmin.
-
The psycopg Python package.
This must be installed into the HQueue Server installation:
Linux
In a terminal, run:
sudo /opt/hqueue/bin/pip3 install psycopg2-binary
Mac
In a terminal, run:
sudo /Library/HQueueServer/Frameworkds/Python.framework/Versions/X.Y/bin/pip3 install psycopg2-binary
Windows
In a Windows command prompt terminal, run as administrator:
cd C:/HQueueServer/pythonXY/Scripts pip3.exe install psycopg2-binary
Setup Instructions ¶
-
Stop the HQueue Server.
See the FAQs for instructions on how to stop the server.
-
Access the PostgreSQL database shell.
In a terminal or Windows command prompt, run:
psql -U postgres
You will be prompted to enter the
postgres
password that was set during the PostgreSQL installation. -
Create the HQueue database.
In the PostgreSQL database shell, run:
postgres=# CREATE DATABASE hqueue;
The database should be visible in pgAdmin.
-
Create a database user account. (optional)
Note
Skip this step if you already have a database user account that you want to connect to the HQueue database with.
In the PostgreSQL database shell, run:
postgres=# CREATE USER <username> WITH PASSWORD '<password>';
where
<username>
and<password>
are the new user account’s username and password respectively. -
Grant HQueue database access to the database user account.
In the PostgreSQL database shell, run:
postgres=# GRANT CONNECT ON DATABASE hqueue TO <username>; postgres=# \c hqueue postgres=# GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO <username>; postgres=# GRANT ALL PRIVILEGES ON ALL SEQUENCES IN SCHEMA PUBLIC TO <username>;
where
<username>
is the database user account. -
Register a server in pgAdmin.
Populate the name and host name/address fields accordingly. Then populate the username and password fields with the chosen username and password from the previous step respectively.
-
Configure the HQueue server to connect to the PostgreSQL database.
Edit the HQueue server configuration file,
hqserver.ini
in a text editor and add the following to the end of the file:[database] engine = django.db.backends.postgresql name = hqueue user = <username> password = <password>
where
<username>
and<password>
are the user credentials required to connect to the PostgreSQL database.See HQueue Configuration for further details on the database configuration options.
-
Create the HQueue database tables.
Linux
In a terminal, run:
cd /opt/hqueue sudo ./bin/python3 ./hqserver/manage.py migrate
Mac
In a terminal, run:
cd /Library/HQueueServer sudo ./Frameworks/Python.framework/Versions/X.Y/bin/python3 ./hqserver/manage.py migrate
Windows
In a Windows command prompt terminal, run as administrator:
cd C:/HQueueServer pythonXY/bin/pythonX.Y.exe hqserver/manage.py migrate
-
Restart the HQueue Server.
See the FAQs for instructions on how to start the server.