Greenplum gpcopy 安装使用介绍

首先这款工具是两个greenplum集群之间迁移数据的时候使用的,可以迁移完整的数据库,或者是表,可以跨版本迁移,兼容Greenplum Database 4.3.26 以上版本, 以及5.9 以上, 6.x版本。

效率上面要比之前的gptransfer要高,因为是segment之间可以实现并行对拷,但是我这里不会做比对。目前最新版本为2.2版本。

下载地址:https://network.pivotal.io/products/gpdb-data-copy

安装步骤:

1.解压安装包
tar xzvf gpcopy-2.2.0.tar.gz 

2.在master节点,复制gpcopy和gpcopy_helper到相应的bin目录 
$ cp gpcopy $GPHOME/bin  
$cp gpcopy_helper $GPHOME/bin

3.赋予权限
$ chmod 755 $GPHOME/bin/gpcopy
$ chmod 755 $GPHOME/bin/gpcopy_helper

4.在segment节点的操作如下,只拷贝gpcopy_helper到相应目录下并赋予权限即可。
$ gpscp -h sdw1 -h sdw2 gpcopy_helper =:/usr/local/greenplum-db-6.0.0/bin
$ gpssh -h sdw1 -h sdw2 -e 'chmod 755 /usr/local/greenplum-db-6.0.0/bin/gpcopy_helper'

迁移数据实例,这里我的版本为从4.3.30.0迁移数据至6.0.1:

这里只迁移一张表测试,在源端发起gpcopy命令迁移一张名为book_info的表,这里打开debug选项,可以看到具体的执行过程,也方便排错。
gpcopy --source-host 127.0.0.1 --source-user gpadmin  --source-port 1921 --dest-host 192.168.xxx.xxx  --dest-user gpadmin --dest-port 5432 --include-table warehouse.read30.book_info --drop  --dest-table warehouse.read30.book_info --debug

日志如下:

