Simple JChem PostgreSQL Cartridge highly available step by step setup (as of 2021 December) is available here. It does not contain any specific configuration related to database size (e.g. number of structures), or performance tuning. Use it as a starting point for highly available setup followed by custom settings.
Requirements: have PostgreSQL and Java installed. (See JChem PostgreSQL Cartridge requirements.)
Download jchem-psql .deb or .rpm package and run package installation and license file setting as required by your operating system.
Add a user that is going to have access and a database that stores the JPC index data (in our example both are jpc
) to the PostgreSQL database.
Before running service init set the following parameter values in the /etc/chemaxon/jchem-psql.conf
file (URL, user and password should be modified according to your JPC index data user and database created beforehand):
com.chemaxon.jchem.psql.scheme=crdb
com.chemaxon.jchem.psql.crdb.sqlBuilderProvider=POSTGRESQL
com.chemaxon.jchem.psql.crdb.jdbcUrl=jdbc:postgresqllocalhost:5432/jpc
com.chemaxon.jchem.psql.crdb.user=jpc
com.chemaxon.jchem.psql.crdb.password=jpc
com.chemaxon.jchem.psql.crdb.hazelcastConfigFile=/etc/chemaxon/hazelcast.xml
The file hazelcast.xml should be already available in the /etc/chemaxon/ directory. (If not, you can download it from here. In the given file hazelcast discovery is set to TCP/IP, which means that hazelcast instances that are listed with their IP address in the member list will find each other and form a cluster. Change the IP addresses to your current cluster (master and slave) IP address.
<member-list>
<member>172.31.1.8</member>
<member>172.31.10.238</member>
</member-list>
To change hazelcast behaviour modify the network settings in the file.
Change the postgresql.conf
file:
listen_addresses = ‘*’
wal_level = replica
max_wal_senders = 10
hot_standby = on
Set up synchronization mode to synchronous or asynchronous by setting the parameters synchronous_commit
and synchronous_standby_names
.
To make it synchronous set synchronous_commit
to on and synchronous_standby_names
to a valid value different than empty string, we tried ‘*’ which means that all slaves will have synchronous commits. By setting synchronous_commit
to off or setting synchronous_standby_names
to empty string the commits become asynchronous.
Set up the allowed replication connections in the pg_hba.conf
file as required in your system so that the slave PostgreSQL node can reach the master.
Restart PostgreSQL server.
Init jchem-psql service:
sudo service jchem-psql init
sudo service jchem-psql start
Requirements: have PostgreSQL and Java (at least version 8) installed.
Do the steps 1 to 4 the same way as in the master setup.
Change the postgresql.conf
file:
listen_addresses = ‘*’
recovery_target_timeline = ‘latest’
hot_standby = on
Setup replication of the master as postgres user by deleting PostgreSQL data directory (make sure that no data gets lost!) and setting up the replication:
sudo su postgres
rm -rf /var/lib/postgresql/12/main
pg_basebackup -D /var/lib/postgresql/12/main -h 172.31.1.8 -X stream -c fast -R
Restart PostgreSQL server.
Start jchem-psql service:
sudo service jchem-psql start