Greenplum擴容詳解


隨着收集額外數據並且現有數據的定期增長,數據倉庫通常會隨着時間的推移而不斷增長。 有時,有必要增加數據庫能力來聯合不同的數據倉庫到一個數據庫中。 數據倉庫也可能需要額外的計算能力(CPU)來適應新增加的分析項目。 在系統被初始定義時就留出增長的空間是很好的,但是即便用戶預期到了高增長率,提前太多在資源上投資通常也不明智。 因此,用戶應該寄望於定期地執行一次數據庫擴容項目。Greenplum使用gpexpand工具進行擴容,所以本文首先會介紹下gpexpand工具。本文為博客園作者所寫: 一寸HUI,個人博客地址:https://www.cnblogs.com/zsql/

一、gpexpand介紹

gpexpand是在陣列中的新主機上擴展現有的Greenplum數據庫的一個工具,使用方法如下:

gpexpand [{-f|--hosts-file} hosts_file] | {-i|--input} input_file [-B batch_size] | [{-d | --duration} hh:mm:ss | {-e|--end} 'YYYY-MM-DD hh:mm:ss'] [-a|-analyze] [-n parallel_processes] | {-r|--rollback} | {-c|--clean} [-v|--verbose] [-s|--silent] [{-t|--tardir} directory ] [-S|--simple-progress ] gpexpand -? | -h | --help gpexpand --version

參數詳解:

-a | --analyze 在擴展后運行ANALYZE更新表的統計信息,默認是不運行ANALYZE。 -B batch_size 在暫停一秒鍾之前發送給給定主機的遠程命令的批量大小。默認值是16, 有效值是1-128。 gpexpand工具會發出許多設置命令,這些命令可能會超出主機的已驗證 連接的最大閾值(由SSH守護進程配置中的MaxStartups定義)。該一秒鍾 的暫停允許在gpexpand發出更多命令之前完成認證。 默認值通常不需要改變。但是,如果gpexpand由於連接錯誤 (例如'ssh_exchange_identification: Connection closed by remote host.')而失敗,則可能需要減少命令的最大數量。 -c | --clean 刪除擴展模式。 -d | --duration hh:mm:ss 擴展會話的持續時間。 -e | --end 'YYYY-MM-DD hh:mm:ss' 擴展會話的結束日期及時間。 -f | --hosts-file filename 指定包含用於系統擴展的新主機列表的文件的名稱。文件的每一行都必須包含一個主機名。 該文件可以包含指定或不指定網絡接口的主機名。gpexpand工具處理這兩種情況, 如果原始節點配置了多個網絡接口,則將接口號添加到主機名的末尾。 Note: Greenplum數據庫Segment主機的命名習慣是sdwN,其中sdw 是前綴並且N是數字。例如,sdw1、sdw2等等。 對於具有多個接口的主機,約定是在主機名后面添加破折號(-)和數字。例如sdw1-1 和sdw1-2是主機sdw1的兩個接口名稱。 -i | --input input_file 指定擴展配置文件的名稱,其中為每個要添加的Segment包含一行,格式為: hostname:address:port:datadir:dbid:content:preferred_role -n parallel_processes 要同時重新分布的表的數量。有效值是1 - 96。 每個表重新分布過程都需要兩個數據庫連接:一個用於更改表,另一個用於在擴展方案中更新表的狀態。 在增加-n之前,檢查服務器配置參數max_connections的當前值, 並確保不超過最大連接限制。 -r | --rollback 回滾失敗的擴展設置操作。 -s | --silent 以靜默模式運行。在警告時,不提示確認就可繼續。 -S | --simple-progress 如果指定,gpexpand工具僅在Greenplum數據庫表 gpexpand.expansion_progress中記錄最少的進度信息。該工具不在表 gpexpand.status_detail中記錄關系大小信息和狀態信息。 指定此選項可通過減少寫入gpexpand表的進度信息量來提高性能。 [-t | --tardir] directory Segment主機上一個目錄的完全限定directory,gpexpand 工具會在其中拷貝一個臨時的tar文件。該文件包含用於創建Segment實例的Greenplum數據庫文件。 默認目錄是用戶主目錄。 -v | --verbose 詳細調試輸出。使用此選項,該工具將輸出用於擴展數據庫的所有DDL和DML。 --version 顯示工具的版本號並退出。 -? | -h | --help 顯示在線幫助

gpexpand的具體過程:

gpexpand工具分兩個階段執行系統擴展:Segment初始化和表重新分布

  • 在初始化階段,gpexpand用一個輸入文件運行,該文件指定新Segment的數據目錄、 dbid值和其他特征。用戶可以手動創建輸入文件,也可以在交互式對話中 按照提示進行操作。
  • 在表數據重分布階段,gpexpand會重分布表的數據,使數據在新舊segment 實例之間平衡

  要開始重分布階段,可以通過運行gpexpand並指定-d(運行時間周期) 或-e(結束時間)選項,或者不指定任何選項。如果客戶指定了結束時間或運行周期,工具會在 擴展模式下重分布表,直到達到設定的結束時間或執行周期。如果沒指定任何選項,工具會繼續處理直到擴展模式的表 全部完成重分布。每張表都會通過ALTER TABLE命令來在所有的節點包括新增加的segment實例 上進行重分布,並設置表的分布策略為其原始策略。如果gpexpand完成所有表的重分布,它會 顯示成功信息並退出。

二、擴容介紹

擴容可以分為縱向擴容和橫向擴容,擴容的先決條件如下:

  • 用戶作為Greenplum數據庫超級用戶(gpadmin)登錄。
  • 新的Segment主機已被根據現有的Segment主機安裝和配置。這包括:
  1.   配置硬件和操作系統
  2.   安裝Greenplum軟件
  3.   創建gpadmin用戶帳戶
  4.   交換SSH密鑰
  • 用戶的Segment主機上有足夠的磁盤空間來臨時保存最大表的副本。
  • 重新分布數據時,Greenplum數據庫必須以生產模式運行。Greenplum數據庫不能是受限模式或 Master模式。不能指定gpstart的選項-R或者-m 啟動Greenplum數據庫

擴容的基本步驟:

  1. 創建擴容輸入文件:gpexpand -f hosts_file
  2. 初始化Segment並且創建擴容schema:gpexpand -i input_file,gpexpand會創建一個數據目錄、從現有的數據庫復制表到新的Segment上並且為擴容方案中的每個表捕捉元數據用於狀態跟蹤。 在這個處理完成后,擴容操作會被提交並且不可撤回。
  3. 重新分布表數據:gpexpand -d duration
  4. 移除擴容schema:gpexpand -c

三、縱向擴容

3.1、擴容前准備

首先看看現有的集群的狀態:gpstate

