黑马程序员技术交流社区

标题: 【上海校区】postgresql 物理备份 barman 之 [打印本页]

作者: 梦缠绕的时候    时间: 2018-10-11 09:43
标题: 【上海校区】postgresql 物理备份 barman 之
os: ubuntu 16.04
postgresql: 9.6.8
barman: 2.5
ip 规划
192.168.56.101 node1 barman
192.168.56.102 node2 postgresql
barman 是2ndquadrant推出的一款 postgresql 开源备份软件,官网介绍的非常强大。
barman 建议以一个 dedicated server 存在。尽量不要部署到 postgresql server 上,但不是不能部署到 postgresql server 主机上。
ssh/rsyncnode1 修改配置文件
/etc/barman.d/dn1-ssh.conf
# egrep ^[^";"] /etc/barman.d/dn1-ssh.conf[dn1_ssh]description =  "dn1 PostgreSQL Database (via SSH)"ssh_command = ssh postgres@192.168.56.102conninfo = host=192.168.56.102 user=barman dbname=postgresbackup_method = rsyncreuse_backup = copyparallel_jobs = 1archiver = onnode1、node2 配置相互免密登录
过程略,可参考另外一篇blog。https://blog.csdn.net/ctypyb2002/article/details/80572181需要注意的是 node1 在 barman 用户下,node2 在 postgres 用户下。
node1 查看
barman@nodex:~$ barman show-server dn1_ssh |grep incoming_wals_directory        incoming_wals_directory: /var/lib/barman/dn1_ssh/incomingnode2 修改 postgresql.conf
postgres@nodex:~$ vi /etc/postgresql/9.6/main/postgresql.confarchive_command = 'gzip < %p > /data/backup/pgwalarchive/%f.gz && rsync -a %p barman@192.168.56.101:/var/lib/barman/dn1_ssh/incoming/%f'node1 查看定义的 server_name
barman@nodex:~$ barman show-server allbarman@nodex:~$ barman check dn1_sshServer dn1_ssh:        PostgreSQL: OK        is_superuser: OK        wal_level: OK        directories: OK        retention policy settings: OK        backup maximum age: OK (no last_backup_maximum_age provided)        compression settings: OK        failed backups: OK (there are 0 failed backups)        minimum redundancy requirements: OK (have 0 backups, expected at least 0)        ssh: OK (PostgreSQL server)        not in recovery: OK        archive_mode: OK        archive_command: OK        continuous archiving: OK        archiver errors: OKbarman@nodex:~$ barman backup dn1_sshStarting backup using rsync-exclusive method for server dn1_ssh in /var/lib/barman/dn1_ssh/base/20181008T155150Backup start at LSN: 0/17000028 (000000010000000000000017, 00000028)This is the first backup for server dn1_sshWAL segments preceding the current backup have been found:        000000010000000000000015 from server dn1_ssh has been removedStarting backup copy via rsync/SSH for 20181008T155150Copy done (time: 2 seconds)This is the first backup for server dn1_sshAsking PostgreSQL server to finalize the backup.Backup size: 21.1 MiBBackup end at LSN: 0/17000130 (000000010000000000000017, 00000130)Backup completed (start time: 2018-10-08 15:51:52.151974, elapsed time: 3 seconds)barman@nodex:~$ barman status dn1_sshServer dn1_ssh:        Description: dn1 PostgreSQL Database (via SSH)        Active: True        Disabled: False        PostgreSQL version: 9.6.8        Cluster state: in production        pgespresso extension: Not available        Current data size: 21.0 MiB        PostgreSQL Data directory: /data/pg9.6/main        Current WAL segment: 000000010000000000000018        PostgreSQL 'archive_command' setting: gzip < %p > /data/backup/pgwalarchive/%f.gz && rsync -a %p barman@192.168.56.101:/var/lib/barman/dn1_ssh/incoming/%f        Last archived WAL: 000000010000000000000017.00000028.backup, at Mon Oct  8 15:51:56 2018        Failures of WAL archiver: 17 (000000010000000000000015 at Mon Oct  8 15:32:55 2018)        Server WAL archiving rate: 2.22/hour        Retention policies: not enforced        No. of available backups: 1        First available backup: 20181008T155150        Last available backup: 20181008T155150        Minimum redundancy requirements: satisfied (1/0)        ---------------------作者:peiybpeiyb 来源:CSDN 原文:https://blog.csdn.net/ctypyb2002 ... 360?utm_source=copy 版权声明:本文为博主原创文章,转载请附上博文链接!

作者: 不二晨    时间: 2018-10-15 15:56
奈斯
作者: 魔都黑马少年梦    时间: 2018-11-1 16:29





欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/) 黑马程序员IT技术论坛 X3.2