Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Pg 10 wal Archive synchronization configuration

2025-01-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/03 Report--

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

Possible problems:

After modifying the directory / db/wal_archive permission, the error is still reported as follows:

Rsync: mkstemp "/ .000000010000000001.2Z6cX4" (in archive) failed: Permission denied (13)

Solution: please check the SELINUX configuration item of / etc/selinux/config:

SELINUX=disabled

2.rsync server (172.16.3.226)

1)。 Modify configuration

# 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] #

two。 Start the service

# systemctl start rsyncd

# systemctl enable rsyncd

Second, transfer files

Rync client (172.16.3.225)

1. Install softwar

# yum install-y rsync

two。 Set up a database archive directory

# mkdir-p-m 0700 / db/wal_archive

# chown-R postgres.postgres / db/wal_archive

3. Synchronize script configuration

Wal synchronization beyond 1 hour

Sync_archives.sh

#! bin/sh

Export PATH=/bin:$PATH

Find / db/wal_archive-name '0000cycles'-type f-mmin 60 | xargs-I {} rsync-avz {} 172.16.3.226::archive

Archive deletion script

Delete wal beyond two days

Del_archives.sh

#! bin/sh

Export PATH=/bin:$PATH

Find / db/wal_archive-name '0000cycles'-type f-mtime + 2-delete

# crontab-e

* / opt/cron/sync_archives.sh

0 1 * / opt/cron/del_archives.sh

III. Database archiving configuration

#-

# 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)

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report