[gpadmin@lgh1 conf]$ gpstate 20210331:14:10:34:014725 gpstate:lgh1:gpadmin-[INFO]:-Starting gpstate with args: 20210331:14:10:34:014725 gpstate:lgh1:gpadmin-[INFO]:-local Greenplum Version: 'postgres (Greenplum Database) 6.14.1 build commit:5ef30dd4c9878abadc0124e0761e4b988455a4bd'
20210331:14:10:34:014725 gpstate:lgh1:gpadmin-[INFO]:-master Greenplum Version: 'PostgreSQL 9.4.24 (Greenplum Database 6.14.1 build commit:5ef30dd4c9878abadc0124e0761e4b988455a4bd) on x86_64-unknown-linux-gnu, compiled by gcc (GCC) 6.4.0, 64-bit compiled on Feb 22 2021 18:27:08'
20210331:14:10:34:014725 gpstate:lgh1:gpadmin-[INFO]:-Obtaining Segment details from master... 20210331:14:10:34:014725 gpstate:lgh1:gpadmin-[INFO]:-Gathering data from segments... 20210331:14:10:35:014725 gpstate:lgh1:gpadmin-[INFO]:-Greenplum instance status summary 20210331:14:10:35:014725 gpstate:lgh1:gpadmin-[INFO]:-----------------------------------------------------
20210331:14:10:35:014725 gpstate:lgh1:gpadmin-[INFO]:-   Master instance = Active 20210331:14:10:35:014725 gpstate:lgh1:gpadmin-[INFO]:-   Master standby = lgh2 20210331:14:10:35:014725 gpstate:lgh1:gpadmin-[INFO]:-   Standby master state                                      = Standby host passive 20210331:14:10:35:014725 gpstate:lgh1:gpadmin-[INFO]:-   Total segment instance count from metadata                = 4
20210331:14:10:35:014725 gpstate:lgh1:gpadmin-[INFO]:-----------------------------------------------------
20210331:14:10:35:014725 gpstate:lgh1:gpadmin-[INFO]:- Primary Segment Status 20210331:14:10:35:014725 gpstate:lgh1:gpadmin-[INFO]:-----------------------------------------------------
20210331:14:10:35:014725 gpstate:lgh1:gpadmin-[INFO]:-   Total primary segments = 2
20210331:14:10:35:014725 gpstate:lgh1:gpadmin-[INFO]:-   Total primary segment valid (at master)                   = 2
20210331:14:10:35:014725 gpstate:lgh1:gpadmin-[INFO]:-   Total primary segment failures (at master)                = 0
20210331:14:10:35:014725 gpstate:lgh1:gpadmin-[INFO]:-   Total number of postmaster.pid files missing              = 0
20210331:14:10:35:014725 gpstate:lgh1:gpadmin-[INFO]:-   Total number of postmaster.pid files found                = 2
20210331:14:10:35:014725 gpstate:lgh1:gpadmin-[INFO]:-   Total number of postmaster.pid PIDs missing               = 0
20210331:14:10:35:014725 gpstate:lgh1:gpadmin-[INFO]:-   Total number of postmaster.pid PIDs found                 = 2
20210331:14:10:35:014725 gpstate:lgh1:gpadmin-[INFO]:-   Total number of /tmp lock files missing                   = 0
20210331:14:10:35:014725 gpstate:lgh1:gpadmin-[INFO]:-   Total number of /tmp lock files found                     = 2
20210331:14:10:35:014725 gpstate:lgh1:gpadmin-[INFO]:-   Total number postmaster processes missing                 = 0
20210331:14:10:35:014725 gpstate:lgh1:gpadmin-[INFO]:-   Total number postmaster processes found                   = 2
20210331:14:10:35:014725 gpstate:lgh1:gpadmin-[INFO]:-----------------------------------------------------
20210331:14:10:35:014725 gpstate:lgh1:gpadmin-[INFO]:- Mirror Segment Status 20210331:14:10:35:014725 gpstate:lgh1:gpadmin-[INFO]:-----------------------------------------------------
20210331:14:10:35:014725 gpstate:lgh1:gpadmin-[INFO]:-   Total mirror segments = 2
20210331:14:10:35:014725 gpstate:lgh1:gpadmin-[INFO]:-   Total mirror segment valid (at master)                    = 2
20210331:14:10:35:014725 gpstate:lgh1:gpadmin-[INFO]:-   Total mirror segment failures (at master)                 = 0
20210331:14:10:35:014725 gpstate:lgh1:gpadmin-[INFO]:-   Total number of postmaster.pid files missing              = 0
20210331:14:10:35:014725 gpstate:lgh1:gpadmin-[INFO]:-   Total number of postmaster.pid files found                = 2
20210331:14:10:35:014725 gpstate:lgh1:gpadmin-[INFO]:-   Total number of postmaster.pid PIDs missing               = 0
20210331:14:10:35:014725 gpstate:lgh1:gpadmin-[INFO]:-   Total number of postmaster.pid PIDs found                 = 2
20210331:14:10:35:014725 gpstate:lgh1:gpadmin-[INFO]:-   Total number of /tmp lock files missing                   = 0
20210331:14:10:35:014725 gpstate:lgh1:gpadmin-[INFO]:-   Total number of /tmp lock files found                     = 2
20210331:14:10:35:014725 gpstate:lgh1:gpadmin-[INFO]:-   Total number postmaster processes missing                 = 0
20210331:14:10:35:014725 gpstate:lgh1:gpadmin-[INFO]:-   Total number postmaster processes found                   = 2
20210331:14:10:35:014725 gpstate:lgh1:gpadmin-[INFO]:-   Total number mirror segments acting as primary segments   = 0
20210331:14:10:35:014725 gpstate:lgh1:gpadmin-[INFO]:-   Total number mirror segments acting as mirror segments    = 2
20210331:14:10:35:014725 gpstate:lgh1:gpadmin-[INFO]:-----------------------------------------------------

現在的狀態是有3台主機,一個是master節點,還有兩個segment的機器,每個segment的機器上都有一個primary和mirror的segment,現在計划在現有的集群上進行segment的擴容,在每台機器上的segment的數量翻倍,
現在segment的目錄為:

primary:/apps/data1/primary mirror:/apps/data1/mirror

現在需要在兩個segment的主機上創建新的目錄如下:

primary:/apps/data2/primary mirror:/apps/data2/mirror

上面的目錄的所屬組和用戶均為gpadmin:gpamdin,這里創建目錄可以使用gpssh創建也可以一個一個的創建

3.2、創建初始化文件

查看目前segment的主機:

[gpadmin@lgh1 conf]$ cat seg_hosts lgh2 lgh3

執行:gpexpand -f seg_hosts

[gpadmin@lgh1 conf]$ gpexpand -f seg_hosts 20210331:14:16:29:015453 gpexpand:lgh1:gpadmin-[INFO]:-local Greenplum Version: 'postgres (Greenplum Database) 6.14.1 build commit:5ef30dd4c9878abadc0124e0761e4b988455a4bd'
20210331:14:16:29:015453 gpexpand:lgh1:gpadmin-[INFO]:-master Greenplum Version: 'PostgreSQL 9.4.24 (Greenplum Database 6.14.1 build commit:5ef30dd4c9878abadc0124e0761e4b988455a4bd) on x86_64-unknown-linux-gnu, compiled by gcc (GCC) 6.4.0, 64-bit compiled on Feb 22 2021 18:27:08'
20210331:14:16:29:015453 gpexpand:lgh1:gpadmin-[INFO]:-Querying gpexpand schema for current expansion state System Expansion is used to add segments to an existing GPDB array. gpexpand did not detect a System Expansion that is in progress. Before initiating a System Expansion, you need to provision and burn-in the new hardware. Please be sure to run gpcheckperf to make sure the new hardware is working properly. Please refer to the Admin Guide for more information. Would you like to initiate a new System Expansion Yy|Nn (default=N): > y You must now specify a mirroring strategy for the new hosts. Spread mirroring places a given hosts mirrored segments each on a separate host. You must be adding more hosts than the number of segments per host to use this. Grouped mirroring places all of a given hosts segments on a single mirrored host. You must be adding at least 2 hosts in order to use this. What type of mirroring strategy would you like? spread|grouped (default=grouped): #默認的mirror方式 >

