满堂花醉三千客,一剑霜寒十四洲。这篇文章主要讲述记一次 Centos7PostgreSql数据库安装扩展相关的知识,希望能为你提供帮助。
一、数据库搭建
1、yum 指定目录安装
2、yum 直接安装
3、编译安装
4、PostgreSql 基本操作
二、扩展安装
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)安装扩展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)删除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)
至此,Centos7PostgreSql数据库安装插件基本操作完毕!
希望能够对您有所帮助!
【记一次 Centos7PostgreSql数据库安装扩展】
推荐阅读
- 记一次Centos禁用SELinux
- 记一次Notepad++安装NppFTP连接Linux 系统(例如(Centos))
- CentOS7 防火墙相关操作与端口配置 (收集+持续更新)
- 记一次Centos7 手动安装Mysql 5.7 数据库 (使用 Mysql的 rpm文件)
- Linux之ssh-copy-id命令
- 记一次Centos7安装使用PostWoman
- 记一次Centos7安装 lepus 天兔数据库监控系统 v3.8_beta
- 晋级TypeScript高手,成为抢手的前端开发人才
- 搭建并实现智能DNS