首页 技术 正文
技术 2022年11月14日
0 收藏 525 点赞 4,650 浏览 1915 个字

1.下载对应数据库版本及操作系统的pg_rman源码

https://github.com/ossc-db/pg_rman/releases

本例使用的是centos6.9+pg10,因此下载的是pg_rman-1.3.7-pg10.tar.gz

源码是与操作系统无关的,在编译安装的时候会适配对应的操作系统

2.上传安装包并解压安装

# tar vxf pg_rman-1.3.7-pg10.tar.gz
# cd pg_rman-1.3.7-pg10
# export PATH=$PATH:/usr/local/pgsql/bin
# make

make时出现以下错误,提示找不到connect.h

pgut/pgut.c:11:30: error: fe_utils/connect.h: No such file or directory
pgut/pgut.c: In function ‘pgut_connect’:
pgut/pgut.c:949: error: ‘ALWAYS_SECURE_SEARCH_PATH_SQL’ undeclared (first use in this function)
pgut/pgut.c:949: error: (Each undeclared identifier is reported only once
pgut/pgut.c:949: error: for each function it appears in.)
make: *** [pgut/pgut.o] Error 1

解决方法,从其他版本copy一个connect.h过来

# cp /usr/local/pgsql-12.0/include/server/fe_utils/connect.h /usr/local/pgsql/include/server/fe_utils/

之后执行make

# make
# make install

验证rman,使用make installcheck验证

# chown -R postgres.postgres pg_rman-1.3.7-pg10
# su - postgres
$ cd /data/software/pg_rman-1.3.7-pg10
$ make installcheck

3.开启数据库归档

# su - postgres
$ cd /archlog
$ mkdir pg-10.0
$ cd $PGDATA
$ vi postgresql.conf

修改如下部分

# - Archiving -archive_mode = on           # enables archiving; off, on, or always
# (change requires restart)
archive_command = 'test ! -f /archlog/pg-10.0/%f && cp %p /archlog/pg-10.0/%f' # command to use to archive a logfile segment
# placeholders: %p = path of file to archive
# %f = file name only
# e.g. 'test ! -f /mnt/server/archivedir/%f && cp %p /mnt/server/archivedir/%f'
archive_timeout = 1800 # force a logfile segment switch after this
# number of seconds; 0 disables

修改后,需要重启数据库

$ pg_ctl restart
$ psql
#切换以下redo,测试归档设置是否OK
select pg_switch_wal();

4.配置环境变量

# su - postgres
$ vi .bash_profile

添加如下环境变量

export BACKUP_PATH=/pgdata/pg_rman_backup

5.初始化pg_rman,并全备测试

$ pg_rman init
$ pg_rman backup --backup-mode=full -C -P
$ pg_rman show

6.删除归档的脚本和后台执行全备的脚本

$ pg_archivecleanup -d /archlog/archivedir 000000010000EEF700000060
$ nohup pg_rman backup --backup-mode=full -C -P > /archlog/pg_rman_backup/full_backup.log 2>&1 &

第二个nohub,意思是no hung up,在每一个ssh断开的时候,会向其所有子进程发送hung up信号,子程序会停止,使用nohub后,在ssh退出时,程序会继续执行

&是后台执行的意思,会让这个命令在后台执行,但是在ssh退出后,程序会被退出,两者结合起来可以实现后台执行

  

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,491
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,907
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,740
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,493
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:8,132
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:5,294