A.
INSTALASI POSTGRESQL :
1.
Login kedalam sistem linux :
sani@sanilaptop:~$
2.
Masuk ke dalam direktori Downloads :
sani@sanilaptop:~$
cd Downloads/
3.
Pastikan paket postgresql-9.3.1.tar.gz sudah tersedia atau belum pada
direktori Downloads :
sani@sanilaptop:~/Downloads$
ls
1385515_317577291718559_1641401235_n.jpg
7.Manajemen
Memory.pdf
AJP.gif
ajpp.png
Bab_III.pdf
BBM
v1.0.0.70.-(androidesia-blogspot-com.apk
bootstrap-3.0.0.zip
contact.html~
elegant_green_vcard-PSD_template.zip
free-template-Whirlpool_site
grand
design
laporan_worksheet3.odt
Makalah
Lingkungan Manajemen.docx
MANAJEMEN_MEMORI.ppt
'Marry
Your Daughter' by Brian McNight.html
mnjmemori-up.pdf
Pengantar
Jaringan komputer.odp
postgresql-9.3.1.tar.gz
Presentasi
MySQL.pdf
tugas-akutansi-3a.odt
USER_MANAJEMEN.pdf
USER_ROLE_GROUP.pdf
4.
Urai paket tarball postgresql-9.3.0.tar.gz hasil Downloads :
sani@sanilaptop:~/Downloads$
tar -xzvf postgresql-9.3.1.tar.gz -C /home/sani/
5.
Masuk kedalam direktori hasil urai paket tarball
postgresql-9.3.0.tar.gz yaitu direktori postgresql-9.3.0 :
sani@sanilaptop:~$
cd postgresql-9.3.1/
6.
Lihat seluruh isi direktori postgresql-9.3.1 :
sani@sanilaptop:~/postgresql-9.3.1$
ls
aclocal.m4
config configure configure.in contrib COPYRIGHT doc
GNUmakefile.in HISTORY INSTALL Makefile README src
7.
Jalankan perintah berikut ini untuk configure PostgreSQL-9.3
yang akan diinstall dalam direktori /home/siswa/pg93 ( pastikan
direktori pg93 belum pernah ada )
sani@sanilaptop:~/postgresql-9.3.1$
./configure–prefix=/home/sani/pg931
“
Jika tidak
berhasil, maka harus meng-install libreadline6 terlebih dahulu “
|
8.
Install paket library yang dibutuhkan (libreadline6) :
sani@sanilaptop:~/postgresql-9.3.1$
sudo apt-get install libreadline6 libreadline6-dev
[sudo]
password for sani:
Reading
package lists... Done
Building
dependency tree
...
...
Jika
instalasasi'a gagal, maka harus menginstall library lainnya
seperti sudo apt-get install zlib1g-dev
jika
sudah make dan siap di install, maka lanjutkan untuk menginstall
make
|
9.
Jalankan perintah compile source program PostgreSQL :
sani@sanilaptop:~/postgresql-9.3.1$
make
10.
Instalasi PostgreSQL harus dilakukan oleh super user dengan
menjalankan perintah sudo :
sani@sanilaptop:~/postgresql-9.3.1$
sudo make install
make[1]:
Leaving directory `/home/sani/postgresql-9.3.1/config'
PostgreSQL
installation complete.
Jika
mendapatkan pesan seperti diatas maka binary program PostgreSQL
telah sukses
diinstall
dikomputer anda dalam direktori /home/siswa/pg93
|
B.
DIREKTORI CLUSTER DATA
1.
Buat direktori cluster data yang didalamnya akan tersimpan file-file
konfigurasi dan binary basis data dari sistem database PostgreSQL :
sani@sanilaptop:~$
/home/siswa
sani@sanilaptop:~$
mkdir pgdata
2.
Jalankan perintah inisialisasi cluster data di direktori pgdata :
sani@sanilaptop:~$
/home/sani/pg931/bin/initdb -D pgdata
The
files belonging to this database system will be owned by user "sani".
This
user must also own the server process
...
...
Success.
You can now start the database server using:
/home/sani/pg931/bin/postgres
-D pgdata
or
/home/sani/pg931/bin/pg_ctl
-D pgdata -l logfile start
3.
Jalankan service PostgreSQL :
sani@sanilaptop:~$
/home/sani/pg931/bin/pg_ctl -D /home/sani/pgdata/ -l
/home/sani/pgsani@sanilaptop:data/logfile.log start
server
starting
4.
Cek status service PostgreSQL :
sani@sanilaptop:~$
/home/sani/pg931/bin/pg_ctl -D /home/sani/pgdata/ -l
/home/sani/pgsani@sanilaptop:data/logfile.log status
pg_ctl:
server is running (PID: 5224)
/home/sani/pg931/bin/postgres
"-D" "/home/sani/pgdata"
5.
Stop service PostgreSQL :
sani@sanilaptop:~$
/home/sani/pg931/bin/pg_ctl -D /home/sani/pgdata/ -l
/home/sani/pgsani@sanilaptop:data/logfile.log status
waiting
for server to shut down.... done
server
stopped
C.
SETTING KONEKSI & UBAH PORT
1.
Ubah setingan koneksi database agar bisa diakses lewat komputer
lokal, dengan cara mengedit file pg_hba.conf
sani@sanilaptop:~$
gedit pgdata/pg_hba.conf
-
aktifkan koneksi dengan membuka konfigurasi listen_addreses dengan
menghapus tanda pagar listen_addresses = 'localhost'
-
ubah port cluster postgresql anda di port 5454 (hilangkan tanda pagar
dan ubah menjadi 5454)
port
= 5454
2.
restart service PostgreSQL :
sani@sanilaptop:~$
/home/sani/pg931/bin/pg_ctl -D /home/sani/pgdata/ -l
/home/sani/pgsani@sanilaptop:data/logfile.log restart
waiting
for server to shut down.... done
server
stopped
server
starting
3.
Login ke database template1 :
sani@sanilaptop:~$
/home/sani/pg931/bin/psql template1 -h localhost -p 5454
psql
(9.3.1)
Type
"help" for help.
template1=#
4.Seting
password super user sani :
template1=#
alter user sani with password 'password';
ALTER
ROLE
5.
Keluar dari prompt postgresql
template1=#
\q
D.
AKTIFKAN KONFIGURASI DENGAN PASSWORD
1.
Buka file konfigurasi pg_hba.conf dan ubah dibagian terakhir file
method otentikasi dari trust menjadi password :
sani@sanilaptop:~$
gedit pgdata/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 password
#
IPv6 local connections:
host
all all ::1/128 password
2.
Restart Service PostgreSQL :
sani@sanilaptop:~$
/home/sani/pg931/bin/pg_ctl -D /home/sani/pgdata/ -l
/home/sani/pgdata/logfile.log restart
waiting
for server to shut down.... done
server
stopped
server
starting
E.
BUAT USER POSTGRESQL
1.
Login ke database server :
sani@sanilaptop:~$
/home/sani/pg931/bin/psql template1 -h localhost -p 5454
Password:
(password sani 'password' )
psql
(9.3.1)
Type
"help" for help.
template1=#
2.Buat
user ahmad dengan password '1234':
template1=#
CREATE USER ahmad WITH PASSWORD '1234' CREATEDB ;
CREATE
ROLE
template1=#\q
3.
User ahmad buat database dblatihan :
sani@sanilaptop:~$
/home/siswa/pg93/bin/createdb dblatihan -U ahmad -h localhost -p 5454
4.
User ahmad login kedatabase dblatihan :
sani@sanilaptop:~$
/home/sani/pg931/bin/psql dblatihan -U ahmad -h localhost -p 5454
Password
for user ahmad:
psql
(9.3.1)
Type
"help" for help.
dblatihan=>
\q
===
Membuat file pg931_start.sh agar mudah saat login sehingga tidak
panjang ===
sani@sanilaptop:~$
gedit pg931_start.sh
isinya
:
/home/sani/pg931/bin/pg_ctl
-D /home/sani/pgdata/ -l /home/sani/pgdata/logfile.log start
===
Membuat file pg931_restart.sh agar mudah saat restart service
sehingga tidak panjang ===
sani@sanilaptop:~$
gedit pg931_restart.sh
isinya
:
/home/sani/pg931/bin/pg_ctl
-D /home/sani/pgdata/ -l /home/sani/pgdata/logfile.log restart
===
Membuat file pg931_stop.sh agar mudah saat menghentikan service
sehingga tidak panjang ===
sani@sanilaptop:~$
gedit pg931_stop.sh
isinya
:
/home/sani/pg931/bin/pg_ctl
-D /home/sani/pgdata/ -l /home/sani/pgdata/logfile.log stop
===
Memberi Permision kepada seluruh yang mengandung pg931 ===
sani@sanilaptop:~$
chmod 755 pg931_*