国产xxxx99真实实拍_久久不雅视频_高清韩国a级特黄毛片_嗯老师别我我受不了了小说

資訊專欄INFORMATION COLUMN

升級 postgresql

learn_shifeng / 3548人閱讀

摘要:但如果涉及到跨大版本升級比如升級到,這種直接替換軟件就不行了,因為跨版本的內部存儲形式發生了變化官方對于升級提供了種方法,這里遷移我使用了來進行處理細節可以參考官方文檔。

1 場景描述

最近使用 postgresql 命令行比較多,就找了個類似 mycli 工具,pgcli,這個是針對 postgresql 的,興沖沖的安裝了

brew install pgcli

沒想到這貨自動幫我升級了 postgresql,我原來使用的是 9.5.7, 自動幫我升級到了 9.6.3

查看升級日志 pg_upgrade_server.log

pg_ctl: another server might be running; trying to start server anyway
waiting for server to start....FATAL:  database files are incompatible with server
DETAIL:  The data directory was initialized by PostgreSQL version 9.5, which is not compatible with this version 9.6.3.
 stopped waiting
pg_ctl: could not start server
Examine the log output.

這是需要遷移數據的節奏啊,遷移之前需要的明白點什么

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

官方對于升級提供了 3 種方法,這里遷移我使用了 pg_upgrade 來進行處理, 細節可以參考官方文檔。

再進行下一步之前,把 postgresql 服務關掉,執行如下命令

brew services stop postgresql
2 如何遷移數據 2.1 備份數據
mv /usr/local/var/postgresql /usr/local/var/postgresql.old

2.2 使用新版本初始化新的數據庫
initdb /usr/local/var/postgres -E utf8 --locale=zh_CN.UTF-8

運行結果

The files belonging to this database system will be owned by user "allen".
This user must also own the server process.

The database cluster will be initialized with locale "zh_CN.UTF-8".
initdb: could not find suitable text search configuration for locale "zh_CN.UTF-8"
The default text search configuration will be set to "simple".

Data page checksums are disabled.

creating directory /usr/local/var/postgres ... 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:

    pg_ctl -D /usr/local/var/postgres -l logfile start
2.3 遷移舊數據

pg_upgrade 語法簡單如下:

pg_upgrade -b 舊版本的bin目錄 -B 新版本的bin目錄 -d 舊版本的數據目錄 -D 新版本的數據目錄 [其他選項...]

然后運行遷移命令

pg_upgrade -b /usr/local/Cellar/postgresql@9.5/9.5.7/bin -B /usr/local/bin  -d /usr/local/var/postgres.old -D /usr/local/var/postgres  

運行結果

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

最后提示生成兩個腳本,一個是 analyze_new_cluster.sh,需要在新版本中執行,用來收集統計信息,另一個是 delete_old_cluster.sh,用來刪除舊版本集群數據,當然為了安全起見可以等系統運行幾天沒問題再來刪除。

運行下 analyze_new_cluster.sh 腳本

./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:
    "/usr/local/bin/vacuumdb" --all --analyze-only

vacuumdb: processing database "activity_tool": Generating minimal optimizer statistics (1 target)
vacuumdb: processing database "allen": Generating minimal optimizer statistics (1 target)
vacuumdb: processing database "cw": Generating minimal optimizer statistics (1 target)
vacuumdb: processing database "djexample": Generating minimal optimizer statistics (1 target)
vacuumdb: processing database "finance": Generating minimal optimizer statistics (1 target)
vacuumdb: processing database "iop": Generating minimal optimizer statistics (1 target)
vacuumdb: processing database "learn": Generating minimal optimizer statistics (1 target)
vacuumdb: processing database "postgres": Generating minimal optimizer statistics (1 target)
vacuumdb: processing database "servicemall": Generating minimal optimizer statistics (1 target)
vacuumdb: processing database "store": Generating minimal optimizer statistics (1 target)
vacuumdb: processing database "template1": Generating minimal optimizer statistics (1 target)
vacuumdb: processing database "test_store": Generating minimal optimizer statistics (1 target)
vacuumdb: processing database "uio": Generating minimal optimizer statistics (1 target)
vacuumdb: processing database "vbdev": Generating minimal optimizer statistics (1 target)
vacuumdb: processing database "vbdevelop": Generating minimal optimizer statistics (1 target)
vacuumdb: processing database "xiuzan": Generating minimal optimizer statistics (1 target)
vacuumdb: processing database "xzdevelop": Generating minimal optimizer statistics (1 target)
vacuumdb: processing database "activity_tool": Generating medium optimizer statistics (10 targets)
vacuumdb: processing database "allen": Generating medium optimizer statistics (10 targets)
vacuumdb: processing database "cw": Generating medium optimizer statistics (10 targets)
vacuumdb: processing database "djexample": Generating medium optimizer statistics (10 targets)
vacuumdb: processing database "finance": Generating medium optimizer statistics (10 targets)
vacuumdb: processing database "iop": Generating medium optimizer statistics (10 targets)
vacuumdb: processing database "learn": Generating medium optimizer statistics (10 targets)
vacuumdb: processing database "postgres": Generating medium optimizer statistics (10 targets)
vacuumdb: processing database "servicemall": Generating medium optimizer statistics (10 targets)
vacuumdb: processing database "store": Generating medium optimizer statistics (10 targets)
vacuumdb: processing database "template1": Generating medium optimizer statistics (10 targets)
vacuumdb: processing database "test_store": Generating medium optimizer statistics (10 targets)
vacuumdb: processing database "uio": Generating medium optimizer statistics (10 targets)
vacuumdb: processing database "vbdev": Generating medium optimizer statistics (10 targets)
vacuumdb: processing database "vbdevelop": Generating medium optimizer statistics (10 targets)
vacuumdb: processing database "xiuzan": Generating medium optimizer statistics (10 targets)
vacuumdb: processing database "xzdevelop": Generating medium optimizer statistics (10 targets)
vacuumdb: processing database "activity_tool": Generating default (full) optimizer statistics
vacuumdb: processing database "allen": Generating default (full) optimizer statistics
vacuumdb: processing database "cw": Generating default (full) optimizer statistics
vacuumdb: processing database "djexample": Generating default (full) optimizer statistics
vacuumdb: processing database "finance": Generating default (full) optimizer statistics
vacuumdb: processing database "iop": Generating default (full) optimizer statistics
vacuumdb: processing database "learn": Generating default (full) optimizer statistics
vacuumdb: processing database "postgres": Generating default (full) optimizer statistics
vacuumdb: processing database "servicemall": Generating default (full) optimizer statistics
vacuumdb: processing database "store": Generating default (full) optimizer statistics
vacuumdb: processing database "template1": Generating default (full) optimizer statistics
vacuumdb: processing database "test_store": Generating default (full) optimizer statistics
vacuumdb: processing database "uio": Generating default (full) optimizer statistics
vacuumdb: processing database "vbdev": Generating default (full) optimizer statistics
vacuumdb: processing database "vbdevelop": Generating default (full) optimizer statistics
vacuumdb: processing database "xiuzan": Generating default (full) optimizer statistics
vacuumdb: processing database "xzdevelop": Generating default (full) optimizer statistics

