iis服务器助手广告广告
返回顶部
首页 > 资讯 > 数据库 >pgbackrest 简要使用说明
  • 238
分享到

pgbackrest 简要使用说明

2024-04-02 19:04:59 238人浏览 八月长安
摘要

测试环境:Centos linux release 7.4.1708 (Core) X64postgresql: 10.1(Source)pgbackrest: pgbackrest-release-1.2

测试环境:

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

[root@localhost 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

[root@localhost 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

[postgres@localhost ~]$ 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.

[postgres@localhost ~]$ 



###### 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


您可能感兴趣的文档:

--结束END--

本文标题: pgbackrest 简要使用说明

本文链接: https://www.lsjlt.com/news/40610.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

本篇文章演示代码以及资料文档资料下载

下载Word文档到电脑,方便收藏和打印~

下载Word文档
猜你喜欢
  • oracle怎么查询当前用户所有的表
    要查询当前用户拥有的所有表,可以使用以下 sql 命令:select * from user_tables; 如何查询当前用户拥有的所有表 要查询当前用户拥有的所有表,可以使...
    99+
    2024-05-14
    oracle
  • oracle怎么备份表中数据
    oracle 表数据备份的方法包括:导出数据 (exp):将表数据导出到外部文件。导入数据 (imp):将导出文件中的数据导入表中。用户管理的备份 (umr):允许用户控制备份和恢复过程...
    99+
    2024-05-14
    oracle
  • oracle怎么做到数据实时备份
    oracle 实时备份通过持续保持数据库和事务日志的副本来实现数据保护,提供快速恢复。实现机制主要包括归档重做日志和 asm 卷管理系统。它最小化数据丢失、加快恢复时间、消除手动备份任务...
    99+
    2024-05-14
    oracle 数据丢失
  • oracle怎么查询所有的表空间
    要查询 oracle 中的所有表空间,可以使用 sql 语句 "select tablespace_name from dba_tablespaces",其中 dba_tabl...
    99+
    2024-05-14
    oracle
  • oracle怎么创建新用户并赋予权限设置
    答案:要创建 oracle 新用户,请执行以下步骤:以具有 create user 权限的用户身份登录;在 sql*plus 窗口中输入 create user identified ...
    99+
    2024-05-14
    oracle
  • oracle怎么建立新用户
    在 oracle 数据库中创建用户的方法:使用 sql*plus 连接数据库;使用 create user 语法创建新用户;根据用户需要授予权限;注销并重新登录以使更改生效。 如何在 ...
    99+
    2024-05-14
    oracle
  • oracle怎么创建新用户并赋予权限密码
    本教程详细介绍了如何使用 oracle 创建一个新用户并授予其权限:创建新用户并设置密码。授予对特定表的读写权限。授予创建序列的权限。根据需要授予其他权限。 如何使用 Oracle 创...
    99+
    2024-05-14
    oracle
  • oracle怎么查询时间段内的数据记录表
    在 oracle 数据库中查询指定时间段内的数据记录表,可以使用 between 操作符,用于比较日期或时间的范围。语法:select * from table_name wh...
    99+
    2024-05-14
    oracle
  • oracle怎么查看表的分区
    问题:如何查看 oracle 表的分区?步骤:查询数据字典视图 all_tab_partitions,指定表名。结果显示分区名称、上边界值和下边界值。 如何查看 Oracle 表的分区...
    99+
    2024-05-14
    oracle
  • oracle怎么导入dump文件
    要导入 dump 文件,请先停止 oracle 服务,然后使用 impdp 命令。步骤包括:停止 oracle 数据库服务。导航到 oracle 数据泵工具目录。使用 impdp 命令导...
    99+
    2024-05-14
    oracle
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作