메뉴 닫기

Postgresql 9.5.3 설치

CentOS6 환경에 postgresql-9.5.3 설치 내용 이다.

Source 파일로 설치 되었으며, 아래와 같이 진행 한다.

 

PostgreSQL 9.5.3 설치


 

 

1. 필수 라이브러리 설치

#yum -y install gcc gcc-c++ boost boost-devel pkgconfig uuidd libtool autoconf make coreutils uuid-dev uuid-devel libuuid-devel e2fsprogs-devel readline readline-devel zlib zlib-devel openssl openssl-devel gettext

 

2. PostgreSQL 설치

#cd /usr/local/src

#wget https://ftp.postgresql.org/pub/source/v9.5.3/postgresql-9.5.3.tar.gz

#tar zxvf postgresql-9.5.3.tar.gz

#cd postgresql-9.5.3

#./configure –prefix=/usr/local/pgsql –enable-depend –enable-nls=ko –with-openssl

#make && make install

 

3. PostgreSQL 명령어 설정

#ln -s /usr/local/pgsql/bin/psql /usr/bin/psql
#ln -s /usr/local/pgsql/bin/dropdb /usr/bin/dropdb
#ln -s /usr/local/pgsql/bin/dropuser /usr/bin/dropuser
#ln -s /usr/local/pgsql/bin/createuser /usr/bin/createuser
#ln -s /usr/local/pgsql/bin/createdb /usr/bin/createdb

 

4. PostgreSQL 실행 유저 및 디렉토리 생성

#useradd postgres
#chown -R postgres:postgres /usr/local/pgsql

#mkdir –parents /usr/local/pgsql/data
#chown -R postgres:postgres /usr/local/pgsql/data

 

 

5. Passwordless 설정

vi /etc/sudoers

## The COMMANDS section may have other options added to it.
##
## Allow root to run any commands anywhere
root ALL=(ALL) ALL
postgres ALL=(ALL) NOPASSWD: NOPASSWD: ALL   // 내용 추가

 

6. DB Directory 생성

#su – postgres
#/usr/local/pgsql/bin/initdb -E UTF-8 –locale=ko_KR.UTF-8 –lc-collate=C -D /usr/local/pgsql/data

postgresql_1

 

7. 시작 및 종료

# Start foreground running
sudo -u postgres /usr/local/pgsql/bin/postgres -D /usr/local/pgsql/data

# Start background running
sudo -u postgres /usr/local/pgsql/bin/pg_ctl -D /usr/local/pgsql/data -l logfile start

# Stop
sudo -u postgres /usr/local/pgsql/bin/pg_ctl -D /usr/local/pgsql/data stop

 

8. 시작 및 종료 스크립트 생성

vi start.sh
#!/bin/bash
sudo -u postgres /usr/local/pgsql/bin/pg_ctl -D /usr/local/pgsql/data -l logfile start

vi stop.sh
#!/bin/bash
sudo -u postgres /usr/local/pgsql/bin/pg_ctl -D /usr/local/pgsql/data stop

 

# chmod 755 start.sh stop.sh

 

9. 접속 테스트

# su – postgres
$ /usr/local/pgsql/bin/createdb test
$ psql test
test=#

 

 

 

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x