0223---在华为云服务器上 安装 postgresql14.7过程

在centos7 服务器上 安装 postgresql14.7过程

一 安装过程

1 从官网确定安装脚本

  1. https://www.postgresql.org ,点击DownLoads
    在这里插入图片描述
  2. 选择 Linux
  3. 选择postgresql版本
  4. 选择 centos7
    在这里插入图片描述

2 选择后执行 官方提供的脚本

# Install the repository RPM:
sudo yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm

# Install PostgreSQL:
sudo yum install -y postgresql14-server postgresql14-contrib

# Optionally initialize the database and enable automatic start:
sudo /usr/pgsql-14/bin/postgresql-14-setup initdb
sudo systemctl enable postgresql-14
sudo systemctl start postgresql-14

3 默认安装位置

  1. pg 系统安装位置
[root@wy pgsql-14]# tree -d -L 3 /usr/pgsql-14/
/usr/pgsql-14/
├── bin
├── doc
│   └── extension
├── lib
│   └── bitcode
└── share
    ├── contrib
    ├── extension
    ├── locale
    │   ├── cs
    │   ├── de
    │   ├── el
    │   ├── es
    │   ├── fr
    │   ├── it
    │   ├── ja
    │   ├── ko
    │   ├── pl
    │   ├── pt_BR
    │   ├── ru
    │   ├── sv
    │   ├── tr
    │   ├── uk
    │   ├── vi
    │   └── zh_CN
    ├── man
    │   ├── man1
    │   ├── man3
    │   └── man7
    ├── timezonesets
    └── tsearch_data

  1. 初始化的生成的数据库位置
/var/lib/pgsql/
└── 14
    ├── backups
    └── data
        ├── base
        │   ├── 1
        │   ├── 14485
        │   └── 14486
        ├── global
        ├── log
        ├── pg_commit_ts
        ├── pg_dynshmem
        ├── pg_logical
        │   ├── mappings
        │   └── snapshots
        ├── pg_multixact
        │   ├── members
        │   └── offsets
        ├── pg_notify
        ├── pg_replslot
        ├── pg_serial
        ├── pg_snapshots
        ├── pg_stat
        ├── pg_stat_tmp
        ├── pg_subtrans
        ├── pg_tblspc
        ├── pg_twophase
        ├── pg_wal
        │   └── archive_status
        └── pg_xact

二 修改必要的设置

1 检查防火墙的设置

centos7 防火墙 放行 TCP 5432端口

--查看服务器当前防火墙的状态。
[root@orc19c ~]# systemctl  status firewalld
● firewalld.service - firewalld - dynamic firewall daemon
   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)
   Active: active (running) since Thu 2023-05-25 09:58:07 CST; 1 months 14 days ago

-- 查看当前防火墙放行了哪些端口
[root@orc19c ~]# firewall-cmd --list-ports
1521/tcp 5500/tcp
--查看防火墙使用的默认区域(zone)
[root@orc19c ~]# firewall-cmd --get-default-zone
public
--把PG的默认使用端口加入到操作系统防火墙默认区域中
[root@orc19c ~]#firewall-cmd --zone=public  --add-port=5432/tcp --permanent
--使防火墙规则生效
[root@orc19c ~]#firewall-cmd --reload
--或

2 设置 postgres 用户密码

[root@wy ~]# su - postgres
-bash-4.2$ psql
postgres=# ALTER USER postgres WITH PASSWORD 'XXXXXX';
# 重启 postgresql 服务
[root@wy ~]# systemctl restart postgresql-14

3 修改配置文件 pg_hba.conf 和 postgresql.conf

修改 /var/lib/pgsql/14/data 目录下的配置文件

  1. vim pg_hba.conf 添加
# IPv4 local connections:
host    all             all             0.0.0.0/0               scram-sha-256

  1. vim postgresql.conf
#listen_addresses = 'localhost'         # what IP address(es) to listen on;
listen_addresses = '*'                  # what IP address(es) to listen on;

4 安装 pldebugger 插件

  1. 官方网址

