CentOS 8 PostgreSQL 12 개발자 gcc컴파일 환경 작성하기

Linux

CentOS 8에서 PostgreSQL client 패키지 또는 server 패키지를 설치하지 않고 PostgreSQL 개발자 컴파일 환경을 작성하는 방법을 소개합니다. CentOS 7 또는 Red Hat 7에서 PostgreSQL개발자 컴파일 환경을 작성하는 방법에 대해서는 “RedHat Enterprise Linux 7.9에서 PostgreSQL 12 개발자 라이브러리 설치하기” 글을 참조 하십시오.

이 글의 명령 실행 전체 로그는 여기를 참조 하십시오.

작업 환경

# cat /etc/redhat-release
CentOS Linux release 8.4.2105
# uname -a
Linux localhost.local 4.18.0-193.19.1.el8_2.x86_64 #1 SMP Mon Sep 14 14:37:00 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux

CentOS 8의 기본 postgresql패키지 비활성화

다음과 같은 명령으로 CentOS 8에서 기본으로 설치할 수 있도록 준비된 postgresql 패키지를 표시합니다. 이 글은 관리자 root 유저로 실행했습니다. wheel 그룹 유저로 실행할 경우 sudo 명령을 사용하십시오

# yum module list | grep postgresql
postgresql 9.6 client, server [d] PostgreSQL server and client module
postgresql 10 [d] client, server [d] PostgreSQL server and client module
postgresql 12 client, server [d] PostgreSQL server and client module
postgresql 13 client, server [d] PostgreSQL server and client module
Hint: [d]efault, [e]nabled, [x]disabled, [i]nstalled

위와 같은 기본으로 준비되어 있는 postgresql 패키지만으로는 postgresql12-devel 패키지를 설치 할 수 없습니다. 아래와 같이 postgresql12-devel 패키지를 설치하려고 하면 패키지를 찾을 수 없다는 메시지와 함께 에러 종료됩니다.

# yum install postgresql12-devel
Last metadata expiration check: 0:18:44 ago on Mon 05 Jul 2021 12:56:53 PM UTC.
No match for argument: postgresql12-devel
Error: Unable to find a match: postgresql12-devel

다음과 같이 yum -qy module disable postgresql 명령을 통해 기본으로 준비된 postgresql 패키지를 비활성화 합니다.

# yum -qy module disable postgresql
# yum module list | grep postgresql
postgresql 9.6 [x] client, server [d] PostgreSQL server and client module                                                                                                  
postgresql 10 [d][x] client, server [d] PostgreSQL server and client module                                                                                                  
postgresql 12 [x] client, server [d] PostgreSQL server and client module                                                                                                  
postgresql 13 [x] client, server [d] PostgreSQL server and client module
Hint: [d]efault, [e]nabled, [x]disabled, [i]nstalled

PostgreSQL 저장소(Repository) 추가하기

# yum install https://download.postgresql.org/pub/repos/yum/reporpms/EL-8-x86_64/pgdg-redhat-repo-latest.noarch.rpm

... 중간 생략 ...
Installing:
 pgdg-redhat-repo    noarch       42.0-18  @commandline 12 k

... 중간 생략 ...
Is this ok [y/N]: y

... 중간 생략 ...

Installed:
  pgdg-redhat-repo-42.0-18.noarch

Complete!

다음 명령으로 추가된 PostgreSQL 저장소(Repository)를 확인할 수 있습니다.

# yum repolist enabled
repo id      repo name
appstream    CentOS Linux 8 - AppStream
baseos       CentOS Linux 8 - BaseOS
extras       CentOS Linux 8 - Extras
pgdg-common  PostgreSQL common RPMs for RHEL/CentOS 8 - x86_64
pgdg10       PostgreSQL 10 for RHEL/CentOS 8 - x86_64
pgdg11       PostgreSQL 11 for RHEL/CentOS 8 - x86_64
pgdg12       PostgreSQL 12 for RHEL/CentOS 8 - x86_64
pgdg13       PostgreSQL 13 for RHEL/CentOS 8 - x86_64
pgdg96       PostgreSQL 9.6 for RHEL/CentOS 8 - x86_64

PostgreSQL용 개발자 라이브러리 설치하기

다음과 같이 PostgreSQL 개발자 라이브러리를 설치합니다. 설치 결과 메시지는 여기를 참조하세요.

# yum install -y postgresql12-devel

설치 완료 확인

정상으로 PostgreSQL용 개발자 라이브러리가 설치되었음을 다음 명령으로 확인할 수 있습니다.

# ls /usr/pgsql-12/include
# ls /usr/pgsql-12/include/internal
# ls /usr/pgsql-12/lib/libpq.so

샘플 소스 작성 및 컴파일 실행은 다음 글을 참조하십시오.

PostgreSQL 데이터 취득 gcc프로그램 샘플 작성하기
PostgreSQL 서버에 접속하여 데이터를 취득, 그 결과를 출력하는 libpq C 라이브러리 사용 gcc 샘플 프로그램을 작성하는 방법을 소개합니다. 전제 조건 "Linux7 CentOS7에서 PostgreSQL...
제목과 URL을 복사했습니다