postgis mysql_PostGIS postgresql12安装postgis/mysql_fdw/pgrouting

这篇博客详细介绍了如何在CentOS 7.4上安装PostgreSQL 12、PostGIS 2.5、mysql_fdw 1.1和pgrouting 2.6.3。在安装过程中,遇到了mysql-devel与mariadb-devel的冲突,最终解决了问题,并成功安装所需组件。文章还列出了安装和配置的步骤,包括创建数据库、扩展、服务器、用户映射以及外部表。
摘要由CSDN通过智能技术生成

环境

linux centOS 7.4

postgresql 12.2

postgis 2.5

mysql_fdw 1.1

pgrouting 2.6.3

操作步骤

前面写过一篇postgresql安装和使用mysql_fdw,但是那篇用的是postgresql9.4,现在该版本已经停止维护了。

所以与时俱进,更新一版postgresql12的安装方式:

在安装过程中,遇到需要mariadb-devel依赖。但是我的centerOS7.4版本中,装了mysql5.6,一直提示mariadb-devel被已安装的mysql-community-devel取代,单独卸载mysql-community-devel也没有用。

ff071e741fc2916cc7d669cd64ca20f9.png

后来只能把mysql全部删除了:

1)首先停用mysql:

service mysqld stop

2)查看mysql所有安装的包:

[root@localhost~]# rpm -qa | grep mysql

0eb4f6680b86cba0944e24c49ad3c153.png

3)逐个卸载:

[root@localhost ~]# rpm -e mysql-community-release-el6-5.noarch //这里写你自己的

[root@localhost~]# rpm -e --nodeps mysql包

ad1d4b011ed0dee4ef5453c67b778362.png

4)检查是否卸载干净:

ae4c1ac614f964e4547cabf2e7bc4dff.png

安装mysql_fdw

yum是个好东西,只是mysql_fdw的资源很难找,现在我们有链接了就可以直接yum安装了。

[root@localhost ~]# yum install mysql_fdw_12-2.5.3-1.rhel7.x86_64.rpm //会资源找不到

改用以下方法:

[root@localhost ~]# yum install https://download.postgresql.org/pub/repos/yum/12/redhat/rhel-7-x86_64/mysql_fdw_12-2.5.3-1.rhel7.x86_64.rpm

(这里虽然安装成功,但是有警告。是否有问题,留待后面考证)

5ca9f25187b4dcf7fc9143d04f75cec7.png

安装PgRouting

[root@localhost ~]# yum install pgrouting_12(12是我装的postgresql的版本)

这里遇到一个问题,pgrouting安装时会检测postgis的依赖。yum安装,目前版本是pgrouting3.0,而pgrouting3.0依赖postgis3.0,与之前我们装的postgis版本不一致,会报错。所以这里安装还是固定版本2.6.3

安装完成后,检查环境

gw_iocs=# \dx

7439ec3d6659a6ee56f0fccc3e4fd9be.png

功能记录

Iocs_dispatch命令记录:

1、postgres=# create database gw_iocs owner postgres;

CREATE DATABASE

2、postgres=# grant all privileges on database gw_iocs to postgres;

GRANT

3、postgres=# \c gw_iocs;

您现在已经连接到数据库 "gw_iocs",用户 "postgres".

4、gw_iocs=# create extension postgis;

CREATE EXTENSION

5、gw_iocs=# create extension mysql_fdw;

CREATE EXTENSION

6、gw_iocs=# create server iocs_server foreign data wrapper mysql_fdw options (host '10.19..',port '3306');

CREATE SERVER

7、gw_iocs=# create user mapping for postgres server iocs_server options (username 'root',password '123456');

CREATE USER MAPPING

8、gw_iocs=# grant usage on foreign server iocs_server to postgres;

GRANT

9、gw_iocs=# create foreign table f_dispatch_ledger_area(id int,area_name text,parent_id int) server iocs_server options (dbname 'iocs-dispatch',table_name 'dispatch_ledger_area');

CREATE FOREIGN TABLE

10、gw_iocs=# select * from f_dispatch_ledger_area;

79f1906581c51caceb860c802cb58d41.png

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值