** No hostnames were given that do not already exist in the **
** array. Additional segments will be added existing hosts. ** By default, new hosts are configured with the same number of primary segments as existing hosts. Optionally, you can increase the number of segments per host. For example, if existing hosts have two primary segments, entering a value of 2 will initialize two additional segments on existing hosts, and four segments on new hosts. In addition, mirror segments will be added for these new primary segments if mirroring is enabled. How many new primary segments per host do you want to add? (default=0): > 1 Enter new primary data directory 1: > /apps/data2/primary Enter new mirror data directory 1: > /apps/data2/mirror Generating configuration file... 20210331:14:17:05:015453 gpexpand:lgh1:gpadmin-[INFO]:-Generating input file... Input configuration file was written to 'gpexpand_inputfile_20210331_141705'. Please review the file and make sure that it is correct then re-run with: gpexpand -i gpexpand_inputfile_20210331_141705 #生成的初始化文件 20210331:14:17:05:015453 gpexpand:lgh1:gpadmin-[INFO]:-Exiting...

查看初始化文件:

[gpadmin@lgh1 conf]$ cat gpexpand_inputfile_20210331_141705 lgh3|lgh3|6001|/apps/data2/primary/gpseg2|7|2|p lgh2|lgh2|7001|/apps/data2/mirror/gpseg2|10|2|m lgh2|lgh2|6001|/apps/data2/primary/gpseg3|8|3|p lgh3|lgh3|7001|/apps/data2/mirror/gpseg3|9|3|m

3.3、初始化Segment並且創建擴容schema

執行命令:gpexpand  -i gpexpand_inputfile_20210331_141705

[gpadmin@lgh1 conf]$ gpexpand  -i gpexpand_inputfile_20210331_141705 20210331:14:21:40:016004 gpexpand:lgh1:gpadmin-[INFO]:-local Greenplum Version: 'postgres (Greenplum Database) 6.14.1 build commit:5ef30dd4c9878abadc0124e0761e4b988455a4bd'
20210331:14:21:40:016004 gpexpand:lgh1:gpadmin-[INFO]:-master Greenplum Version: 'PostgreSQL 9.4.24 (Greenplum Database 6.14.1 build commit:5ef30dd4c9878abadc0124e0761e4b988455a4bd) on x86_64-unknown-linux-gnu, compiled by gcc (GCC) 6.4.0, 64-bit compiled on Feb 22 2021 18:27:08'
20210331:14:21:40:016004 gpexpand:lgh1:gpadmin-[INFO]:-Querying gpexpand schema for current expansion state 20210331:14:21:40:016004 gpexpand:lgh1:gpadmin-[INFO]:-Heap checksum setting consistent across cluster 20210331:14:21:40:016004 gpexpand:lgh1:gpadmin-[INFO]:-Syncing Greenplum Database extensions 20210331:14:21:40:016004 gpexpand:lgh1:gpadmin-[INFO]:-The packages on lgh2 are consistent. 20210331:14:21:41:016004 gpexpand:lgh1:gpadmin-[INFO]:-The packages on lgh3 are consistent. 20210331:14:21:41:016004 gpexpand:lgh1:gpadmin-[INFO]:-Locking catalog 20210331:14:21:41:016004 gpexpand:lgh1:gpadmin-[INFO]:-Locked catalog 20210331:14:21:42:016004 gpexpand:lgh1:gpadmin-[INFO]:-Creating segment template 20210331:14:21:42:016004 gpexpand:lgh1:gpadmin-[INFO]:-Copying postgresql.conf from existing segment into template 20210331:14:21:43:016004 gpexpand:lgh1:gpadmin-[INFO]:-Copying pg_hba.conf from existing segment into template 20210331:14:21:43:016004 gpexpand:lgh1:gpadmin-[INFO]:-Creating schema tar file
20210331:14:21:43:016004 gpexpand:lgh1:gpadmin-[INFO]:-Distributing template tar file to new hosts 20210331:14:21:44:016004 gpexpand:lgh1:gpadmin-[INFO]:-Configuring new segments (primary) 20210331:14:21:44:016004 gpexpand:lgh1:gpadmin-[INFO]:-{'lgh2': '/apps/data2/primary/gpseg3:6001:true:false:8:3::-1:', 'lgh3': '/apps/data2/primary/gpseg2:6001:true:false:7:2::-1:'} 20210331:14:21:47:016004 gpexpand:lgh1:gpadmin-[INFO]:-Cleaning up temporary template files 20210331:14:21:48:016004 gpexpand:lgh1:gpadmin-[INFO]:-Cleaning up databases in new segments. 20210331:14:21:49:016004 gpexpand:lgh1:gpadmin-[INFO]:-Unlocking catalog 20210331:14:21:49:016004 gpexpand:lgh1:gpadmin-[INFO]:-Unlocked catalog 20210331:14:21:49:016004 gpexpand:lgh1:gpadmin-[INFO]:-Creating expansion schema 20210331:14:21:49:016004 gpexpand:lgh1:gpadmin-[INFO]:-Populating gpexpand.status_detail with data from database template1 20210331:14:21:50:016004 gpexpand:lgh1:gpadmin-[INFO]:-Populating gpexpand.status_detail with data from database postgres 20210331:14:21:50:016004 gpexpand:lgh1:gpadmin-[INFO]:-Populating gpexpand.status_detail with data from database gpebusiness 20210331:14:21:50:016004 gpexpand:lgh1:gpadmin-[INFO]:-Populating gpexpand.status_detail with data from database gpperfmon 20210331:14:21:50:016004 gpexpand:lgh1:gpadmin-[INFO]:-Starting new mirror segment synchronization 20210331:14:21:58:016004 gpexpand:lgh1:gpadmin-[INFO]:-************************************************
20210331:14:21:58:016004 gpexpand:lgh1:gpadmin-[INFO]:-Initialization of the system expansion complete. 20210331:14:21:58:016004 gpexpand:lgh1:gpadmin-[INFO]:-To begin table expansion onto the new segments 20210331:14:21:58:016004 gpexpand:lgh1:gpadmin-[INFO]:-rerun gpexpand 20210331:14:21:58:016004 gpexpand:lgh1:gpadmin-[INFO]:-************************************************
20210331:14:21:58:016004 gpexpand:lgh1:gpadmin-[INFO]:-Exiting...

使用gpstate驗證下:(segment為8了,成功)

