SlideShare a Scribd company logo
How to configure multiple PostgreSQL-9.3
instances on same server
-- Vivek Singh
Multiple PostgreSQL Instances on Same Server
• Steps to Create Multiple PostgreSQL Instances on Same Server
• Below are the steps to create two instances of Postgresql 9.3
version on same machine.
• In this example, one instance is for "env1" environment and the
other one is for "env2".
• 1. Create two copies of Postgres init files, one for each
environment:
• cd /etc/init.d/
• cp postgresql-9.3 postgresql-env1
• cp postgresql-9.3 postgresql-env2
• mv postgresql-9.3 postgresql-old
Multiple PostgreSQL Instances on Same Server
• 2. Create 2 files of same postgres init file names in /etc/sysconfig/pgsql/
• cat > /etc/sysconfig/pgsql/postgresql-env1 <<EOF
• PGENGINE=/usr/pgsql-9.3/bin
• PGPORT=5432
• PGDATA=/var/lib/pgsql/9.3/env1/data
• PGLOG=/var/lib/pgsql/9.3/pgstartup.5432.log
• EOF
• cat > /etc/sysconfig/pgsql/postgresql-env2 <<EOF
• PGENGINE=/usr/pgsql-9.3/bin
• PGPORT=5433
• PGDATA=/var/lib/pgsql/9.3/env2/data
• PGLOG=/var/lib/pgsql/9.3/pgstartup.5433.log
• EOF
Multiple PostgreSQL Instances on Same Server
• 3. Initialise the data directories for both
instances:
• /etc/init.d/postgresql-env1 initdb
• /etc/init.d/postgresql-env2 initdb
• 4. Change port is postgresql.conf files:
• echo "port = 5432"
>>/var/lib/pgsql/9.3/env1/data/postgresql.conf
• echo "port = 5433"
>>/var/lib/pgsql/9.3/env2/data/postgresql.conf
Multiple PostgreSQL Instances on Same Server
• 5. Start both postgres services:
• cd /etc/init.d
• service postgresql-env1 start
• service postgresql-env2 start
• 6. Add services to start up on reboot:
• chkconfig add postgresql-env1
• chkconfig add postgresql-env2
• chkconfig postgresql-env1 on
• chkconfig postgresql-env2 on
Multiple PostgreSQL Instances on Same Server
• 7. Verify ports by psql commands:
• $ psql -p5432 -c "select name, setting from
pg_settings where name ='port'"
• name | setting
• port | 5432
• $ psql -p5433 -c "select name, setting from
pg_settings where name ='port'"
• name | setting
• port | 5433
Multiple PostgreSQL Instances on Same Server
• 8. Verify postmaster processes:
• $ ps -ef | grep postmaster
• postgres 26200 1 0 21:15 ? 00:00:00
/usr/pgsql-9.3/bin/postmaster -p 5432 -D
/var/lib/pgsql/9.3/env1/data
• postgres 26265 1 0 21:16 ? 00:00:00
/usr/pgsql-9.3/bin/postmaster -p 5433 -D
/var/lib/pgsql/9.3/env2/data

More Related Content

PDF
Object Storage with Gluster
PDF
Cookbook testing with KitcenCI and Serverrspec
PDF
Declare your infrastructure: InfraKit, LinuxKit and Moby
PDF
Wordpress y Docker, de desarrollo a produccion
PPT
On MongoDB backup
PPT
Linux Backup System using rsync, tar, gzip
PDF
Subversion To Mercurial
PDF
The top 5 Kubernetes metrics to monitor
Object Storage with Gluster
Cookbook testing with KitcenCI and Serverrspec
Declare your infrastructure: InfraKit, LinuxKit and Moby
Wordpress y Docker, de desarrollo a produccion
On MongoDB backup
Linux Backup System using rsync, tar, gzip
Subversion To Mercurial
The top 5 Kubernetes metrics to monitor

What's hot (20)

PDF
Docker orchestration using core os and ansible - Ansible IL 2015
DOCX
Linux server backup solution
PPTX
OpenShift4 Installation by UPI on kvm
PDF
Quay 3.3 installation
PDF
Максим Барышиков-«WoT: Geographically distributed cluster of clusters»
ODP
Continuous Security
PPTX
Practical Glusto Example
PDF
2017-03-11 02 Денис Нелюбин. Docker & Ansible - лучшие друзья DevOps
PPTX
AWS 기반 Docker, Kubernetes
PDF
CoreOS intro
PDF
PPTX
Inside Sqale's Backend at Sapporo Ruby Kaigi 2012
ODP
Linuxday.at - Lightning Talk
PDF
Kubernetes + Docker + Elixir - Alexei Sholik, Andrew Dryga | Elixir Club Ukraine
PDF
CoreOS + Kubernetes @ All Things Open 2015
PDF
Small, Simple, and Secure: Alpine Linux under the Microscope
PDF
Warsztaty ansible
PDF
CoreOS: Control Your Fleet
DOCX
DockerCoreNet
PDF
Pythonic Deployment with Fabric 0.9
Docker orchestration using core os and ansible - Ansible IL 2015
Linux server backup solution
OpenShift4 Installation by UPI on kvm
Quay 3.3 installation
Максим Барышиков-«WoT: Geographically distributed cluster of clusters»
Continuous Security
Practical Glusto Example
2017-03-11 02 Денис Нелюбин. Docker & Ansible - лучшие друзья DevOps
AWS 기반 Docker, Kubernetes
CoreOS intro
Inside Sqale's Backend at Sapporo Ruby Kaigi 2012
Linuxday.at - Lightning Talk
Kubernetes + Docker + Elixir - Alexei Sholik, Andrew Dryga | Elixir Club Ukraine
CoreOS + Kubernetes @ All Things Open 2015
Small, Simple, and Secure: Alpine Linux under the Microscope
Warsztaty ansible
CoreOS: Control Your Fleet
DockerCoreNet
Pythonic Deployment with Fabric 0.9
Ad

