PostGIS 13.5 主从搭建

2024-05-25 22:32
文章标签 搭建 主从 postgis 13.5

本文主要是介绍PostGIS 13.5 主从搭建,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

PostGIS 主从搭建

适用版本

  • postgresql 13.5
  • PostGIS 3.1.4

服务器规划

服务器IP用途
postgis01172.88.0.181主库
postgis02172.88.0.182从库

主库 PostGIS 数据库安装

  • 安装 postgresql
[root@postgis01 ~]# yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm && yum install -y postgresql13 postgresql13-server
  • 安装 PostGIS 插件
[root@postgis01 ~]# yum -y install postgis31_13
  • 创建数据目录
[root@postgis01 ~]# mkdir -p /deploy/postgis/data && chown -R postgres:postgres /deploy/postgis/data
  • 修改配置(添加以下两行内容)
[root@postgis01 ~]# systemctl edit postgresql-13.service
[Service]
Environment=PGDATA=/deploy/postgis/data
  • 重新加载系统
[root@postgis01 ~]# systemctl daemon-reload
  • 初始化数据库
[root@postgis01 ~]# /usr/pgsql-13/bin/postgresql-13-setup initdb
  • 修改配置文件
[root@postgis01 ~]# vim /deploy/postgis/data/postgresql.conf
listen_addresses = '*'
[root@postgis01 ~]# vim /deploy/postgis/data/pg_hba.conf
host    all             all             0.0.0.0/0               trust
  • 启动
[root@postgis01 ~]# systemctl enable postgresql-13 && systemctl start postgresql-13
  • 修改密码
[root@postgis01 ~]# su - postgres
-bash-4.2$ psql
postgres=# alter user postgres with password '123456';
ALTER ROLE
postgres=# \q
-bash-4.2$ exit
登出

配置主从日志同步

  • 修改主节点配置
[root@postgis01 ~]# vim /deploy/postgis/data/postgresql.conf
synchronous_standby_names = '*'
[root@postgis01 ~]# vim /deploy/postgis/data/pg_hba.conf
host    replication     all             172.88.0.182/32         trust
  • 主库创建同步用户
[root@postgis01 ~]# su - postgres
-bash-4.2$ psql
postgres=# create role rpl login replication encrypted password '123456';
CREATE ROLE
postgres=# 
  • 创建用于从库复制的slot
postgres=# select * from pg_create_physical_replication_slot('stand_slot');slot_name  | lsn 
------------+-----stand_slot | 
(1 行记录)
postgres=# \q
-bash-4.2$ exit
  • 重启数据库
[root@postgis01 ~]# systemctl restart postgresql-13

从库 PostGIS 数据库安装

  • 安装 postgresql
[root@postgis02 ~]# yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm && yum install -y postgresql13 postgresql13-server
  • 安装 PostGIS 插件
[root@postgis02 ~]# yum -y install postgis31_13
  • 创建数据目录
[root@postgis02 ~]# mkdir -p /deploy/postgis/data
[root@postgis02 ~]# chown -R postgres:postgres /deploy/postgis/data
[root@postgis02 ~]# chmod 0700 /deploy/postgis/data
  • 修改配置
[root@postgis02 ~]# vim /usr/lib/systemd/system/postgresql-13.service
Environment=PGDATA=/deploy/postgis/data
  • 重新加载系统
[root@postgis02 ~]# systemctl daemon-reload
  • 备份主库数据
[root@postgis02 ~]# pg_basebackup --pgdata=/deploy/postgis/data --format=p --write-recovery-conf --checkpoint=fast --label=mffb --progress --host=172.88.0.181 --port=5432 --username=rpl
  • 修改从库配置
[root@postgis02 ~]# vim /deploy/postgis/data/postgresql.conf
listen_addresses = '*'
primary_conninfo = 'host=172.88.0.181 port=5432 user=rpl password=123456'
primary_slot_name = 'stand_slot'
[root@postgis02 ~]# vim /deploy/postgis/data/pg_hba.conf
host    all             all             0.0.0.0/0               trust
  • 重启从库
[root@postgis02 ~]# systemctl restart postgresql-13

添加 PostGIS 插件支持

-- 在对应的库下运行以下sql
create extension postgis;

