/******************************************************************************
-- Title : [9.2] PostgreSQL 패키지를 이용한 설치 - ver.dBRang
-- Reference : http://opensourcedbms.com/dbms/installing-postgresql-9-2-on-cent-os-6-3-...
-- Key word : pgsql postgresql DB설치 DB 설치
*******************************************************************************/
-- 1. YUM 업데이트
# yum update
-- 2. 패키지(.rpm) 다운로드
ㅇ "http://yum.pgrpms.org/reporpms/"에서 해당 패키지(PostgreSQL 9.2 - CentOS 확인
ㅇ 해당 파일에서 속성을 통해 경로 Copy As below:
"http://yum.pgrpms.org/9.2/redhat/rhel-6-i386/pgdg-centos92-9.2-6.noarch.rpm"
# wget http://yum.pgrpms.org/9.2/redhat/rhel-6-i386/pgdg-centos92-9.2-6.noarch.rpm
ㅇ wget 튜일리티 설치 필요시
# yum install wget
-- 3. 패키지 설치
# rpm -ivh pgdg-centos92-9.2-6.noarch.rpm
-- 4. 패키지 설치 확인
# yum search postgres
ㅇ 아래 패키지 존재 확인
- postgresql92.i386 : PostgreSQL client programs and libraries
- postgresql92-server.i386 : The programs needed to create and run a PostgreSQL server
-- 5. PostgreSQL 서버 설치(4번에서 패키지명 확인)
# yum install postgresql92 postgresql92-server
(/var/lib/pgsql/9.2/data 삭제시에는 reinstall로 재설치)
ㅇ 설치 확인
# ls /var/lib/pgsql/9.2/data
-- 6. Service Name 확인
# ls /etc/init.d/postgre*
ㅇ 결과 확인(depend on PostgreSQL Generation) : postgresql-9.2
-- 7. DB 초기화(6번의 서비스 내용 사용)
# service postgresql-9.2 initdb
-- 8. PostgreSQL 시작
ㅇ Service Name으로 시작
# service postgresql-9.2 start
-- 9. 자동 시작 설정(Optional)
# chkconfig postgresql-9.2 on
-- 10. pg/sql 접속
ㅇ postgres 계정을 만들지 않았는데 접속된다.
ㅇ 패키지 생성시 자동으로 만든 듯 싶다.
ㅇ /etc/passwd에 보면 등록되어 있다.
# su - postgres
$ psql -dpostgres
postgres=# select * from pg_database;
postgres=# \q
-- 11. postgres사용자의 .bash_profile 변경
$ vi /home/pgsql/.bash_profile에서 아래 스크립트 추가
POSTGRES_HOME=/usr/pgsql-9.2
PGLIB=$POSTGRES_HOME/lib
PGDATA=$POSTGRES_HOME/data
MANPATH=$MANPATH:$POSTGRES_HOME/man
PATH=$POSTGRES_HOME/bin:$PATH
export POSTGRES_HOME
export PGLIB
export PGDATA
export MANPATH
export PATH
$ source /home/pgsql/.bash_profile
-- 12. Super User 생성
$ psql -dpostgres
postgres=# create role {account} login password '{password}' superuser;
postgres=# \q
-- 13. postgresql.conf 파일 변경
# vi /var/lib/pgsql/9.2/data/postgresql.conf 에서
#listen_addresses = 'localhost' →
listen_addresses = '*'
로 변경
-- 14. pg_hba.conf 파일 변경
# vi /var/lib/pgsql/9.2/data/postgresql.conf 에서
host all all 172.20.20.0/24 md5
host all all 203.236.86.0/24 md5
추가
-- 15. DB 재시작
# service postgresql-9.2 restart
-- 16. 방화벽 포트 오픈
# vi /etc/sysconfig/iptables 에서
-A INPUT -m state --state NEW -m tcp -p tcp --dport 5432 -
j ACCEPT
추가
-- 17. 방화벽 재시작
# service iptables restart