웹사이트 검색

CentOS 8에 PostGIS PostgreSQL 데이터베이스 익스텐더를 설치하는 방법


이 페이지에서

  1. 전제 조건
  2. 시작하기\n
  3. PostGIS 설치
  4. 확장 프로그램 만들기\n
  5. 결론

PostGIS는 PostgreSQL 데이터베이스 관리 시스템을 위한 무료 오픈 소스 데이터베이스 익스텐더입니다. 면적, 합집합, 교차점, 거리, 데이터 유형과 같은 몇 가지 추가 기능을 추가하고 SQL에서 위치 쿼리를 실행할 수 있도록 도와줍니다. PostGIS를 사용하면 PostgreSQL 데이터베이스에 데이터의 폴리곤 및 포인트 유형을 저장할 수 있습니다.

이 튜토리얼에서는 CentOS 8에서 PostgreSQL과 함께 PostGIS를 설치하는 방법을 보여줍니다.

전제 조건

  • CentOS 8을 실행하는 서버.\n
  • 서버에 루트 암호가 구성되어 있습니다.\n

시작하기

시작하기 전에 시스템에 PostGIS 및 EPEL 저장소를 설치해야 합니다. 다음 명령을 실행하여 둘 다 설치할 수 있습니다.

dnf -y install https://download.postgresql.org/pub/repos/yum/reporpms/EL-8-x86_64/pgdg-redhat-repo-latest.noarch.rpm
dnf -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm

다음으로 다음 명령을 사용하여 Powertool 리포지토리를 활성화하고 기본 PostgreSQL 리포지토리를 비활성화합니다.

dnf config-manager --set-enabled PowerTools
dnf -qy module disable postgresql

완료되면 다음 단계로 진행할 수 있습니다.

PostGIS 설치

이제 다음 명령을 실행하여 PostGIS를 설치할 수 있습니다.

dnf install postgis25_12

설치가 완료되면 다음 명령을 사용하여 PostGIS 패키지를 확인할 수 있습니다.

rpm -qi postgis25_12

다음과 같은 결과가 표시되어야 합니다.

Name        : postgis25_12
Version     : 2.5.5
Release     : 2.rhel8
Architecture: x86_64
Install Date: Monday 01 February 2021 11:59:37 PM EST
Group       : Unspecified
Size        : 29832534
License     : GPLv2+
Signature   : DSA/SHA1, Tuesday 10 November 2020 01:36:47 PM EST, Key ID 1f16d2e1442df0f8
Source RPM  : postgis25_12-2.5.5-2.rhel8.src.rpm
Build Date  : Tuesday 10 November 2020 01:30:09 PM EST
Build Host  : koji-rhel8-x86-64-pgbuild
Relocations : (not relocatable)
Vendor      : PostgreSQL Global Development Group
URL         : http://www.postgis.net/
Summary     : Geographic Information Systems Extensions to PostgreSQL
Description :
PostGIS adds support for geographic objects to the PostgreSQL object-relational
database. In effect, PostGIS "spatially enables" the PostgreSQL server,
allowing it to be used as a backend spatial database for geographic information
systems (GIS), much like ESRI's SDE or Oracle's Spatial extension. PostGIS
follows the OpenGIS "Simple Features Specification for SQL" and has been
certified as compliant with the "Types and Functions" profile.

다음으로 다음 명령을 사용하여 PostgreSQL 데이터베이스를 초기화합니다.

/usr/pgsql-12/bin/postgresql-12-setup initdb

그런 다음 PostgreSQL 서비스를 시작하고 다음 명령을 사용하여 시스템 재부팅 시 시작되도록 활성화합니다.

systemctl start postgresql-12.service
systemctl enable postgresql-12.service

확장 프로그램 만들기

이 시점에서 PostgreSQL 및 PostGIS가 설치되었습니다. 이제 PostGIS용 확장 프로그램을 만들어야 합니다.

먼저 다음 명령을 사용하여 Postgres 사용자로 로그인합니다.

su - postgres

다음으로 다음 명령을 사용하여 postgres 사용자 및 데이터베이스를 생성합니다.

createuser test_usr
createdb test_postgis -O test_usr

그런 다음 다음 명령을 사용하여 데이터베이스에 연결합니다.

psql -d test_postgis

다음 출력이 표시되어야 합니다.

psql (12.5)
Type "help" for help.

다음으로 다음 명령을 사용하여 PostGIS 확장을 만듭니다.

CREATE EXTENSION postgis;

다음으로 다음 명령을 사용하여 PostGIS 버전을 확인할 수 있습니다.

select PostGIS_Full_Version();

다음 출력에 PostGIS 버전이 표시되어야 합니다.

                                                                                          postgis_full_version                                 
                                                          
-----------------------------------------------------------------------------------------------------------------------------------------------
----------------------------------------------------------
 POSTGIS="2.5.5" [EXTENSION] PGSQL="120" GEOS="3.8.1-CAPI-1.13.3" PROJ="Rel. 7.2.1, January 1st, 2021" GDAL="GDAL 3.2.1, released 2020/12/29" L
IBXML="2.9.7" LIBJSON="0.13.1" LIBPROTOBUF="1.3.0" RASTER
(1 row)

그런 다음 다음 명령을 사용하여 Postgres 셸을 종료합니다.

exit
exit

결론

위 가이드에서는 CentOS 8에서 PostgreSQL과 함께 PostGIS를 설치하는 방법을 배웠습니다. 이제 PostGIS를 사용하여 데이터베이스에 지오메트리를 추가할 수 있습니다.