欧美一级特黄大片做受成人-亚洲成人一区二区电影-激情熟女一区二区三区-日韩专区欧美专区国产专区

如何使用rsync實(shí)現(xiàn)postgres日志傳送standby服務(wù)器-創(chuàng)新互聯(lián)

這篇文章主要介紹了如何使用rsync實(shí)現(xiàn)postgres日志傳送standby服務(wù)器,具有一定借鑒價(jià)值,感興趣的朋友可以參考下,希望大家閱讀完這篇文章之后大有收獲,下面讓小編帶著大家一起了解一下。

創(chuàng)新互聯(lián)建站專(zhuān)業(yè)為企業(yè)提供日土網(wǎng)站建設(shè)、日土做網(wǎng)站、日土網(wǎng)站設(shè)計(jì)、日土網(wǎng)站制作等企業(yè)網(wǎng)站建設(shè)、網(wǎng)頁(yè)設(shè)計(jì)與制作、日土企業(yè)網(wǎng)站模板建站服務(wù),十多年日土做網(wǎng)站經(jīng)驗(yàn),不只是建網(wǎng)站,更提供有價(jià)值的思路和整體網(wǎng)絡(luò)服務(wù)。

日志傳送standby服務(wù)器

    連續(xù)歸檔可以配合隨時(shí)準(zhǔn)備取代失效主服務(wù)器的一個(gè)或多個(gè)備份服務(wù)器, 用于創(chuàng)建一個(gè)高可用性(HA)集群。這個(gè)能力通常被稱(chēng)為溫備份或日志傳送

    從一個(gè)數(shù)據(jù)庫(kù)服務(wù)器移動(dòng) WAL 到另一個(gè)服務(wù)器通常被稱(chēng)為日志傳送(LogShipping)。PostgreSQL 實(shí)現(xiàn)了基于文件的日志傳送,意思是 WAL 記錄每次移動(dòng)一個(gè)完整的文件(WAL 段)。 也可以基于記錄的日志傳送,

    日志傳送是異步的,也就是 WAL 記錄在事務(wù)提交之后才被傳送,可以使用 archive_timeout 來(lái)設(shè)置日志傳送間隔時(shí)間(應(yīng)該是最長(zhǎng)間隔時(shí)間)

    在啟動(dòng),standby 服務(wù)器調(diào)用 restore_command 命令開(kāi)始恢復(fù)在 wal 歸檔位置有效的所有的 WAL, 一旦恢復(fù)完可用 WAL,restore_command 就失敗, 將嘗試從 pg_wal 目錄下恢復(fù)可用的 WAL。 如果那也失敗了,并且已經(jīng)配置了流復(fù)制,則嘗試連接到主服務(wù)器, 從在歸檔或 pg_wal 中找到的最后一條有效的記錄開(kāi)始 WAL 流復(fù)制。如果那也失敗了, 或沒(méi)有配置流復(fù)制,或連接斷開(kāi),備服務(wù)器再次回到步驟 1,嘗試從歸檔里恢復(fù)文件。 循環(huán)嘗試從歸檔、pg_wal、連續(xù)流復(fù)制通道,直到服務(wù)器停止或通過(guò)觸發(fā)器文件觸發(fā)失效切換。

實(shí)驗(yàn)使用兩臺(tái)主機(jī),都安裝postgresql-10.7,已配置流復(fù)制

  • 主庫(kù):192.168.56.25 m1  使用rsync命令傳送wal文件到m7

  • 叢庫(kù):192.168.56.5 m7  在此機(jī)上配置rsync做為服務(wù)運(yùn)行,接收叢m1傳送過(guò)來(lái)的wal文件

叢庫(kù)的配置,設(shè)置hot_standby使standby庫(kù)接收連接。省略standby庫(kù)從主庫(kù)基礎(chǔ)備份還原過(guò)程

[postgres@localhost data]$ cat recovery.conf
standby_mode = 'on'
restore_command = 'cp /usr/local/pg/arch_bak/%f %p'
recovery_target_timeline = 'latest'
postgres=# show  hot_standby;
 hot_standby
-------------
 on
(1 row)

m1上配置rsync服務(wù)器,使用rsync-3.1.3版本,省略rsyn安裝過(guò)程

