Вы здесь

Install PostgreSQL 9.4 on Fedora 23/22, CentOS/RHEL/SL 7.2/6.7/5.11

This is guide, howto install PostgreSQL 9.4 (currently 9.4.5) database server on Fedora 23/22/21/20/19, CentOS/Red Hat (RHEL)/Scientific Linux (SL) 7.2/6.7/5.11. This guide uses PostgreSQL own YUM repos, which are always up-to-date and stable releases are available instantly.

Note: If you are upgrading PostgresSQL (from earlier version), then make sure that you backup (dump and copy) your database and configs.

1. Install PostgreSQL 9.4.5 Database Server on Fedora 23/22/21/20/19, CentOS/Red Hat (RHEL)/Scientific Linux (SL) 7.2/6.7/5.11

1.1 Change root user

1.2 Exclude Fedora, CentOS, Red Hat (RHEL) and Scientific Linux (SL) own PostgreSQL Packages

This is important step to get PostgreSQL repository working properly. Exclude PostgreSQL packages from the repository of the distro.

Fedora

Add exclude to /etc/yum.repos.d/fedora.repo file [fedora] section:

Add exclude to /etc/yum.repos.d/fedora-updates.repo file [updates] section:

CentOS

Add exclude to /etc/yum.repos.d/CentOS-Base.repo file [base] and [updates] sections:

Red Hat (RHEL)

Add exclude to /etc/yum/pluginconf.d/rhnplugin.conf file [main] section:

Scientific Linux (SL)

Add exclude to /etc/yum.repos.d/sl.repo file [sl] and [sl-security] sections:

1.3 Install PostgreSQL 9.4 Repository

Fedora

CentOS 7.2/6.7/5.11

Red Hat (RHEL) 7.2/6.7/5.11

Scientific Linux (SL) 7.2/6.7/5.11

1.4 Install PostgreSQL 9.4 with DNF/YUM

2. Configure PostgreSQL 9.4

2.1 Initialize Cluster with initdb Command

Here is multiple alternatives howto do this (like service postgresql-9.x initdb/etc/init.d/postgresql-9.x initdb) and postgresql-setup initdb, so that’s why I use here universal PostgreSQL initdb method, which should work with Fedora 23/22/21/20/19, CentOS/Red Hat (RHEL)/Scientific Linux (SL) 7.2/6.7/5.11:

2.2 Set PostgreSQL Server to Listen Addresses and Set Port

Open /var/lib/pgsql/9.4/data/postgresql.conf file, and add/uncomment/modify following:

If you want just localhost setup, then use following:

 

Or if you want use specific ip, then use following:

 

 

2.3 Set PostgreSQL Permissions

Modify PostgreSQL /var/lib/pgsql/9.4/data/pg_hba.conf (host-based authentication) file:

You can find more examples and full guide from PostgreSQL pg_hba.conf manual.

 

2.4 Start PostgreSQL Server and Autostart PostgreSQL on Boot

Fedora 23/22/21/20/19 and CentOS/Red Hat (RHEL)/Scientific Linux (SL) 7.2

 

 

CentOS/Red Hat (RHEL)/Scientific Linux (SL) 6.7/5.11

 

2.5 Create Test Database and Create New User

Change to postgres user

Create test database (as postgres user)

Login test database (as postgres user)

Create New “testuser” Role with Superuser and Password

Test Connection from localhost (as Normal Linux User)

 

3. Enable Remote Connections to PostgreSQL Server –> Open PostgreSQL Port (5432) on Iptables Firewall

3.1. CentOS/Red Hat (RHEL) 6.7/5.11

3.1.1 Edit /etc/sysconfig/iptables file:

3.1.2 Add following INPUT rule:

3.1.3 Restart Iptables Firewall:

3.2. Fedora 23/22/21/20/19 and CentOS/Red Hat (RHEL) 7.2

 

3.2.1 List Your Active Firewalld Zones

Example output:

3.2.2 Add New Rule to Firewalld

You might have active zone like public, FedoraWorkstation, FedoraServer.

3.2.3 Restart firewalld.service

4. Test remote connection

Note: You have to allow remote connections on pg_hba.conf, check step 2.3 and PostgreSQL pg_hba.conf manual.

PostgreSQL_teg: 

Post new comment

Filtered HTML

  • Адреса страниц и электронной почты автоматически преобразуются в ссылки.
  • Разрешённые HTML-теги: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Строки и параграфы переносятся автоматически.

Plain text

  • HTML-теги не обрабатываются и показываются как обычный текст
  • Адреса страниц и электронной почты автоматически преобразуются в ссылки.
  • Строки и параграфы переносятся автоматически.
CAPTCHA
Этот вопрос задается для того, чтобы выяснить, являетесь ли Вы человеком или представляете из себя автоматическую спам-рассылку.
6 + 14 =
Решите эту простую математическую задачу и введите результат. Например, для 1+3, введите 4.