pgbackrest 简要使用说明

测试环境:

CentOS Linux release 7.4.1708 (Core) X64

PostgreSQL: 10.1(Source)

pgbackrest: pgbackrest-release-1.27.tar.gz

1.Test-Simple-1.302120.tar.gz

# perl Makefile.PL

# make

# make test

......

......

All tests successful.

Files=220, Tests=2514, 29 wallclock secs ( 1.10 usr  0.60 sys + 17.97 cusr  4.61 csys = 24.28 CPU)

Result: PASS

#

# make install

2.DBI-1.637.tar.gz

# tar zxvf DBI-1.637.tar.gz

# cd DBI-1.637

# perl Makefile.PL

# make

# make test

......

......

All tests successful.

Files=194, Tests=9005, 113 wallclock secs ( 2.57 usr  0.80 sys + 94.07 cusr 12.95 csys = 110.39 CPU)

Result: PASS

PERL_DL_NONLAZY=1 /usr/bin/perl "-Iblib/lib" "-Iblib/arch" test.pl

test.pl

DBI test application $Revision$

Switch: DBI 1.637 by Tim Bunce, 1.637

Available Drivers: DBM, ExampleP, File, Gofer, Proxy, Sponge

dbi:ExampleP:: testing 3 sets of 20 connections:

Connecting... 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20

Disconnecting...

Connecting... 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20

Disconnecting...

Connecting... 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20

Disconnecting...

connect 20 and disconnect them, 3 times: 0.0040s / 60 = 0.0001s

Testing handle creation speed...

51282 NullP sth/s perl 5.016003 x86_64-linux-thread-multi (gcc 4.8.5 -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic) 0.000019s

test.pl done

#

# make install

3.version-0.9918.tar.gz

# perl Makefile.PL

# make

# make test

......

......

All tests successful.

Test Summary Report

-------------------

t/07locale.t    (Wstat: 0 Tests: 8 Failed: 0)

TODO passed:   7

Files=12, Tests=2502,  2 wallclock secs ( 0.45 usr  0.12 sys +  1.05 cusr  1.13 csys =  2.75 CPU)

Result: PASS

make[1]: Entering directory `/home/soft/dbd-pg/version-0.9918/vutil'

No tests defined for version::vxs extension.

make[1]: Leaving directory `/home/soft/dbd-pg/version-0.9918/vutil'

# make install

4.DBD-Pg-3.7.0.tar.gz

export PATH=/opt/pgsql/10.1/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin

export LD_LIBRARY_PATH=/opt/pgsql/10.1/lib

export MANPATH=/opt/pgsql/10.1/share/man:$MANPATH

# perl Makefile.PL

Configuring DBD::Pg 3.7.0

PostgreSQL version: 100001 (default port: 5432)

POSTGRES_HOME: (not set)

POSTGRES_INCLUDE: /opt/pgsql/10.1/include

POSTGRES_LIB: /opt/pgsql/10.1/lib

OS: linux

Checking if your kit is complete...

Looks good

Using DBI 1.637 (for perl 5.016003 on x86_64-linux-thread-multi) installed in /usr/local/lib64/perl5/auto/DBI/

Writing Makefile for DBD::Pg

#

# make

cp lib/Bundle/DBD/Pg.pm blib/lib/Bundle/DBD/Pg.pm

cp Pg.pm blib/lib/DBD/Pg.pm

/usr/bin/perl -p -e "s/~DRIVER~/Pg/g; s/^do\(/dontdo\(/" /usr/local/lib64/perl5/auto/DBI/Driver.xst > Pg.xsi

/usr/bin/perl /usr/share/perl5/vendor_perl/ExtUtils/xsubpp  -typemap /usr/share/perl5/ExtUtils/typemap  Pg.xs > Pg.xsc && mv Pg.xsc Pg.c

gcc -c  -I/opt/pgsql/10.1/include -I/usr/local/lib64/perl5/auto/DBI -D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DPGLIBVERSION=100001 -DPGDEFPORT=5432 -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic  -DPERL_EXTMALLOC_DEF -Dmalloc=Perl_malloc -Dfree=Perl_mfree -Drealloc=Perl_realloc -Dcalloc=Perl_calloc -DVERSION=\"3.7.0\" -DXS_VERSION=\"3.7.0\" -fPIC "-I/usr/lib64/perl5/CORE"   Pg.c