完成主从同步!

这篇关于PostGIS 13.5 主从搭建的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/1002802

相关文章

本地搭建DeepSeek-R1、WebUI的完整过程及访问

《本地搭建DeepSeek-R1、WebUI的完整过程及访问》:本文主要介绍本地搭建DeepSeek-R1、WebUI的完整过程及访问的相关资料,DeepSeek-R1是一个开源的人工智能平台,主... 目录背景       搭建准备基础概念搭建过程访问对话测试总结背景       最近几年,人工智能技术

5分钟获取deepseek api并搭建简易问答应用

《5分钟获取deepseekapi并搭建简易问答应用》本文主要介绍了5分钟获取deepseekapi并搭建简易问答应用,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需... 目录1、获取api2、获取base_url和chat_model3、配置模型参数方法一:终端中临时将加

Redis主从/哨兵机制原理分析

《Redis主从/哨兵机制原理分析》本文介绍了Redis的主从复制和哨兵机制,主从复制实现了数据的热备份和负载均衡,而哨兵机制可以监控Redis集群,实现自动故障转移,哨兵机制通过监控、下线、选举和故... 目录一、主从复制1.1 什么是主从复制1.2 主从复制的作用1.3 主从复制原理1.3.1 全量复制

Mycat搭建分库分表方式

《Mycat搭建分库分表方式》文章介绍了如何使用分库分表架构来解决单表数据量过大带来的性能和存储容量限制的问题,通过在一对主从复制节点上配置数据源,并使用分片算法将数据分配到不同的数据库表中,可以有效... 目录分库分表解决的问题分库分表架构添加数据验证结果 总结分库分表解决的问题单表数据量过大带来的性能

Java汇编源码如何查看环境搭建

《Java汇编源码如何查看环境搭建》:本文主要介绍如何在IntelliJIDEA开发环境中搭建字节码和汇编环境,以便更好地进行代码调优和JVM学习,首先,介绍了如何配置IntelliJIDEA以方... 目录一、简介二、在IDEA开发环境中搭建汇编环境2.1 在IDEA中搭建字节码查看环境2.1.1 搭建步

mysql主从及遇到的问题解决

《mysql主从及遇到的问题解决》本文详细介绍了如何使用Docker配置MySQL主从复制,首先创建了两个文件夹并分别配置了`my.cnf`文件,通过执行脚本启动容器并配置好主从关系,文中还提到了一些... 目录mysql主从及遇到问题解决遇到的问题说明总结mysql主从及遇到问题解决1.基于mysql

Python基于火山引擎豆包大模型搭建QQ机器人详细教程(2024年最新)

《Python基于火山引擎豆包大模型搭建QQ机器人详细教程(2024年最新)》:本文主要介绍Python基于火山引擎豆包大模型搭建QQ机器人详细的相关资料,包括开通模型、配置APIKEY鉴权和SD... 目录豆包大模型概述开通模型付费安装 SDK 环境配置 API KEY 鉴权Ark 模型接口Prompt

鸿蒙开发搭建flutter适配的开发环境

《鸿蒙开发搭建flutter适配的开发环境》文章详细介绍了在Windows系统上如何创建和运行鸿蒙Flutter项目,包括使用flutterdoctor检测环境、创建项目、编译HAP包以及在真机上运... 目录环境搭建创建运行项目打包项目总结环境搭建1.安装 DevEco Studio NEXT IDE

搭建Kafka+zookeeper集群调度

前言 硬件环境 172.18.0.5        kafkazk1        Kafka+zookeeper                Kafka Broker集群 172.18.0.6        kafkazk2        Kafka+zookeeper                Kafka Broker集群 172.18.0.7        kafkazk3

【IPV6从入门到起飞】5-1 IPV6+Home Assistant(搭建基本环境)

【IPV6从入门到起飞】5-1 IPV6+Home Assistant #搭建基本环境 1 背景2 docker下载 hass3 创建容器4 浏览器访问 hass5 手机APP远程访问hass6 更多玩法 1 背景 既然电脑可以IPV6入站,手机流量可以访问IPV6网络的服务,为什么不在电脑搭建Home Assistant(hass),来控制你的设备呢?@智能家居 @万物互联