[root@localhost ~]# cat /etc/rsyncd.conf 
uid=postgres
gid=postgres
use chroot = no
max connections = 5
read only = false   
pid file = /var/run/rsyncd.pid
log file = /var/log/rsync.log
transfer logging = yes
log format = %t %a %m %f %b
timeout = 300
[arch_bak]
path = /usr/local/pg/arch_bak
auth users = tridge, susan
secrets file = /etc/rsyncd.secrets
[wal_bak]
path = /usr/local/pg/data/pg_wal
auth users = tridge, susan
secrets file = /etc/rsyncd.secrets
[root@localhost ~]# cat /etc/rsyncd.secrets
tridge:mypass
susan:herpass

啟動(dòng)rsync服務(wù)器

[root@localhost arch_bak]# /usr/local/bin/rsync --daemon
[root@localhost arch_bak]# ll
total 0
[root@localhost arch_bak]# pwd
/usr/local/pg/arch_bak

從m7同步standby服務(wù)器創(chuàng)建之前歸檔wal日志文件

[root@z_leader rsync-3.1.3]# /usr/local/bin/rsync  -av /usr/local/pg/arch/ tridge@192.168.56.5::arch_bak/
Password:
sending incremental file list
./
00000005000000000000000B
00000005000000000000000C.partial
00000006.history
00000006000000000000000C
00000006000000000000000D
00000006000000000000000E
00000006000000000000000F
000000060000000000000010
sent 117,470,037 bytes  received 179 bytes  18,072,340.92 bytes/sec
total size is 117,440,721  speedup is 1.00

在m1上查看傳輸過(guò)的文件,及standby服務(wù)器表記錄

[root@localhost arch_bak]# ll
total 114692
-rw------- 1 postgres postgres 16777216 Mar  2 09:02 00000005000000000000000B
-rw------- 1 postgres postgres 16777216 Mar  2 09:08 00000005000000000000000C.partial
-rw------- 1 postgres postgres 16777216 Mar  2 11:15 00000006000000000000000C
-rw------- 1 postgres postgres 16777216 Mar 17 09:51 00000006000000000000000D
-rw------- 1 postgres postgres 16777216 Mar 17 09:55 00000006000000000000000E
-rw------- 1 postgres postgres 16777216 Mar 17 10:13 00000006000000000000000F
-rw------- 1 postgres postgres 16777216 Mar 17 20:02 000000060000000000000010
-rw------- 1 postgres postgres      209 Mar  2 09:08 00000006.history
postgres=# select * from test;
 id | e_name |   e_mail    | d_id
----+--------+-------------+------
  1 | zbs    | 123@126.com |   10
  3 | zbs2   | 124@126.com |   10
  4 | zbs2   | 124@126.com |   10
  2 | zbs1   | 124@126.com |   10
  5 | zbs2   | 124@126.com |   10
  6 | zbs2   | 124@126.com |   10
  7 | zbs2   | 124@126.com |   10
  8 | zbs2   | 124@126.com |   10
(8 rows)

在主庫(kù)上插入2兩條記錄,并歸檔

postgres=# select * from test;
 id | e_name |   e_mail    | d_id
----+--------+-------------+------
  1 | zbs    | 123@126.com |   10
  3 | zbs2   | 124@126.com |   10
  4 | zbs2   | 124@126.com |   10
  2 | zbs1   | 124@126.com |   10
  5 | zbs2   | 124@126.com |   10
  6 | zbs2   | 124@126.com |   10
  7 | zbs2   | 124@126.com |   10
  8 | zbs2   | 124@126.com |   10
(8 rows)
postgres=# insert into test values(9,'zbs3','124@126.com',20);
INSERT 0 1
postgres=# insert into test values(10,'zbs3','124@126.com',20);
INSERT 0 1
postgres=# select pg_switch_wal();
 pg_switch_wal
---------------
 0/11000888
(1 row)

在m7上使用rsync命令同步新生成的歸檔

[root@z_leader rsync-3.1.3]# /usr/local/bin/rsync  -av /usr/local/pg/arch/ tridge@192.168.56.5::arch_bak/
Password:
sending incremental file list
./
000000060000000000000011
sent 16,781,696 bytes  received 46 bytes  4,794,783.43 bytes/sec
total size is 134,217,937  speedup is 8.00