Done
3 重啟玩耍
brew services start postgresql

查看下服務狀態

brew services list

運行結果

Name           Status  User  Plist
postgresql     started allen /Users/allen/Library/LaunchAgents/homebrew.mxcl.postgresql.plist

接著就可以愉快的使用 pgcli 了。

參考借鑒文章和文檔

https://www.postgresql.org/do...

https://stackoverflow.com/que...

http://www.cnblogs.com/space-...

http://www.cnblogs.com/shineq...

http://www.linuxidc.com/Linux...

文章版權歸作者所有,未經允許請勿轉載,若此文章存在違規行為,您可以聯系管理員刪除。

轉載請注明本文地址:http://specialneedsforspecialkids.com/yun/38964.html

相關文章

  • PostgreSQL升級方案

    摘要:小版本更新不受影響,比如到升級不受影響。下面介紹兩種升級方案可供選擇,均是官方文檔提及的方案官方文檔參考。方案命令是直接對舊的數據庫目錄文件進行升級的方案,直接將舊版本的數據文件格式升級為新版本使用的格式。 PostgreSQL在默認情況下,是不能跨版本升級的(9.4, 9.5, 9.6等等這些版本跨版本升級。小版本更新不受影響,比如9.6.1到9.6.2升級不受影響)。甚至PG為了數...

    darkerXi 評論0 收藏0
  • Rails 3 升級 Rails 4 中遇到的問題及解決方法

    摘要:的問題當出現不能的時候,我也嘗試過這種提示里面的命令,可是還是不能解決這個問題。解決方法一般自己機器上面的都是測試數據,所以可以直接刪除掉舊的數據庫文件。解決方法然后就可以該干嘛干嘛了。 有些出現的問題其實是不懂正確的流程,都是在試錯,可是還是學到了很多東西,寫下了,希望對我和大家都有幫助。 Homebrew 的問題 當我去運行brew update的時候出現錯誤untracked...

    史占廣 評論0 收藏0
  • 新書推薦 |《PostgreSQL實戰》出版(提供樣章下載)

    摘要:作者譚峰張文升出版日期年月頁數頁定價元本書特色中國開源軟件推進聯盟分會特聘專家撰寫,國內多位開源數據庫專家鼎力推薦。張文升中國開源軟件推進聯盟分會核心成員之一。 很高興《PostgreSQL實戰》一書終于出版,本書大體上系統總結了筆者 PostgreSQL DBA 職業生涯的經驗總結,本書的另一位作者張文升擁有豐富的PostgreSQL運維經驗,目前就職于探探科技任首席PostgreS...

    Martin91 評論0 收藏0
  • 阿里云FreeBSD系統升級與安裝PHP環境

    摘要:所以就安裝了另外一個很喜歡的數據庫的已經修復了,后面會補上的安裝添加自啟動初始化數據庫啟動數據庫服務安裝上面是一條命令安裝自啟動配置略安裝 系統升級 阿里云的FreeBSD系統默認安裝版本是10.1,這個版本已經超出了官方的維護時間了,所以首先要進行系統的版本升級 設置當前系統版本為10.1-release,setenv UNAME_r 10.1-RELEASE 修改update...

    tinna 評論0 收藏0
  • 阿里云FreeBSD系統升級與安裝PHP環境

    摘要:所以就安裝了另外一個很喜歡的數據庫的已經修復了,后面會補上的安裝添加自啟動初始化數據庫啟動數據庫服務安裝上面是一條命令安裝自啟動配置略安裝 系統升級 阿里云的FreeBSD系統默認安裝版本是10.1,這個版本已經超出了官方的維護時間了,所以首先要進行系統的版本升級 設置當前系統版本為10.1-release,setenv UNAME_r 10.1-RELEASE 修改update...

    Cobub 評論0 收藏0

發表評論

0條評論

最新活動
閱讀需要支付1元查看
<