Overview

In this section, we will configure the virtual machines and install, and configure the environment. In the other other sections we will play with the environment.

We will use:

Vagrant - For Virtualization

Ubuntu - For Operation System

2nd Quandrant - For Rempgr

Virtual Environment Config

To configure the Virtual Environment, we will use Vagrant and Ubuntu machines. You can configure the following vagrant file:

Vagrant Config

The vagrant file is the following:

Vagrant file

Once the machines are up, we can start with the installation. Bare in mind that this vagrant will automatically configure the IPs as well, but will not configure /etc/hosts. Something which we will do now.

Server Config

For the servers we have to:

Configure /etc/hosts

Configure 2nd Quadrant Repository

Install 2nd Quadrant Packages

So, let's get going.

Modify /etc/hosts

That is pretty trivial, just add the IPs and the hostnames to /etc/hosts:

Hosts

That will allow, the hosts to see and ping each other.

Then we can configure the repositories:

Configure Repositories

I decided to use 2nd quadrant packages, as they are the ones I use for work as well :) First thing first, we have to update our repos and pull the latest metadata from them.

Update repos

Install PostgreSQL

Then we can proceed with installation of PostgreSQL

Install PostgreSQL

Do this on both machines: server1 and server2

Install REPMGR Repos

Then we can proceed with adding the repo for REPMGR

Add REPMGR Repo

Configure SSH keys

To configure passwordless connection, we have to:

Generate public / private key pair

Put the public key in the authorized keys on the other host (e.g. the public key of server1, in the authorized_keys file on server2)

So let's get going:

Generate Public/Private Key pair

This will generate us two files: Private and Public key. Private key, NEVER SHARE :)

Keys

The content of that server and put it in the authorized_keys file of server1 and vica versa:

Add public key to server1

After you do that on both servers, you can connect without password:

Test Passwordless Configuration

Cluster Environment

After we've installed and configured all the packages, we can proceed with cluster configuration. Firstly, we have to configure the database and the users:

Configure User

The user to be used for the replication can be configured as so:

Replication User Configuration

Do that on both servers.

After, we have done that, we can configure security connection to the PostgreSQL in pg_hba.conf

Connection Configuration

To allow repmgr user to be able to connect to PostgreSQL, we need to append to the pg_hba.conf file the following entries.

Configure pg_hba.conf

We can test the settings as follows:

Test connections

Do that on both servers, to verify the configuration.