20200701:11:36:20 gpcopy:gpadmin:192-168-102-67:024611-[INFO]:-"--drop" will work as "--truncate" on partition tables
20200701:11:36:20 gpcopy:gpadmin:192-168-102-67:024611-[INFO]:-Starting copy...
20200701:11:36:20 gpcopy:gpadmin:192-168-102-67:024611-[INFO]:-Copy Timestamp = 1593574580239008343
20200701:11:36:20 gpcopy:gpadmin:192-168-102-67:024611-[DEBUG]:-'gpcopy' --debug --dest-host '192.168.102.44' --dest-port '5432' --dest-table 'warehouse.read30.book_info' --dest-user 'gpadmin' --drop --include-table 'warehouse.read30.book_info' --source-host '127.0.0.1' --source-port '1921' --source-user 'gpadmin'
20200701:11:36:20 gpcopy:gpadmin:192-168-102-67:024611-[INFO]:-pg_dump (PostgreSQL) 8.2.15
20200701:11:36:20 gpcopy:gpadmin:192-168-102-67:024611-[INFO]:-pg_dumpall (PostgreSQL) 8.2.15
20200701:11:36:21 gpcopy:gpadmin:192-168-102-67:024611-[DEBUG]:-Resolving IP address of node186
20200701:11:36:21 gpcopy:gpadmin:192-168-102-67:024611-[DEBUG]:-Resolving IP address of node186
20200701:11:36:21 gpcopy:gpadmin:192-168-102-67:024611-[DEBUG]:-Resolving IP address of node186
20200701:11:36:21 gpcopy:gpadmin:192-168-102-67:024611-[DEBUG]:-Resolving IP address of node186
20200701:11:36:21 gpcopy:gpadmin:192-168-102-67:024611-[DEBUG]:-Resolving IP address of node187
20200701:11:36:21 gpcopy:gpadmin:192-168-102-67:024611-[DEBUG]:-Resolving IP address of node187
20200701:11:36:21 gpcopy:gpadmin:192-168-102-67:024611-[DEBUG]:-Resolving IP address of node187
20200701:11:36:21 gpcopy:gpadmin:192-168-102-67:024611-[DEBUG]:-Resolving IP address of node187
20200701:11:36:21 gpcopy:gpadmin:192-168-102-67:024611-[DEBUG]:-Resolving IP address of node188
20200701:11:36:21 gpcopy:gpadmin:192-168-102-67:024611-[DEBUG]:-Resolving IP address of node188
20200701:11:36:21 gpcopy:gpadmin:192-168-102-67:024611-[DEBUG]:-Resolving IP address of node188
20200701:11:36:21 gpcopy:gpadmin:192-168-102-67:024611-[DEBUG]:-Resolving IP address of node188
20200701:11:36:21 gpcopy:gpadmin:192-168-102-67:024611-[DEBUG]:-Resolving IP address of node189
20200701:11:36:21 gpcopy:gpadmin:192-168-102-67:024611-[DEBUG]:-Resolving IP address of node189
20200701:11:36:21 gpcopy:gpadmin:192-168-102-67:024611-[DEBUG]:-Resolving IP address of node189
20200701:11:36:21 gpcopy:gpadmin:192-168-102-67:024611-[DEBUG]:-Resolving IP address of node189
20200701:11:36:21 gpcopy:gpadmin:192-168-102-67:024611-[DEBUG]:-Resolving IP address of node190
20200701:11:36:21 gpcopy:gpadmin:192-168-102-67:024611-[DEBUG]:-Resolving IP address of node190
20200701:11:36:21 gpcopy:gpadmin:192-168-102-67:024611-[DEBUG]:-Resolving IP address of node190
20200701:11:36:21 gpcopy:gpadmin:192-168-102-67:024611-[DEBUG]:-Resolving IP address of node190
20200701:11:36:21 gpcopy:gpadmin:192-168-102-67:024611-[DEBUG]:-Resolving IP address of node191
20200701:11:36:21 gpcopy:gpadmin:192-168-102-67:024611-[DEBUG]:-Resolving IP address of node191
20200701:11:36:21 gpcopy:gpadmin:192-168-102-67:024611-[DEBUG]:-Resolving IP address of node191
20200701:11:36:21 gpcopy:gpadmin:192-168-102-67:024611-[DEBUG]:-Resolving IP address of node191
20200701:11:36:21 gpcopy:gpadmin:192-168-102-67:024611-[DEBUG]:-Resolving IP address of node192
20200701:11:36:21 gpcopy:gpadmin:192-168-102-67:024611-[DEBUG]:-Resolving IP address of node192
20200701:11:36:22 gpcopy:gpadmin:192-168-102-67:024611-[DEBUG]:-Resolving IP address of node192
20200701:11:36:22 gpcopy:gpadmin:192-168-102-67:024611-[DEBUG]:-Resolving IP address of node192
20200701:11:36:22 gpcopy:gpadmin:192-168-102-67:024611-[DEBUG]:-Resolving IP address of node193
20200701:11:36:22 gpcopy:gpadmin:192-168-102-67:024611-[DEBUG]:-Resolving IP address of node193
20200701:11:36:22 gpcopy:gpadmin:192-168-102-67:024611-[DEBUG]:-Resolving IP address of node193
20200701:11:36:22 gpcopy:gpadmin:192-168-102-67:024611-[DEBUG]:-Resolving IP address of node193
20200701:11:36:22 gpcopy:gpadmin:192-168-102-67:024611-[DEBUG]:-Resolving IP address of node194
20200701:11:36:22 gpcopy:gpadmin:192-168-102-67:024611-[DEBUG]:-Resolving IP address of node194
20200701:11:36:22 gpcopy:gpadmin:192-168-102-67:024611-[DEBUG]:-Resolving IP address of node194
20200701:11:36:22 gpcopy:gpadmin:192-168-102-67:024611-[DEBUG]:-Resolving IP address of node194
20200701:11:36:22 gpcopy:gpadmin:192-168-102-67:024611-[DEBUG]:-Resolving IP address of node195
20200701:11:36:22 gpcopy:gpadmin:192-168-102-67:024611-[DEBUG]:-Resolving IP address of node195
20200701:11:36:22 gpcopy:gpadmin:192-168-102-67:024611-[DEBUG]:-Resolving IP address of node195
20200701:11:36:22 gpcopy:gpadmin:192-168-102-67:024611-[DEBUG]:-Resolving IP address of node195
20200701:12:38:30 gpcopy:gpadmin:192-168-102-67:024611-[INFO]:-Copying source database "warehouse"
20200701:12:38:30 gpcopy:gpadmin:192-168-102-67:024611-[INFO]:-Copying selected tables from database "warehouse" => "warehouse"
20200701:12:38:30 gpcopy:gpadmin:192-168-102-67:024611-[INFO]:-Copying source database "warehouse"
20200701:12:38:30 gpcopy:gpadmin:192-168-102-67:024611-[INFO]:-Copying selected tables from database "warehouse" => "warehouse"
20200701:13:41:35 gpcopy:gpadmin:192-168-102-67:024611-[DEBUG]:-[Worker 0] Generated Dump Command: pg_dump --gp-syntax -h 127.0.0.1 -p 1921 -U gpadmin -s -x -t '"read30"."book_info"' 'warehouse'
20200701:13:41:50 gpcopy:gpadmin:192-168-102-67:024611-[INFO]:-[Worker 0] Creating table "warehouse"."read30"."book_info"
20200701:13:41:52 gpcopy:gpadmin:192-168-102-67:024611-[INFO]:-[Worker 0] Transferring table "warehouse"."read30"."book_info" => "warehouse"."read30"."book_info"
20200701:13:41:52 gpcopy:gpadmin:192-168-102-67:024611-[DEBUG]:-[Worker 0] There are 210750 rows in the source table "warehouse"."read30"."book_info"
20200701:13:41:52 gpcopy:gpadmin:192-168-102-67:024611-[DEBUG]:-[Worker 0] EXTERNAL WEB TABLE command of receiving data: CREATE EXTERNAL WEB TEMP TABLE gpcopy_ext_5811f956934f44d09a3266c2804c73b0 (like "read30"."book_info") EXECUTE '[ "$GP_SEGMENT_ID" -ge 32 ] && exit 0 || gpcopy_helper   --listen --seg-id $GP_SEGMENT_ID --cmd-id 06ffde17-f435-4f1d-bcb6-82ae0c3bdf37-1 ' FORMAT 'csv'
20200701:13:41:52 gpcopy:gpadmin:192-168-102-67:024611-[DEBUG]:-[Worker 0] Querying ports of helper programs: COPY gpcopy_ports_temp_1593574580239008343 FROM PROGRAM '[ ! -f /tmp/gpcopy-06ffde17-f435-4f1d-bcb6-82ae0c3bdf37-1-<SEGID>.txt ] && exit 0 || cat /tmp/gpcopy-06ffde17-f435-4f1d-bcb6-82ae0c3bdf37-1-<SEGID>.txt' ON SEGMENT
20200701:13:41:52 gpcopy:gpadmin:192-168-102-67:024611-[DEBUG]:-[Worker 0] sendData() retried 0 times to get notification from receiveData()
20200701:13:41:52 gpcopy:gpadmin:192-168-102-67:024611-[DEBUG]:-[Worker 0] Querying ports of helper programs: COPY gpcopy_ports_temp_1593574580239008343 FROM PROGRAM '[ ! -f /tmp/gpcopy-06ffde17-f435-4f1d-bcb6-82ae0c3bdf37-1-<SEGID>.txt ] && exit 0 || cat /tmp/gpcopy-06ffde17-f435-4f1d-bcb6-82ae0c3bdf37-1-<SEGID>.txt' ON SEGMENT
20200701:13:41:52 gpcopy:gpadmin:192-168-102-67:024611-[DEBUG]:-[Worker 0] sendData() retried 1 times to get notification from receiveData()
20200701:13:41:52 gpcopy:gpadmin:192-168-102-67:024611-[DEBUG]:-[Worker 0] Querying ports of helper programs: COPY gpcopy_ports_temp_1593574580239008343 FROM PROGRAM '[ ! -f /tmp/gpcopy-06ffde17-f435-4f1d-bcb6-82ae0c3bdf37-1-<SEGID>.txt ] && exit 0 || cat /tmp/gpcopy-06ffde17-f435-4f1d-bcb6-82ae0c3bdf37-1-<SEGID>.txt' ON SEGMENT
20200701:13:41:52 gpcopy:gpadmin:192-168-102-67:024611-[DEBUG]:-[Worker 0] Retried 2 times to get segment helpers' ports, got 32 items
20200701:13:41:52 gpcopy:gpadmin:192-168-102-67:024611-[DEBUG]:-[Worker 0] COPY command of sending data: COPY "read30"."book_info" TO PROGRAM 'MATCHED=0; SEGMENTS=(0 2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40 42 44 46 48 50 52 54 56 58 60 62); for i in "${SEGMENTS[@]}"; do [ $i = <SEGID> ] && MATCHED=1; done; [ $MATCHED = 1 ] && gpcopy_helper  --seg-id <SEGID> --host 192.168.102.186,99999,192.168.102.186,99999,192.168.102.186,99999,192.168.102.186,99999,192.168.102.187,99999,192.168.102.187,99999,192.168.102.187,99999,192.168.102.187,99999,192.168.102.188,99999,192.168.102.188,99999,192.168.102.188,99999,192.168.102.188,99999,192.168.102.189,99999,192.168.102.189,99999,192.168.102.189,99999,192.168.102.189,99999,192.168.102.190,99999,192.168.102.190,99999,192.168.102.190,99999,192.168.102.190,99999,192.168.102.191,99999,192.168.102.191,99999,192.168.102.191,99999,192.168.102.191,99999,192.168.102.192,99999,192.168.102.192,99999,192.168.102.192,99999,192.168.102.192,99999,192.168.102.193,99999,192.168.102.193,99999,192.168.102.193,99999,192.168.102.193,99999 --port 2957,99999,20070,99999,13858,99999,29752,99999,16716,99999,22531,99999,12541,99999,22943,99999,22064,99999,23146,99999,14673,99999,9919,99999,18608,99999,19244,99999,31550,99999,26638,99999,25206,99999,18879,99999,27699,99999,11510,99999,1722,99999,26931,99999,9677,99999,9313,99999,17531,99999,25182,99999,2143,99999,19173,99999,12249,99999,22772,99999,22354,99999,8994,99999 || cat > /dev/null' ON SEGMENT CSV IGNORE EXTERNAL PARTITIONS
20200701:13:41:53 gpcopy:gpadmin:192-168-102-67:024611-[DEBUG]:-[Worker 0] Querying ports of helper programs: COPY gpcopy_ports_temp_1593574580239008343 FROM PROGRAM '[ ! -f /tmp/gpcopy-06ffde17-f435-4f1d-bcb6-82ae0c3bdf37-2-<SEGID>.txt ] && exit 0 || cat /tmp/gpcopy-06ffde17-f435-4f1d-bcb6-82ae0c3bdf37-2-<SEGID>.txt' ON SEGMENT
20200701:13:41:54 gpcopy:gpadmin:192-168-102-67:024611-[DEBUG]:-[Worker 0] sendData() retried 0 times to get notification from receiveData()
20200701:13:41:54 gpcopy:gpadmin:192-168-102-67:024611-[DEBUG]:-[Worker 0] Querying ports of helper programs: COPY gpcopy_ports_temp_1593574580239008343 FROM PROGRAM '[ ! -f /tmp/gpcopy-06ffde17-f435-4f1d-bcb6-82ae0c3bdf37-2-<SEGID>.txt ] && exit 0 || cat /tmp/gpcopy-06ffde17-f435-4f1d-bcb6-82ae0c3bdf37-2-<SEGID>.txt' ON SEGMENT
20200701:13:41:54 gpcopy:gpadmin:192-168-102-67:024611-[DEBUG]:-[Worker 0] sendData() retried 1 times to get notification from receiveData()
20200701:13:41:54 gpcopy:gpadmin:192-168-102-67:024611-[DEBUG]:-[Worker 0] EXTERNAL WEB TABLE command of receiving data: CREATE EXTERNAL WEB TEMP TABLE gpcopy_ext_e5fe6d3080974adfbbd5f52092ac9299 (like "read30"."book_info") EXECUTE '[ "$GP_SEGMENT_ID" -ge 32 ] && exit 0 || gpcopy_helper   --listen --seg-id $GP_SEGMENT_ID --cmd-id 06ffde17-f435-4f1d-bcb6-82ae0c3bdf37-2 ' FORMAT 'csv'
20200701:13:41:54 gpcopy:gpadmin:192-168-102-67:024611-[DEBUG]:-[Worker 0] Querying ports of helper programs: COPY gpcopy_ports_temp_1593574580239008343 FROM PROGRAM '[ ! -f /tmp/gpcopy-06ffde17-f435-4f1d-bcb6-82ae0c3bdf37-2-<SEGID>.txt ] && exit 0 || cat /tmp/gpcopy-06ffde17-f435-4f1d-bcb6-82ae0c3bdf37-2-<SEGID>.txt' ON SEGMENT
20200701:13:41:54 gpcopy:gpadmin:192-168-102-67:024611-[DEBUG]:-[Worker 0] sendData() retried 2 times to get notification from receiveData()
20200701:13:41:54 gpcopy:gpadmin:192-168-102-67:024611-[DEBUG]:-[Worker 0] Querying ports of helper programs: COPY gpcopy_ports_temp_1593574580239008343 FROM PROGRAM '[ ! -f /tmp/gpcopy-06ffde17-f435-4f1d-bcb6-82ae0c3bdf37-2-<SEGID>.txt ] && exit 0 || cat /tmp/gpcopy-06ffde17-f435-4f1d-bcb6-82ae0c3bdf37-2-<SEGID>.txt' ON SEGMENT
20200701:13:41:54 gpcopy:gpadmin:192-168-102-67:024611-[DEBUG]:-[Worker 0] Retried 3 times to get segment helpers' ports, got 32 items
20200701:13:41:54 gpcopy:gpadmin:192-168-102-67:024611-[DEBUG]:-[Worker 0] COPY command of sending data: COPY "read30"."book_info" TO PROGRAM 'MATCHED=0; SEGMENTS=(1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 51 53 55 57 59 61 63); for i in "${SEGMENTS[@]}"; do [ $i = <SEGID> ] && MATCHED=1; done; [ $MATCHED = 1 ] && gpcopy_helper  --seg-id <SEGID> --host 99999,192.168.102.186,99999,192.168.102.186,99999,192.168.102.186,99999,192.168.102.186,99999,192.168.102.187,99999,192.168.102.187,99999,192.168.102.187,99999,192.168.102.187,99999,192.168.102.188,99999,192.168.102.188,99999,192.168.102.188,99999,192.168.102.188,99999,192.168.102.189,99999,192.168.102.189,99999,192.168.102.189,99999,192.168.102.189,99999,192.168.102.190,99999,192.168.102.190,99999,192.168.102.190,99999,192.168.102.190,99999,192.168.102.191,99999,192.168.102.191,99999,192.168.102.191,99999,192.168.102.191,99999,192.168.102.192,99999,192.168.102.192,99999,192.168.102.192,99999,192.168.102.192,99999,192.168.102.193,99999,192.168.102.193,99999,192.168.102.193,99999,192.168.102.193 --port 99999,17797,99999,15665,99999,4329,99999,15049,99999,20824,99999,6720,99999,8586,99999,23038,99999,10541,99999,30364,99999,9500,99999,7701,99999,23928,99999,3665,99999,16433,99999,2692,99999,13524,99999,13027,99999,15874,99999,23137,99999,27277,99999,21208,99999,6724,99999,11457,99999,4168,99999,22219,99999,5697,99999,25952,99999,33248,99999,30903,99999,18538,99999,3264 || cat > /dev/null' ON SEGMENT CSV IGNORE EXTERNAL PARTITIONS
20200701:13:41:55 gpcopy:gpadmin:192-168-102-67:024611-[INFO]:-[Worker 0] Committing changes of table "warehouse"."read30"."book_info" => "warehouse"."read30"."book_info"
20200701:13:41:55 gpcopy:gpadmin:192-168-102-67:024611-[INFO]:-[Worker 0] [Progress: (0/1) DBs, (1/1) tables done] Finished copying table "warehouse"."read30"."book_info" => "warehouse"."read30"."book_info"
20200701:13:41:55 gpcopy:gpadmin:192-168-102-67:024611-[INFO]:-[Progress: (1/1) DBs, (1/1) tables done] Finished copying database "warehouse"
20200701:13:41:55 gpcopy:gpadmin:192-168-102-67:024611-[DEBUG]:-Beginning cleanup
20200701:13:41:55 gpcopy:gpadmin:192-168-102-67:024611-[INFO]:-------------------------------------------------
20200701:13:41:55 gpcopy:gpadmin:192-168-102-67:024611-[INFO]:-Total elapsed time: 2h5m35.087123637s
20200701:13:41:55 gpcopy:gpadmin:192-168-102-67:024611-[INFO]:-Copied 1 databases
20200701:13:41:55 gpcopy:gpadmin:192-168-102-67:024611-[INFO]:- Database warehouse: successfully copied 1 tables, skipped 0 tables, failed 0 tables
20200701:13:41:55 gpcopy:gpadmin:192-168-102-67:024611-[DEBUG]:-Cleanup complete
20200701:13:41:55 gpcopy:gpadmin:192-168-102-67:024611-[INFO]:-Copy completed successfully

迁移先决条件,迁移命令参数,等等可以参考官方文档,如下:

参考:
https://gpdb.docs.pivotal.io/data-copy/2-2/install.html
https://gpdb.docs.pivotal.io/data-copy/2-2/gpcopy-migrate.html
https://gpdb.docs.pivotal.io/data-copy/2-2/gpcopy.html

评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值