gcc -c  -I/opt/pgsql/10.1/include -I/usr/local/lib64/perl5/auto/DBI -D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DPGLIBVERSION=100001 -DPGDEFPORT=5432 -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic  -DPERL_EXTMALLOC_DEF -Dmalloc=Perl_malloc -Dfree=Perl_mfree -Drealloc=Perl_realloc -Dcalloc=Perl_calloc -DVERSION=\"3.7.0\" -DXS_VERSION=\"3.7.0\" -fPIC "-I/usr/lib64/perl5/CORE"   dbdimp.c

gcc -c  -I/opt/pgsql/10.1/include -I/usr/local/lib64/perl5/auto/DBI -D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DPGLIBVERSION=100001 -DPGDEFPORT=5432 -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic  -DPERL_EXTMALLOC_DEF -Dmalloc=Perl_malloc -Dfree=Perl_mfree -Drealloc=Perl_realloc -Dcalloc=Perl_calloc -DVERSION=\"3.7.0\" -DXS_VERSION=\"3.7.0\" -fPIC "-I/usr/lib64/perl5/CORE"   quote.c

In file included from Pg.h:59:0,

from quote.c:10:

/usr/local/lib64/perl5/auto/DBI/DBIXS.h:491:25: warning: ‘dbi_get_state’ defined but not used [-Wunused-function]

