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

  • 相关阅读:
    Shell编程-02-Shell变量
    Linux 下强大的查找命令find
    DevOps 学院
    史上最详细、最全面的Hadoop环境搭建
    Linux 中10个命令链接操作符,帮助新手快速入门运维!
    25个Linux性能监控工具
    一文详解 Linux系统常用监控工具
    ansible 安装指南
    Tomcat管理页面
    Tomcat基础知识
  • 原文地址:https://www.cnblogs.com/rongfengliang/p/12058819.html
Copyright © 2011-2022 走看看