PostgreSQL
We will be using an Ubuntu / Debian
machine to setup our PostgreSQL
server.
Prerequisites
You will need sudo
privileges for setting up PostgreSQL
in the following steps.
Steps to setup PostgreSQL
- To install
PostgreSQL
, first refresh your server’s local package index:sudo apt update
- Then, install the Postgres package along with a -contrib package that adds some additional utilities and functionality:
sudo apt install postgresql postgresql-contrib
- After installation, a default user
PostgreSQL
is created, to access thePostgreSQL
shell, log in to this user:sudo -i -u postgres
- Create a new role:You will be prompted with some choices to create a user based on your specifications
createuser --interactive
PostgreSQL
authentication system requires for each role to have a database associated with it. Let's create the required database with same name as your role:For example:createdb <your_user_name>
We will assume from now on that your user is named as "tdms_user"createdb tdms_user
- To log in with the new user, you will need a Linux user with the same username, if you already have a user with the same name, then skip this step:
sudo adduser tdms_user
- Once this account is created, log in to this user:
sudo -i -u tdms_user
- Now let's log in to the
PostgreSQL
shell:psql
- To connect with a different database, run:where "some_other_db" is the name of another database.
psql -d some_other_db
Allowing remote connections on PostgreSQL
To allow remote connections to your PostgreSQL
server, you need to know your cluster version.
To find the clusters available, run:
sudo pg_lsclusters
Now for your particular cluster you need to update its configuration files. Let's assume you want to allow remote connections for the cluster version 12
In the file
/etc/postgresql/12/main/postgresql.conf
, allow your CloudTDMS IPv4 address by changing the following line:listen_addresses='localhost'
to
listen_addresses='<your_tdms_ip_address>'
where you need to replace "<your_tdms_ip_address>" with the IP address of your CloudTDMS server
In the file
/etc/postgresql/12/main/pg_hba.conf
, allow your CloudTDMS IPv4 address by changing the following line:# IPv4 local connections:
host all all 127.0.0.1/32 md5to
# IPv4 local connections:
host all all <your_tdms_ip_address>/32 md5where you need to replace "<your_tdms_ip_address>" with the IP address of your CloudTDMS server
Restart your cluster:
sudo pg_ctlcluter 12 main restart
Here again we assume you are restarting cluster with version 12
Setting up your PostgreSQL storage on CloudTDMS
Open the storages
tab and insert the following values for your new PostgreSQL storage
Name
: Name for the storage.Hostname
: Domain Name or IPv4 address of yourPostgreSQL
serverPort
: The port on which yourPostgreSQL
server is listening for storages (default is 5432).Username
: Username of yourPostgreSQL
server.Password
: Password of yourPostgreSQL
user.Database
: The database name.