CentOS 5/6 및 RHEL 5/6에 PostgreSQL 9.1 설치

CentOS 5/6 및 RHEL 5/6에 PostgreSQL 9.1 설치

2022-10-18 last update

5 minutes reading pgsql PostgreSQL postgres psql
PostgreSQL은 오픈 소스 객체 관계형, 확장성이 뛰어난 SQL 호환 데이터베이스 관리 시스템입니다. 이 문서는 CentOS 5/6 및 RHEL 5/6에 PostgreSQL 9.1을 설치하는 데 도움이 됩니다. 1단계: PostgreSQL Yum 저장소 추가첫 번째 단계는 시스템에 postgres 저장소를 설치하는 것입니다. 시스템 아키텍처 및 운영 체제에 따라 아래 명령 중 하나를 사용하십시오. .
CentOS/RHEL 5, 32-Bit:
#  rpm -Uvh http://yum.postgresql.org/9.1/redhat/rhel-5-i386/pgdg-centos91-9.1-4.noarch.rpm

CentOS/RHEL 6, 32-Bit:
#  rpm -Uvh http://yum.postgresql.org/9.1/redhat/rhel-6-i386/pgdg-centos91-9.1-4.noarch.rpm

CentOS/RHEL 5, 64-Bit:
#  rpm -Uvh http://yum.postgresql.org/9.1/redhat/rhel-5.0-x86_64//pgdg-centos91-9.1-4.noarch.rpm

CentOS/RHEL 6, 64-Bit:
#  rpm -Uvh http://yum.postgresql.org/9.1/redhat/rhel-6.3-x86_64/pgdg-centos91-9.1-4.noarch.rpm
2단계: Yum.Below 명령을 사용하여 PostgreSQL Server 9.1을 설치하면 시스템에 PostgreSQL 9.1이 설치됩니다.
# yum install postgresql91-server
샘플 출력
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
 * base: ftp.iitm.ac.in
 * epel: mirror.yourconnect.com
 * extras: ftp.iitm.ac.in
 * updates: ftp.iitm.ac.in
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package postgresql91-server.i686 0:9.1.9-1PGDG.rhel6 will be installed
--> Processing Dependency: postgresql91 = 9.1.9-1PGDG.rhel6 for package: postgresql91-server-9.1.9-1PGDG.rhel6.i686
--> Processing Dependency: libpq.so.5 for package: postgresql91-server-9.1.9-1PGDG.rhel6.i686
--> Running transaction check
---> Package postgresql91.i686 0:9.1.9-1PGDG.rhel6 will be installed
---> Package postgresql91-libs.i686 0:9.1.9-1PGDG.rhel6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

====================================================================================================
 Package                       Arch           Version                        Repository        Size
====================================================================================================
Installing:
 postgresql91-server           i686           9.1.9-1PGDG.rhel6              pgdg91           3.6 M
Installing for dependencies:
 postgresql91                  i686           9.1.9-1PGDG.rhel6              pgdg91           973 k
 postgresql91-libs             i686           9.1.9-1PGDG.rhel6              pgdg91           192 k

Transaction Summary
====================================================================================================
Install       3 Package(s)

Total download size: 4.7 M
Installed size: 20 M
Is this ok [y/N]: y
Downloading Packages:
(1/3): postgresql91-9.1.9-1PGDG.rhel6.i686.rpm                               | 973 kB     00:02
(2/3): postgresql91-libs-9.1.9-1PGDG.rhel6.i686.rpm                          | 192 kB     00:02
(3/3): postgresql91-server-9.1.9-1PGDG.rhel6.i686.rpm                        | 3.6 MB     00:07
----------------------------------------------------------------------------------------------------
Total                                                               321 kB/s | 4.7 MB     00:15
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Warning: RPMDB altered outside of yum.
  Installing : postgresql91-libs-9.1.9-1PGDG.rhel6.i686                                         1/3
  Installing : postgresql91-9.1.9-1PGDG.rhel6.i686                                              2/3
  Installing : postgresql91-server-9.1.9-1PGDG.rhel6.i686                                       3/3

Installed:
  postgresql91-server.i686 0:9.1.9-1PGDG.rhel6

Dependency Installed:
  postgresql91.i686 0:9.1.9-1PGDG.rhel6          postgresql91-libs.i686 0:9.1.9-1PGDG.rhel6

Complete!
3단계: 설치 후 최초 PGDATA 초기화PosgreSQL 서버 설치 후, 최초 사용 전 초기화가 필요합니다. 데이터베이스를 초기화하려면 아래 명령을 사용하십시오.
# /etc/init.d/postgresql-9.1 initdb
위의 명령은 처음으로 postgres를 초기화하는 데 시간이 걸립니다. PGDATA 환경 변수는 데이터 디렉토리의 경로를 포함합니다. PostgreSQL 데이터 디렉토리 경로
/var/lib/pgsql/9.1/data/
이전 버전( PostgreSQL 7 또는 8 )은 기본적으로 데이터 디렉토리에 아래 경로를 사용합니다.
/var/lib/pgsql/data/
4단계: 다음 명령을 사용하여 PostgreSQL ServerStart postgresql 서비스를 시작합니다.
# service postgresql-9.1 start
시스템 부팅 시 자동 시작되도록 PostgreSQL 서비스를 설정합니다.
# chkconfig postgresql-9.1 on
5단계: PostgreSQL 관리 명령 프롬프트에 액세스합니다. 관리 사용자로 postgres에 액세스하려면 먼저 postgres 시스템 계정으로 전환합니다.
# su - postgres
psql 명령을 사용하여 관리자 권한으로 postgres 프롬프트에 액세스합니다.
$ psql
샘플 출력:
psql (9.1.9)
Type "help" for help.

postgres=#
phpPgAdmin을 설치하는 방법에 대한 아래 기사를 읽으십시오. >> How to Install phpPgAdmin on CentOS using Yum CentOS 5/6 및 RHEL 5/6 시스템에 PostgreSQL 9.1을 설치하기 위해 이 튜토리얼을 사용해 주셔서 감사합니다.