Similar to How to configure multiple PostgreSQL-9 (20)

PDF
Out of the box replication in postgres 9.4(pg confus)
PDF
Out of the Box Replication in Postgres 9.4(PgConfUS)
PPTX
Why favour Icinga over Nagios - Rootconf 2015
PDF
Automating complex infrastructures with Puppet
PDF
9 steps to install and configure postgre sql from source on linux
ODP
Nagios Conference 2014 - Mike Weber - Expanding NRDS Capabilities on Linux Sy...
PDF
Testing with PostgreSQL
ODP
OpenGurukul : Database : PostgreSQL
PDF
Write php deploy everywhere tek11
PDF
Automating Complex Setups with Puppet
PDF
The Accidental DBA
PPT
Logstash
PDF
Out of the Box Replication in Postgres 9.4(PgCon)
PDF
Out of the Box Replication in Postgres 9.4(PgCon)
PDF
Out of the box replication in postgres 9.4
PDF
Out of the Box Replication in Postgres 9.4(pgconfsf)
PDF
pgpool-II demonstration
PDF
Our Puppet Story (Linuxtag 2014)
PDF
ITB2019 NGINX Overview and Technical Aspects - Kevin Jones
PPTX
Nagios Conference 2014 - Rob Hassing - How To Maintain Over 20 Monitoring App...
Out of the box replication in postgres 9.4(pg confus)
Out of the Box Replication in Postgres 9.4(PgConfUS)
Why favour Icinga over Nagios - Rootconf 2015
Automating complex infrastructures with Puppet
9 steps to install and configure postgre sql from source on linux
Nagios Conference 2014 - Mike Weber - Expanding NRDS Capabilities on Linux Sy...
Testing with PostgreSQL
OpenGurukul : Database : PostgreSQL
Write php deploy everywhere tek11
Automating Complex Setups with Puppet
The Accidental DBA
Logstash
Out of the Box Replication in Postgres 9.4(PgCon)
Out of the Box Replication in Postgres 9.4(PgCon)
Out of the box replication in postgres 9.4
Out of the Box Replication in Postgres 9.4(pgconfsf)
pgpool-II demonstration
Our Puppet Story (Linuxtag 2014)
ITB2019 NGINX Overview and Technical Aspects - Kevin Jones
Nagios Conference 2014 - Rob Hassing - How To Maintain Over 20 Monitoring App...
Ad

How to configure multiple PostgreSQL-9

  • 1. How to configure multiple PostgreSQL-9.3 instances on same server -- Vivek Singh
  • 2. Multiple PostgreSQL Instances on Same Server • Steps to Create Multiple PostgreSQL Instances on Same Server • Below are the steps to create two instances of Postgresql 9.3 version on same machine. • In this example, one instance is for "env1" environment and the other one is for "env2". • 1. Create two copies of Postgres init files, one for each environment: • cd /etc/init.d/ • cp postgresql-9.3 postgresql-env1 • cp postgresql-9.3 postgresql-env2 • mv postgresql-9.3 postgresql-old
  • 3. Multiple PostgreSQL Instances on Same Server • 2. Create 2 files of same postgres init file names in /etc/sysconfig/pgsql/ • cat > /etc/sysconfig/pgsql/postgresql-env1 <<EOF • PGENGINE=/usr/pgsql-9.3/bin • PGPORT=5432 • PGDATA=/var/lib/pgsql/9.3/env1/data • PGLOG=/var/lib/pgsql/9.3/pgstartup.5432.log • EOF • cat > /etc/sysconfig/pgsql/postgresql-env2 <<EOF • PGENGINE=/usr/pgsql-9.3/bin • PGPORT=5433 • PGDATA=/var/lib/pgsql/9.3/env2/data • PGLOG=/var/lib/pgsql/9.3/pgstartup.5433.log • EOF
  • 4. Multiple PostgreSQL Instances on Same Server • 3. Initialise the data directories for both instances: • /etc/init.d/postgresql-env1 initdb • /etc/init.d/postgresql-env2 initdb • 4. Change port is postgresql.conf files: • echo "port = 5432" >>/var/lib/pgsql/9.3/env1/data/postgresql.conf • echo "port = 5433" >>/var/lib/pgsql/9.3/env2/data/postgresql.conf
  • 5. Multiple PostgreSQL Instances on Same Server • 5. Start both postgres services: • cd /etc/init.d • service postgresql-env1 start • service postgresql-env2 start • 6. Add services to start up on reboot: • chkconfig add postgresql-env1 • chkconfig add postgresql-env2 • chkconfig postgresql-env1 on • chkconfig postgresql-env2 on
  • 6. Multiple PostgreSQL Instances on Same Server • 7. Verify ports by psql commands: • $ psql -p5432 -c "select name, setting from pg_settings where name ='port'" • name | setting • port | 5432 • $ psql -p5433 -c "select name, setting from pg_settings where name ='port'" • name | setting • port | 5433
  • 7. Multiple PostgreSQL Instances on Same Server • 8. Verify postmaster processes: • $ ps -ef | grep postmaster • postgres 26200 1 0 21:15 ? 00:00:00 /usr/pgsql-9.3/bin/postmaster -p 5432 -D /var/lib/pgsql/9.3/env1/data • postgres 26265 1 0 21:16 ? 00:00:00 /usr/pgsql-9.3/bin/postmaster -p 5433 -D /var/lib/pgsql/9.3/env2/data