zoukankan      html  css  js  c++  java
  • wal2json pg扩展centos7构建

    使用wal2json可以将pg 变动输出为json 格式,是一个pg 扩展,支持pg9.4+ 目前看到netflix 的dblog 对于pg 的支持就是基于此插件
    以下是关于centos 7的构建说明

    因为使用了centos-release-scl

    pg 开发包安装

    • 添加yum仓库包
    yum install https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
    • 安装开发包
    yum install -y postgresql11-devel
    • 配置pg_config
      为了复用,使用的profile
     
    export PATH=$PATH:/usr/pgsql-11/bin

    生效

    source /etc/profile

    安装centos-release-scl

    • 包含了llvm(clang,以及gcc)
    yum install -y devtoolset-7-llvm centos-release-scl devtoolset-7-gcc* llvm5.0

    说明: 安装llvm5.0 是在安装阶段需要的

    构建

    • clone 代码
    git clone https://github.com/eulerto/wal2json.git
    • 构建
      需要先进入scl 的devtoolset 环境
     
    scl enable devtoolset-7 bash
    cd wal2json
    make
    • 效果
    gcc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -fPIC -I. -I./ -I/usr/pgsql-11/include/server -I/usr/pgsql-11/include/internal -D_GNU_SOURCE -I/usr/include/libxml2 -I/usr/include -c -o wal2json.o wal2json.c
    gcc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -fPIC -L/usr/pgsql-11/lib -Wl,--as-needed -L/usr/lib64/llvm5.0/lib -L/usr/lib64 -Wl,--as-needed -Wl,-rpath,'/usr/pgsql-11/lib',--enable-new-dtags -shared -o wal2json.so wal2json.o
    /opt/rh/llvm-toolset-7/root/usr/bin/clang -Wno-ignored-attributes -fno-strict-aliasing -fwrapv -O2 -I. -I./ -I/usr/pgsql-11/include/server -I/usr/pgsql-11/include/internal -D_GNU_SOURCE -I/usr/include/libxml2 -I/usr/include -flto=thin -emit-llvm -c -o wal2json.bc wal2json.c
    • 安装
    make install

    效果

    /bin/mkdir -p '/usr/pgsql-11/lib'
    /bin/install -c -m 755 wal2json.so '/usr/pgsql-11/lib/'
    /bin/mkdir -p '/usr/pgsql-11/lib/bitcode/wal2json'
    /bin/mkdir -p '/usr/pgsql-11/lib/bitcode'/wal2json/
    /bin/install -c -m 644 wal2json.bc '/usr/pgsql-11/lib/bitcode'/wal2json/./
    cd '/usr/pgsql-11/lib/bitcode' && /usr/lib64/llvm5.0/bin/llvm-lto -thinlto -thinlto-action=thinlink -o wal2json.index.bc wal2json/wal2json.bc

    说明

    以上就是看到dblog 使用了wal2json 扩展插件,进行的一个学习环境准备,后边可以构建一个docker镜像

    参考资料

    https://github.com/eulerto/wal2json
    https://www.postgresql.org/download/linux/redhat/
    https://medium.com/netflix-techblog/dblog-a-generic-change-data-capture-framework-69351fb9099b

  • 相关阅读:
    [UE4]使用C++重写蓝图,SpawnObject根据类型动态创建UObject
    [UE4]在C++中使用中文变量和中文注释
    [UE4]The global shader cache file missing 运行错误解决办法
    [UE4]自定义结构体、类、数据表
    [UE4]使用UFUNCTION注意事项
    [UE4]一个好用的虚幻4插件,根据资源名称动态加载资源,GetCurrentLeveName(获得当前地图名称)
    [UE4]小地图UI放在哪里创建合适?
    [UE4]动态改变相机OrthWidh、关掉阴影
    [UE4]迁移小地图到其他工程
    [UE4]正交
  • 原文地址:https://www.cnblogs.com/rongfengliang/p/12058819.html
Copyright © 2011-2022 走看看