在m1上查看是表數(shù)據(jù)是否同步,在主庫(kù)插入的2條記錄成功應(yīng)用到從庫(kù)

postgres=# select * from test;
 id | e_name |   e_mail    | d_id
----+--------+-------------+------
  1 | zbs    | 123@126.com |   10
  3 | zbs2   | 124@126.com |   10
  4 | zbs2   | 124@126.com |   10
  2 | zbs1   | 124@126.com |   10
  5 | zbs2   | 124@126.com |   10
  6 | zbs2   | 124@126.com |   10
  7 | zbs2   | 124@126.com |   10
  8 | zbs2   | 124@126.com |   10
  9 | zbs3   | 124@126.com |   20
 10 | zbs3   | 124@126.com |   20
(10 rows)

到此,使用rsyn傳輸wal歸檔文件到standby服務(wù)器使用成功,rsync只輸出了新的文件000000060000000000000011

下面實(shí)驗(yàn)直接同步wal日志文件

m1目前wal目錄

[postgres@localhost pg_wal]$ pwd
/usr/local/pg/data/pg_wal
[postgres@localhost pg_wal]$ ll
total 81948
-rw------- 1 postgres postgres       41 Mar  2 09:24 00000002.history
-rw------- 1 postgres postgres       83 Mar  2 09:24 00000003.history
-rw------- 1 postgres postgres      302 Mar  2 09:24 000000040000000000000009.00000028.backup
-rw------- 1 postgres postgres      125 Mar  2 09:24 00000004.history
-rw------- 1 postgres postgres      167 Mar  2 09:24 00000005.history
-rw------- 1 postgres postgres 16777216 Mar 23 09:38 000000060000000000000010
-rw------- 1 postgres postgres 16777216 Mar 23 09:46 000000060000000000000011
-rw------- 1 postgres postgres 16777216 Mar  2 09:24 000000060000000000000012
-rw------- 1 postgres postgres 16777216 Mar 17 10:05 000000060000000000000013
-rw------- 1 postgres postgres 16777216 Mar 17 10:15 000000060000000000000014
-rw------- 1 postgres postgres      209 Mar  2 09:24 00000006.history
drwx------ 2 postgres postgres     4096 Mar 23 09:46 archive_status

在m7上查看wal目錄,并輸出不同的文件

[root@z_leader pg_wal]# /usr/local/bin/rsync  -av /usr/local/pg/data/pg_wal/ tridge@192.168.56.5::wal_bak/
Password:
sending incremental file list
./
00000002.history
00000003.history
00000004.history
000000040000000000000009.00000028.backup
00000005.history
00000006.history
000000060000000000000011
000000060000000000000012
000000060000000000000013
000000060000000000000014
000000060000000000000015
archive_status/
archive_status/00000002.history.done
archive_status/00000004.history.done
archive_status/000000040000000000000009.00000028.backup.done
archive_status/00000006.history.done
archive_status/000000060000000000000011.done
sent 33,626,454 bytes  received 98,679 bytes  3,967,662.71 bytes/sec
total size is 83,887,007  speedup is 2.49

現(xiàn)在在主庫(kù)上再插入兩條記錄

postgres=# insert into test values(11,'zbs3','124@126.com',20);
INSERT 0 1
postgres=# insert into test values(12,'zbs3','124@126.com',20);
INSERT 0 1
postgres=# select * from test;
 id | e_name |   e_mail    | d_id
----+--------+-------------+------
  1 | zbs    | 123@126.com |   10
  3 | zbs2   | 124@126.com |   10
  4 | zbs2   | 124@126.com |   10
  2 | zbs1   | 124@126.com |   10
  5 | zbs2   | 124@126.com |   10
  6 | zbs2   | 124@126.com |   10
  7 | zbs2   | 124@126.com |   10
  8 | zbs2   | 124@126.com |   10
  9 | zbs3   | 124@126.com |   20
 10 | zbs3   | 124@126.com |   20
 11 | zbs3   | 124@126.com |   20
 12 | zbs3   | 124@126.com |   20