[gpadmin@lgh1 conf]$ gpstate 20210331:14:23:19:016384 gpstate:lgh1:gpadmin-[INFO]:-Starting gpstate with args: 20210331:14:23:19:016384 gpstate:lgh1:gpadmin-[INFO]:-local Greenplum Version: 'postgres (Greenplum Database) 6.14.1 build commit:5ef30dd4c9878abadc0124e0761e4b988455a4bd'
20210331:14:23:19:016384 gpstate:lgh1:gpadmin-[INFO]:-master Greenplum Version: 'PostgreSQL 9.4.24 (Greenplum Database 6.14.1 build commit:5ef30dd4c9878abadc0124e0761e4b988455a4bd) on x86_64-unknown-linux-gnu, compiled by gcc (GCC) 6.4.0, 64-bit compiled on Feb 22 2021 18:27:08'
20210331:14:23:19:016384 gpstate:lgh1:gpadmin-[INFO]:-Obtaining Segment details from master... 20210331:14:23:19:016384 gpstate:lgh1:gpadmin-[INFO]:-Gathering data from segments... 20210331:14:23:19:016384 gpstate:lgh1:gpadmin-[INFO]:-Greenplum instance status summary 20210331:14:23:19:016384 gpstate:lgh1:gpadmin-[INFO]:-----------------------------------------------------
20210331:14:23:19:016384 gpstate:lgh1:gpadmin-[INFO]:-   Master instance                                           = Active 20210331:14:23:19:016384 gpstate:lgh1:gpadmin-[INFO]:-   Master standby                                            = lgh2 20210331:14:23:19:016384 gpstate:lgh1:gpadmin-[INFO]:-   Standby master state                                      = Standby host passive 20210331:14:23:19:016384 gpstate:lgh1:gpadmin-[INFO]:-   Total segment instance count from metadata                = 8
20210331:14:23:19:016384 gpstate:lgh1:gpadmin-[INFO]:-----------------------------------------------------
20210331:14:23:19:016384 gpstate:lgh1:gpadmin-[INFO]:- Primary Segment Status 20210331:14:23:19:016384 gpstate:lgh1:gpadmin-[INFO]:-----------------------------------------------------
20210331:14:23:19:016384 gpstate:lgh1:gpadmin-[INFO]:-   Total primary segments = 4
20210331:14:23:19:016384 gpstate:lgh1:gpadmin-[INFO]:-   Total primary segment valid (at master)                   = 4
20210331:14:23:19:016384 gpstate:lgh1:gpadmin-[INFO]:-   Total primary segment failures (at master)                = 0
20210331:14:23:19:016384 gpstate:lgh1:gpadmin-[INFO]:-   Total number of postmaster.pid files missing              = 0
20210331:14:23:19:016384 gpstate:lgh1:gpadmin-[INFO]:-   Total number of postmaster.pid files found                = 4
20210331:14:23:19:016384 gpstate:lgh1:gpadmin-[INFO]:-   Total number of postmaster.pid PIDs missing               = 0
20210331:14:23:19:016384 gpstate:lgh1:gpadmin-[INFO]:-   Total number of postmaster.pid PIDs found                 = 4
20210331:14:23:19:016384 gpstate:lgh1:gpadmin-[INFO]:-   Total number of /tmp lock files missing                   = 0
20210331:14:23:19:016384 gpstate:lgh1:gpadmin-[INFO]:-   Total number of /tmp lock files found                     = 4
20210331:14:23:19:016384 gpstate:lgh1:gpadmin-[INFO]:-   Total number postmaster processes missing                 = 0
20210331:14:23:19:016384 gpstate:lgh1:gpadmin-[INFO]:-   Total number postmaster processes found                   = 4
20210331:14:23:19:016384 gpstate:lgh1:gpadmin-[INFO]:-----------------------------------------------------
20210331:14:23:19:016384 gpstate:lgh1:gpadmin-[INFO]:- Mirror Segment Status 20210331:14:23:19:016384 gpstate:lgh1:gpadmin-[INFO]:-----------------------------------------------------
20210331:14:23:19:016384 gpstate:lgh1:gpadmin-[INFO]:-   Total mirror segments = 4
20210331:14:23:19:016384 gpstate:lgh1:gpadmin-[INFO]:-   Total mirror segment valid (at master)                    = 4
20210331:14:23:19:016384 gpstate:lgh1:gpadmin-[INFO]:-   Total mirror segment failures (at master)                 = 0
20210331:14:23:19:016384 gpstate:lgh1:gpadmin-[INFO]:-   Total number of postmaster.pid files missing              = 0
20210331:14:23:19:016384 gpstate:lgh1:gpadmin-[INFO]:-   Total number of postmaster.pid files found                = 4
20210331:14:23:19:016384 gpstate:lgh1:gpadmin-[INFO]:-   Total number of postmaster.pid PIDs missing               = 0
20210331:14:23:19:016384 gpstate:lgh1:gpadmin-[INFO]:-   Total number of postmaster.pid PIDs found                 = 4
20210331:14:23:19:016384 gpstate:lgh1:gpadmin-[INFO]:-   Total number of /tmp lock files missing                   = 0
20210331:14:23:19:016384 gpstate:lgh1:gpadmin-[INFO]:-   Total number of /tmp lock files found                     = 4
20210331:14:23:19:016384 gpstate:lgh1:gpadmin-[INFO]:-   Total number postmaster processes missing                 = 0
20210331:14:23:19:016384 gpstate:lgh1:gpadmin-[INFO]:-   Total number postmaster processes found                   = 4
20210331:14:23:19:016384 gpstate:lgh1:gpadmin-[INFO]:-   Total number mirror segments acting as primary segments   = 0
20210331:14:23:19:016384 gpstate:lgh1:gpadmin-[INFO]:-   Total number mirror segments acting as mirror segments    = 4
20210331:14:23:19:016384 gpstate:lgh1:gpadmin-[INFO]:-----------------------------------------------------
20210331:14:23:19:016384 gpstate:lgh1:gpadmin-[INFO]:-   Cluster Expansion                                         = In Progress 20210331:14:23:19:016384 gpstate:lgh1:gpadmin-[INFO]:-----------------------------------------------------

3.4、重分布數據

執行命令:gpexpand -d 1:00:00  #不動命令回去看gpexpand命令說明,這里沒有業務表,所以很快就重分布完成了,如果數據量很大,可以增加線程

