pg_upgrade鍗囩骇鏁版嵁搴?1.1-9.4.5
pg_upgrade鍗囩骇鏁版嵁搴?.1.1-9.4.5
瀹為檯鎿嶄綔锛?
宸叉湁鐜鍜宲g
192.168.12.231 pg9.1.1
绔彛 5432
瀹夎鐩綍 /pgtina
鏁版嵁鐩綍 /pgtina/data
1銆佸湪鏈満鍣ㄤ笂瀹夎9.4.5
绔彛 1922 --闅忔剰鎸囧畾锛屼絾涓嶅彲涓庝箣鍓嶇殑涓€鏍?
瀹夎鐩綍 /pgnew
鏁版嵁鐩綍 /pgnew/data
./configure --prefix=/pgnew --with-pgport=1922 && gmake world && gmake install-world
瀹夎鏃跺€欒寰楀甫world锛屽唴澶栨ā鍧楅兘瑕侊紝涓嶇劧鎵句笉鍒皃g_upgrade
2銆佷慨鏀瑰睘涓?
[root@datanode1 /]# chown -R postgres:postgres pgnew
[root@datanode1 /]# chmod 700 /pgnew
[postgres@datanode1 pgtina]$ chmod 700 data
3銆佸垵濮嬪寲鏂板簱
[postgres@datanode1 pgnew]$ mkdir data
[postgres@datanode1 pgnew]$ /pgnew/bin/initdb -E UTF8 -D /pgnew/data --locale=C -U postgres -W ---鍒濆鍖杔ocale鎸囧畾閿欒锛屾寜鐓т笅闈㈢殑鏉?
4銆佷慨鏀筽g_hba.cof
鍥犱负鍗囩骇闇€瑕佸娆¤繛鎺ユ柊鑰侀泦缇ゆ暟鎹簱瀹炰緥, 鎵€浠ヤ慨鏀逛负浣跨敤鏈湴trust璁よ瘉.
postgres@localhost-> vi /pgdata01/pg_root/pg_hba.conf
postgres@localhost-> vi /pgdata01/pg_root_9.4/pg_hba.conf
local all all trust
host all all 127.0.0.1/32 trust
5銆佷慨鏀筽ostgresql.conf
娉ㄦ剰浣跨敤涓嶅悓鐨勭洃鍚鍙? (PostgreSQL 9.4鏂板)
6銆佸仠姝㈡棫搴?
pg_ctl -D /pgtina/data stop
7銆?.4鐨刾g_upgrade妫€娴嬪吋瀹规€?
[postgres@datanode1 data]$ /pgnew/bin/pg_upgrade -c --link -b /pgtina/bin -B /pgnew/bin -d /pgtina/data -D /pgnew/data -p 5432 -P 1922 -U postgres
Performing Consistency Checks
-----------------------------
Checking cluster versions ok
*failure*
Consult the last few lines of "pg_upgrade_server.log" for
the probable cause of the failure.
connection to database failed: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/pgnew/data/.s.PGSQL.5432"? ---涔嬪墠/data鐩綍鐨勬潈闄愪笉鏄?00锛屼慨鏀瑰悗灏卞ソ浜?
could not connect to old postmaster started with the command:
"/pgtina/bin/pg_ctl" -w -l "pg_upgrade_server.log" -D "/pgtina/data" -o "-p 5432 -b -c listen_addresses='' -c unix_socket_permissions=0700 -c unix_socket_directory='/pgnew/data'" start
Failure, exiting
----妫€娴嬪け璐?
閲嶆柊鍒濆鍖栵細
[postgres@datanode1 data]$ /pgnew/bin/pg_upgrade -c --link -b /pgtina/bin -B /pgnew/bin -d /pgtina/data -D /pgnew/data -U postgres
Performing Consistency Checks
-----------------------------
Checking cluster versions ok
Checking database user is a superuser 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 invalid "line" user columns ok
lc_collate cluster values do not match: old "en_US.UTF-8", new "C"
Failure, exiting
鍒濆鍖栫殑鏃跺€欏嚭浜嗛棶棰橈細
鍒犻櫎data鐩綍锛岄噸鏂板仛涓€娆″垵濮嬪寲
/pgnew/bin/initdb -E UTF8 -D /pgnew/data --locale=en_US.UTF-8 -U postgres -W
[postgres@datanode1 data]$ /pgnew/bin/pg_upgrade -c --link -b /pgtina/bin -B /pgnew/bin -d /pgtina/data -D /pgnew/data -U postgres
Performing Consistency Checks
-----------------------------
Checking cluster versions ok
Checking database user is a superuser 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 invalid "line" user columns ok
Checking for presence of required libraries ok
Checking database user is a superuser ok
Checking for prepared transactions ok
*Clusters are compatible*
8銆佸崌绾?
/pgnew/bin/pg_upgrade --link -b /pgtina/bin -B /pgnew/bin -d /pgtina/data -D /pgnew/data -U postgres -j 8 -k -r -v 鍘绘帀浜?c
鍗囩骇鎴愬姛鍚庯紝鏃ュ織鏂囦欢琚嚜鍔ㄥ垹闄わ紝鍙互鍦ㄥ懡浠よ涓敤-r鍙傛暟鎸囧畾淇濈暀銆?
9銆佸崌绾у畬鎴愶細
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
10銆佸惎鍔ㄦ柊搴?
/pgnew/bin/pg_ctl -D /pgnew/data start
11銆佺櫥褰曟煡鐪?
[postgres@datanode1 data]$ psql -h 127.0.0.1 -U postgres -p 1922 ---涓嶈兘鐩存帴浣跨敤psql锛岃鎸囧畾浣嶇疆鎵嶈銆?
psql (9.1.1, server 9.4.5)
WARNING: psql version 9.1, server version 9.4.
Some psql features might not work.
Type "help" for help.
postgres=#
[postgres@datanode1 data]$ /pgnew/bin/psql -p 1922 -U postgres
psql (9.4.5)
Type "help" for help.
postgres=#
12銆佸垎鏋愬叏搴?
[postgres@datanode1 data]$ "/pgnew/bin/vacuumdb" -U "postgres" --all --analyze-only -p 1922
vacuumdb: vacuuming database "postgres"
vacuumdb: vacuuming database "template1"
vacuumdb: vacuuming database "tina"
13銆佽繛鎺ユ煡鐪?-姝e父
[postgres@datanode1 data]$ /pgnew/bin/pg_ctl reload -D /pgnew/data
server signaled
瀹為檯鎿嶄綔锛?
宸叉湁鐜鍜宲g
192.168.12.231 pg9.1.1
绔彛 5432
瀹夎鐩綍 /pgtina
鏁版嵁鐩綍 /pgtina/data
1銆佸湪鏈満鍣ㄤ笂瀹夎9.4.5
绔彛 1922 --闅忔剰鎸囧畾锛屼絾涓嶅彲涓庝箣鍓嶇殑涓€鏍?
瀹夎鐩綍 /pgnew
鏁版嵁鐩綍 /pgnew/data
./configure --prefix=/pgnew --with-pgport=1922 && gmake world && gmake install-world
瀹夎鏃跺€欒寰楀甫world锛屽唴澶栨ā鍧楅兘瑕侊紝涓嶇劧鎵句笉鍒皃g_upgrade
2銆佷慨鏀瑰睘涓?
[root@datanode1 /]# chown -R postgres:postgres pgnew
[root@datanode1 /]# chmod 700 /pgnew
[postgres@datanode1 pgtina]$ chmod 700 data
3銆佸垵濮嬪寲鏂板簱
[postgres@datanode1 pgnew]$ mkdir data
[postgres@datanode1 pgnew]$ /pgnew/bin/initdb -E UTF8 -D /pgnew/data --locale=C -U postgres -W ---鍒濆鍖杔ocale鎸囧畾閿欒锛屾寜鐓т笅闈㈢殑鏉?
4銆佷慨鏀筽g_hba.cof
鍥犱负鍗囩骇闇€瑕佸娆¤繛鎺ユ柊鑰侀泦缇ゆ暟鎹簱瀹炰緥, 鎵€浠ヤ慨鏀逛负浣跨敤鏈湴trust璁よ瘉.
postgres@localhost-> vi /pgdata01/pg_root/pg_hba.conf
postgres@localhost-> vi /pgdata01/pg_root_9.4/pg_hba.conf
local all all trust
host all all 127.0.0.1/32 trust
5銆佷慨鏀筽ostgresql.conf
娉ㄦ剰浣跨敤涓嶅悓鐨勭洃鍚鍙? (PostgreSQL 9.4鏂板)
6銆佸仠姝㈡棫搴?
pg_ctl -D /pgtina/data stop
7銆?.4鐨刾g_upgrade妫€娴嬪吋瀹规€?
[postgres@datanode1 data]$ /pgnew/bin/pg_upgrade -c --link -b /pgtina/bin -B /pgnew/bin -d /pgtina/data -D /pgnew/data -p 5432 -P 1922 -U postgres
Performing Consistency Checks
-----------------------------
Checking cluster versions ok
*failure*
Consult the last few lines of "pg_upgrade_server.log" for
the probable cause of the failure.
connection to database failed: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/pgnew/data/.s.PGSQL.5432"? ---涔嬪墠/data鐩綍鐨勬潈闄愪笉鏄?00锛屼慨鏀瑰悗灏卞ソ浜?
could not connect to old postmaster started with the command:
"/pgtina/bin/pg_ctl" -w -l "pg_upgrade_server.log" -D "/pgtina/data" -o "-p 5432 -b -c listen_addresses='' -c unix_socket_permissions=0700 -c unix_socket_directory='/pgnew/data'" start
Failure, exiting
----妫€娴嬪け璐?
閲嶆柊鍒濆鍖栵細
[postgres@datanode1 data]$ /pgnew/bin/pg_upgrade -c --link -b /pgtina/bin -B /pgnew/bin -d /pgtina/data -D /pgnew/data -U postgres
Performing Consistency Checks
-----------------------------
Checking cluster versions ok
Checking database user is a superuser 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 invalid "line" user columns ok
lc_collate cluster values do not match: old "en_US.UTF-8", new "C"
Failure, exiting
鍒濆鍖栫殑鏃跺€欏嚭浜嗛棶棰橈細
鍒犻櫎data鐩綍锛岄噸鏂板仛涓€娆″垵濮嬪寲
/pgnew/bin/initdb -E UTF8 -D /pgnew/data --locale=en_US.UTF-8 -U postgres -W
[postgres@datanode1 data]$ /pgnew/bin/pg_upgrade -c --link -b /pgtina/bin -B /pgnew/bin -d /pgtina/data -D /pgnew/data -U postgres
Performing Consistency Checks
-----------------------------
Checking cluster versions ok
Checking database user is a superuser 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 invalid "line" user columns ok
Checking for presence of required libraries ok
Checking database user is a superuser ok
Checking for prepared transactions ok
*Clusters are compatible*
8銆佸崌绾?
/pgnew/bin/pg_upgrade --link -b /pgtina/bin -B /pgnew/bin -d /pgtina/data -D /pgnew/data -U postgres -j 8 -k -r -v 鍘绘帀浜?c
鍗囩骇鎴愬姛鍚庯紝鏃ュ織鏂囦欢琚嚜鍔ㄥ垹闄わ紝鍙互鍦ㄥ懡浠よ涓敤-r鍙傛暟鎸囧畾淇濈暀銆?
9銆佸崌绾у畬鎴愶細
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
10銆佸惎鍔ㄦ柊搴?
/pgnew/bin/pg_ctl -D /pgnew/data start
11銆佺櫥褰曟煡鐪?
[postgres@datanode1 data]$ psql -h 127.0.0.1 -U postgres -p 1922 ---涓嶈兘鐩存帴浣跨敤psql锛岃鎸囧畾浣嶇疆鎵嶈銆?
psql (9.1.1, server 9.4.5)
WARNING: psql version 9.1, server version 9.4.
Some psql features might not work.
Type "help" for help.
postgres=#
[postgres@datanode1 data]$ /pgnew/bin/psql -p 1922 -U postgres
psql (9.4.5)
Type "help" for help.
postgres=#
12銆佸垎鏋愬叏搴?
[postgres@datanode1 data]$ "/pgnew/bin/vacuumdb" -U "postgres" --all --analyze-only -p 1922
vacuumdb: vacuuming database "postgres"
vacuumdb: vacuuming database "template1"
vacuumdb: vacuuming database "tina"
13銆佽繛鎺ユ煡鐪?-姝e父
[postgres@datanode1 data]$ /pgnew/bin/pg_ctl reload -D /pgnew/data
server signaled