This guide explains how to configure a VT Docs server installed on an AWS EC2 instance can be configured to use AWS RDS as a database.
Note: This guide assumes you running VT Docs on either RHEL or AWS Linux and you are running VT Docs 3.4.2 or greater.
Install on RDS
For this, you will need a PostgreSQL RDS instance setup (we support v12 - v15). It should be a part of the same security group that the EC2 VT Docs instance is a member of so they can communicate via port 5432.
The RDS instance should have the following parameter set:
max_locks_per_transaction=500
When creating the PostgreSQL RDS instance you will be asked to provide a master username and password for the database
By default the master username is ‘postgres’. In the instructions below replace <master user> with the Postgres master username.
Creating the VT Docs user and Schema
The first step to complete is to create the VT Docs user and database in Postgres. Once that is complete we can bootstrap the database with an empty VT Docs schema.
Creating the VT Docs database and user
Download the sql file listed below to create VT Docs user and database structure on your external PostgreSQL:
https://visiblethread.s3.amazonaws.com/public/download/createDocsDB.sql
On your EC2 instance, use psql to run the file 'createDocsDB.sql' as the master user. In the example below we are using the default master user “postgres”.
This will create a database called “vtdocs” with a database user called “vtdocs”. You must specify a password you wish to use for this database user.
mkdir vtsetuptmp
cd vtsetuptmp
curl -O https://visiblethread.s3.amazonaws.com/public/download/createDocsDB.sql > createDocsDB.sql
psql -h <postgresql RDS endpoint name> -p 5432 -d postgres -U <master user> -f createDocsDB.sql -v pwd="'a secure password'"
Create the empty VT Docs Schema
Download the SQL file from here:
https://visiblethread.s3.amazonaws.com/public/download/vtdocs-tables.sql
Run the attached file 'vtdocs-tables.sql' as the vtdocs user (you will be prompted for a password. Enter the password you specified above). The exact format for connecting with a psql client will depend on your system. An example is listed below:
curl -O https://visiblethread.s3.amazonaws.com/public/download/vtdocs-tables.sql > vtdocs-tables.sql
psql -h <postgresql RDS endpoint name> -p 5432 -U vtdocs -f vtdocs-tables.sql
Modify the VT Docs environment file to point to your Database server
On your EC2 instance that is running VT Docs, navigate to the following folder:
/etc/default/visiblethread.env
Open the ‘visiblethread.env’ file for editing:
sudo nano visiblethread.env
Update the line that contains vtdocs.database.host=127.0.0.1 with vtdocs.database.host=<rds-endpoint-address>
Update the line that contains vtdocs.database.username="visiblethread" with vtdocs.database.username=vtdocs
Update vtdocs.database.password=password with the password you have specified for the vtdocs user above.
Save and exit nano with ctrl + o, enter then ctrl + x, enter.
Restart the VT Docs services:
sudo systemctl restart visiblethread-docs
When complete, restart the Apache service
sudo systemctl restart httpd