20210331:14:28:45:016891 gpexpand:lgh1:gpadmin-[INFO]:-local Greenplum Version: 'postgres (Greenplum Database) 6.14.1 build commit:5ef30dd4c9878abadc0124e0761e4b988455a4bd'
20210331:14:28:45:016891 gpexpand:lgh1:gpadmin-[INFO]:-master Greenplum Version: 'PostgreSQL 9.4.24 (Greenplum Database 6.14.1 build commit:5ef30dd4c9878abadc0124e0761e4b988455a4bd) on x86_64-unknown-linux-gnu, compiled by gcc (GCC) 6.4.0, 64-bit compiled on Feb 22 2021 18:27:08'
20210331:14:28:45:016891 gpexpand:lgh1:gpadmin-[INFO]:-Querying gpexpand schema for current expansion state 20210331:14:28:45:016891 gpexpand:lgh1:gpadmin-[INFO]:-Expanding postgres.gpcc_schema.pghba_lock 20210331:14:28:46:016891 gpexpand:lgh1:gpadmin-[INFO]:-Finished expanding postgres.gpcc_schema.pghba_lock 20210331:14:28:46:016891 gpexpand:lgh1:gpadmin-[INFO]:-Expanding gpperfmon.gpmetrics.gpcc_schedule 20210331:14:28:46:016891 gpexpand:lgh1:gpadmin-[INFO]:-Finished expanding gpperfmon.gpmetrics.gpcc_schedule 20210331:14:28:46:016891 gpexpand:lgh1:gpadmin-[INFO]:-Expanding gpperfmon.gpmetrics.gpcc_scan_history 20210331:14:28:46:016891 gpexpand:lgh1:gpadmin-[INFO]:-Finished expanding gpperfmon.gpmetrics.gpcc_scan_history 20210331:14:28:46:016891 gpexpand:lgh1:gpadmin-[INFO]:-Expanding gpperfmon.gpmetrics.gpcc_wlm_rule 20210331:14:28:46:016891 gpexpand:lgh1:gpadmin-[INFO]:-Finished expanding gpperfmon.gpmetrics.gpcc_wlm_rule 20210331:14:28:46:016891 gpexpand:lgh1:gpadmin-[INFO]:-Expanding gpperfmon.gpmetrics.gpcc_export_log 20210331:14:28:46:016891 gpexpand:lgh1:gpadmin-[INFO]:-Finished expanding gpperfmon.gpmetrics.gpcc_export_log 20210331:14:28:47:016891 gpexpand:lgh1:gpadmin-[INFO]:-Expanding gpperfmon.gpmetrics.gpcc_table_info 20210331:14:28:47:016891 gpexpand:lgh1:gpadmin-[INFO]:-Finished expanding gpperfmon.gpmetrics.gpcc_table_info 20210331:14:28:47:016891 gpexpand:lgh1:gpadmin-[INFO]:-Expanding gpperfmon.gpmetrics._gpcc_plannode_history 20210331:14:28:47:016891 gpexpand:lgh1:gpadmin-[INFO]:-Finished expanding gpperfmon.gpmetrics._gpcc_plannode_history 20210331:14:28:47:016891 gpexpand:lgh1:gpadmin-[INFO]:-Expanding gpperfmon.gpcc_schema.pghba_lock 20210331:14:28:47:016891 gpexpand:lgh1:gpadmin-[INFO]:-Finished expanding gpperfmon.gpcc_schema.pghba_lock 20210331:14:28:47:016891 gpexpand:lgh1:gpadmin-[INFO]:-Expanding gpperfmon.gpmetrics.gpcc_alert_history 20210331:14:28:47:016891 gpexpand:lgh1:gpadmin-[INFO]:-Finished expanding gpperfmon.gpmetrics.gpcc_alert_history 20210331:14:28:47:016891 gpexpand:lgh1:gpadmin-[INFO]:-Expanding gpperfmon.gpmetrics.gpcc_database_history 20210331:14:28:48:016891 gpexpand:lgh1:gpadmin-[INFO]:-Finished expanding gpperfmon.gpmetrics.gpcc_database_history 20210331:14:28:48:016891 gpexpand:lgh1:gpadmin-[INFO]:-Expanding gpperfmon.gpmetrics.gpcc_disk_history 20210331:14:28:48:016891 gpexpand:lgh1:gpadmin-[INFO]:-Finished expanding gpperfmon.gpmetrics.gpcc_disk_history 20210331:14:28:48:016891 gpexpand:lgh1:gpadmin-[INFO]:-Expanding gpperfmon.gpmetrics.gpcc_pg_log_history 20210331:14:28:48:016891 gpexpand:lgh1:gpadmin-[INFO]:-Finished expanding gpperfmon.gpmetrics.gpcc_pg_log_history 20210331:14:28:48:016891 gpexpand:lgh1:gpadmin-[INFO]:-Expanding gpperfmon.gpmetrics.gpcc_plannode_history 20210331:14:28:49:016891 gpexpand:lgh1:gpadmin-[INFO]:-Finished expanding gpperfmon.gpmetrics.gpcc_plannode_history 20210331:14:28:49:016891 gpexpand:lgh1:gpadmin-[INFO]:-Expanding gpperfmon.gpmetrics.gpcc_queries_history 20210331:14:28:49:016891 gpexpand:lgh1:gpadmin-[INFO]:-Finished expanding gpperfmon.gpmetrics.gpcc_queries_history 20210331:14:28:49:016891 gpexpand:lgh1:gpadmin-[INFO]:-Expanding gpperfmon.gpmetrics.gpcc_system_history 20210331:14:28:49:016891 gpexpand:lgh1:gpadmin-[INFO]:-Finished expanding gpperfmon.gpmetrics.gpcc_system_history 20210331:14:28:50:016891 gpexpand:lgh1:gpadmin-[INFO]:-Expanding gpperfmon.gpmetrics.gpcc_table_info_history 20210331:14:28:50:016891 gpexpand:lgh1:gpadmin-[INFO]:-Finished expanding gpperfmon.gpmetrics.gpcc_table_info_history 20210331:14:28:50:016891 gpexpand:lgh1:gpadmin-[INFO]:-Expanding gpperfmon.gpmetrics.gpcc_wlm_log_history 20210331:14:28:50:016891 gpexpand:lgh1:gpadmin-[INFO]:-Finished expanding gpperfmon.gpmetrics.gpcc_wlm_log_history 20210331:14:28:50:016891 gpexpand:lgh1:gpadmin-[INFO]:-Expanding gpperfmon.gpmetrics._gpcc_pg_log_meta 20210331:14:28:50:016891 gpexpand:lgh1:gpadmin-[INFO]:-Finished expanding gpperfmon.gpmetrics._gpcc_pg_log_meta 20210331:14:28:50:016891 gpexpand:lgh1:gpadmin-[INFO]:-EXPANSION COMPLETED SUCCESSFULLY 20210331:14:28:50:016891 gpexpand:lgh1:gpadmin-[INFO]:-Exiting...

3.5、移除擴容schema

執行命令:gpexpand -c

[gpadmin@lgh1 conf]$ gpexpand -c 20210331:14:32:01:017244 gpexpand:lgh1:gpadmin-[INFO]:-local Greenplum Version: 'postgres (Greenplum Database) 6.14.1 build commit:5ef30dd4c9878abadc0124e0761e4b988455a4bd'
20210331:14:32:01:017244 gpexpand:lgh1:gpadmin-[INFO]:-master Greenplum Version: 'PostgreSQL 9.4.24 (Greenplum Database 6.14.1 build commit:5ef30dd4c9878abadc0124e0761e4b988455a4bd) on x86_64-unknown-linux-gnu, compiled by gcc (GCC) 6.4.0, 64-bit compiled on Feb 22 2021 18:27:08'
20210331:14:32:01:017244 gpexpand:lgh1:gpadmin-[INFO]:-Querying gpexpand schema for current expansion state Do you want to dump the gpexpand.status_detail table to file? Yy|Nn (default=Y): > y 20210331:14:32:05:017244 gpexpand:lgh1:gpadmin-[INFO]:-Dumping gpexpand.status_detail to /apps/data1/master/gpseg-1/gpexpand.status_detail 20210331:14:32:05:017244 gpexpand:lgh1:gpadmin-[INFO]:-Removing gpexpand schema 20210331:14:32:05:017244 gpexpand:lgh1:gpadmin-[INFO]:-Cleanup Finished.  exiting...

這里為止縱向擴容就完成了,不出錯都是傻瓜式的操作,出錯多看日志,也不難。

注意:如果在擴容的時候失敗或者出錯了,記得回滾:gpexpand -r ,還有就是擴容成功,數據重分布成功后記得使用analyze或者analyzedb進行分析

四、橫向擴容

4.1、安裝前准備

參考:greenplum6.14、GPCC6.4安裝詳解 第一部分

4.2、基本配置和規划

規划,新增兩台機器(紅色粗體部分),由於配置了mirror,所以至少要新增兩台機器擴容,不然會報錯:

 

 在新的兩個機器進行如下操作:

#創建gp用戶和用戶組 groupdel gpadmin userdel gpadmin groupadd gpadmin useradd -g gpadmin gpadmin #創建segment目錄 mkdir /apps/data1/primary mkdir /apps/data2/primary mkdir /apps/data1/mirror mkdir /apps/data2/mirror chown -R gpamdin:gpamdin /apps/data* #拷貝master主機的安裝目錄 cd /usr/local &&  tar -cf /usr/local/gp6.tar greenplum-db-6.14.1 #master主機操作 scp gp6.tar root@lgh4:/usr/local/ #master主機操作 scp gp6.tar root@lgh5:/usr/local/ #master主機操作 cd /usr/local tar -xf gp6.tar
ln -s greenplum-db-6.14.1 greenplum-db chown -R gpadmin:gpadmin greenplum-db* #ssh免密配置 ssh-copy-id lgh4 #master主機操作 ssh-copy-id lgh5  #master主機操作

修改seg_hosts,all_hosts文件,添加新主機名進去:

[gpadmin@mvxl53201 conf]$ cat seg_hosts
lgh2
lgh3
lgh4 #new
lgh5 #new
[gpadmin@mvxl53201 conf]$ cat all_hosts lgh1 lgh2 lgh3 lgh4 #new lgh5 #new

執行:gpssh-exkeys -f all_hosts

[gpadmin@lgh1 conf]$ gpssh-exkeys -f all_hosts [STEP 1 of 5] create local ID and authorize on local host ... /apps/gpadmin/.ssh/id_rsa file exists ... key generation skipped [STEP 2 of 5] keyscan all hosts and update known_hosts file [STEP 3 of 5] retrieving credentials from remote hosts ... send to lgh2 ... send to lgh3 ... send to lgh4 ... send to lgh5 [STEP 4 of 5] determine common authentication file content [STEP 5 of 5] copy authentication files to all remote hosts ... finished key exchange with lgh2 ... finished key exchange with lgh3 ... finished key exchange with lgh4 ... finished key exchange with lgh5 [INFO] completed successfully

