Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | |
7 | 8 | 9 | 10 | 11 | 12 | 13 |
14 | 15 | 16 | 17 | 18 | 19 | 20 |
21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 | 29 | 30 |
Tags
- PostgreSQL
- 프록시패턴 #Gof #ProxyPattern #Proxy
- CentOS
- 데이터베이스
- MariaDB #DB #기본쿼리 #select
- GoF #빌더패턴 #Builder Pattern
- Bridge Pattern #구조패턴 #Structure Pattern
- 자바 #인터페이스 #추상클래스 #abstract #
- GOF #
Archives
- Today
- Total
개발자 기초부터 시작하기
PostgreSQL CentOS에 설치해보기 본문
CentOS에 PostgreSQL 설치 후 접속해보기.
다운로드
https://www.postgresql.org/ftp/source 에 접속하여 원하는 버전 다운로드
저는 10.8 버전을 다운로드 하였습니다.
$ wget https://ftp.postgresql.org/pub/source/v10.8/postgresql-10.8.tar.gz
빌드환경 구성 및 빌드
configure / make / make install (간단 설명) 로 환경을 구성해줍니다.
xxxxxxxxxx
$ ./configure --prefix=/usr/local/cafe24/pgsql --with-python --with-openssl --enable-nls=ko
-- prefix 부분은 수정해서 사용하시면 됩니다
xxxxxxxxxx
$ make
xxxxxxxxxx
$ make install
위 과정을 따르고 정상적으로 설치가 되었는지 prefix 해준곳을 확인합니다.
💡 오류 점검
CASE 1 ReadLine 라이브러리 미설치
xxxxxxxxxx
$ yum install readLine
CASE 2 Python.h 가 없는 경우
xxxxxxxxxx
yum install python-devel # for python2.x installs
yum install python34-devel # for python3.4 installs
유저 추가
postgreSQL은 root 계정으로는 실행할 수 없기에 계정을 하나 만들어준뒤 pgsql 폴더의 권한을 바꿉니다.
xxxxxxxxxx
$ adduser -M postgres
$ chown -R postgres:postgres /user/local/cafe24/pgsql
환경설정 (/etc/profile)
/etc/profile 의 내용을 수정해줍니다.
x
$ vi /etc/profile
----------------------------------------------------------------------------
...생략...
#postgres
export POSTGRES_HOME=/usr/local/cafe24/pgsql
export PGLIB=$POSTGRES_HOME/lib
export PGDATA=$POSTGRES_HOME/data
export PATH=$PATH:$POSTGRES_HOME/bin
기본 데이터 베이스 생성
initdb는 postgreSQL 설치 후 시스템카달로그를 포함하고 있는 postgres 기본 DB를 생성하는 명령어이다. postgres 유저로 initdb 명령을 실행해보자
xxxxxxxxxx
$ sudo -u postgres /usr/local/cafe24/pgsql/bin/initdb -E UTF8 --locale=ko_KR.UTF-8 /usr/local/cafe24/pgsql/data
💡 데이터베이스의 경로를 다르게 정하고 싶을때
/etc/profile 에 정했던 PGDATA 의 경로를 수정하면 된다.
이 PGDATA라는 환경변수가 바로 postgreSQL의 DB가 생성되는 경로를 갖고 있는 환경변수이며 별도로 지정하지 않으면 이 변수의 경로로 DB 경로로 지정해 구동된다.
접속해보기
- postgres user 로 시작
- 설치한 폴더 안의 bin 폴더 밑에 pg_ctl
- 데이터베이스경로를 지정
- logging 폴더를 지정
- start
xxxxxxxxxx
$ sudo -u postgres /usr/local/cafe24/pgsql/bin/pg_ctl -D /usr/local/cafe24/pgsql/data -l /usr/local/cafe24/pgsql/data/logfile start
- 동작 확인
xxxxxxxxxx
$ ps -ef | grep postgres
- 접속 (간단하게 버전 확인)
xxxxxxxxxx
$ psql -U postgres
추가 설정
-
사용자 비밀번호 정하기
-
postgreSQL에서 설정
xxxxxxxxxx
postgres=# alter user postgres with password '비밀번호';
-
접근 설정
xxxxxxxxxx
$ vi /usr/local/cafe24/psql/data/pg_hba.conf
-------------------------------------------------------------------
....
# TYPE DATABASE USER ADDRESS METHOD
# "local" is for Unix domain socket connections only
local all postgres password
-
서버 재가동 후 재접속
-
FIN
Comments