成人午夜视频全免费观看高清-秋霞福利视频一区二区三区-国产精品久久久久电影小说-亚洲不卡区三一区三区一区

PostgreSQL數(shù)據(jù)庫(kù)單機(jī)怎樣擴(kuò)展為流復(fù)制

本篇文章為大家展示了PostgreSQL數(shù)據(jù)庫(kù)單機(jī)怎樣擴(kuò)展為流復(fù)制,內(nèi)容簡(jiǎn)明扼要并且容易理解,絕對(duì)能使你眼前一亮,通過(guò)這篇文章的詳細(xì)介紹希望你能有所收獲。

公司主營(yíng)業(yè)務(wù):成都網(wǎng)站建設(shè)、網(wǎng)站建設(shè)、移動(dòng)網(wǎng)站開(kāi)發(fā)等業(yè)務(wù)。幫助企業(yè)客戶真正實(shí)現(xiàn)互聯(lián)網(wǎng)宣傳,提高企業(yè)的競(jìng)爭(zhēng)能力。成都創(chuàng)新互聯(lián)是一支青春激揚(yáng)、勤奮敬業(yè)、活力青春激揚(yáng)、勤奮敬業(yè)、活力澎湃、和諧高效的團(tuán)隊(duì)。公司秉承以“開(kāi)放、自由、嚴(yán)謹(jǐn)、自律”為核心的企業(yè)文化,感謝他們對(duì)我們的高要求,感謝他們從不同領(lǐng)域給我們帶來(lái)的挑戰(zhàn),讓我們激情的團(tuán)隊(duì)有機(jī)會(huì)用頭腦與智慧不斷的給客戶帶來(lái)驚喜。成都創(chuàng)新互聯(lián)推出葉城免費(fèi)做網(wǎng)站回饋大家。

1. 在standby服務(wù)器安裝postgres數(shù)據(jù)庫(kù),不需要初始化.

安裝過(guò)程詳見(jiàn):http://www.cnblogs.com/ilifeilong/p/6979288.html

2. 在primary服務(wù)器創(chuàng)建具有REPLICATION權(quán)限的復(fù)制用戶

postgres=# CREATE ROLE repl WITH REPLICATION PASSWORD ‘repl‘ LOGIN;

3. 允許復(fù)制用戶遠(yuǎn)程連接到primary服務(wù)器

$ grep "^host" pg_hba.conf host    all             all             127.0.0.1/32            trust host    replication             repl             0.0.0.0/0               md5  host    all             all             ::1/128                 trust

4. 在primary服務(wù)器設(shè)置流復(fù)制相關(guān)的參數(shù)

$ mkdir /usr/local/pgsql/arch  $ egrep "archive_mode|max_wal_senders|wal_keep_segments|archive_command|wal_level|hot_standby" postgresql.conf al_level = hot_standby            # minimal, archive, hot_standby, or logical archive_mode = on        # enables archiving; off, on, or always archive_command = ‘test ! -f /usr/local/pgsql/arch/%f && cp %p /usr/local/pgsql/arch/%f‘         max_wal_senders = 5        # max number of walsender processes wal_keep_segments = 30        # in logfile segments, 16MB each; 0 disables hot_standby = on            # "on" allows queries during recovery #hot_standby_feedback = off        # send info from standby to prevent

5. 重新啟動(dòng)primary服務(wù)器進(jìn)程

$ pg_ctl stop -m fast $ pg_ctl start

6. 對(duì)primary服務(wù)器做一個(gè)全備并傳輸?shù)絪tandby服務(wù)器

  • 在primary服務(wù)器通過(guò)pg_(start|stop)_backup函數(shù)進(jìn)行備份

postgres=# SELECT pg_start_backup(‘label‘, true);  pg_start_backup  -----------------  7/E6000060 (1 row) $ rsync -az --progress ${PGDATA} postgres@10.189.100.195:/usr/local/pgsql/ --exclude postmaster.pid postgres=# SELECT pg_stop_backup(); NOTICE:  pg_stop_backup complete, all required WAL segments have been archived  pg_stop_backup  ----------------  7/E60005C8 (1 row)

在standby服務(wù)器通過(guò)pg_basebackup命令進(jìn)行備份,要求standby的PGDATA目錄為空

$ pg_basebackup --host=10.189.102.118 --username=repl --port=5432 --label=backup --verbose --progress --pgdata=/usr/local/pgsql/data --checkpoint=fast --format=p --xlog-method=stream Password:  transaction log start point: 7/EA000028 on timeline 1 pg_basebackup: starting background WAL receiver 65933562/65933562 kB (100%), 1/1 tablespace                                          transaction log end point: 7/EA000830 pg_basebackup: waiting for background process to finish streaming ... pg_basebackup: base backup completed

7. 設(shè)置standby數(shù)據(jù)庫(kù)復(fù)制相關(guān)參數(shù),使得standby失效轉(zhuǎn)移后可以作為主庫(kù)工作

