pg 10 wal 归档同步配置

一.rsync server(172.16.3.226)

CentOS 7.2 X64

# yum install -y rsync

# mkdir -p -m 0700 /db/wal_archive

# chown -R postgres.postgres /db/wal_archive

可能存在的问题:

修改目录/db/wal_archive权限后仍报错如下:

rsync: mkstemp "/.000000010000000000000001.2Z6cX4" (in archive) failed: Permission denied (13)

解决办法:请查询 /etc/selinux/config的SELINUX配置项:

SELINUX=disabled

2.rsync server(172.16.3.226)

1).修改配置

# vi /etc/rsyncd.conf

[[email protected] wal_archive]# vi /etc/rsyncd.conf

# /etc/rsyncd: configuration file for rsync daemon mode

# See rsyncd.conf man page for more options.

# configuration example:

# uid = nobody

# gid = nobody

# use chroot = yes

# max connections = 4

# pid file = /var/run/rsyncd.pid

# exclude = lost+found/

# transfer logging = yes

# timeout = 900

# ignore nonreadable = yes

# dont compress   = *.gz *.tgz *.zip *.z *.Z *.rpm *.deb *.bz2

# [ftp]

#        path = /home/ftp

#        comment = ftp export area

############# new add ##############

[archive]

# destination directory for copy

path = /db/wal_archive

# hosts you allow to access

hosts allow = 172.16.3.225

hosts deny = *

list = true

uid = postgres

gid = postgres

read only = false

[[email protected] wal_archive]#

2.启动服务

# systemctl start rsyncd

# systemctl enable rsyncd

二、传输文件

rync client(172.16.3.225)

1.安装软件

# yum install -y rsync

2.建立数据库归档目录

# mkdir -p -m 0700 /db/wal_archive

# chown -R postgres.postgres /db/wal_archive

3.同步脚本配置

1小时以外的wal同步

sync_archives.sh

#!bin/sh

export PATH=/bin:$PATH

find /db/wal_archive -name ‘0000*‘ -type f -mmin 60 | xargs -I{} rsync -avz {} 172.16.3.226::archive

归档删除脚本

两天以外的wal删除

del_archives.sh

#!bin/sh

export PATH=/bin:$PATH

find /db/wal_archive -name ‘0000*‘ -type f -mtime +2 - delete

# crontab -e

* * * * * /opt/cron/sync_archives.sh

0 1 * * * /opt/cron/del_archives.sh

三、数据库归档配置

#------------------------------------------------------------------------------

# WRITE AHEAD LOG

#------------------------------------------------------------------------------

# - Settings -

#wal_level = replica                    # minimal, replica, or logical

# (change requires restart)

#fsync = on                             # flush data to disk for crash safety

# (turning this off can cause

# unrecoverable data corruption)

#synchronous_commit = on                # synchronization level;

# off, local, remote_write, remote_apply, or on

#wal_sync_method = fsync                # the default is the first option

# supported by the operating system:

#   open_datasync

#   fdatasync (default on Linux)

#   fsync

#   fsync_writethrough

#   open_sync

#full_page_writes = on                  # recover from partial page writes

#wal_compression = off                  # enable compression of full-page writes

#wal_log_hints = off                    # also do full page writes of non-critical updates

# (change requires restart)

#wal_buffers = -1                       # min 32kB, -1 sets based on shared_buffers

# (change requires restart)

#wal_writer_delay = 200ms               # 1-10000 milliseconds

#wal_writer_flush_after = 1MB           # measured in pages, 0 disables

#commit_delay = 0                       # range 0-100000, in microseconds

#commit_siblings = 5                    # range 1-1000

# - Checkpoints -

#checkpoint_timeout = 5min              # range 30s-1d

#max_wal_size = 1GB

#min_wal_size = 80MB

checkpoint_completion_target = 0.9      # checkpoint target duration, 0.0 - 1.0

#checkpoint_flush_after = 256kB         # measured in pages, 0 disables

#checkpoint_warning = 30s               # 0 disables

# - Archiving -

archive_mode = on               # enables archiving; off, on, or always

# (change requires restart)

archive_command = ‘cp -an %p > /db/wal_archive/%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 = 86400         # force a logfile segment switch after this

# number of seconds; 0 disables

#------------------------------------------------------------------------------

# REPLICATION

#------------------------------------------------------------------------------

# - Sending Server(s) -

# Set these on the master and on any standby that will send replication data.

max_wal_senders = 20          # max number of walsender processes

# (change requires restart)

wal_keep_segments = 1000       # in logfile segments, 16MB each; 0 disables

#wal_sender_timeout = 60s       # in milliseconds; 0 disables

#max_replication_slots = 10     # max number of replication slots

# (change requires restart)

#track_commit_timestamp = off   # collect timestamp of transaction commit

# (change requires restart)