(12 rows)

在m7同步wal日志文件到m1

[root@z_leader pg_wal]# /usr/local/bin/rsync  -av /usr/local/pg/data/pg_wal/ tridge@192.168.56.5::wal_bak/
Password:
sending incremental file list
./
000000060000000000000012
000000060000000000000016
archive_status/
sent 16,802,460 bytes  received 24,649 bytes  3,739,357.56 bytes/sec
total size is 83,887,007  speedup is 4.99

在m1上查看是表數(shù)據(jù)是否同步,在主庫(kù)插入的2條記錄成功應(yīng)用到從庫(kù)

postgres=#  select * from test;
 id | e_name |   e_mail    | d_id
----+--------+-------------+------
  1 | zbs    | 123@126.com |   10
  3 | zbs2   | 124@126.com |   10
  4 | zbs2   | 124@126.com |   10
  2 | zbs1   | 124@126.com |   10
  5 | zbs2   | 124@126.com |   10
  6 | zbs2   | 124@126.com |   10
  7 | zbs2   | 124@126.com |   10
  8 | zbs2   | 124@126.com |   10
  9 | zbs3   | 124@126.com |   20
 10 | zbs3   | 124@126.com |   20
 11 | zbs3   | 124@126.com |   20
 12 | zbs3   | 124@126.com |   20
(12 rows)

到此,使用rsyn傳輸wal文件到standby服務(wù)器使用成功,rsync會(huì)認(rèn)識(shí)發(fā)生變化的文件,并同步變化的部分。

感謝你能夠認(rèn)真閱讀完這篇文章,希望小編分享的“如何使用rsync實(shí)現(xiàn)postgres日志傳送standby服務(wù)器”這篇文章對(duì)大家有幫助,同時(shí)也希望大家多多支持創(chuàng)新互聯(lián),關(guān)注創(chuàng)新互聯(lián)-成都網(wǎng)站建設(shè)公司行業(yè)資訊頻道,更多相關(guān)知識(shí)等著你來(lái)學(xué)習(xí)!

當(dāng)前題目:如何使用rsync實(shí)現(xiàn)postgres日志傳送standby服務(wù)器-創(chuàng)新互聯(lián)
網(wǎng)頁(yè)地址:http://aaarwkj.com/article30/dspjso.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)頁(yè)設(shè)計(jì)公司、網(wǎng)站收錄、用戶(hù)體驗(yàn)、定制網(wǎng)站、定制開(kāi)發(fā)、App開(kāi)發(fā)

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶(hù)投稿、用戶(hù)轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

成都網(wǎng)頁(yè)設(shè)計(jì)公司
亚洲精品丝袜成人偷拍| 91精品国产人妻女教师| 亚洲一区在线观看激情| 亚洲欧美综合一区二区三区| 欧美日韩激情在线一区| 人妻在线中文字幕一区| 日本午夜诱惑在线观看| 在线免费观看午夜视频| 成熟女人毛茸茸的视频| 日韩三级av黄片在线| 亚洲第一青青草原在线| 欧美日韩亚洲一区二区搜索| 日韩精品毛片在线看| 激情啪啪啪的免费网站| 新午夜福利片在线观看| 91精品国产综合久久麻豆| 后入蜜桃臀美女在线观看| 在线视频天堂亚洲天堂| 亚洲国产日韩欧美综合久久| 欧美成人高清在线播放| 欧美三级美国三级亚洲三级| 操老熟女一区二区三区| 少妇高潮惨叫久久麻豆传| 禁止18岁以下的视频| 久久青草精品欧美日韩精品| 蜜臀综合亚洲国产精品| 韩国av网址在线观看| 亚洲精品??一区二区| 国产极品嫩模在线观看91| 农村人妻一区二区三区视频| 亚洲精品国产自在现线| 青青草老司机在线视频| 神马影院在线观看午夜| 亚洲欧美日韩午夜在线| 亚洲va久久久噜噜噜久久狠| 激情啪啪啪的免费网站| 国内自拍韩国资源在线| 在线看日本一区二区| 国产亚洲综合精品综合区| 亚洲中文字幕第11页| 亚洲五月婷婷久久综合|