• [如何编译openGauss对应版本的wal2json.so]


    wal2json是逻辑解码插件,使用该插件可以访问由INSERT和UPDATE生成的元组,解析WAL中的内容。
    本篇文章介绍了如何手动编译openGauss对应版本的wal2json.so。

    首先,需要一套对应版本数据库的软件和openGauss-server的源码,以及wal2json代码进行编译安装。本篇文章以openGauss 3.0.0为例

    对应的网址如下:
    1.openGauss-server源码路径:openGauss-server: openGauss kernel ~ openGauss is an open source relational database management system.
    2.openGauss软件下载路径:软件包 | openGauss
    3.wal2json代码路径:wal2json: This project is a fork from wal2json, a compatibility version for openGuass.

    我编译好的openGauss 3.0的 wal2json.so(x86)放到了gitee上,需要的朋友可以自取:wal2json-openGauss3.0-x86: wal2json-openGauss3.0-x86

    一、下载openGauss-server源码

    1. [mog@localhost ~]$ pwd
    2. /home/mog
    3. [mog@localhost ~]$ mkdir opengauss-server-package
    4. [mog@localhost ~]$ cd opengauss-server-package/
    5. [mog@localhost opengauss-server-package]$ git clone https://gitee.com/opengauss/openGauss-server.git
    6. Cloning into 'openGauss-server'...
    7. remote: Enumerating objects: 59079, done.
    8. remote: Counting objects: 100% (13276/13276), done.
    9. remote: Compressing objects: 100% (4659/4659), done.

    二、复制openGauss部分源码到软件目录下,并替换pg_config_os.h

    复制opengauss源码src/include/*的内容到数据库安装目录的include/postgresql/server 下,cd到这个目录下,执行 rm -f pg_config_os.h; cp port/linux.h pg_config_os.h

    因此我本地源码对应的要拷贝的目录为:

    /home/mog/opengauss-server-package/openGauss-server/src/include/*
    

    这里 /mogdb/software是我本地数据库的软件目录。

    因此我软件的对应目录为

    /mogdb/software/include/postgresql/server
    

    进行拷贝

    cp -r /home/mog/opengauss-server-package/openGauss-server/src/include/* /mogdb/software/include/postgresql/server
    

    替换pg_config_os.h

    1. cd /mogdb/software/include/postgresql/server
    2. rm -f pg_config_os.h
    3. cp port/linux.h pg_config_os.h

    三、源码安装g++

    #编译前需要确保g+ +安装,g+ +需要c+ +14版本
    本地发现g++版本不够,重新编译安装较高版本,这里gcc要至少6.1版本,否则会有相关报错

    yum -y install gcc+ gcc-c++

    当前版本较低

    1.下载源码包

    wget http://ftp.gnu.org/gnu/gcc/gcc-6.2.0/gcc-6.2.0.tar.bz2
    

    2.解压

    tar jxf gcc-6.2.0.tar.bz2
    

    3.下载编译依赖

    1. cd gcc-6.2.0
    2. ./contrib/download_prerequisites

    4.生成makefile文件

    1. mkdir gcc-build-6.2.0
    2. cd gcc-build-6.2.0/
    3. ../configure -enable-checking=release -enable-languages=c,c++ -disable-multilib

    5.编译

    make
    

    漫长的等待

    6.安装

    make install
    

    四、下载wal2json代码并编译

    git clone https://gitee.com/enmotech/wal2json
    

    1. export PATH=/mogdb/software/bin:$PATH
    2. make
    3. make install

    发现编译过程存在报错,我们把对应的几个.h里进行修改,去掉std::

    最后编译成功

    wal2json放到对应路径下

    已经可以正常使用了

    1. postgres=# select * from pg_create_logical_replication_slot('mdb_20220823025242_slot','wal2json');
    2. slotname | xlog_position
    3. -------------------------+---------------
    4. mdb_20220823025242_slot | D70/EE73A0A8
    5. (1 row)
  • 相关阅读:
    NeurIPS 2023 放榜!3200多篇上榜,录用率26.1%
    【工作记录】css3 grid布局笔记
    Azure Function 时区设置
    【Unity Texture】_MainTex的含义
    bash关闭按tab两次才显示关闭按tab显示隐藏文件
    计算机网络:从入门到放弃
    安科瑞EMS能效管理平台降低铜电解单耗的应用-Susie 周
    B+树结构与索引<二> _ 索引页示例
    swagger常用注解
    使用s3 api访问AWS S3服务
  • 原文地址:https://blog.csdn.net/weixin_47308871/article/details/126651895