成人国产在线小视频_日韩寡妇人妻调教在线播放_色成人www永久在线观看_2018国产精品久久_亚洲欧美高清在线30p_亚洲少妇综合一区_黄色在线播放国产_亚洲另类技巧小说校园_国产主播xx日韩_a级毛片在线免费

資訊專欄INFORMATION COLUMN

PostgreSQL主備集群模式下版本升級(jí)

IT那活兒 / 2418人閱讀
PostgreSQL主備集群模式下版本升級(jí)
點(diǎn)擊上方“IT那活兒”公眾號(hào),關(guān)注后了解更多內(nèi)容,不管IT什么活兒,干就完了!?。?/strong>

master節(jié)點(diǎn)數(shù)據(jù)庫(kù)版本升級(jí)

1. master節(jié)點(diǎn)安裝新版本數(shù)據(jù)庫(kù)并初始化數(shù)據(jù)目錄
initdb -A trust -D /data/pg140 -E utf8 -k -U postgres -W --wal-segsize=1024
2. 檢查當(dāng)前數(shù)據(jù)同步狀態(tài)
user:postgres@db:postgres[[local]:5432]#select * from pg_stat_replication ;
+-[ RECORD 1 ]-----+-------------------------------+
| pid | 15236                         |
|
 usesysid | 16384 |
| usename | replic |
|
 application_name | walreceiver |
| client_addr | 192.168.229.121               |
|
 client_hostname | NULL |
| client_port | 46028                         |
|
 backend_start | 2021-08-11 10:30:16.978079+08 |
| backend_xmin | 499                           |
|
 state | streaming |
| sent_lsn | 3/800000D8 |
|
 write_lsn | 3/800000D8 |
| flush_lsn | 3/800000D8 |
|
 replay_lsn | 3/800000D8 |
| write_lag | NULL |
|
 flush_lag | NULL |
| replay_lag | NULL |
|
 sync_priority | 0 |
| sync_state | async |
|
 reply_time | 2021-08-11 10:31:47.648992+08 |
+------------------+-------------------------------+
3. 停止主備數(shù)據(jù)庫(kù)
pg_ctl stop -D $PGDATA
4. master節(jié)點(diǎn)進(jìn)行數(shù)據(jù)庫(kù)升級(jí)
1)注意:要求新舊版本數(shù)據(jù)塊大小、wal-blocksize大小必須一致。
2)調(diào)整pg_hba.conf 認(rèn)證模式為trust。
3)使用pg_upgrade進(jìn)行升級(jí)檢查。
[postgres@PG-1 pg133]$ /opt/pgsql/pg140/bin/pg_upgrade -b /opt/pgsql/pg133/bin/ -B /opt/pgsql/pg140/bin/ -d /data/pg133 -D /data/pg140 -j 8 -p 5432 -P 5433 -c
Performing Consistency Checks
-----------------------------
Checking cluster versions ok
Checking database user is the install user                  ok
Checking database connection settings                       ok
Checking for prepared transactions ok
Checking for system-defined composite types in user tables  ok
Checking for reg* data types in user tables                 ok
Checking for contrib/isn with bigint-passing mismatch ok
Checking for user-defined encoding conversions ok
Checking for user-defined postfix operators ok
Checking for presence of required libraries ok
Checking database user is the install user                  ok
Checking for prepared transactions ok
Checking for new cluster tablespace directories ok
*Clusters are compatible*
注意:要所有的檢查選項(xiàng)都通過(guò)。
4)執(zhí)行升級(jí)
[postgres@PG-1 pg133]$ /opt/pgsql/pg140/bin/pg_upgrade -b /opt/pgsql/pg133/bin/ -B /opt/pgsql/pg140/bin/ -d /data/pg133 -D /data/pg140 -j 8 -p 5432 -P 5433
Performing Consistency Checks
-----------------------------
Checking cluster versions ok
Checking database user is the install user                  ok
Checking database connection settings                       ok
Checking for prepared transactions ok
Checking for system-defined composite types in user tables  ok
Checking for reg* data types in user tables                 ok
Checking for contrib/isn with bigint-passing mismatch ok
Checking for user-defined encoding conversions ok
Checking for user-defined postfix operators ok
Creating dump of global objects ok
Creating dump of database schemas
ok
Checking for presence of required libraries ok
Checking database user is the install user                  ok
Checking for prepared transactions ok
Checking for new cluster tablespace directories ok
If pg_upgrade fails after this point, you must re-initdb the
new cluster before continuing.
Performing Upgrade
------------------
Analyzing all rows in the new cluster ok
Freezing all rows in the new cluster ok
Deleting files from new pg_xact ok
Copying old pg_xact to new server                           ok
Setting next transaction ID and epoch for new cluster
ok
Deleting files from new pg_multixact/offsets ok
Copying old pg_multixact/offsets to new server              ok
Deleting files from new pg_multixact/members ok
Copying old pg_multixact/members to new server              ok
Setting next multixact ID and offset for new cluster ok
Resetting WAL archives ok
Setting frozenxid and minmxid counters in new cluster ok
Restoring global objects in the new cluster ok
Restoring database schemas in the new cluster
ok
Copying user relation files
ok
Setting next OID for new cluster ok
Sync data directory to disk ok
Creating script to delete old cluster ok
Upgrade Complete
----------------
Optimizer statistics are not transferred by pg_upgrade.
Once you start the new server, consider running:
/opt/pgsql/pg140/bin/vacuumdb --all --analyze-in-stages
Running this script will delete the old clusters data files:
./delete_old_cluster.sh
注意:所有狀態(tài)都OK,表示升級(jí)完成
5)調(diào)整配置參數(shù)、啟動(dòng)新版本數(shù)據(jù)庫(kù)及統(tǒng)計(jì)信息收集

