Your Own Machines
Deploy on existing servers
This method is suitable for deployment on existing servers, whether with another cloud provider or in your own data center.
Prerequisites
You will need root
access or a user with sudo
privileges to access the servers via SSH. You can use your private SSH key (assuming the corresponding public key has already been added to the servers), or a username and password if password access is enabled on your servers.
See also the Requirements and Compatibility pages.
Deployment
- Console (UI)
- Command line
Select 'Your Own Machines' in the deployment destination.
Specify the name and IP addresses of your servers.
Use private IP addresses so that the cluster does not listen a public IP.
Example:
Please note that at least 3 servers are required to ensure high availability.
Select authentication method.
Optionally, specify an IP address to provide a single entry point for client access to databases in the cluster.
Example:
This must be an IP address that is currently unused on your network. The address will be assigned to the cluster after deployment.
Not for cloud environments. Because VIP-based solutions like keepalived
or vip-manager
may not works in such environments.
Optionally, check the box for "HAProxy load balancer".
This feature supports load balancing for read operations, facilitating effective scale-out strategies through the use of read-only replicas. See the details on the Architecture page
Choose which environment your database cluster belongs to.
Specify a name for your cluster.
Optionally, specify a description.
Select the PostgreSQL version to install.
Review the summary and click the "CREATE CLUSTER" button.
Wait until deployment is complete. This process takes about 10 minutes.
You can see the deployment log in the "Operations" section. To do this, select the relevant event with the "deploy" type and click "Show details" under the Actions tab.
After a successful deployment, you can obtain the connection info on the cluster page. To do this, click on the name of your cluster on the "Clusters" page.
Example of a cluster page:
We also support converting your existing PostgreSQL installation into a high-availability cluster. If you want to upgrade your current PostgreSQL setup to a clustered configuration, simply set postgresql_exists=true
in the inventory file.
Please note that during the cluster setup process, your existing PostgreSQL service will be automatically restarted, leading to a brief period of database downtime. Plan this transition accordingly.
- Edit the
inventory
file
Specify IP addresses and connection settings (ansible_user
, ansible_ssh_pass
, or ansible_ssh_private_key_file
) for your environment:
nano inventory
- Edit the variable file
vars/main.yml
nano vars/main.yml
Minimum set of variables:
proxy_env
to download packages in environments without direct internet access (optional)patroni_cluster_name
postgresql_version
postgresql_data_dir
cluster_vip
to provide a single entry point for client access to databases in the cluster (optional)with_haproxy_load_balancing
to enable load balancing (optional)dcs_type
"etcd" (default) or "consul"
See the vars/main.yml, system.yml and (Debian.yml or RedHat.yml) files for more details.
- Try to connect to hosts
ansible all -m ping
- Run playbook:
ansible-playbook deploy_pgcluster.yml
Deploy Cluster with TimescaleDB
To deploy a PostgreSQL High-Availability Cluster with the TimescaleDB extension, add the enable_timescale
variable:
Example:
ansible-playbook deploy_pgcluster.yml -e "enable_timescale=true"