Centos7 PostgreSql 데이터베이스 설치 확장 기록

1. 데이터베이스 구축
1. yum 지정 디렉터리 설치
https://blog.csdn.net/llwy1428/article/details/105143053
2. yum 직접 설치
https://blog.csdn.net/llwy1428/article/details/102486414
3. 컴파일 설치
https://blog.csdn.net/llwy1428/article/details/95444151
4. PostgreSql 기본 작업
https://blog.csdn.net/llwy1428/article/details/102598732
2. 확장 설치
1、epel-7.repo

[root@pgadmin ~]# cd /etc/yum.repos.d/
[root@pgadmin yum.repos.d]# wget https://mirrors.aliyun.com/repo/epel-7.repo

2. 설치 도구
[root@localhost ~]# yum install pgagent_11 postgis25_11 -y

3. 현재 서버에서 사용할 수 있는 Extension 확장 목록 보기
#     
[root@localhost ~]# su - postgres
Last login: Mon Mar 16 21:15:46 CST 2020 on pts/3
#    postgresql    
[postgres@localhost ~]$ psql
psql (11.5)
Type "help" for help.

postgres=# select name from pg_available_extensions;
             name             
------------------------------
 insert_username
 dict_int
 adminpack
 amcheck
 intagg
 autoinc
 intarray
 bloom
 file_fdw
 dblink
 btree_gin
 fuzzystrmatch
 seg
 btree_gist
 jsonb_plperl
 hstore
 citext
 isn
 jsonb_plperlu
 cube
 hstore_plperl
 dict_xsyn
 hstore_plperlu
 earthdistance
 lo
 ltree
 pg_trgm
 tcn
 moddatetime
 pageinspect
 pg_visibility
 pgstattuple
 postgres_fdw
 pg_buffercache
 xml2
 pg_freespacemap
 refint
 sslinfo
 tablefunc
 pg_prewarm
 pgcrypto
 pg_stat_statements
 pgrowlocks
 timetravel
 tsm_system_rows
 address_standardizer
 tsm_system_time
 unaccent
 address_standardizer_data_us
 uuid-ossp
 postgis
 postgis_sfcgal
 postgis_tiger_geocoder
 postgis_topology
 plpgsql
(55 rows)

4. 현재 데이터베이스 목록 보기
postgres=# \l
                                  List of databases
   Name    |  Owner   | Encoding |   Collate   |    Ctype    |   Access privileges   
-----------+----------+----------+-------------+-------------+-----------------------
 postgres  | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | 
 template0 | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/postgres          +
           |          |          |             |             | postgres=CTc/postgres
 template1 | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/postgres          +
           |          |          |             |             | postgres=CTc/postgres
(3 rows)

5. 기본 데이터베이스에 pgagent 확장 설치
postgres=# create extension pgagent;
CREATE EXTENSION

설치 확장 성공
서비스 시작, 종료, 전원 켜기 시작 설정
    
[root@localhost ~]# systemctl start pgagent_11
    
[root@localhost ~]# systemctl stop pgagent_11
        
[root@localhost ~]# systemctl status pgagent_11
      
[root@localhost ~]# systemctl enable pgagent_11
        
[root@localhost ~]# systemctl disable pgagent_11

6. 지정된 데이터베이스에 확장 설치
(1) 테스트 데이터베이스를 만들고 목록을 보기
postgres=# create database pgtest;
CREATE DATABASE
postgres=# \l
                                  List of databases
   Name    |  Owner   | Encoding |   Collate   |    Ctype    |   Access privileges   
-----------+----------+----------+-------------+-------------+-----------------------
 pgtest    | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | 
 postgres  | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | 
 template0 | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/postgres          +
           |          |          |             |             | postgres=CTc/postgres
 template1 | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/postgres          +
           |          |          |             |             | postgres=CTc/postgres
(4 rows)

(2) 데이터베이스 전환
postgres=# \c pgtest
You are now connected to database "pgtest" as user "postgres".
pgtest=#

(3) 확장postgis 설치
pgtest=# create extension "uuid-ossp";
CREATE EXTENSION

(4) 설치 확장 uid-ossp
pgtest=# create extension postgis;
CREATE EXTENSION

(5) 확장 ltree 설치
pgtest=# create extension "ltree";
CREATE EXTENSION

(6) 확장timetravel 설치
pgtest=# create extension "timetravel";
CREATE EXTENSION

추가 확장: 생략.
(7) 현재 설치된 확장 보기
pgtest=# \dx
                                      List of installed extensions
    Name    | Version |   Schema   |                             Description                             
------------+---------+------------+---------------------------------------------------------------------
 ltree      | 1.1     | public     | data type for hierarchical tree-like structures
 plpgsql    | 1.0     | pg_catalog | PL/pgSQL procedural language
 postgis    | 2.5.3   | public     | PostGIS geometry, geography, and raster spatial types and functions
 timetravel | 1.0     | public     | functions for implementing time travel
 uuid-ossp  | 1.1     | public     | generate universally unique identifiers (UUIDs)
(5 rows)

(8) Extension 확장 제거, 결과 보기
pgtest=# drop extension timetravel;
DROP EXTENSION
pgtest=# \dx
                                      List of installed extensions
   Name    | Version |   Schema   |                             Description                             
-----------+---------+------------+---------------------------------------------------------------------
 ltree     | 1.1     | public     | data type for hierarchical tree-like structures
 plpgsql   | 1.0     | pg_catalog | PL/pgSQL procedural language
 postgis   | 2.5.3   | public     | PostGIS geometry, geography, and raster spatial types and functions
 uuid-ossp | 1.1     | public     | generate universally unique identifiers (UUIDs)
(4 rows)

 
이로써 Centos7 PostgreSql 데이터베이스에 플러그인을 설치하는 기본 작업이 완료되었습니다!
도움이 되었으면 좋겠습니다!

좋은 웹페이지 즐겨찾기