RPM 설치
yum install postgresql-server
postgresql-server-9.6.1-1.el7.x86_64
postgresql-libs-9.6.1-1.el7.x86_64
postgresql-9.6.1-1.el7.x86_64
OS 그룹, 유저 추가
root user 에서 수행
groupadd dba
useradd -g dba -s /bin/bash -d /data/postgres postgres
PostgreSQL 클러스터 초기화
/usr/pgsql-9.6/bin/pg_ctl initdb -D /data/postgres/data
-D 옵션에 해당하는 디렉토리가 존재하면 안 된다.
[postgres@testdb02:~]$ /usr/pgsql-9.6/bin/pg_ctl initdb -D /data/postgres/data The database cluster will be initialized with locale "en_US.UTF-8". Data page checksums are disabled. creating directory /data/postgres/data ... ok WARNING: enabling "trust" authentication for local connections Success. You can now start the database server using: |
Parameter 수정
cd ..data
vi postgresql.conf
-- 재시작 필요
max_connections = 100
shared_buffers = 128MB --> TOTAL 8GB 의 경우 2GB 로 셋팅
hba.conf 수정
기존 셋팅 삭제하고 아래 config 만 넣음
local all all md5
사용자편의 스크립트 구성
-- vi startup.sh
/usr/pgsql-9.6/bin/pg_ctl start -D /data/postgres/data -l /data/postgres/postgres.log
-- vi shutdown.sh
/usr/pgsql-9.6/bin/pg_ctl stop -D /data/postgres/data -l /data/postgres/postgres.log
-- vi reload.sh
/usr/pgsql-9.6/bin/pg_ctl reload -D /data/postgres/data -l /data/postgres/postgres.log
구동 문제 시
[postgres@testdb02:~]$ cat postgres.log
< 2017-05-18 15:50:02.528 KST > FATAL: could not create lock file "/var/run/postgresql/.s.PGSQL.5432.lock": No such file or directory
< 2017-05-18 15:50:02.529 KST > LOG: database system is shut down
/var/run/postgresql 디렉토리가 존재하면 삭제하고,
postgresql owner, group 으로 디렉토리를 생성합니다.