Setup postgresql92 » Historie » Revision 5
« Zurück |
Revision 5/6
(Vergleich)
| Weiter »
Jeremias Keihsler, 12.04.2019 16:59
Install Procedure for PostgreSQL 9.2¶
Requirements¶
To install postgresql you will need the following:- a installed and supported operating system (e.g. CentOS 7.x)
- root-access
- a fast internet connection
Preliminary Note¶
This procedure is based on a documentation supplied by- https://www.if-not-true-then-false.com/2012/install-postgresql-on-fedora-centos-red-hat-rhel/
- https://www.linode.com/docs/databases/postgresql/how-to-install-postgresql-relational-databases-on-centos-7/
Install¶
Install postgresql and postgresql-server packages on CentOS 6.x:¶
yum install postgresql postgresql-server postgresql-libs postgresql-contrib postgresql-devel
Configure PostgreSQL 9.2 Database Server¶
Initialize the cluster first with initdb command:
/usr/bin/postgresql-setup initdb
Edit /var/lib/pgsql/data/postgresql.conf file:
vim /var/lib/pgsql/data/postgresql.conf
Set PostgreSQL server to listen all addresses and Change PostgreSQL port (default is 5432). Add/Uncomment/Edit following lines:
...
listen_addresses = '*'
...
port = 5432
...
Edit /var/lib/pgsql/data/pg_hba.conf file:
vim /var/lib/pgsql/data/pg_hba.conf
Add (example) your local network with md5 passwords:
...
# Local networks
local all all trust
host all all xx.xx.xx.xx/xx md5
# Example
host all all 10.20.4.0/24 md5
host all mes 0.0.0.0/0 md5
manually start PostgreSQL Server:
systemctl start postgresql.service
automatically start the service at boot time:
systemctl enable postgresql.service
you can check the runlevels by
systemctl is-enabled postgresql.service
Change to postgres user:
su - postgres
Create test database (as postgres user):
createdb test
Login test database (as postgres user):
psql test
Create New “testuser” Role with Superuser and Password:
CREATE ROLE testuser WITH SUPERUSER LOGIN PASSWORD 'test';
logout from
psql
by \q
configure firewall¶
Open PostgreSQL Port (5432) on Iptables Firewall (as root user again)
firewall-cmd --permanent --add-port=10050/tcp --zone=public
firewall-cmd --reload
Usage¶
Test remote connection:
psql -h dbserver -U testuser test
Post Installation Steps¶
DON'T FORGET TO REMOVE testuser
BEFORE GOING TO PRODUCTION
dropuser testuser
DON'T FORGET TO SETUP vacuum
BEFORE GOING TO PRODUCTION
vacuumdb -a -U postgres -z -v
maybe with a cron-job
OR
as autovacuum
is working by default, let's get some log-entries to see it actually working by changing postgres.conf
log_autovacuum_min_duration = 10
you can check the settings of the database by
su - postgres
psql test
psql# show all;
Von Jeremias Keihsler vor mehr als 5 Jahren aktualisiert · 5 Revisionen