PostgreSQL
오픈소스 비즈니스 컨설팅 사이트는 모든 사람이 동참하는 개방된 사이트 입니다.
오픈 소스와 오픈 API와 관계된 사항은 자유로이 추가, 수정 하셔도 됩니다. 모두의 동참을 바랍니다.
오픈소스 비즈니스 컨설팅에 대한 문의는
으로 메일 주세요.
오픈 소스와 오픈 API와 관계된 사항은 자유로이 추가, 수정 하셔도 됩니다. 모두의 동참을 바랍니다.
오픈소스 비즈니스 컨설팅에 대한 문의는
으로 메일 주세요.
오픈소스 비즈니스 컨설팅
PostgreSQL 8.3.1에 대한 전반적인 사항을 정리한다.
일반적으로 널리 사용되는 관계형 데이터베이스이다.
- 홈페이지 : http://www.postgresql.org/
- 다운로드 : http://www.postgresql.org/download/
- 라이센스 : BSD License
- 플랫폼 : Windows, Unix, Linux
목차 |
[편집] 추가 컴포넌트 설치
- "Application Stack Builder" 메뉴를 선택하여 PostgreSQL에서 사용할 추가 컴포넌트를 설치한다.
- 컴포넌트를 설치할 데이터베이스를 선택한다.
- 데이터베이스에 접속하기 위한 드라이버를 선택한다.
- .NET으로 접속하기 위해 "Npgsql v1.0.0"을 선택한다.
- Java로 접속하기 위해 "psqlJDBC v8.3.603"을 선택한다.
- ODBC로 접속하기 위해 "psqlODBC v08.03.0100"을 선택한다.
- 컴포넌트를 다운로드할 사이트를 선택한다.
- 다운로드한 컴포넌트를 임시 보관할 디렉토리를 지정한다.
- "Next" 버튼을 눌러 컴포넌트의 설치를 시작한다.
[편집] PostgreSQL .NET Provider (Npgsql) 설치
- "Next" 버튼을 눌러 설치를 시작한다.
- 라이센스를 확인한다.
- 설치할 디렉토리를 지정한다.
- "Install" 버튼을 눌러 설치를 시작한다.
- "Finish" 버튼을 눌러 설치를 종료한다.
[편집] psqlODBC 설치
- "Next" 버튼을 눌러 설치를 시작한다.
- 라이센스를 확인한다.
- 설치할 디렉토리를 지정한다.
- "Install" 버튼을 눌러 설치를 시작한다.
- "Finish" 버튼을 눌러 설치를 종료한다.
[편집] PostgreSQL JDBC Drivers (psqlJDBC) 설치
- "Next" 버튼을 눌러 설치를 시작한다.
- 라이센스를 확인한다.
- 설치할 디렉토리를 지정한다.
- "Install" 버튼을 눌러 설치를 시작한다.
- "Finish" 버튼을 눌러 설치를 종료한다.
- "Finish" 버튼을 눌러 컴포넌트의 설치를 완료한다.
[편집] Linux용 설치 가이드
Ubuntu Server 8.10에서 PostgreSQL을 정리한다.
- PostgreSQL 8.3 설치
- sudo apt-get install postgresql
- PostgreSQL의 Super User를 등록 한다.
- 참고 문헌 : User Guide - phpPgAdmin (Administer Your PostgreSQL Database)
- Ubuntu Server에 root로 로그인하여 다음 명령을 실행 한다.
su postgres createuser -P 관리자_아이디 //--- 관리자로 사용할 아이디를 등록 한다 Enter password for new role: Enter it again: Shall the new role be a superuser? (y/n) y
- 설치 정보
- 설치 폴더 : /usr/lib/postgresql/8.3/
- 환경 폴더 : /etc/postgresql/8.3/main, /etc/postgresql-common
- 데이터 폴더 :
- 작업 폴더 : /var/lib/postgresql/
- 로그 폴더 : /var/log/postgresql/
- 기동 종료 : /etc/init.d/postgresql-8.3 start, stop, restart, status
- 서비스 확인 : ps -ef | grep postgre
- 로그 정보 :
- postgres 사용자의 홈 디렉토리 : /var/lib/postgresql
[편집] CentOS용 설치 가이드
- CentOS에서 PostgreSQL 설치
#--- CentOS에 root로 로그인 한다. yum -y install postgresql postgresql-server postgresql-odbc postgresql-jdbc postgresql-devel rpm -qa | grep postgresql #--- postgresql 설치 확인
- 설치 정보
- 설치 폴더 : /usr/share/pgsql/
- 데이터 폴더 : /var/lib/pgsql/
- 실행 파일 : /usr/bin/
- 기동 종료 : /etc/init.d/postgresql start, stop, restart 또는 service postgresql start, stop, restart
- 서비스 확인 : ps -ef | grep postmaster | grep -v grep
[편집] 사용자 가이드
- PostgreSQL Database Server를 시작/종료하는 방법
- "시작" 메뉴에서 "설정" 메뉴를 선택한 후 "제어판"을 선택한다.
- "관리 도구"를 더블 클릭한 후 "서비스"를 더블 클릭한다.
- "PostgreSQL Database Server 8.3"을 선택한 후 오른쪽 마우스를 클릭하여 PostgreSQL Database Server를 시작하거나 중지(종료)할 수 있다.
[편집] 관리자 가이드
[편집] CentOS에서 DB Schema 추가 설정
#--- useridDB : 데이터베이스명
#--- userid : 데이터베이스의 사용자 아이디
#--- userpassword : userid의 암호
su - postgres
createuser -s -l userid
createdb useridDB
psql
alter user userid with encrpted password 'userpassword';
alter database useridDB owner to userid;
[편집] 백업 및 복구
- DB별 백업 및 복구
su - postgres pg_dumpall -f db_all.out //--- DB 전체 백업 pg_dump mydb > mydb.sql pg_dump -h localhost -U postgres -Ft -f mydb.backup mydb //--- DB 백업 pg_dump -h localhost -U postgres -Ft -f mydb.backup -t zipcode mydb //--- 테이블 백업 pg_restore -l mydb.backup > mydb.toc //--- 내용 보기 pg_restore -h localhost -U postgres -Ft -d mydb mydb.backup //--- DB 복구 //--- mydb.toc에서 복구가 필요없는 자료는 삭제하거나 ;로 표시한 후 아래 명령을 실행한다. pg_restore -h localhost -U postgres -L mydb.toc -d mydb mydb.backup //--- 부분 복구
- PostgreSQL database의 백업 및 복구
- postgres 사용자로 백업 시
su - postgres
pg_dumpall -f db_backup.sql
psql -d ${DB_NAME} < db_backup.sql
- root 사용자로 백업 시 (DB_NAME. 데이터베이스 명, DB_USER. 데이터베이스 사용자)
su - root
pg_dump -h 127.0.0.1 -U ${DB_USER} -W -b -f db_backup.sql ${DB_NAME}
psql -h 127.0.0.1 -U ${DB_USER} -W -d ${DB_NAME} < db_backup.sql
[편집] 라이센스
- PostgreSQL, Slony, & JDBC are released under the BSD License.
- GridSQL is released under the GPLv2 with the following license exception.
- psqlODBC & Npgsql are released under the LGPL.
- pgAdmin III is released under the Artistic Licence.
- PostGIS & phpPgAdmin Server are released under the GPLv2.
- PHP is released under the PHP License.
- The Apache Webserver is released under the Apache License.
- This product includes software released under the OpenSSL License.
- This product includes Kerberos software released under the MIT License.




