https://rhel.pkgs.org/7/postgresql-14-x86_64/pldebugger_14-1.4-1.rhel7.x86_64.rpm.html

  1. 由于安装了 postgresql的yum源,可以直接安装pldebugger:
# yum install pldebugger_14
  1. 修改 postgresql.conf
shared_preload_libraries = 'plugin_debugger'

5 安装 postgis 拓展

[root@wy extension]# yum search postgis
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
============================================== N/S matched: postgis ==============================================
postgis-docs.x86_64 : Extra documentation for PostGIS
postgis-utils.x86_64 : The utils for PostGIS
postgis24_11-client.x86_64 : Client tools and their libraries of PostGIS
postgis24_11-devel.x86_64 : Development headers and libraries for PostGIS
postgis24_11-docs.x86_64 : Extra documentation for PostGIS
postgis24_11-gui.x86_64 : GUI for PostGIS
postgis24_11-utils.x86_64 : The utils for PostGIS
postgis25_11-client.x86_64 : Client tools and their libraries of PostGIS
postgis25_11-devel.x86_64 : Development headers and libraries for PostGIS
postgis25_11-docs.x86_64 : Extra documentation for PostGIS
postgis25_11-gui.x86_64 : GUI for PostGIS
postgis25_11-utils.x86_64 : The utils for PostGIS
postgis25_12-client.x86_64 : Client tools and their libraries of PostGIS
postgis25_12-devel.x86_64 : Development headers and libraries for PostGIS
postgis25_12-docs.x86_64 : Extra documentation for PostGIS
postgis25_12-gui.x86_64 : GUI for PostGIS
postgis25_12-utils.x86_64 : The utils for PostGIS
postgis30_11-client.x86_64 : Client tools and their libraries of PostGIS
postgis30_11-devel.x86_64 : Development headers and libraries for PostGIS
postgis30_11-docs.x86_64 : Extra documentation for PostGIS
postgis30_11-gui.x86_64 : GUI for PostGIS
postgis30_11-utils.x86_64 : The utils for PostGIS
postgis30_12-client.x86_64 : Client tools and their libraries of PostGIS
postgis30_12-devel.x86_64 : Development headers and libraries for PostGIS
postgis30_12-docs.x86_64 : Extra documentation for PostGIS
postgis30_12-gui.x86_64 : GUI for PostGIS
postgis30_12-utils.x86_64 : The utils for PostGIS
postgis30_13-client.x86_64 : Client tools and their libraries of PostGIS
postgis30_13-devel.x86_64 : Development headers and libraries for PostGIS
postgis30_13-docs.x86_64 : Extra documentation for PostGIS
postgis30_13-gui.x86_64 : GUI for PostGIS
postgis30_13-utils.x86_64 : The utils for PostGIS
postgis31_11-client.x86_64 : Client tools and their libraries of PostGIS
postgis31_11-devel.x86_64 : Development headers and libraries for PostGIS
postgis31_11-docs.x86_64 : Extra documentation for PostGIS
postgis31_11-gui.x86_64 : GUI for PostGIS
postgis31_11-utils.x86_64 : The utils for PostGIS
postgis31_12-client.x86_64 : Client tools and their libraries of PostGIS
postgis31_12-devel.x86_64 : Development headers and libraries for PostGIS
postgis31_12-docs.x86_64 : Extra documentation for PostGIS
postgis31_12-gui.x86_64 : GUI for PostGIS
postgis31_12-utils.x86_64 : The utils for PostGIS
postgis31_13-client.x86_64 : Client tools and their libraries of PostGIS
postgis31_13-devel.x86_64 : Development headers and libraries for PostGIS
postgis31_13-docs.x86_64 : Extra documentation for PostGIS
postgis31_13-gui.x86_64 : GUI for PostGIS
postgis31_13-utils.x86_64 : The utils for PostGIS
postgis31_14-client.x86_64 : Client tools and their libraries of PostGIS
postgis31_14-devel.x86_64 : Development headers and libraries for PostGIS
postgis31_14-docs.x86_64 : Extra documentation for PostGIS
postgis31_14-gui.x86_64 : GUI for PostGIS
postgis31_14-utils.x86_64 : The utils for PostGIS
postgis32_11-client.x86_64 : Client tools and their libraries of PostGIS
postgis32_11-devel.x86_64 : Development headers and libraries for PostGIS
postgis32_11-docs.x86_64 : Extra documentation for PostGIS
postgis32_11-gui.x86_64 : GUI for PostGIS
postgis32_11-utils.x86_64 : The utils for PostGIS
postgis32_12-client.x86_64 : Client tools and their libraries of PostGIS
postgis32_12-devel.x86_64 : Development headers and libraries for PostGIS
postgis32_12-docs.x86_64 : Extra documentation for PostGIS
postgis32_12-gui.x86_64 : GUI for PostGIS
postgis32_12-utils.x86_64 : The utils for PostGIS
postgis32_13-client.x86_64 : Client tools and their libraries of PostGIS
postgis32_13-devel.x86_64 : Development headers and libraries for PostGIS
postgis32_13-docs.x86_64 : Extra documentation for PostGIS
postgis32_13-gui.x86_64 : GUI for PostGIS
postgis32_13-utils.x86_64 : The utils for PostGIS
postgis32_14-client.x86_64 : Client tools and their libraries of PostGIS
postgis32_14-devel.x86_64 : Development headers and libraries for PostGIS
postgis32_14-docs.x86_64 : Extra documentation for PostGIS
postgis32_14-gui.x86_64 : GUI for PostGIS
postgis32_14-utils.x86_64 : The utils for PostGIS
postgis32_15-client.x86_64 : Client tools and their libraries of PostGIS
postgis32_15-devel.x86_64 : Development headers and libraries for PostGIS
postgis32_15-docs.x86_64 : Extra documentation for PostGIS
postgis32_15-gui.x86_64 : GUI for PostGIS
postgis32_15-utils.x86_64 : The utils for PostGIS
postgis33_11-client.x86_64 : Client tools and their libraries of PostGIS
postgis33_11-devel.x86_64 : Development headers and libraries for PostGIS
postgis33_11-docs.x86_64 : Extra documentation for PostGIS
postgis33_11-gui.x86_64 : GUI for PostGIS
postgis33_11-utils.x86_64 : The utils for PostGIS
postgis33_12-client.x86_64 : Client tools and their libraries of PostGIS
postgis33_12-devel.x86_64 : Development headers and libraries for PostGIS
postgis33_12-docs.x86_64 : Extra documentation for PostGIS
postgis33_12-gui.x86_64 : GUI for PostGIS
postgis33_12-utils.x86_64 : The utils for PostGIS
postgis33_13-client.x86_64 : Client tools and their libraries of PostGIS
postgis33_13-devel.x86_64 : Development headers and libraries for PostGIS
postgis33_13-docs.x86_64 : Extra documentation for PostGIS
postgis33_13-gui.x86_64 : GUI for PostGIS
postgis33_13-utils.x86_64 : The utils for PostGIS
postgis33_14-client.x86_64 : Client tools and their libraries of PostGIS
postgis33_14-devel.x86_64 : Development headers and libraries for PostGIS
postgis33_14-docs.x86_64 : Extra documentation for PostGIS
postgis33_14-gui.x86_64 : GUI for PostGIS
postgis33_14-utils.x86_64 : The utils for PostGIS
postgis33_15-client.x86_64 : Client tools and their libraries of PostGIS
postgis33_15-devel.x86_64 : Development headers and libraries for PostGIS
postgis33_15-docs.x86_64 : Extra documentation for PostGIS
postgis33_15-gui.x86_64 : GUI for PostGIS
postgis33_15-utils.x86_64 : The utils for PostGIS
SFCGAL.x86_64 : C++ wrapper library around CGAL for PostGIS
pgrouting_11.x86_64 : Routing functionality for PostGIS
pgrouting_12.x86_64 : Routing functionality for PostGIS
pgrouting_13.x86_64 : Routing functionality for PostGIS
pgrouting_14.x86_64 : Routing functionality for PostGIS
pgrouting_15.x86_64 : Routing functionality for PostGIS
postgis.x86_64 : Geographic Information Systems Extensions to PostgreSQL
postgis24_11.x86_64 : Geographic Information Systems Extensions to PostgreSQL
postgis25_11.x86_64 : Geographic Information Systems Extensions to PostgreSQL
postgis25_12.x86_64 : Geographic Information Systems Extensions to PostgreSQL
postgis30_11.x86_64 : Geographic Information Systems Extensions to PostgreSQL
postgis30_12.x86_64 : Geographic Information Systems Extensions to PostgreSQL
postgis30_13.x86_64 : Geographic Information Systems Extensions to PostgreSQL
postgis31_11.x86_64 : Geographic Information Systems Extensions to PostgreSQL
postgis31_12.x86_64 : Geographic Information Systems Extensions to PostgreSQL
postgis31_13.x86_64 : Geographic Information Systems Extensions to PostgreSQL
postgis31_14.x86_64 : Geographic Information Systems Extensions to PostgreSQL
postgis32_11.x86_64 : Geographic Information Systems Extensions to PostgreSQL
postgis32_12.x86_64 : Geographic Information Systems Extensions to PostgreSQL
postgis32_13.x86_64 : Geographic Information Systems Extensions to PostgreSQL
postgis32_14.x86_64 : Geographic Information Systems Extensions to PostgreSQL
postgis32_15.x86_64 : Geographic Information Systems Extensions to PostgreSQL
postgis33_11.x86_64 : Geographic Information Systems Extensions to PostgreSQL
postgis33_12.x86_64 : Geographic Information Systems Extensions to PostgreSQL
postgis33_13.x86_64 : Geographic Information Systems Extensions to PostgreSQL
postgis33_14.x86_64 : Geographic Information Systems Extensions to PostgreSQL
postgis33_15.x86_64 : Geographic Information Systems Extensions to PostgreSQL


