Pra installasi :
IP
|
10.1.XX.XX
|
OS
|
Linux
xxxxxxx015 3.10.0-514.el7.x86_64 #1 SMP
Wed Oct 19 11:24:13 EDT 2016 x86_64 x86_64 x86_64 GNU/Linux
|
User
OS
|
Postgre (sudoer)
|
1. Siapkan rpm dari situs resmi postgresql
[postgre@xxxxxx ~]$ pwd
/home/postgre
[postgre@xxxxxx ~]$ cd 9.5-9/
[postgre@xxxxxx 9.5-9]$ ls
postgresql95-9.5.9-1PGDG.rhel7.x86_64.rpm
postgresql95-contrib-9.5.9-1PGDG.rhel7.x86_64.rpm
postgresql95-libs-9.5.9-1PGDG.rhel7.x86_64.rpm
postgresql95-odbc-09.06.0100-1PGDG.rhel7.x86_64.rpm
postgresql95-server-9.5.9-1PGDG.rhel7.x86_64.rpm
2. Installasi rpm postgresql
[postgre@xxxxxx 9.5-9]$ sudo su -
[sudo] password for postgre:
Last login: Mon Apr 16 14:39:37 WIB 2018 on pts/2
[root@xxxxxx ~]# pwd
/root
[root@xxxxxx ~]# cd /home/postgre/9.5-9/
[root@xxxxxx 9.5-9]# rpm -Uvh postgresql95-libs-9.5.9-1PGDG.rhel7.x86_64.rpm
warning: postgresql95-libs-9.5.9-1PGDG.rhel7.x86_64.rpm: Header V4 DSA/SHA1 Signature, key ID 442df0f8: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:postgresql95-libs-9.5.9-1PGDG.rhe################################# [100%]
[root@xxxxxx 9.5-9]# rpm -Uvh postgresql95-9.5.9-1PGDG.rhel7.x86_64.rpm
warning: postgresql95-9.5.9-1PGDG.rhel7.x86_64.rpm: Header V4 DSA/SHA1 Signature, key ID 442df0f8: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:postgresql95-9.5.9-1PGDG.rhel7 ################################# [100%]
[root@xxxxxx 9.5-9]# rpm -Uvh postgresql95-server-9.5.9-1PGDG.rhel7.x86_64.rpm
warning: postgresql95-server-9.5.9-1PGDG.rhel7.x86_64.rpm: Header V4 DSA/SHA1 Si gnature, key ID 442df0f8: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:postgresql95-server-9.5.9-1PGDG.r################################# [100%]
[root@xxxxxx 9.5-9]# rpm -Uvh postgresql95-contrib-9.5.9-1PGDG.rhel7.x86_64.rpm
warning: postgresql95-contrib-9.5.9-1PGDG.rhel7.x86_64.rpm: Header V4 DSA/SHA1 S ignature, key ID 442df0f8: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:postgresql95-contrib-9.5.9-1PGDG.################################# [100%]
[root@xxxxxx 9.5-9]#
3. Inisialisasi PGDATA
[root@xxxxxx 9.5-9]# /usr/pgsql-9.5/bin/postgresql95-setup initdb
Initializing database ... OK
[root@xxxxxx bin]#
4. Edit /var/lib/pgsql/9.5/data/postgresql.conf
Tambahkan command berikut di postgresql.conf
listen_addresses = '*'
port = 5432
5. Edit /var/lib/pgsql/9.5/data/pg_hba.conf
Tambahkan command berikut di pg_hba.conf
host all all 0.0.0.0/0 md5
6. Mencoba Start service postgresql
[root@localhost ~]# systemctl start postgresql-9.5.service
7. Stop service postgresql
[root@localhost ~]# systemctl stop postgresql-9.5.service
8. Pindahkan data direktori postgres ke /data/PROD_POSTGRE/
cp -rp /var/lib/pgsql/ /data/
cd /data/
mv pgsql PROD_POSTGRE
9. Edit file postgresql-9.5.service di /usr/lib/systemd/system
vi /usr/lib/systemd/system/postgresql-9.5.service
ubah script
Environment=PGDATA=/var/lib/pgsql/9.5/data/
Menjadi
Environment=PGDATA=/data/PROD_POSTGRE/9.5/data/
10. Start service postgresql
[root@localhost ~]# systemctl start postgresql-9.5.service
[root@xxxxxx system]# systemctl status postgresql-9.5.service
● postgresql-9.5.service - PostgreSQL 9.5 database server
Loaded: loaded (/usr/lib/systemd/system/postgresql-9.5.service; disabled; vendor preset: disabled)
Active: active (running) since Mon 2018-04-16 16:18:20 WIB; 1min 3s ago
Process: 4460 ExecStart=/usr/pgsql-9.5/bin/pg_ctl start -D ${PGDATA} -s -w -t 300 (code=exited, status=0/SUCCESS)
Process: 4452 ExecStartPre=/usr/pgsql-9.5/bin/postgresql95-check-db-dir ${PGDATA} (code=exited, status=0/SUCCESS)
Main PID: 4463 (postgres)
CGroup: /system.slice/postgresql-9.5.service
├─4463 /usr/pgsql-9.5/bin/postgres -D /data/PROD_POSTGRE/9.5/data
├─4464 postgres: logger process
├─4466 postgres: checkpointer process
├─4467 postgres: writer process
├─4468 postgres: wal writer process
├─4469 postgres: autovacuum launcher process
└─4470 postgres: stats collector process
Apr 16 16:18:19 xxxxxx systemd[1]: Starting PostgreSQL 9.5 database s....
Apr 16 16:18:19 xxxxxx pg_ctl[4460]: < 2018-04-16 16:18:19.716 WIB >L...s
Apr 16 16:18:19 xxxxxx pg_ctl[4460]: < 2018-04-16 16:18:19.716 WIB >H....
Apr 16 16:18:20 xxxxxx systemd[1]: Started PostgreSQL 9.5 database se....
Hint: Some lines were ellipsized, use -l to show in full.
[root@xxxxxx system]#
11. Masuk ke user postgres
su - postgres
12. Buat database dan userdatabase di postgresql
-bash-4.2$ psql
psql (9.5.9)
Type "help" for help.
postgres=# alter user postgres password ‘postgres’;
ALTER ROLE
postgres=# \q
13. Postgresql 9.5.9 siap digunakan
0 komentar