PostgreSQL 구성에 필요한 패키지 readline: 프롬프트 상에서 줄 편집 및 입력 기록 저장등의 역할을 하는 라이브러리 readline-devel ncurses : 텍스트 사용자 인터페이스를 터미널 독립방식으로 기록할 수 있도록 API를 제공하는 프로그래밍 라이브러리 ncurses-devel zlib : 데이터 압축 라이브러리 zlib-devel gcc : 컴파일러
설치 소스 Build 하기 #./configure –prefix=/usr/local/pgsql && make && make install
계정 생성 및 디렉토리 권한 변경
useradd pgsql -d /home/pgsq
chown -R pgsql.pgsql /usr/local/pgsql
pgsql 계정에 변수 추가하기 vim /home/pgsql/.bash_profile export PATH=$PATH:/usr/local/pgsql/bin export PGDATA=/usr/local/pgsql/data #initdb -D /usr/local/pgsql/data
Postgresql 시작하기
DB 초기화를 위하여 postgres 계정으로 로그인 한 후 DB를 초기화 및 DB 생성 #su - pgsql #cd /usr/local/pgsql/bin #./initdb -D (스토리지 경로 예: /DATA/) The files belonging to this database system will be owned by user "pgsql". . . . Success. You can now start the database server using: ./postgres -D /usr/local/pgsql/data/ or ./pg_ctl -D /usr/local/pgsql/data/ -l logfile start
DB를 실행 시켜준다. #./postgres -D (스토리지 경로 예: /DATA) &
DB 가 정상적으로 올라왔는지 로그인 및 확인 [pgsql@200-VM bin]$ ./psql template1 psql (9.3.5) Type "help" for help. template1=# \l (소문자 L) List of databases Name | Owner | Encoding | Collate | Ctype | Access privileges -----------+-------+----------+-------------+-------------+------------------- postgres | pgsql | UTF8 | en_US.UTF-8 | en_US.UTF-8 | template0 | pgsql | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/pgsql + | | | | | pgsql=CTc/pgsql template1 | pgsql | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/pgsql + | | | | | pgsql=CTc/pgsql (3 rows) template1=#
PostgreSQL 실행 종료가 되지 않을 경우 아래와 같이 조치한다. 메세지> pg_ctl: server does not shut down
Attempt Normal Stop: bash-3.1$pg_ctl stop Attempt Smart Stop: bash-3.1$pg_ctl stop -m s Attempt Fast Stop: bash-3.1$pg_ctl stop -m f Attempt Immediate Stop: bash-3.1$pg_ctl stop -m i