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

posted on   荣锋亮  阅读(1236)  评论(0编辑  收藏  举报

编辑推荐:
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· .NET10 - 预览版1新功能体验(一)
历史上的今天:
2018-12-18 microcks 微服务mocks 工具&&运行时
2018-12-18 openresty 编译ngx_pagespeed 模块-docker 构建
2018-12-18 nginx ssi + ngx_pagespeed 实现micro frontends 开发
2017-12-18 ArangoDB Foxx service 使用
2013-12-18 silverlight 进行本地串口调用的一种可行的解决方法

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5
点击右上角即可分享
微信分享提示