4.3、創建初始化文件

執行:gpexpand -f seg_hosts

[gpadmin@lgh1 conf]$ gpexpand -f seg_hosts 20210331:15:00:52:020105 gpexpand:lgh1:gpadmin-[INFO]:-local Greenplum Version: 'postgres (Greenplum Database) 6.14.1 build commit:5ef30dd4c9878abadc0124e0761e4b988455a4bd'
20210331:15:00:52:020105 gpexpand:lgh1:gpadmin-[INFO]:-master Greenplum Version: 'PostgreSQL 9.4.24 (Greenplum Database 6.14.1 build commit:5ef30dd4c9878abadc0124e0761e4b988455a4bd) on x86_64-unknown-linux-gnu, compiled by gcc (GCC) 6.4.0, 64-bit compiled on Feb 22 2021 18:27:08'
20210331:15:00:52:020105 gpexpand:lgh1:gpadmin-[INFO]:-Querying gpexpand schema for current expansion state System Expansion is used to add segments to an existing GPDB array. gpexpand did not detect a System Expansion that is in progress. Before initiating a System Expansion, you need to provision and burn-in the new hardware. Please be sure to run gpcheckperf to make sure the new hardware is working properly. Please refer to the Admin Guide for more information. Would you like to initiate a new System Expansion Yy|Nn (default=N): > y You must now specify a mirroring strategy for the new hosts. Spread mirroring places a given hosts mirrored segments each on a separate host. You must be adding more hosts than the number of segments per host to use this. Grouped mirroring places all of a given hosts segments on a single mirrored host. You must be adding at least 2 hosts in order to use this. What type of mirroring strategy would you like? spread|grouped (default=grouped): > By default, new hosts are configured with the same number of primary segments as existing hosts. Optionally, you can increase the number of segments per host. For example, if existing hosts have two primary segments, entering a value of 2 will initialize two additional segments on existing hosts, and four segments on new hosts. In addition, mirror segments will be added for these new primary segments if mirroring is enabled. How many new primary segments per host do you want to add? (default=0): > Generating configuration file... 20210331:15:00:59:020105 gpexpand:lgh1:gpadmin-[INFO]:-Generating input file... Input configuration file was written to 'gpexpand_inputfile_20210331_150059'. Please review the file and make sure that it is correct then re-run with: gpexpand -i gpexpand_inputfile_20210331_150059 #生成文件 20210331:15:00:59:020105 gpexpand:lgh1:gpadmin-[INFO]:-Exiting...

查看初始化的文件:

[gpadmin@lgh1 conf]$ cat gpexpand_inputfile_20210331_150059 lgh5|lgh5|6000|/apps/data1/primary/gpseg4|11|4|p lgh4|lgh4|7000|/apps/data1/mirror/gpseg4|17|4|m lgh5|lgh5|6001|/apps/data2/primary/gpseg5|12|5|p lgh4|lgh4|7001|/apps/data2/mirror/gpseg5|18|5|m lgh4|lgh4|6000|/apps/data1/primary/gpseg6|13|6|p lgh5|lgh5|7000|/apps/data1/mirror/gpseg6|15|6|m lgh4|lgh4|6001|/apps/data2/primary/gpseg7|14|7|p lgh5|lgh5|7001|/apps/data2/mirror/gpseg7|16|7|m

4.4、初始化Segment並且創建擴容schema

執行:gpexpand -i gpexpand_inputfile_20210331_150059

[gpadmin@lgh1 conf]$ gpexpand -i gpexpand_inputfile_20210331_150059 20210331:15:04:06:020454 gpexpand:lgh1:gpadmin-[INFO]:-local Greenplum Version: 'postgres (Greenplum Database) 6.14.1 build commit:5ef30dd4c9878abadc0124e0761e4b988455a4bd'
20210331:15:04:06:020454 gpexpand:lgh1:gpadmin-[INFO]:-master Greenplum Version: 'PostgreSQL 9.4.24 (Greenplum Database 6.14.1 build commit:5ef30dd4c9878abadc0124e0761e4b988455a4bd) on x86_64-unknown-linux-gnu, compiled by gcc (GCC) 6.4.0, 64-bit compiled on Feb 22 2021 18:27:08'
20210331:15:04:06:020454 gpexpand:lgh1:gpadmin-[INFO]:-Querying gpexpand schema for current expansion state 20210331:15:04:06:020454 gpexpand:lgh1:gpadmin-[INFO]:-Heap checksum setting consistent across cluster 20210331:15:04:06:020454 gpexpand:lgh1:gpadmin-[INFO]:-Syncing Greenplum Database extensions 20210331:15:04:07:020454 gpexpand:lgh1:gpadmin-[INFO]:-The packages on lgh5 are consistent. 20210331:15:04:08:020454 gpexpand:lgh1:gpadmin-[INFO]:-The packages on lgh4 are consistent. 20210331:15:04:08:020454 gpexpand:lgh1:gpadmin-[INFO]:-Locking catalog 20210331:15:04:08:020454 gpexpand:lgh1:gpadmin-[INFO]:-Locked catalog 20210331:15:04:09:020454 gpexpand:lgh1:gpadmin-[INFO]:-Creating segment template 20210331:15:04:09:020454 gpexpand:lgh1:gpadmin-[INFO]:-Copying postgresql.conf from existing segment into template 20210331:15:04:09:020454 gpexpand:lgh1:gpadmin-[INFO]:-Copying pg_hba.conf from existing segment into template 20210331:15:04:10:020454 gpexpand:lgh1:gpadmin-[INFO]:-Creating schema tar file
20210331:15:04:10:020454 gpexpand:lgh1:gpadmin-[INFO]:-Distributing template tar file to new hosts 20210331:15:04:11:020454 gpexpand:lgh1:gpadmin-[INFO]:-Configuring new segments (primary) 20210331:15:04:11:020454 gpexpand:lgh1:gpadmin-[INFO]:-{'lgh5': '/apps/data1/primary/gpseg4:6000:true:false:11:4::-1:,/apps/data2/primary/gpseg5:6001:true:false:12:5::-1:', 'lgh4': '/apps/data1/primary/gpseg6:6000:true:false:13:6::-1:,/apps/data2/primary/gpseg7:6001:true:false:14:7::-1:'} 20210331:15:04:17:020454 gpexpand:lgh1:gpadmin-[INFO]:-Cleaning up temporary template files 20210331:15:04:17:020454 gpexpand:lgh1:gpadmin-[INFO]:-Cleaning up databases in new segments. 20210331:15:04:19:020454 gpexpand:lgh1:gpadmin-[INFO]:-Unlocking catalog 20210331:15:04:19:020454 gpexpand:lgh1:gpadmin-[INFO]:-Unlocked catalog 20210331:15:04:19:020454 gpexpand:lgh1:gpadmin-[INFO]:-Creating expansion schema 20210331:15:04:19:020454 gpexpand:lgh1:gpadmin-[INFO]:-Populating gpexpand.status_detail with data from database template1 20210331:15:04:19:020454 gpexpand:lgh1:gpadmin-[INFO]:-Populating gpexpand.status_detail with data from database postgres 20210331:15:04:19:020454 gpexpand:lgh1:gpadmin-[INFO]:-Populating gpexpand.status_detail with data from database gpebusiness 20210331:15:04:20:020454 gpexpand:lgh1:gpadmin-[INFO]:-Populating gpexpand.status_detail with data from database gpperfmon 20210331:15:04:20:020454 gpexpand:lgh1:gpadmin-[INFO]:-Starting new mirror segment synchronization 20210331:15:04:34:020454 gpexpand:lgh1:gpadmin-[INFO]:-************************************************
20210331:15:04:34:020454 gpexpand:lgh1:gpadmin-[INFO]:-Initialization of the system expansion complete. 20210331:15:04:34:020454 gpexpand:lgh1:gpadmin-[INFO]:-To begin table expansion onto the new segments 20210331:15:04:34:020454 gpexpand:lgh1:gpadmin-[INFO]:-rerun gpexpand 20210331:15:04:34:020454 gpexpand:lgh1:gpadmin-[INFO]:-************************************************
20210331:15:04:34:020454 gpexpand:lgh1:gpadmin-[INFO]:-Exiting...

