网创优客建站品牌官网
为成都网站建设公司企业提供高品质网站建设
热线:028-86922220
成都专业网站建设公司

定制建站费用3500元

符合中小企业对网站设计、功能常规化式的企业展示型网站建设

成都品牌网站建设

品牌网站建设费用6000元

本套餐主要针对企业品牌型网站、中高端设计、前端互动体验...

成都商城网站建设

商城网站建设费用8000元

商城网站建设因基本功能的需求不同费用上面也有很大的差别...

成都微信网站建设

手机微信网站建站3000元

手机微信网站开发、微信官网、微信商城网站...

建站知识

当前位置:首页 > 建站知识

pg10wal归档同步配置

一.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

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

[postgres@localhost 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)


新闻名称:pg10wal归档同步配置
URL分享:http://bjjierui.cn/article/jscsde.html

其他资讯