时间: 2024-10-13 12:17:54

pg 10 wal 归档同步配置的相关文章

linux云自动化运维基础知识10(日志同步和时间同步)

####1.系统日志默认分类#### /var/log/messages    ##系统服务及日志,包括服务的信息,报错等等/var/log/secure        ##系统认证信息日志/var/log/maillog    ##系统邮件服务信息/var/log/cron        ##系统定时任务信息/var/log/boot.log    ##系统启动信息 ####2.日志管理服务rsyslog#### 1.rsyslog负责采集日志和分类存放日志2.rsyslog日志分类vim /

mysql5.7主从同步配置

1. 准备工作 先安装.配置好两台MySQL服务器 主服务器IP:192.168.1.1 从服务器IP:192.168.1.2 mysql的安装请参考之前的文章. 2. 配置主(master)vi /etc/my.cnf修改或添加下面这几行:server-id=1 log-bin=mysql-bin # 启用二进制日志 两个可选参数(2选1):binlog-do-db=db1,db2 #需要同步的库binlog-ignore-db=db1,db2 #忽略不同步的库 保存后重启 /etc/init

mysql5.7.17主从同步配置

一.mysql同步原理 1.mysql主库在事务提交时将数据变更作为时间记录到二进制日志(binary log)中: 2.slave IO线程将master的binary log events读写到它的中继(Relay log): 3.slave SQL进程读取Relay log,将重做记录数据到数据库中. 二.主从同步配置 2,1.配置环境 masterIP:192.168.152.128 mysql version:5.7.17 本地多实例配置  端口为3307.3308. 前期已配置多实例

Linux下Mongodb数据库主从同步配置

说明: 有两台已经安装完成的Mongodb数据库服务器,现在需要把一台设置为主库,另一台设置为从库,实现主从同步. 操作系统:CentOS 7.0 64位 MongoDB数据库版本:mongodb-linux-x86_64-2.6.5 准备工作:MongoDB数据库安装 具体操作: 一.配置MongoDB主库 以下操作在MongoDB主库服务器上进行 1.cd  /usr/local/mongodb/ #进入MongoDB安装目录 vi /usr/local/mongodb/mongodb.co

AIX HACMP系统错误--NODE同步配置错误

AIX HACMP系统错误--NODE同步配置错误 环境: 操作系统: AIX 5300-08 集群软件: CRS 10.2.0.1 数据库:   Oracle 10.2.0.1 故障现象:    在构建AXI RAC时,从一个node同步hacmp配置到另一个node时,出现以下错误: Verification to be performed on the following: Cluster Topology Cluster Resources Verification will autom

sersync+rsync实时同步配置案例

目前业内比较靠谱的同步解决方案有: rsync+inotify-tools,Openduckbill+inotify-tools和rsync+sersync 前两者由于是基于脚本语言编写,所以规范程度,执行效率相对rsync+sersync就稍微弱一些. sersync是使用c++编写,基于boost1.43.0,inotify api,rsync command开发,主要用于服务器同步,web镜像等功能.其对linux系统文件系统产生的临时文件和重复的文件操作能够进行过滤,所以在结合rsync

企业生产MySQL主从同步配置

MySQL主从同步配置 前言:测试环境 一台mysql多个实例 主机IP地址 10.0.0.52 Master   3306 Salve    3307 一.主库要开启binlog服务 1. 1修改配置文件3306/my.cnf [[email protected] ~]# egrep "log-bin|server-id" /data/3306/my.cnf   log-bin = /data/3306/mysql-bin server-id = 1 1. 2查看主库有没有开启bin

MySQL 主主同步配置和主从配置步骤

MySQL 主主同步配置步骤 转载:http://www.jb51.net/article/33624.htm 创建同步用户.修改 /etc/my.cnf 配置文件,为其添加以下内容.分别重启服务器ODD EVEN 上的mysql服务 MySQL 主主同步配置 服务器名 IP 系统 MySQL odd.example.com 192.168.1.116 rhel-5.8 5.5.16 even.example.com 192.168.1.115 rhel-5.8 5.5.16 假设要同步的库是

Linux服务器集群架构部署搭建(六)数据库服务器MySQL编译安装及主从同步配置(1)

命运是大海,当你能够畅游时,你就要纵情游向你的所爱,因为你不知道狂流什么会到来,卷走一切希望与梦想. 作者:燁未央_Estelle声明:测试学习,不足之处,欢迎指正. 第一章 数据库企业应用场景 1.1 数据库的企业应用 MySQL是一种关联数据库管理系统,关联数据库将数据保存在不同的表中,而不是将所有数据放在一个大仓库内,这样就增加了速度并提高了灵活性.MySQL所使用的SQL语言是用于访问数据库的最常用标准化语言.MySQL软件采用了双授权政策,它分为社区版和商业版,由于其体积小.速度快.总