4.5、重分布數據

執行:gpexpand -d 1:00:00

[gpadmin@lgh1 conf]$ gpexpand -d 1:00:00
20210331:15:06:46:021037 gpexpand:lgh1:gpadmin-[INFO]:-local Greenplum Version: 'postgres (Greenplum Database) 6.14.1 build commit:5ef30dd4c9878abadc0124e0761e4b988455a4bd'
20210331:15:06:46:021037 gpexpand:lgh1:gpadmin-[INFO]:-master Greenplum Version: 'PostgreSQL 9.4.24 (Greenplum Database 6.14.1 build commit:5ef30dd4c9878abadc0124e0761e4b988455a4bd) on x86_64-unknown-linux-gnu, compiled by gcc (GCC) 6.4.0, 64-bit compiled on Feb 22 2021 18:27:08'
20210331:15:06:46:021037 gpexpand:lgh1:gpadmin-[INFO]:-Querying gpexpand schema for current expansion state 20210331:15:06:46:021037 gpexpand:lgh1:gpadmin-[INFO]:-Expanding postgres.gpcc_schema.pghba_lock 20210331:15:06:46:021037 gpexpand:lgh1:gpadmin-[INFO]:-Finished expanding postgres.gpcc_schema.pghba_lock 20210331:15:06:46:021037 gpexpand:lgh1:gpadmin-[INFO]:-Expanding gpperfmon.gpmetrics.gpcc_export_log 20210331:15:06:46:021037 gpexpand:lgh1:gpadmin-[INFO]:-Finished expanding gpperfmon.gpmetrics.gpcc_export_log 20210331:15:06:47:021037 gpexpand:lgh1:gpadmin-[INFO]:-Expanding gpperfmon.gpmetrics.gpcc_schedule 20210331:15:06:47:021037 gpexpand:lgh1:gpadmin-[INFO]:-Finished expanding gpperfmon.gpmetrics.gpcc_schedule 20210331:15:06:47:021037 gpexpand:lgh1:gpadmin-[INFO]:-Expanding gpperfmon.gpmetrics.gpcc_wlm_rule 20210331:15:06:47:021037 gpexpand:lgh1:gpadmin-[INFO]:-Finished expanding gpperfmon.gpmetrics.gpcc_wlm_rule 20210331:15:06:47:021037 gpexpand:lgh1:gpadmin-[INFO]:-Expanding gpperfmon.gpmetrics.gpcc_table_info 20210331:15:06:47:021037 gpexpand:lgh1:gpadmin-[INFO]:-Finished expanding gpperfmon.gpmetrics.gpcc_table_info 20210331:15:06:47:021037 gpexpand:lgh1:gpadmin-[INFO]:-Expanding gpperfmon.gpmetrics._gpcc_pg_log_meta 20210331:15:06:47:021037 gpexpand:lgh1:gpadmin-[INFO]:-Finished expanding gpperfmon.gpmetrics._gpcc_pg_log_meta 20210331:15:06:48:021037 gpexpand:lgh1:gpadmin-[INFO]:-Expanding gpperfmon.gpmetrics._gpcc_plannode_history 20210331:15:06:48:021037 gpexpand:lgh1:gpadmin-[INFO]:-Finished expanding gpperfmon.gpmetrics._gpcc_plannode_history 20210331:15:06:48:021037 gpexpand:lgh1:gpadmin-[INFO]:-Expanding gpperfmon.gpcc_schema.pghba_lock 20210331:15:06:48:021037 gpexpand:lgh1:gpadmin-[INFO]:-Finished expanding gpperfmon.gpcc_schema.pghba_lock 20210331:15:06:48:021037 gpexpand:lgh1:gpadmin-[INFO]:-Expanding gpperfmon.gpmetrics.gpcc_alert_history 20210331:15:06:48:021037 gpexpand:lgh1:gpadmin-[INFO]:-Finished expanding gpperfmon.gpmetrics.gpcc_alert_history 20210331:15:06:48:021037 gpexpand:lgh1:gpadmin-[INFO]:-Expanding gpperfmon.gpmetrics.gpcc_database_history 20210331:15:06:48:021037 gpexpand:lgh1:gpadmin-[INFO]:-Finished expanding gpperfmon.gpmetrics.gpcc_database_history 20210331:15:06:49:021037 gpexpand:lgh1:gpadmin-[INFO]:-Expanding gpperfmon.gpmetrics.gpcc_disk_history 20210331:15:06:49:021037 gpexpand:lgh1:gpadmin-[INFO]:-Finished expanding gpperfmon.gpmetrics.gpcc_disk_history 20210331:15:06:49:021037 gpexpand:lgh1:gpadmin-[INFO]:-Expanding gpperfmon.gpmetrics.gpcc_pg_log_history 20210331:15:06:49:021037 gpexpand:lgh1:gpadmin-[INFO]:-Finished expanding gpperfmon.gpmetrics.gpcc_pg_log_history 20210331:15:06:50:021037 gpexpand:lgh1:gpadmin-[INFO]:-Expanding gpperfmon.gpmetrics.gpcc_plannode_history 20210331:15:06:50:021037 gpexpand:lgh1:gpadmin-[INFO]:-Finished expanding gpperfmon.gpmetrics.gpcc_plannode_history 20210331:15:06:50:021037 gpexpand:lgh1:gpadmin-[INFO]:-Expanding gpperfmon.gpmetrics.gpcc_queries_history 20210331:15:06:50:021037 gpexpand:lgh1:gpadmin-[INFO]:-Finished expanding gpperfmon.gpmetrics.gpcc_queries_history 20210331:15:06:50:021037 gpexpand:lgh1:gpadmin-[INFO]:-Expanding gpperfmon.gpmetrics.gpcc_system_history 20210331:15:06:51:021037 gpexpand:lgh1:gpadmin-[INFO]:-Finished expanding gpperfmon.gpmetrics.gpcc_system_history 20210331:15:06:51:021037 gpexpand:lgh1:gpadmin-[INFO]:-Expanding gpperfmon.gpmetrics.gpcc_table_info_history 20210331:15:06:51:021037 gpexpand:lgh1:gpadmin-[INFO]:-Finished expanding gpperfmon.gpmetrics.gpcc_table_info_history 20210331:15:06:51:021037 gpexpand:lgh1:gpadmin-[INFO]:-Expanding gpperfmon.gpmetrics.gpcc_wlm_log_history 20210331:15:06:51:021037 gpexpand:lgh1:gpadmin-[INFO]:-Finished expanding gpperfmon.gpmetrics.gpcc_wlm_log_history 20210331:15:06:52:021037 gpexpand:lgh1:gpadmin-[INFO]:-Expanding gpperfmon.gpmetrics.gpcc_scan_history 20210331:15:06:52:021037 gpexpand:lgh1:gpadmin-[INFO]:-Finished expanding gpperfmon.gpmetrics.gpcc_scan_history 20210331:15:06:56:021037 gpexpand:lgh1:gpadmin-[INFO]:-EXPANSION COMPLETED SUCCESSFULLY 20210331:15:06:56:021037 gpexpand:lgh1:gpadmin-[INFO]:-Exiting...

4.6、移除擴容schema

執行命令:gpexpand -c

