install PostgreSQL on CentOS7

1. Install (  2015-04-21 > 최신 버전은 9.4  )

[root@localhost ~]# rpm -Uvh http://yum.postgresql.org/9.4/redhat/rhel-7-x86_64/pgdg-centos94-9.4-1.noarch.rpm
http://yum.postgresql.org/9.4/redhat/rhel-7-x86_64/pgdg-centos94-9.4-1.noarch.rpm(을)를 복구합니다
경고: /var/tmp/rpm-tmp.z0BMz8: Header V4 DSA/SHA1 Signature, key ID 442df0f8: NOKEY
준비 중…                         ################################# [100%]
Updating / installing…
1:pgdg-centos94-9.4-1              ################################# [100%]
[root@localhost ~]# yum install postgresql94 postgresql94-server postgresql94-libs postgresql94-contrib postgresql94
Loaded plugins: fastestmirror, langpacks
http://linuxdownload.adobe.com/linux/x86_64/repodata/repomd.xml: [Errno 14] curl#6 – “Could not resolve host: linuxdownload.adobe.com; 이름 혹은 서비스를 알 수 없습니다”
Trying other mirror.
http://mirror.oasis.onnetcorp.com/centos/7.1.1503/os/x86_64/repodata/repomd.xml: [Errno 12] Timeout on http://mirror.oasis.onnetcorp.com/centos/7.1.1503/os/x86_64/repodata/repomd.xml: (28, ‘Resolving timed out after 30383 milliseconds’)
Trying other mirror.
base                                                                                                                        | 3.6 kB  00:00:00
epel/x86_64/metalink                                                                                      | 4.4 kB  00:00:00
epel                                                                                                                        | 4.4 kB  00:00:00
extras                                                                                                                     | 3.4 kB  00:00:00
.
.
.

2. Configure

Initialize the PostgreSQL.

[root@itzgeek~/]# /usr/pgsql-9.4/bin/postgresql94-setup initdb

PostgreSQL normally listens on the localhosts only, if would you like to enable the PostgreSQL to listen on all ip addresses; edit the /var/lib/pgsql/9.1/data/postgresql.conf .

[root@itzgeek~/]# vi /var/lib/pgsql/9.4/data/postgresql.conf

Go to Connections and Communications section, find the “listen_address” variable. Uncomment the “listen_addresses” and place “*” instead of “localhost”

Before editing:

#listen_addresses = "localhost"

After editing:

listen_addresses = "*"

Add your network to access database remotely; Edit  /var/lib/pgsql/9.4/data/pg_hba.conf.

[root@itzgeek~/]#  vi /var/lib/pgsql/9.4/data/pg_hba.conf

Add the following line according to your network configuration with md5 password authentication (Enable remote access of database).

# IPv4 local connections:
host    all             all             127.0.0.1/32            md5
host    all             all             107.155.94.0/24         md5
# IPv6 local connections:
host    all             all             ::1/128                 md5

Restart the PostgreSQL server.

[root@itzgeek~/]# systemctl start postgresql-9.4.service

Confirm the PostgreSQL listening.

[root@itzgeek ~/]# netstat -antup | grep 5432
tcp        0      0 0.0.0.0:5432            0.0.0.0:*               LISTEN      39620/postgres
tcp6       0      0 :::5432                 :::*                    LISTEN      39620/postgres

Auto start the service on startup.

[root@itzgeek~/]# systemctl enable postgresql-9.4.service

Creating Database:

Login as postgres user.

[root@geeksite~/]$ su -l postgres

create the database called “test”

-bash-4.2$ createdb test

Login into the database.

-bash-4.2$ psql test

Create a new user called “raj” to manage the databases.

test=# CREATE USER raj WITH SUPERUSER LOGIN PASSWORD 'raj';

Login with the superuser.

sam@geeksite~/$ psql -h localhost -d test -U raj

That’s all!. You have successfully installed