-
Notifications
You must be signed in to change notification settings - Fork 9
Installation Step 1
Quickest way to get PGSQL is to use apt-get utility.
sudo apt-get update
sudo apt-get install postgresql postgresql-contrib
In order to install and configure a cluster of PGSQL servers, follow the original documentation on http://postgresql.org
To start, stop or restart PGSQL use the /etc/init.d/postgresql script:
# /etc/init.d/postgresql start
user@host:/etc/init.d$ sudo ./postgresql start
Verify PGSQL operation with:
postgresql status
Which version of PGSQL you get by default will depend on the version of the distribution. You may use PostgreSQL Yum Repository, if the version supplied by your operating system is not the one you want. The PostgreSQL Yum repository currently supports many Linux and Unix distributions.
In order to use the PostgreSQL Yum Repository repository, you must first install the repository RPM. For example download the 9.5 RPM from the repository RPM listing, and install it with commands:
yum install http://yum.postgresql.org/9.5/redhat/rhel-7-x86_64/pgdg-redhat95-9.5-2.noarch.rpm
sudo /usr/pgsql-9.5/bin/postgresql95-setup initdb
Enable PostgerSQL 9.5 and start:
sudo systemctl list-unit-files | grep postgresql
sudo systemctl enable postgresql-9.5.service
sudo systemctl start postgresql-9.5.service
Check your work:
service postgresql-9.5 status
psql --version
continue with recommended DB configuration and tuning as follows:
Configure proper authentication for network and local connections in /var/lib/pgsql/9.5/data/pg_hba.conf:
# TYPE DATABASE USER ADDRESS METHOD
# "local" is for Unix domain socket connections only
local all all password
# IPv4 local connections:
host all all 127.0.0.1/32 md5
# IPv6 local connections:
host all all ::1/128 md5
# Allow replication connections from localhost, by a user with the
# replication privilege.
#local replication postgres peer
#host replication postgres 127.0.0.1/32 ident
#host replication postgres ::1/128 ident
Tune Postgresql performance by editing in /etc/postgresql/9.5/main/postgresql.conf:
synchronous_commit = off
shared_buffers = 128MB
wal_buffers = 1024kB
wal_writer_delay = 1000ms
autovacuum = on
autovacuum_max_workers = 3
autovacuum_naptime = 10min
autovacuum_vacuum_threshold = 1000
autovacuum_analyze_threshold = 500
Restart postgres or reboot the system now to verify the PGSQL start automatically with new settings.
In order to check the PGSQL logs look at /var/lib/pgsql/9.5/data/pg_log