# 安装
[root@wy ~]# yum install postgis33_14-client.x86_64  postgis33_14-devel.x86_64 postgis33_14-docs.x86_64 postgis33_14-gui.x86_64 postgis33_14-utils.x86_64

6 pgsql添加postgis拓展

postgres=# CREATE EXTENSION postgis;

postgres=# select name from pg_available_extensions;
postgres=# select * from pg_extension;

7 postgis使用例子

# 二维坐标点组成的多边形 0 0, 60 50,220 50, 220 -40, 50 -40, 0 0 
# 判断一个点是否落在多边形内,不包含边界上的点
SELECT  ST_Contains(
    ST_MakePolygon(
        ST_GeomFromText('LINESTRING ( 0 0,60 50,220 50,220 -40,50 -40,0 0 )')
        ) ,st_point(60,49)
    );

# 判断一个点是否落在多边形内,包含边界上的点
SELECT  ST_Covers(
    ST_MakePolygon(
        ST_GeomFromText('LINESTRING ( 0 0,60 50,220 50,220 -40,50 -40,0 0 )')
        ) ,st_point(60,50)
    );

SELECT  ST_GeomFromText('LINESTRING ( 0 0,60 50,220 50,220 -40,50 -40 ,0 0)');

Text(‘LINESTRING ( 0 0,60 50,220 50,220 -40,50 -40,0 0 )’)
) ,st_point(60,49)
);