[gpadmin@lgh1 conf]$ gpexpand -c 20210331:15:08:19:021264 gpexpand:lgh1:gpadmin-[INFO]:-local Greenplum Version: 'postgres (Greenplum Database) 6.14.1 build commit:5ef30dd4c9878abadc0124e0761e4b988455a4bd'
20210331:15:08:19:021264 gpexpand:lgh1:gpadmin-[INFO]:-master Greenplum Version: 'PostgreSQL 9.4.24 (Greenplum Database 6.14.1 build commit:5ef30dd4c9878abadc0124e0761e4b988455a4bd) on x86_64-unknown-linux-gnu, compiled by gcc (GCC) 6.4.0, 64-bit compiled on Feb 22 2021 18:27:08'
20210331:15:08:19:021264 gpexpand:lgh1:gpadmin-[INFO]:-Querying gpexpand schema for current expansion state Do you want to dump the gpexpand.status_detail table to file? Yy|Nn (default=Y): > y 20210331:15:08:21:021264 gpexpand:lgh1:gpadmin-[INFO]:-Dumping gpexpand.status_detail to /apps/data1/master/gpseg-1/gpexpand.status_detail 20210331:15:08:21:021264 gpexpand:lgh1:gpadmin-[INFO]:-Removing gpexpand schema 20210331:15:08:21:021264 gpexpand:lgh1:gpadmin-[INFO]:-Cleanup Finished.  exiting...

查看擴容結果:gpstate

[gpadmin@lgh1 conf]$ gpstate 20210331:15:10:11:021437 gpstate:lgh1:gpadmin-[INFO]:-Starting gpstate with args: 20210331:15:10:11:021437 gpstate:lgh1:gpadmin-[INFO]:-local Greenplum Version: 'postgres (Greenplum Database) 6.14.1 build commit:5ef30dd4c9878abadc0124e0761e4b988455a4bd'
20210331:15:10:11:021437 gpstate:lgh1:gpadmin-[INFO]:-master Greenplum Version: 'PostgreSQL 9.4.24 (Greenplum Database 6.14.1 build commit:5ef30dd4c9878abadc0124e0761e4b988455a4bd) on x86_64-unknown-linux-gnu, compiled by gcc (GCC) 6.4.0, 64-bit compiled on Feb 22 2021 18:27:08'
20210331:15:10:11:021437 gpstate:lgh1:gpadmin-[INFO]:-Obtaining Segment details from master... 20210331:15:10:11:021437 gpstate:lgh1:gpadmin-[INFO]:-Gathering data from segments... 20210331:15:10:11:021437 gpstate:lgh1:gpadmin-[INFO]:-Greenplum instance status summary 20210331:15:10:11:021437 gpstate:lgh1:gpadmin-[INFO]:-----------------------------------------------------
20210331:15:10:11:021437 gpstate:lgh1:gpadmin-[INFO]:-   Master instance                                           = Active 20210331:15:10:11:021437 gpstate:lgh1:gpadmin-[INFO]:-   Master standby                                            = lgh2 20210331:15:10:11:021437 gpstate:lgh1:gpadmin-[INFO]:-   Standby master state                                      = Standby host passive 20210331:15:10:11:021437 gpstate:lgh1:gpadmin-[INFO]:-   Total segment instance count from metadata = 16
20210331:15:10:11:021437 gpstate:lgh1:gpadmin-[INFO]:-----------------------------------------------------
20210331:15:10:11:021437 gpstate:lgh1:gpadmin-[INFO]:- Primary Segment Status 20210331:15:10:11:021437 gpstate:lgh1:gpadmin-[INFO]:-----------------------------------------------------
20210331:15:10:11:021437 gpstate:lgh1:gpadmin-[INFO]:-   Total primary segments = 8
20210331:15:10:11:021437 gpstate:lgh1:gpadmin-[INFO]:-   Total primary segment valid (at master)                   = 8
20210331:15:10:11:021437 gpstate:lgh1:gpadmin-[INFO]:-   Total primary segment failures (at master)                = 0
20210331:15:10:11:021437 gpstate:lgh1:gpadmin-[INFO]:-   Total number of postmaster.pid files missing              = 0
20210331:15:10:11:021437 gpstate:lgh1:gpadmin-[INFO]:-   Total number of postmaster.pid files found                = 8
20210331:15:10:11:021437 gpstate:lgh1:gpadmin-[INFO]:-   Total number of postmaster.pid PIDs missing               = 0
20210331:15:10:11:021437 gpstate:lgh1:gpadmin-[INFO]:-   Total number of postmaster.pid PIDs found                 = 8
20210331:15:10:11:021437 gpstate:lgh1:gpadmin-[INFO]:-   Total number of /tmp lock files missing                   = 0
20210331:15:10:11:021437 gpstate:lgh1:gpadmin-[INFO]:-   Total number of /tmp lock files found                     = 8
20210331:15:10:11:021437 gpstate:lgh1:gpadmin-[INFO]:-   Total number postmaster processes missing                 = 0
20210331:15:10:11:021437 gpstate:lgh1:gpadmin-[INFO]:-   Total number postmaster processes found                   = 8
20210331:15:10:11:021437 gpstate:lgh1:gpadmin-[INFO]:-----------------------------------------------------
20210331:15:10:11:021437 gpstate:lgh1:gpadmin-[INFO]:- Mirror Segment Status 20210331:15:10:11:021437 gpstate:lgh1:gpadmin-[INFO]:-----------------------------------------------------
20210331:15:10:11:021437 gpstate:lgh1:gpadmin-[INFO]:-   Total mirror segments = 8
20210331:15:10:11:021437 gpstate:lgh1:gpadmin-[INFO]:-   Total mirror segment valid (at master)                    = 8
20210331:15:10:11:021437 gpstate:lgh1:gpadmin-[INFO]:-   Total mirror segment failures (at master)                 = 0
20210331:15:10:11:021437 gpstate:lgh1:gpadmin-[INFO]:-   Total number of postmaster.pid files missing              = 0
20210331:15:10:11:021437 gpstate:lgh1:gpadmin-[INFO]:-   Total number of postmaster.pid files found                = 8
20210331:15:10:11:021437 gpstate:lgh1:gpadmin-[INFO]:-   Total number of postmaster.pid PIDs missing               = 0
20210331:15:10:11:021437 gpstate:lgh1:gpadmin-[INFO]:-   Total number of postmaster.pid PIDs found                 = 8
20210331:15:10:11:021437 gpstate:lgh1:gpadmin-[INFO]:-   Total number of /tmp lock files missing                   = 0
20210331:15:10:11:021437 gpstate:lgh1:gpadmin-[INFO]:-   Total number of /tmp lock files found                     = 8
20210331:15:10:11:021437 gpstate:lgh1:gpadmin-[INFO]:-   Total number postmaster processes missing                 = 0
20210331:15:10:11:021437 gpstate:lgh1:gpadmin-[INFO]:-   Total number postmaster processes found                   = 8
20210331:15:10:11:021437 gpstate:lgh1:gpadmin-[INFO]:-   Total number mirror segments acting as primary segments   = 0
20210331:15:10:11:021437 gpstate:lgh1:gpadmin-[INFO]:-   Total number mirror segments acting as mirror segments    = 8
20210331:15:10:11:021437 gpstate:lgh1:gpadmin-[INFO]:-----------------------------------------------------

注意:如果在擴容的時候失敗或者出錯了,記得回滾:gpexpand -r ,還有就是擴容成功,數據重分布成功后記得使用analyze或者analyzedb進行分析

 

參考網址:

http://docs-cn.greenplum.org/v6/admin_guide/expand/expand-main.html

http://docs-cn.greenplum.org/v6/utility_guide/admin_utilities/gpexpand.html#topic1


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM