PostgreSQL如何恢复误操作的数据,walminer关键时刻救你一命!

上一篇文章介绍了PostgreSQL如何恢复误操作的数据(详见:PG数据库误删除数据怎么办,还需要跑路吗?),由于使用了Walminer 4.8版本,这个需要购买license,才能使用。有读者私信,有没有开源的工具可以使用呢?当然了,Walminer有完全开源的3.0版,但它需要以插件的方式安装在数据库,支持PostgreSQL10及其以上版本,功能上也相比Walminer 4.x版本弱。如果你的需求不高,应该也能满足使用,下面就来说说walminer 3.0是怎么使用的。

WalMiner3.0安装

软件下载地址:https://gitee.com/movead/XLogMiner/tree/master/
它的安装方式主要有2种:

编译一:PG源码编译 如果你从编译pg数据库开始

  1. 将walminer目录放置到编译通过的PG工程的"…/contrib/"目录下

  2. 进入walminer目录

  3. 执行命令

    make && make install
    

编译二:依据PG安装编译 如果你使用yum或者pg安装包安装了pg

  1. 配置pg的bin路径至环境变量

    export PATH=/h2/pg_install/bin:$PATH
    
  2. 进入walminer代码路径

  3. 执行编译安装

    USE_PGXS=1 MAJORVERSION=12 make
    #MAJORVERSION支持‘10’,‘11’,‘12’,‘13’,‘14’,‘15’,‘16’,‘17’
    USE_PGXS=1 MAJORVERSION=12 make install
    

以我本机的pg 14.4安装为例:

--把下载的软件进行解压
[root@pgdkcs XLogMiner-walminer_3.0_stable]# unzip -q XLogMiner-walminer_3.0_stable.zip
[root@pgdkcs XLogMiner-walminer_3.0_stable]# cd walminer/
[root@pgdkcs walminer]# ls
datadictionary.c  expected             imagemanage.c  pagecollect.h  todo.md        wal2sql_ddl.h  wal2sql_spi.h      walminer_12.conf   walminer.c           walminer_contents.h  walminer_decode.h  wm_compatible.c  wm_utils.h
datadictionary.h  fetchcatalogtable.c  Makefile       sql            wal2sql.c      wal2sql.h      wallist.c          walminer--2.0.sql  walminer.conf        walminer.control     walminer_thread.c  wm_compatible.h
debug_info.md     image                pagecollect.c  temp.h         wal2sql_ddl.c  wal2sql_spi.c  walminer--1.0.sql  walminer--3.0.sql  walminer_contents.c  walminer_decode.c    walreader.c        wm_utils.c

[root@pgdkcs walminer]# USE_PGXS=1 MAJORVERSION=14 make
gcc -std=gnu99 -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werror=vla -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -O2 -fPIC -DPG_VERSION_14 -I. -I./ -I/usr/local/pg144/include/postgresql/server -I/usr/local/pg144/include/postgresql/internal  -D_GNU_SOURCE -I/usr/include/libxml2   -c -o walminer.o walminer.c
gcc -std=gnu99 -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werror=vla -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -O2 -fPIC -DPG_VERSION_14 -I. -I./ -I/usr/local/pg144/include/postgresql/server -I/usr/local/pg144/include/postgresql/internal  -D_GNU_SOURCE -I/usr/include/libxml2   -c -o wm_utils.o wm_utils.c
gcc -std=gnu99 -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werror=vla -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -O2 -fPIC -DPG_VERSION_14 -I. -I./ -I/usr/local/pg144/include/postgresql/server -I/usr/local/pg144/include/postgresql/internal  -D_GNU_SOURCE -I/usr/include/libxml2   -c -o datadictionary.o datadictionary.c
gcc -std=gnu99 -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werror=vla -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -O2 -fPIC -DPG_VERSION_14 -I. -I./ -I/usr/local/pg144/include/postgresql/server -I/usr/local/pg144/include/postgresql/internal  -D_GNU_SOURCE -I/usr/include/libxm

你可能感兴趣的:(PG,数据恢复,postgresql,数据库)