判断一个点是否落在多边形内,包含边界上的点

SELECT ST_Covers(
ST_MakePolygon(
ST_GeomFromText(‘LINESTRING ( 0 0,60 50,220 50,220 -40,50 -40,0 0 )’)
) ,st_point(60,50)
);

SELECT ST_GeomFromText(‘LINESTRING ( 0 0,60 50,220 50,220 -40,50 -40 ,0 0)’);


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
openGauss是一款开源的关系型数据库管理系统,它具有多核高性能、全链路安全性、智能运维等企业级特性。 openGauss内核早期源自开源数据库PostgreSQL,融合了华为在数据库领域多年的内核经验,在架构、事务、存储引擎、优化器及ARM架构上进行了适配与优化。作为一个开源数据库,期望与广泛的开发者共同构建一个多元化技术的开源数据库社区。 软件特点: 1、高性能 openGauss突破了多核CPU的瓶颈,实现两路鲲鹏128核150万tpmC,内存优化表(MOT)引擎达350万tpmC。 2、数据分区 内部线程共享的关键数据结构进行数据分区,减少加锁访问冲突。比如CLOG就采用分区优化,解决ClogControlLock锁瓶颈。 3、NUMA化内核数据结构 关键数据结构NUMA化分配,减少跨CPU访问。比如全局PGPROC数组按照NUMA Node的数目分为多份,分别在对应NUMA Node上申请内存。解决ProcArrayLock锁瓶颈。 4、绑核优化 把网络中断绑核和后台业务线程绑核区分开,避免运行线程在核间迁移造成的性能不稳定。 5、ARM指令优化 结合ARM平台的原子操作lse进行优化,实现关键互斥变量原子高效操作。 6、SQL BY PASS 通过SQL BY PASS优化SQL执行流程,简化CPU执行开销。 7、高可靠 正常业务负载情况下,RTO小于10秒,降低节点故障导致的业务不可用时间。 8、并行恢复 主机日志传输到备机时,备机日志落盘的同时,发送给重做恢复分发线程,分发线程根据日志类型和日志操作的数据页发给多个并行恢复线程进行日志重做,保证备机的重做速度跟上主机日志的产生速度。这样备机实时处于ready状态,从而实现瞬间故障切换。 9、MOT引擎(Beta发布) 内存优化表(MOT)存储引擎是一个专为多核大内存优化的存储引擎,具有极高的联机事务处理(OLTP)性能和资源利用率。MOT的数据和索引完全存储在内存中,通过NUMA感知执行,算法消除闩锁争用以及查询JIT本地编译,提供低时延数据访问及高效事务执行。更多请参考MOT引擎文档。 10、安全 openGauss支持账号管理,账号认证,口令复杂度检查,账号锁定,权限管理和校验,传输加密,操作 审计等全方位的数据库安全能力,保护业务满足安全要求。 11、易运维 openGauss将AI算法集成到数据库中,减少数据库维护的负担。 12、SQL预测 openGauss根据收集的历史性能数据进行编码和基于深度学习的训练及预测,支持SQL执行时间预测。 13、SQL诊断器 openGauss支持SQL执行语句的诊断器,提前发现慢查询。 14、参数自动调整 openGauss通过机器学习方法自动调整数据库参数,提高调参效率,降低正确调参成本。
文档内包含的PPT有: CK Tan-VITESSE DATA-DeepGreen DB- 性能优化、开发方向.pdf 楼方鑫-平民软件-Spark_over_OneProxy_Postgresql.pdf Mason Sharp-华为-Scaling with PostgreSQL 9.6 and Postgres-XL.pdf 陆公瑜-Pivotal- Greenplum 5.0及规划.pdf Sylvain - CodeBunker - The power of PostgreSQL exposed with automatically generated API endpoints.pdf 宋光旋-华东师范大学-窗口函数优化.pdf 曾文旌-阿里云-使用 PostgreSQL 去 O 的冰与火.pdf 孙鹏-英资教育-数据库设计中对JSON的使用.pdf 陈飚-Cloudera-Hadoop最新结构化存储利器Kudu.pdf 唐成-云徙科技-数据库多版本实现内幕.pdf 陈飚-Cloudera-HBase佳实践及优化.pdf 汪洋-平安科技-PG+金融架构演进之路.pdf 陈刚-平安科技-PostgreSQL数据库源码浅析.pdf 王鹏冲-平安科技-从ACID的D看三种主流关系型数据库.pdf 陈旭-平安壹钱包-大数据实时流计算风云榜.pdf 王青松-飞象数据-实现PostgreSQL逻辑复制实战.pdf 德哥-阿里云 - PostgreSQL开发最佳实践.pdf 王硕-瀚高软件-PostgreSQL WAL日志解析与应用.pdf 德哥-阿里云-PostgreSQL前世今生.pdf 叶金荣-知数堂-抽丝剥茧之MySQL疑难杂症排查.pdf 德哥-阿里云-sharding单元化(based on postgres_fdw)最佳实践.pdf 余星-平安壹钱包-浅谈PostgreSQL 高可用架构.pdf 范孝剑-阿里云-PG优化器浅析.pdf 张广舟-阿里云-ApsaraDB for Greenplum介绍.pdf 高金芳-平安科技-PostgreSQL反向代理redis.pdf 张文杰-阿里云-PostgreSQL流复制优化.pdf 何祖文-贵州云飞-PG与智慧物流.pdf 张文升-探探科技-PostgreSQL和探探见证四亿次心动.pdf 姜瑞海-瀚高软件-PostgreSQL自适应流复制.pdf 张晓通-平安壹钱包-从金融架构的视角看数据库.pdf 赖伟-飞象数据-Sybase向PG迁移实践.pdf 张友东-阿里云-MongoDB分布式架构演进.pdf 兰海-武汉大学-从PostgreSQL实现Flashback谈如何内核开发.pdf 赵振平-太阳塔科技-工业大数据初探.pdf 李跃森-腾讯科技-PGXZ在微信支付中的应用.pdf 钟勇-上海宝存-固态硬盘的前世今生.pdf 梁海安-平安科技-金融级PostgreSQL数据库监控与优化.pdf 朱贤文-文武信息-Run your PG on ZFS.pdf
Oracle 10g->11g XTTS迁移方案 Oracle 9i至11g exp迁移 Oracle数据库三种迁移方案 Oracle DataGuard方式迁移数据库 数据库迁移升级最佳实践9i-10g-11g Oracle ASM扩容&数据迁移文档 06使用XTTS技术进行U2L跨平台数据迁移 Oracle 迁移至 PostgreSQL 在华为 ARM 上的解决方案 rman异机迁移 迁移 ORACLE数据库和应用异构迁移最佳实践_樊文凯 数据库信息收集表-Oracle数据库迁移升级场景-云和恩墨 零停机时间完成Oracle 上云迁移 OGG能够复制迁移包含CLOB字段的table? Oracle数据库迁移从Windows到Linux Oracle数据库迁移从Windows到Linux 18小时停机时间完成230TB数据从AIX到Linux的迁移 数据库-Oracle11gR2-RAC-with-ASM存储迁移 PDB迁移和克隆 【深度好文】ORACLE 11.2.0.4到ORACLE 19.3 PDB XTTS迁移方案测试 某医院_数据库迁移升级_实施方案 升级迁移整合守则与实践 某医院HIS核心库XTTS迁移实施方案_云和恩墨_20191126_v1.0 Oracle 11g R2 RAC with ASM存储迁移-手记 ORACLE实用技巧之不知道密码情况下dblink的迁移 Oracle 19C 升级、整合、迁移 Oracle11g单实例迁移到RAC架构方案v1.1 如何利用 RMAN 可传输表空间迁移数据库到不同字节序的平台 (Doc ID 1983639.1) 如何利用 RMAN 可传输表空间迁移数据库到不同字节序的平台 (Doc ID 1983639.1) 跨 OS 平台迁移 Oracle DB (Generic Platform) (Doc ID 1525396.1) RAC的备份迁移及恢复 如何利用 RMAN 可传输表空间迁移数据库到不同字节序的平台 (Doc ID 1983639.1) Oracle数据库基于XTTS技术的数据库迁移技术探讨 某医院_数据库迁移升级_实施方案 跨平台迁移都可以通过XTTS实现 Oracle Database Upgrade and Migration Methods - 数据库升级迁移方法 xtts迁移方案-u2l-v3.5 ORACLE 11G RAC迁移至单机

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值