免费观看又色又爽又黄的小说免费_美女福利视频国产片_亚洲欧美精品_美国一级大黄大色毛片

PostgreSQL升級之pg_upgrade升級-創新互聯

PostgreSQL中的升級,如果針對小版本的升級,比如9.6.1升級到9.6.2(當前的最新版本),只需要用9.6.2版本的軟件替換9.6.1版本的軟件即可,不需要做額外的操作,因為整個大版本是相互兼容的,內部存儲形式也是兼容的。但如果涉及到跨大版本升級比如9.4.11升級到9.6.2,這種直接替換軟件就不行了,因為跨版本的內部存儲形式發生了變化。

專注于為中小企業提供網站建設、成都做網站服務,電腦端+手機端+微信端的三站合一,更高效的管理,為中小企業相山免費做網站提供優質的服務。我們立足成都,凝聚了一批互聯網行業人才,有力地推動了上千家企業的穩健成長,幫助中小企業通過網站建設實現規模擴充和轉變。

官方給了三種升級的方式來解決跨版本升級:

  • pg_dumpall

  • pg_upgrade

  • 通過復制

pg_dumpall是一種把數據從舊版本邏輯導出,再導入新版本的方法,就是一個導出導入的過程。

通過復制的方式是創建一個高版本的從庫,等數據同步完后主變備,備變主,達到升級的目的。

再一種是通過pg_upgrade命令的升級方式,它是一種快速升級的方法,通過創建新的系統表并使用舊的用戶表的方式進行升級。它又分為兩種方式:原地升級和非原地升級,原地升級需要指定--link參數。

下面介紹一下使用pg_upgrade做升級的大體步驟:

示例是從9.4.11升級到9.6.2。

1、安裝新版本軟件

新版本的軟件需要保證與舊版本的軟件在配置上兼容,pg_upgrade會在升級前檢查pg_controldata,確保所有的設置是兼容的。

2、用新版本初始化一個新的數據庫

[postgres@rhel7 ~]$ /opt/pgsql-9.6.2/bin/initdb -D /pgdata-new/ The files belonging to this database system will be owned by user "postgres". This user must also own the server process. The database cluster will be initialized with locale "en_US.UTF-8". The default database encoding has accordingly been set to "UTF8". The default text search configuration will be set to "english". Data page checksums are disabled. fixing permissions on existing directory /pgdata-new ... ok creating subdirectories ... ok selecting default max_connections ... 100 selecting default shared_buffers ... 128MB selecting dynamic shared memory implementation ... posix creating configuration files ... ok running bootstrap script ... ok performing post-bootstrap initialization ... ok syncing data to disk ... ok WARNING: enabling "trust" authentication for local connections You can change this by editing pg_hba.conf or using the option -A, or --auth-local and --auth-host, the next time you run initdb. Success. You can now start the database server using:     /opt/pgsql-9.6.2/bin/pg_ctl -D /pgdata-new/ -l logfile start

3、設置pg_hba.conf,保證pg_upgrade通過連接新舊兩個庫

4、停止舊庫

#創建測試表 [postgres@rhel7 ~]$ psql psql (9.4.11) Type "help" for help.                             ^ postgres=# create table zx (id int); CREATE TABLE postgres=# \d          List of relations  Schema | Name | Type  |  Owner    --------+------+-------+----------  public | zx   | table | postgres (1 row) postgres=# insert into zx values(1); INSERT 0 1 postgres=# select * from zx;  id  ----   1 (1 row) #停止舊庫 [postgres@rhel7 ~]$ /opt/pgsql-9.4/bin/pg_ctl stop -D /usr/local/pgsql/data/ waiting for server to shut down.... done server stopped

5、使用pg_upgrade執行升級

[postgres@rhel7 ~]$ /opt/pgsql-9.6.2/bin/pg_upgrade -d /usr/local/pgsql/data/ -D /pgdata-new/ -b /opt/pgsql-9.4/bin/ -B /opt/pgsql-9.6.2/bin/  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 reg* system OID user data types                ok Checking for contrib/isn with bigint-passing mismatch       ok Checking for roles starting with 'pg_'                      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 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 on the new cluster                        ok Deleting files from new pg_clog                             ok Copying old pg_clog 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 analyze new cluster                      ok Creating script to delete old cluster                       ok Upgrade Complete ---------------- Optimizer statistics are not transferred by pg_upgrade so, once you start the new server, consider running:     ./analyze_new_cluster.sh Running this script will delete the old cluster's data files:     ./delete_old_cluster.sh

介紹下使用的參數-b指定舊版本軟件的bin目錄-B指定新版本軟件的bin目錄,-d指定舊版本對應的數據目錄,-D指定新版本對應的數據目錄。

6、啟動新版本數據庫并做檢查

[postgres@rhel7 ~]$ /opt/pgsql-9.6.2/bin/pg_ctl start -D /pgdata-new/ -l logfile  server starting [postgres@rhel7 ~]$ psql  psql (9.6.2) Type "help" for help. postgres=# \d         List of relations  Schema | Name | Type  |  Owner    --------+------+-------+----------  public | zx   | table | postgres (1 row) postgres=# select * from zx;  id  ----   1 (1 row)

7、恢復配置文件如pg_hba.conf、postgresql.conf等

8、收集統計信息

由于升級過程中不會把統計信息傳到新庫系統表中,需要重新收集統計信息。pg_upgrade的最給出了收集統計信息的腳本:

[postgres@rhel7 ~]$ ./analyze_new_cluster.sh  This script will generate minimal optimizer statistics rapidly so your system is usable, and then gather statistics twice more with increasing accuracy.  When it is done, your system will have the default level of optimizer statistics. If you have used ALTER TABLE to modify the statistics target for any tables, you might want to remove them and restore them after running this script because they will delay fast statistics generation. If you would like default statistics as quickly as possible, cancel this script and run:     "/opt/pgsql-9.6.2/bin/vacuumdb" --all --analyze-only vacuumdb: processing database "postgres": Generating minimal optimizer statistics (1 target) vacuumdb: processing database "template1": Generating minimal optimizer statistics (1 target) vacuumdb: processing database "postgres": Generating medium optimizer statistics (10 targets) vacuumdb: processing database "template1": Generating medium optimizer statistics (10 targets) vacuumdb: processing database "postgres": Generating default (full) optimizer statistics vacuumdb: processing database "template1": Generating default (full) optimizer statistics Done

9、升級成功后刪除舊版本軟件和數據。

官方文檔:https://www.postgresql.org/docs/9.6/static/pgupgrade.html

https://www.postgresql.org/docs/9.6/static/upgrading.html

另外有需要云服務器可以了解下創新互聯cdcxhl.cn,海內外云服務器15元起步,三天無理由+7*72小時售后在線,公司持有idc許可證,提供“云服務器、裸金屬服務器、高防服務器、香港服務器、美國服務器、虛擬主機、免備案服務器”等云主機租用服務以及企業上云的綜合解決方案,具有“安全穩定、簡單易用、服務可用性高、性價比高”等特點與優勢,專為企業上云打造定制,能夠滿足用戶豐富、多元化的應用場景需求。

網站欄目:PostgreSQL升級之pg_upgrade升級-創新互聯
網頁URL:http://newbst.com/article40/dihceo.html

成都網站建設公司_創新互聯,為您提供網站設計關鍵詞優化定制網站手機網站建設軟件開發網站設計公司

廣告

聲明:本網站發布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創新互聯

微信小程序開發