Centos7PostgreSqlデータベースインストール拡張機能を覚えておいてください

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.現在のサーバーで使用可能な拡張機能のリストを表示します

# 切换用户
[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)拡張機能uuid-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)拡張機能を削除して結果を表示する

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)

 

これで、Centos7PostgreSqlデータベースインストールプラグインの基本操作は完了です。

それがあなたを助けることができることを願っています!

 

おすすめ

転載: blog.csdn.net/llwy1428/article/details/105167524