/opt/pgsql/pg140/bin/pg_ctl start -D /data/pg140
/opt/pgsql/pg140/bin/vacuumdb --all --analyze-in-stages

standby節(jié)點(diǎn)數(shù)據(jù)庫(kù)版本升級(jí)

1. standby節(jié)點(diǎn)安裝新版本數(shù)據(jù)庫(kù)。
2. 使用rsync將主節(jié)點(diǎn)數(shù)據(jù)同步到standby節(jié)點(diǎn)。
rsync -avz postgres@192.168.229.129:/data/pg140 /data
3. 調(diào)整數(shù)據(jù)庫(kù)配置參數(shù)。
4. 創(chuàng)建standby.signal,權(quán)限0600或者cp /data/oldatadir/standby.signal /data/pg140。
5. 將連接信息添加到postgresql.auto.conf中或者cp /data/olddatadir/postgresql.auto.conf /data/pg140。

6. 啟動(dòng)standby數(shù)據(jù)庫(kù)。

檢查主備復(fù)制情況

user:postgres@db:postgres[[local]:5432]#select * from pg_stat_replication;
+-[ RECORD 1 ]-----+-------------------------------+
| pid | 15980                         |
|
 usesysid | 16384 |
| usename | replic |
|
 application_name | walreceiver |
| client_addr | 192.168.229.121               |
|
 client_hostname | NULL |
| client_port | 46122                         |
|
 backend_start | 2021-08-11 11:23:38.478461+08 |
| backend_xmin | NULL |
|
 state | streaming |
| sent_lsn | 5/2ABF20                      |
|
 write_lsn | 5/2ABF20 |
| flush_lsn | 5/2ABF20                      |
|
 replay_lsn | 5/2ABF20 |
| write_lag | 00:00:00.000595 |
|
 flush_lag | 00:00:00.000982 |
| replay_lag | 00:00:00.001227               |
|
 sync_priority | 0 |
| sync_state | async |
|
 reply_time | 2021-08-11 11:23:51.450434+08 |
+------------------+-------------------------------+


本文作者:魏 強(qiáng)(上海新炬王翦團(tuán)隊(duì))

本文來(lái)源:“IT那活兒”公眾號(hào)

文章版權(quán)歸作者所有,未經(jīng)允許請(qǐng)勿轉(zhuǎn)載,若此文章存在違規(guī)行為,您可以聯(lián)系管理員刪除。

轉(zhuǎn)載請(qǐng)注明本文地址:http://systransis.cn/yun/129294.html

相關(guān)文章

  • 到底選擇PostgreSOL還是MySQL?看這里

    摘要:經(jīng)過(guò)對(duì)比選型,用戶同時(shí)選用三種數(shù)據(jù)庫(kù)來(lái)針對(duì)性的滿足不同目標(biāo)?;谀軌驇?lái)的這些特性優(yōu)勢(shì),用戶選擇了。相比自建,其可靠性更高,方便運(yùn)維維護(hù)。整個(gè)過(guò)程中用戶不需要任何人工干預(yù)和配置修改,真正做到自動(dòng)容災(zāi)。 據(jù)DB-Engines 最新發(fā)布的2019年8月份數(shù)據(jù)庫(kù)流行度排行榜(如下圖)顯示,名列前茅的MySQL和PostgreSQL數(shù)據(jù)庫(kù)的流行趨勢(shì)與去年同期相比依然穩(wěn)增不減。 showImg...

    沈儉 評(píng)論0 收藏0
  • PostgreSQL UDB,讓31會(huì)議數(shù)據(jù)管理更高效可靠

    摘要:相比自建,其可靠性更高,方便運(yùn)維維護(hù)。宋體經(jīng)過(guò)審慎考慮,用戶同時(shí)選用三種數(shù)據(jù)庫(kù),針對(duì)性的滿足不同目標(biāo)。宋體宋體其中,相比于在上的快速高效是其優(yōu)勢(shì),也是用戶選型的重要砝碼。PostgreSQL UDB用在大數(shù)據(jù)分析上,查詢效率更高。相比自建,其可靠性更高,方便運(yùn)維維護(hù)。 — 31會(huì)議運(yùn)維經(jīng)理 湯雷 如何用好PostgreSQL? PostgreSQL是業(yè)內(nèi)一款十分流行的開(kāi)源數(shù)...

    vspiders 評(píng)論0 收藏0

發(fā)表評(píng)論

0條評(píng)論

最新活動(dòng)
閱讀需要支付1元查看
<