记录日常工作关于系统运维,虚拟化云计算,数据库,网络安全等各方面问题。

环境

linux centOS 7.4
       postgresql 12.2
       postgis 2.5
       mysql_fdw 1.1
       pgrouting 2.6.3

操作步骤

前面写过一篇postgresql安装和使用mysql_fdw,但是那篇用的是postgresql9.4,现在该版本已经停止维护了。
所以与时俱进,更新一版postgresql12的安装方式:

  1. postgres下载大全
    https://download.postgresql.org/pub/repos/yum/12/redhat/rhel-7-x86_64/

  2. 这里下载的是
    https://download.postgresql.org/pub/repos/yum/12/redhat/rhel-7-x86_64/mysql_fdw_12-2.5.3-1.rhel7.x86_64.rpm

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

  4. mariadb-devel依赖

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

    • 1)首先停用mysql:
      service mysqld stop

    • 2)查看mysql所有安装的包:
      [root@localhost~]# rpm -qa | grep mysql
      mysql所有安装的包

    • 3)逐个卸载:
      [root@localhost ~]# rpm -e mysql-community-release-el6-5.noarch //这里写你自己的
      [root@localhost~]# rpm -e --nodeps mysql包
      逐个卸载

    • 4)检查是否卸载干净:
      检查是否卸载干净

  6. 安装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
    (这里虽然安装成功,但是有警告。是否有问题,留待后面考证)
    安装成功

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

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

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

  1. 安装完成后,检查环境
    gw_iocs=# \dx
    检查环境

功能记录

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;
查询结果




转载请标明出处【Centos7安装postgresql12+postgis2.5+mysql+pgrouting】。

《www.micoder.cc》 虚拟化云计算,系统运维,安全技术服务.

网站已经关闭评论