$ mkdir /usr/local/pgsql/arch $ egrep "archive_mode|max_wal_senders|wal_keep_segments|archive_command|wal_level|hot_standby" postgresql.conf wal_level = hot_standby                 # minimal, archive, hot_standby, or logical archive_mode = on               # enables archiving; off, on, or always archive_command = ‘test ! -f /usr/local/pgsql/arch/%f && cp %p /usr/local/pgsql/arch/%f‘ max_wal_senders = 5             # max number of walsender processes wal_keep_segments = 30          # in logfile segments, 16MB each; 0 disables hot_standby = on                        # "on" allows queries during recovery #hot_standby_feedback = off             # send info from standby to prevent

8. 在standby文件創(chuàng)建恢復(fù)文件

$ cat recovery.conf  restore_command = ‘cp /usr/local/pgsql/arch/%f "%p"‘ standby_mode = ‘on‘ primary_conninfo = ‘user=repl password=repl host=10.189.102.118 port=5432 sslmode=disable sslcompression=1‘ archive_cleanup_command = ‘pg_archivecleanup -d /usr/local/pgsql/arch %r >> /usr/local/pgsql/arch/archive_cleanup.log‘ trigger_file = ‘/usr/local/pgsql/data/trigger_active_standby‘

9. 啟動(dòng)standby數(shù)據(jù)庫(kù)進(jìn)程,自動(dòng)啟動(dòng)流復(fù)制

$ pg_ctl start -w waiting for server to start....LOG:  could not create IPv6 socket: Address family not supported by protocol LOG:  redirecting log output to logging collector process HINT:  Future log output will appear in directory "pg_log".  done server started

10. 檢查primary和standby數(shù)據(jù)庫(kù)的延遲

  • 通過(guò)函數(shù)和系統(tǒng)表查看

edbstore=# select * from pg_stat_replication;           #在primary主庫(kù)查看 -[ RECORD 1 ]----+------------------------------ pid              | 15013 usesysid         | 19206 usename          | repl application_name | walreceiver client_addr      | 10.189.100.195 client_hostname  |  client_port      | 56072 backend_start    | 2017-06-13 08:10:35.400508-07 backend_xmin     |  state            | streaming sent_location    | 7/EC01A588 write_location   | 7/EC01A588 flush_location   | 7/EC01A588 replay_location  | 7/EC01A588 sync_priority    | 0 sync_state       | async  edbstore=# SELECT pg_current_xlog_location();                      #在primary主庫(kù)查看  pg_current_xlog_location  --------------------------  7/EC01A588 (1 row)  postgres=# select pg_last_xlog_receive_location(),pg_last_xlog_replay_location(),pg_last_xact_replay_timestamp();     #在standby備庫(kù)查看  pg_last_xlog_receive_location | pg_last_xlog_replay_location | pg_last_xact_replay_timestamp  -------------------------------+------------------------------+-------------------------------  7/EC01A588                    | 7/EC01A588                   | 2017-06-13 08:25:20.281568-07 (1 row)
  • 通過(guò)進(jìn)程查看

$ ps -ef | grep sender | grep -v grep #在primary庫(kù)查看  postgres 15013 24883 0 08:10 ? 00:00:00 postgres: wal sender process repl 10.189.100.195(56072) streaming 7/EC01A668  $ ps -ef | grep receiver | grep -v grep #在standby庫(kù)查看  postgres 12857 12843 0 08:10 ? 00:00:00 postgres: wal receiver process streaming 7/EC01A668

上述內(nèi)容就是PostgreSQL數(shù)據(jù)庫(kù)單機(jī)怎樣擴(kuò)展為流復(fù)制,你們學(xué)到知識(shí)或技能了嗎?如果還想學(xué)到更多技能或者豐富自己的知識(shí)儲(chǔ)備,歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道。

文章名稱(chēng):PostgreSQL數(shù)據(jù)庫(kù)單機(jī)怎樣擴(kuò)展為流復(fù)制
當(dāng)前網(wǎng)址:http://jinyejixie.com/article12/jjpdgc.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站導(dǎo)航、軟件開(kāi)發(fā)、網(wǎng)站內(nèi)鏈、ChatGPT、云服務(wù)器電子商務(wù)

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(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)

成都seo排名網(wǎng)站優(yōu)化
青海省| 丰顺县| 静安区| 仁寿县| 咸阳市| 台中市| 雷州市| 南平市| 忻州市| 炉霍县| 曲阳县| 通海县| 克什克腾旗| 遵义县| 金华市| 罗江县| 海淀区| 沭阳县| 闽清县| 孟津县| 永平县| 韩城市| 吉木萨尔县| 谷城县| 丹巴县| 茶陵县| 湄潭县| 江门市| 遂溪县| 宁乡县| 临清市| 都昌县| 临漳县| 崇信县| 邓州市| 铁岭市| 泽普县| 垫江县| 大连市| 佛冈县| 辉南县|