A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

 找回密码
 加入黑马

QQ登录

只需一步,快速开始

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 = on
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
node1、node2 配置相互免密登录
过程略,可参考另外一篇blog。https://blog.csdn.net/ctypyb2002/article/details/80572181
  • 1
  • 2
需要注意的是 node1 在 barman 用户下,node2 在 postgres 用户下。
node1 查看
barman@nodex:~$ barman show-server dn1_ssh |grep incoming_wals_directory        incoming_wals_directory: /var/lib/barman/dn1_ssh/incoming
  • 1
  • 2
node2 修改 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'
  • 1
  • 2
  • 3
  • 4
node1 查看定义的 server_name
barman@nodex:~$ barman show-server all
  • 1
barman@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: OK
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
barman@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 版权声明:本文为博主原创文章,转载请附上博文链接!

2 个回复

倒序浏览
奈斯
回复 使用道具 举报
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 加入黑马