static dbistate_t** dbi_get_state(pTHX) {                               \

^

/usr/local/lib64/perl5/auto/DBI/DBIXS.h:504:27: note: in expansion of macro ‘_DBISTATE_DECLARE_COMMON’

# define DBISTATE_DECLARE _DBISTATE_DECLARE_COMMON

^

Pg.h:65:1: note: in expansion of macro ‘DBISTATE_DECLARE’

DBISTATE_DECLARE;

^

gcc -c  -I/opt/pgsql/10.1/include -I/usr/local/lib64/perl5/auto/DBI -D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DPGLIBVERSION=100001 -DPGDEFPORT=5432 -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic  -DPERL_EXTMALLOC_DEF -Dmalloc=Perl_malloc -Dfree=Perl_mfree -Drealloc=Perl_realloc -Dcalloc=Perl_calloc -DVERSION=\"3.7.0\" -DXS_VERSION=\"3.7.0\" -fPIC "-I/usr/lib64/perl5/CORE"   types.c

In file included from Pg.h:59:0,

from types.c:15:

/usr/local/lib64/perl5/auto/DBI/DBIXS.h:491:25: warning: ‘dbi_get_state’ defined but not used [-Wunused-function]

static dbistate_t** dbi_get_state(pTHX) {                               \

^

/usr/local/lib64/perl5/auto/DBI/DBIXS.h:504:27: note: in expansion of macro ‘_DBISTATE_DECLARE_COMMON’

# define DBISTATE_DECLARE _DBISTATE_DECLARE_COMMON

^

Pg.h:65:1: note: in expansion of macro ‘DBISTATE_DECLARE’

DBISTATE_DECLARE;

^

Running Mkbootstrap for DBD::Pg ()

chmod 644 Pg.bs

rm -f blib/arch/auto/DBD/Pg/Pg.so

gcc  -shared -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -Wl,-z,relro  Pg.o dbdimp.o quote.o types.o  -o blib/arch/auto/DBD/Pg/Pg.so       \

-L/opt/pgsql/10.1/lib -lpq -lm       \

chmod 755 blib/arch/auto/DBD/Pg/Pg.so

cp Pg.bs blib/arch/auto/DBD/Pg/Pg.bs

chmod 644 blib/arch/auto/DBD/Pg/Pg.bs

Manifying blib/man3/Bundle::DBD::Pg.3pm

Manifying blib/man3/DBD::Pg.3pm

[[email protected] DBD-Pg-3.7.0]# make test

PGINITDB="/opt/pgsql/10.1/bin/initdb" PERL_DL_NONLAZY=1 /usr/bin/perl "-MExtUtils::Command::MM" "-e" "test_harness(0, 'blib/lib', 'blib/arch')" t/*.t

t/00_signature.t .... skipped: Set the environment variable TEST_SIGNATURE to enable this test

t/00basic.t ......... ok

t/01connect.t ....... 1/15 #

# DBI                         Version 1.637

# DBD::Pg                     Version 3.7.0

# Perl                        Version 5.16.3

# OS                          linux

# PostgreSQL (compiled)       100001

# PostgreSQL (target)         100001

# PostgreSQL (reported)       PostgreSQL 10.1 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-16), 64-bit

# Default port                5432

# DBI_DSN                     dbi:Pg:

# DBI_USER                    postgres

# Test schema                 dbd_pg_testschema

# LANG                        en_US.UTF-8

# array_nulls                 on

# backslash_quote             safe_encoding

# client_encoding             UTF8

# server_encoding             UTF8

# standard_conforming_strings on

# Adjusted:                   DBI_DSN

t/01connect.t ....... ok

t/01constants.t ..... ok

t/02attribs.t ....... ok

t/03dbmethod.t ...... ok

t/03smethod.t ....... ok

t/04misc.t .......... ok

t/06bytea.t ......... ok

t/07copy.t .......... ok

t/08async.t ......... ok

t/09arrays.t ........ ok

t/12placeholders.t .. ok

t/20savepoints.t .... ok

t/30unicode.t ....... ok

t/99cleanup.t ....... ok

All tests successful.

Files=16, Tests=2129, 26 wallclock secs ( 0.57 usr  0.13 sys +  3.78 cusr  4.35 csys =  8.83 CPU)

Result: PASS

[[email protected] DBD-Pg-3.7.0]# make install

Files found in blib/arch: installing files in blib/lib into architecture dependent library tree

Installing /usr/local/lib64/perl5/auto/DBD/Pg/Pg.so

Installing /usr/local/lib64/perl5/auto/DBD/Pg/Pg.bs

Installing /usr/local/lib64/perl5/DBD/Pg.pm

Installing /usr/local/lib64/perl5/Bundle/DBD/Pg.pm

Installing /usr/local/share/man/man3/Bundle::DBD::Pg.3pm

Installing /usr/local/share/man/man3/DBD::Pg.3pm

Appending installation info to /usr/lib64/perl5/perllocal.pod

#

5.other perl module

# yum install -y perl-IO-Socket-SSL perl-XML-LibXML openssl-devel perl-Digest-SHA perl-JSON-PP

6.pgbackrest

# tar zxvf pgbackrest-release-1.27.tar.gz

# cd pgbackrest-release-1.27

######  lib ######

# cp -r lib/pgBackRest /usr/share/perl5

# find /usr/share/perl5/pgBackRest -type f -exec chmod 644 {} +

# find /usr/share/perl5/pgBackRest -type d -exec chmod 755 {} +

######  bin ######

# cp bin/pgbackrest /usr/bin/pgbackrest

# chmod 755 /usr/bin/pgbackrest

######  log ######

# mkdir -m 770 /var/log/pgbackrest

# chown postgres:postgres /var/log/pgbackrest

###### conf ######

# touch /etc/pgbackrest.conf

# chmod 640 /etc/pgbackrest.conf

# chown postgres:postgres /etc/pgbackrest.conf

######  Build and Install C Library ######

# cd libc/

# perl Makefile.PL INSTALLMAN1DIR=none INSTALLMAN3DIR=none

Writing Makefile for pgBackRest::LibC

#

# make test

......

......

All tests successful.

Files=1, Tests=4,  1 wallclock secs ( 0.02 usr  0.01 sys +  0.12 cusr  0.03 csys =  0.18 CPU)

Result: PASS

#

# make install

Files found in blib/arch: installing files in blib/lib into architecture dependent library tree

Installing /usr/local/lib64/perl5/auto/pgBackRest/LibC/LibC.so

Installing /usr/local/lib64/perl5/auto/pgBackRest/LibC/LibC.bs

Installing /usr/local/lib64/perl5/pgBackRest/LibC.pm

Installing /usr/local/lib64/perl5/pgBackRest/LibCAuto.pm

Installing /usr/local/lib64/perl5/auto/pgBackRest/LibC/autosplit.ix

Appending installation info to /usr/lib64/perl5/perllocal.pod

#

# su - postgres

Last login: Thu Dec 21 15:50:54 CST 2017 on pts/1

[[email protected] ~]$ pgbackrest --help

Unknown option: help

pgBackRest 1.27 - General help

Usage:

pgbackrest [options] [command]

Commands:

archive-get     Get a WAL segment from the archive.

archive-push    Push a WAL segment to the archive.

backup          Backup a database cluster.

check           Check the configuration.

expire          Expire backups that exceed retention.

help            Get help.

info            Retrieve information about backups.

restore         Restore a database cluster.

stanza-create   Create the required stanza data.

stanza-upgrade  Upgrade a stanza.

start           Allow pgBackRest processes to run.

stop            Stop pgBackRest processes from running.

version         Get version.

Use 'pgbackrest help [command]' for more information.

[[email protected] ~]$

###### root ######

# mkdir /var/lib/pgbackrest

# chmod 750 /var/lib/pgbackrest

# chown postgres:postgres /var/lib/pgbackrest

# su - postgres

$ vi postgresql.conf

listen_addresses = '*'

wal_level = logical

archive_mode = on

archive_command = 'pgbackrest --stanza=db archive-push %p'

#log_line_prefix = '%m [%p] '

#max_wal_senders = 10

wal_keep_segments = 5000

#hot_standby = on

$ openssl rand -base64 48

lFhhFeDQPazx59LPvztsWu5leUqsiOwhI8JT7gMAmACMVX+Kcwak5qDOVNiiNkqX

$ vi /etc/pgbackrest.conf

# 仅包含字母,不能为db01

[db]

db-path=/pgdata10

[global]

repo-cipher-pass=lFhhFeDQPazx59LPvztsWu5leUqsiOwhI8JT7gMAmACMVX+Kcwak5qDOVNiiNkqX

repo-cipher-type=aes-256-cbc

repo-path=/var/lib/pgbackrest

retention-full=2

process-max=3

start-fast=y

stop-auto=y

$ vi .bash_profile

# User specific environment and startup programs

export LD_LIBRARY_PATH=/opt/pgsql/10.1/lib

export MANPATH=/opt/pgsql/10.1/share/man:$MANPATH

export PATH=/opt/pgsql/10.1/bin:$PATH:$HOME/.local/bin:$HOME/bin

1).create repository

$ pgbackrest --stanza=db --log-level-console=info stanza-create

2017-12-21 16:14:25.331 P00   INFO: stanza-create command begin 1.27: --db1-path=/pgdata10 --log-level-console=info --repo-path=/var/lib/pgbackrest --stanza=db01

2017-12-21 16:14:25.801 P00   INFO: stanza-create command end: completed successfully

$

$ pgbackrest --stanza=db --log-level-console=info check

2017-12-21 16:46:45.886 P00   INFO: check command begin 1.27: --db1-path=/pgdata10 --log-level-console=info --repo-path=/var/lib/pgbackrest --stanza=db

2017-12-21 16:46:48.243 P00   INFO: WAL segment 000000010000000000000005 successfully stored in the archive at '/var/lib/pgbackrest/archive/db/10-1/0000000100000000/000000010000000000000005-a85cb846cee3a5a47b487415a2570ce7b5fbf2f8.gz'

2017-12-21 16:46:48.244 P00   INFO: check command end: completed successfully

$

2).备份操作

###### full ######

pgbackrest --stanza=db --type=full --log-level-console=info backup

###### incremental ######

$ pgbackrest --stanza=db --type=incr --log-level-console=info backup

###### diff ######

pgbackrest --stanza=db --type=diff --log-level-console=info backup

###### display backup ######

$ pgbackrest --stanza=db --log-level-console=info info

###### restore(--delta, PGDATA base exist part file,miss some files ) ######

$ pgbackrest --stanza=db --delta --log-level-console=info restore

###### restore(--delta, PGDATA none file) ######

$ pgbackrest --stanza=db --log-level-console=info restore

时间: 2024-10-03 06:08:01

pgbackrest 简要使用说明的相关文章

Kafka 简要使用说明

Kafka 简要使用说明 概念: Partition, consumer group, rebalance 在使用中, 为了保证消费 Kafka 的数据和生产数据的次序严格一致, 一个 Topic 只设置了一个 Partition. 我没有碰到不关心时序的场景, 所有的 Topic 都只有一个 partition. 一个 Topic 可以被多个 consumer group 重复消费, 这些 consumer group 之间是完全隔离的. 一个 consumer group 可以包含一个或多个

tftp 简要使用说明

yum 安装:tftp    tftp-server (2)启动tftp CentOS 6 service xinetd restart chkconfig tftp on CentOS 7 systemctl start tftp.socket systemctl enable tftp.socket (3)服务器默认的站点目录 /var/lib/tftpboot (4)tftp服务端监听于udp的69端口 (5)启动tftp服务 systemctl start tftp.socket (6)

JProfiler 简要使用说明

1.简介 JProfiler是一个ALL-IN-ONE的JAVA剖析工具,可以方便地监控Java程序的CPU.内存使用状况,能够检查垃圾回收.分析性能瓶颈. 本说明文档基于JProfiler 9.2编写. 2.安装 安装包:JProfiler_windows-x64_9_2.exe (JProfiler 9注册码.txt) 如果要监控的远端服务器操作系统不同,在Select Component这步,可以选择安装不同系统的Native libraries for profiling agent.

pyinstaller简要使用说明

pyinstaller可以把.py脚本保存成.exe可执行文件. 安装时使用pip install pyinstaller即可 基本语法:pyinstaller options myscript.py常用的可选参数如下:--onefile 将结果打包成一个可执行文件--onedir 将所有结果打包到一个文件夹中,该文件夹包括一个可执行文件和可执行文件执行时需要的依赖文件(默认)--paths=DIR 设置导入路径--distpath=DIR 设置将打包的结果文件放置的路径--specpath=D

openssl 加密算法 CA 介绍

首先对于tftp服务的简要使用说明 (1)yum安装:tftp.tftp-server (2)启动tftp CentOS 6 service xinetd restart chkconfig tftp on CentOS 7 systemctl start tftp.socket systemctl enable tftp.socket (3)服务器默认的站点目录 /var/lib/tftpboot (4)tftp服务端监听于udp的69端口 (5)启动tftp服务 systemctl star

04 Linux操作系统及常用命令

一.操作系统 shell: GUI: Graphic User Interface 图形用户界面 Windows X-Window: Gnome KDE Xfce CLI:Command Line Interface sh bash csh ksh zsh tcsh 两大雷锋实验室: 贝尔实验室 施乐公司的PARC实验室:以太网,鼠标,图形用户界面 库文件: .dll : dynamic link library,  windows 下的 动态链接库. .so: shared object ,共

使用psftp.exe

使用psftp.exe 点击打开psftp.exe,出现如下图的命令窗口.  输入open [user]@[host],user为用户名,host为sftp服务器的ip,如输入 open aaa@172.18.235.56 回车后出现以下提示  输入n,不需要把key缓存:然后提示输入密码.成功连接后,就会返回命令符. 输入put [FilePath] 就可以把文件传到sftp的文件夹中.如输入 put “D:\temp\temp\sftp架设方案.doc” wk_ad_begin({pid :

Git学习笔记与IntelliJ IDEA整合

一.Git学习笔记(基于Github) 1.安装和配置Git 下载地址: http://git-scm.com/downloads Git简要使用说明: http://rogerdudler.github.io/git-guide/index.zh.html Github官方使用说明: https://help.github.com/articles/set-up-git 默认安装 配置 1)首先你要告诉git你的名字 git config --global user.name " Your N

ansible playbook实践(二)-基础相关命令

ansible相关的命令: ansible  用来执行ansible管理命令 ansible-doc 用来获取模块的帮助文档 ansible-playbook 当有众多任务时,可编写成playbook来运行 ansible的简单使用格式: ansible HOST-PATTERN -m MOD_NAME -a MOD_ARGS 获取模块列表 ansible-doc -l 里面有众多模块,掌握一些常用的即可满足日常工作 ansible-doc -s modulename # 获取模块简要使用说明