Greenplum Database New Features - Enhancements in Managing and Migrating Greenplum Database Objects and Data

1. Enhancement for Restoring Data from a Greenplum Database Backup (GPDB 4.3.1.0)

2. Managing and Migrating Greenplum Database Objects and Data (GPDB 4.3.2.0)   a) 2 New utilities gptransfer, gpreload added. b) The --redirect and --report-status-dir options have been added to the Greenplum Database utility gpdbrestore.
The gadget spec URL could not be found
3. Managing Greenplum Database Objects and Data : a) The GRANT and REVOKE commands support the TRUNCATE privilege on a table ( GPDB 4.3.3.0)  b) Capturing errors that occur from reading data from external data sources does not require an error table (GPDB 4.3.3.0) c) enables delta compression for compressed columns in append-optimized, column-oriented tables(GPDB 4.3.3.0)
The gadget spec URL could not be found

1. [ Added in GPDB 4.3.1.0] : When you run gpdbrestore command to restore your database/tables from a backup, your tables automatically gets analyzed after backup. Analyzing large tables takes long time and hence your restore time increase exponentially. To shorten the restore time, greenplum added a new option in gpdbrestore utility called noanalyze. 

The new option --noanalyze for the Greenplum Database gpdbrestore utility disables ANALYZE of tables during restore.

The default action is to run the ANALYZE command after a restore. This option is useful if running ANALYZE on tables in your database requires a significant amount of time. If you specify this option, you should run ANALYZE manually on restored tables. 

Note:  It is important to analyze the tables after restore. If you skip this step following a restore then you might result in poor database performance.

The gadget spec URL could not be found
2. [ Added in GPDB 4.3.2.0] gptransfer utility : The gptransfer utility copies database objects from databases in a source Greenplum Database system to databases in a destination Greenplum Database system. The gptransfer utility is supported only with the IPv4 protocol. The gptransfer utility is not supported with the IPv6 protocol.

*****************************************************
SYNOPSIS
*****************************************************
gptransfer  { --full | [-d <database1> [ -d <database2> ... ]]
  [-t <db.schema.table> [ -t <db1.schema1.table1> ... ]]
  [-f <table_file> ] } 
  [--delimiter <delim> ]
  [--skip-existing | --truncate | --drop] 
  [--analyze] [--validate=<type> ] [-x] [--dry-run] 
  [--schema-only ]

  [--source-host=<source_host> [--source-port=<source_port>] 
  [--source-user=<source_user>] ]
  [--base-port=<base_gpfdist_port>]
  [--dest-host=<dest_host> --source-map-file=<host_map_file> 
  [--dest-port=<dest_port>] [--dest-user=<dest_user>] ]
  [--dest-database=<dest_database_name>] 

  [--batch-size=<batch_size>] [--sub-batch-size=<sub_batch_size>]
  [--timeout <seconds>]
  [--max-line-length=<length>] 
  [--work-base-dir=<work_dir>] [-l <log_dir>] 

  [-v | --verbose] 
  [-q |--quiet] 
  [-a] 

gptransfer --version 

gptransfer h |-? | --help 
*****************************************************
DESCRIPTION
*****************************************************
The gptransfer utility copies database objects from a source Greenplum Database system to a destination system. You can perform one of the
following types of operations:

* Copy a Greenplum Database system with the --full option.

This option copies all user created databases in a source system to a different destination system. If you specify the --full option, you must
specify both a source and destination system. The destination system cannot contain any user defined databases, only the default databases
postgres, template0, and template1.

* Copy a set of user defined database tables to a destination system. The -f, and -t options copy a specified set of user defined tables and
table data, and re-creates the table indexes. The -d option copies all user defined tables and table data, and re-creates the table indexes
from a specified database.

If the destination system is the same as the source system, you must also specify a destination database with the --dest-database option.
When you specify a destination database, the source database tables are copied into the specified destination database.

If an invalid set of gptransfer options are specified, or if a specified source table or database does not exist, gptransfer returns an error and
quits. No data is copied.

To copy database objects between Greenplum Database systems gptransfer utility uses:

* The Greenplum Database utility gpfdist on the source database system. The gpfdists protocol is not supported

* Writeable external tables on the source database system and readable external tables on the destination database system.

* Named pipes that transfer the data between a writeable external table and a readable external table.

When copying data into the destination system, it is redistributed on the Greenplum Database segments of the destination system. This is the
flow of data when gptransfer copies database data:

writable external table > gpfidst > named pipe > gpfdist > readable external table

*****************************************************
NOTES
*****************************************************

When copying database data between different Greenplum Database systems, gptransfer requires a text file that lists all the source segment host 
names and IP addresses. Specify the name and location of the file with the --source-map-file option. If the file is missing or not all segment 
hosts are listed, gptransfer returns an error and quits. See the description of the option for file format information. 

The source and destination Greenplum Database segment hosts need to be able to communicate with each other. To ensure that the segment hosts 
can communicate, you can use a tool such as the Linux netperf utility. 

If a filespace has been created for a source Greenplum Database system, a corresponding filespace must exist on the target system. 

SSH keys must be exchanged between the two systems before using gptransfer. The gptransfer utility connects to the source system with 
SSH to create the named pipes and start the gpfdist instances. You can use the Greenplum Database gpssh-exkeys utility with a list of all the 
source and destination primary hosts to exchange keys between Greenplum Database hosts. 

Source and destination systems must be able to access the gptransfer work directory. The default directory is the user's home directory. You 
can specify a different directory with the --work-base-dir option. 

The gptransfer utility does not move configuration files such as postgres.conf and pg_hba.conf. You must set up the destination system 
configuration separately. 

The gptransfer utility does not move external objects such as Greenplum Database extensions, third-party jar files, and shared object files. You 
must install the external objects separately. 

The gptransfer utility does not move dependent database object unless you specify the --full option. For example, if a table has a default 
value on a column that is a user-defined function, that function must exist in the destination system database when using the -t, -d, or -f 
options. 

If you move a set of database tables with the -d, -t, and -f options, and the destination table or database does not exist, gptransfer creates 
it. The utility re-creates any indexes on tables before copying data. 

If a table exists on the destination system and one of the options --skip-existing, --truncate, or --drop is not specified, gptransfer returns an error and quits. 

If an error occurs when during the process of copying a table, or table validation fails, gptransfer continues copying the other specified tables. After gptransfer finishes, it displays a list of tables where an error occurred, writes the names of tables that failed into a text file, and then prints the name of the file. You can use this file with the gptransfer -f option to retry copying tables. 

The name of the file that contains the list of tables where errors occurred is failed_migrated_tables_<yyyymmdd_hhmmss>.txt. The <yyyymmdd_hhmmss> is a time stamp when the gptransfer process was started. The file is created in the directory were gptransfer is executed. 

The gp_external_max_segs server configuration parameter controls the number of segment instances that can access a single gpfdist instance 
simultaneously. Setting a low value might affect gptransfer performance. For information about the parameter, see the "Greenplum Database 
Reference Guide". 

*****************************************************
LIMITATION FOR THE SOURCE AND DESTINATION SYSTEMS
*****************************************************

If you are copying data from a system with a larger number of segments to a system fewer number of segment hosts. The total number of primary 
segments on the destination system must be greater than or equal to the total number of segment hosts on the source system. 

For example, a quarter rack V1 DCA has a total of 24 primary segments. The means the source side cannot have more than 24 segment hosts (one 
and one-half racks). 

When you copy data from a source Greenplum Database system with a larger number of primary segment instances than on the destination system, the 
data transfer might be slower when compared to a transfer where the source system has fewer segment instances than the destination system. 
The gptransfer utility uses a different configuration of named pipes and gpfdist instances in the two situations. 

*****************************************************
OPTIONS
*****************************************************

-a 

 Quiet mode, do not prompt the user for confirmation. 

--analyze 

 Run the ANALYZE command on non-system tables. The default is to not run  the ANALYZE command. 

--base-port=<base_gpfdist_port> 

 Base port for gpfdist on source segment systems. If not specified, the  default is 8000. 

--batch-size=<batch_size> 

 Sets the maximum number of tables that gptransfer concurrently copies to  the destination database. If not specified, the default is 2. The 
 maximum is 10. 


-d <database_name> 

 A source database to copy. This option can be specified multiple times  to copy multiple databases to the destination system. All the user  defined tables and table data are copied to the destination system.  Wildcard characters are not supported. 

 If the source database does not exist, gptransfer returns an error and  quits. If a destination database does not exist a database is created. 
 Alternatively, specify the -t or -f option to copy a specified set of  tables. 

 Not valid with the --full option. 

--delimiter=<delim> 

 Delimiter to use for external tables. Specify a single ASCII character  that separates columns within each row of data. The default is octal 
 character \001, the SOH character. 


--dest-database=<dest_database_name> 

 The database in the destination Greenplum Database system. If not  specified, the source tables are copied into a destination system 
 database with the same name as the source system database. 

 This option is required if the source and destination Greenplum Database  systems are the same. 

 If destination database does not exist, it is created. 

 Not valid with the --full option. 

--dest-host=<dest_host> 

 Destination Greenplum Database hostname or IP address. If not specified,  the default is the host the system running gptransfer (127.0.0.1) 

--dest-port=<dest_port> 

 Destination Greenplum Database port number, If not specified, the  default is 5432. 

--dest-user=<dest_user> 

 User ID that is used to connect to the destination Greenplum Database  system. If not specified, the default is the user gpadmin. 

--drop 

 Specify this option to drop the table that is in the destination  database if it already exists. Before copying table data, gptransfer 
 drops the table and creates it again. 

 At most, only one of the options can be specified --skip-existing,  --truncate, or --drop. If one of them is not specified and the table 
 exists in the destination system, gptransfer returns an error and quits. 

 Not valid with the --full option. 

--dry-run 

 When you specify this option, gptransfer generates a list of the  migration operations that would have been performed with the specified 
 options. The data is not migrated. 

 The information is displayed at the command line and written to the log  file. 

-f <table_file> 

 The location and name of file containing list of fully qualified table  names to copy from the Greenplum Database source system. In the text 
 file, you specify a single fully qualified table per line. Wildcard  characters are not supported. 

  sales.public.clients
  sales.public.merchants
  demo.test.lineitem 

 If the source table does not exist, gptransfer returns an error and  quits. If the destination database or table does not exist, it is 
 created. 

 Only the table and table data are copied and indexes are re-created.  Dependent objects are not copied. 

 You cannot specify views, or system catalog tables. The --full option  copies user defined views. 

 If you specify the -d option to copy all the tables from a database, you  do not need to specify individual tables from the database. 
 
 Not valid with the --full option. 


--full 

 Full migration of a Greenplum Database source system to a destination  system. You must specify the options for the destination system, the 
 --source-map-file option, the --dest-host option, and if necessary, the  other destination system options. 

 The --full option cannot be specified with the -t, -d, or -f options. 

 A full migration copies all database objects including, tables,  indexes, users, roles, functions, and resource queues for all user  defined databases. The default databases, postgres, template0 and  template1 are not moved. 

 If a database exists in the destination system, besides the default  postgres, template0 and template1 databases, gptransfer returns an error 
 and quits. 

-l <log_dir> 

 Specify the gptransfer log file directory. If not specified, the default 
 is ~/AdminLogs. 

 --max-line-length=<length> 

 Sets the maximum allowed data row length in bytes for the gpfidst  utility. If not specified, the default is 10485760. Valid range is 
 32768 (32K) to 268435456 (256MB). 

 Should be used when user data includes very wide rows (or when line too  long error message occurs). Should not be used otherwise as it increases 
 resource allocation. 

-q | --quiet 

 If specified, suppress status messages. Messages are only sent to the  log file. 

--schema-only 

 Create only the schemas specified by the command. Data is not transferred. 

 If specified with the --full option, gptransfer replicates the complete  database schema, including all tables, indexes, views, user defined 
 types (UDT), and user defined functions (UDF) for the source databases. 
 No data is transferred. 

 If you specify tables with the -t or -f option with --schema-only,  gptransfer creates only the tables and indexes. No data is transferred. 

 Not valid with the --truncate option. 

--skip-existing 

 Specify this option to skip copying a table from the source database if  the table already exists in the destination database. 

 At most, only one of the options can be specified --skip-existing,  --truncate, or --drop. If one of them is not specified and the table 
 exists in the destination system, gptransfer returns an error and quits. 

 Not valid with the --full option. 

--source-host=<source_host> 

 Source Greenplum Database host name or IP address. If not specified, the  default host is the system running gptransfer (127.0.0.1). 

--source-map-file=<host_map_file> 

 File that lists source segment host name and IP addresses. If the file  is missing or not all segment hosts are listed, gptransfer returns an 
 error and quits. 

 Each line of the file contains a source host name and the host IP  address separated by a comma: hostname,IPaddress. This example lists 
 four Greenplum Database hosts and their IP addresses. 

  sdw1,172.168.2.1
  sdw2,172.168.2.2
  sdw3,172.168.2.3
  sdw4,172.168.2.4 

 This option is required if the --full option is specified or if the  source Greenplum Database system is different than the destination  system. This option is not required if source and destination systems  are the same. 

--source-port=<source_port> 

 Source Greenplum Database port number. If not specified, the default is  5432. 

--source-user=<source_user> 

 User ID that is used to connect to the source Greenplum Database system.  If not specified, the default is the user gpadmin. 

--sub-batch-size=<sub_batch_size> 

 Specifies the maximum degree of parallelism of the operations performed  when migrating a table such as starting gpfdist instances, creating 
 named pipes for the move operations. If not specified, the default is  25. The maximum is 50. 

 Specify the --batch-size option to control the the maximum number of  tables that gptransfer concurrently processes. 
 
 -t <db.schema.table> 

 A table from the source database system to copy. The fully qualified  table name must be specified, for example -t sales.public.clients. 
 Wildcard characters are not supported. 

 If the destination table or database does not exist, it is created. This  option can be specified multiple times to include multiple tables. Only 
 the table and table data are copied and indexes are re-created.  Dependent objects are not copied. 

 If the source table does not exist, gptransfer returns an error and  quits. 

 If you specify the -d option to copy all the tables from a database, you  do not need to specify individual tables from the database. 

 Not valid with the --full option. 


--timeout <seconds> 

 Specify the time out value in seconds that gptransfer passes the gpfdist  processes that gptransfer uses. The value is the time allowed for 
 Greenplum Database to establish a connection to a gpfdist process. You  might need to increase this value when operating on high-traffic 
 networks. 

 The default value is 300 seconds (5 minutes). The minimum value is 2  seconds, the maximum value is 600 seconds. 

--truncate 

 Specify this option to truncate the table that is in the destination  database if it already exists. 

 At most, only one of the options can be specified --skip-existing, 
 --truncate, or --drop. If one of them is not specified and the table 
 exists in the destination system, gptransfer returns an error and quits. 

 Not valid with the --full option. 

--validate=<type> 

 Perform data validation on table data. These are the supported types of  validation. 

  count - Specify this value to compare row counts between source and destination table data. 

  MD5 - Specify this value to compare MD5 values between source and destination table data. 

 If validation for a table fails, gpfidist displays the name of the table  and writes the file name to the text file  failed_migrated_tables_<yyyymmdd_hhmmss>.txt. The yyyymmdd_hhmmss is a  time stamp when the gptransfer process was started. The file is created  in the directory were gptransfer is executed. 

 NOTE: The file contains the table names were validation failed or other  errors occurred during table migration. 

-v |--verbose 

 If specified, sets the logging level to verbose. Additional log 
 information is written to the log file and the command line during 
 command execution. 


--work-base-dir=<work_dir> 

 Specify the directory that gptransfer uses to store temporary working  files such as PID files and named pipes. The default directory is the  user's home directory. 

 Source and destination systems must be able to access the gptransfer  work directory. 

-x 

 Acquire an exclusive lock on tables during the migration to prevent  insert or updates. 

 On the source database, an exclusive lock is acquired when gptransfer  inserts into the external table and is released after validation. 

 On the destination database, an exclusive lock is acquired when  gptransfer selects from external table and released after validation. 

 NOTE: If -x option is not specified and --validate is specified,  validation failures occur if data is inserted into either the source or 
 destination table during the migration process. The gptransfer utility  displays messages if validation errors occur. 

-h | -? | --help 

 Displays the online help. 


--version 

 Displays the version of this utility. 


*****************************************************
EXAMPLE
*****************************************************

This command copies the table public.t1 from the database db1 and all tables in the database db2 to the system mytest2. 

 gptransfer -t db1.public.t1 -d db2 --dest-host=mytest2 
    --source-map-file=gp-source-hosts --truncate

If the databases db1 and db2 do not exist on the system mytest2, they are created. If any of the source tables exist on the destination 
system, gptransfer truncates the table and copies the data from the source to the destination table. 

*****************************************************
See Also
*****************************************************

gpfdist 

See the "Greenplum Database Database Administrator Guide" for information about loading and unloading data. 
[gpadmin@localhost ~]$ 


3. [ Added in GPDB 4.3.2.0] gpreload utility :  The gpreload utility reloads table data with column data sorted. For tables that were created with the table storage option APPENDONLY=TRUE and compression enabled, reloading the data with sorted data can improve table compression. You specify a list of tables to be reloaded the table column to be sorted.

COMMAND NAME: gpreload

Reloads Greenplum Database table data sorting the data based on specified columns.
*****************************************************
SYNOPSIS
*****************************************************
gpreload -d <database> [-p <port>]    {-t |--table-file} <path_to_file>  [-a ]
gpreload -h | --version

*****************************************************
DESCRIPTION
*****************************************************
The gpreload utility reloads table data with column data sorted. For tables that were created with the table storage option APPENDONLY=TRUE
and compression enabled, reloading the data with sorted data can improve table compression. You specify a list of tables to be reloaded the table
column to be sorted in a text file.

Compression is improved by sorting data when the data in the column has a relatively low number of distinct values when compared to the total
number of rows.

For a table being reloaded, the order of the columns to be sorted might affect compression. The columns with fewest distinct values should be
listed first. For example, listing state then city would generally result in better compression than listing city then state.

 public.cust_table: state, city
 public.cust_table: city, state

For information about the format of the file used with gpreload, see the
--table-file option.

*****************************************************
NOTES
****************************************************
To improve reload performance, indexes on tables being reloaded should be removed before reloading the data.

Running the ANALYZE command after reloading table data might query performance because of a change in the data distribution of the reloaded
data.

*****************************************************
OPTIONS
*****************************************************

-a (do not prompt)

 Optional. If specified, the gpreload utility does not prompt the user  for confirmation. 

 -d <database>

 The database that contains the tables to be reloaded. The gpreload  utility connects to the database as the user running the utility. 

-p <port> 

 The Greenplum Database master port. If not specified, the value of the  PGPORT environment variable is used. If the value is not available, an 
 error is returned. 

 {-t | --table-file } <path_to_file> 

 The location and name of file containing list of schema qualified table  names to reload and the column names to reorder from the Greenplum 
 Database. Only user defined tables are supported. Views or system  catalog tables are not supported. 

 If indexes are defined on table listed in the file, gpreload prompts to  continue. 

 Each line specifies a table name and the list of columns to sort. This  is the format of each line in the file: 

  <schema>.<table_name>: <column> [desc] [, <column2> [desc] ... ]

 The table name is followed by a colon ( : ) and then at least one column  name. If you specify more than one column, separate the column names 
 with a comma. The columns are sorted in ascending order. Specify the  keyword desc after the column name to sort the column in descending 
 order. 

 Wildcard characters are not supported. 

 If there are errors in the file, gpreload reports the first error and  exits. No data is reloaded. 

 The following example reloads three tables. 

  public.clients: region, state, rep_id desc
  public.merchants: region, state
  test.lineitem: group, assy, whse 

 In the first table public.clients, the data in the rep_id column is  sorted in descending order. The data in the other columns are sorted in 
 ascending order. 

--version (show utility version)

 Displays the version of this utility.

-? (help)

 Displays the online help.


*****************************************************
EXAMPLE
*****************************************************
This example command reloads the tables in the database mytest that are listed in the file data-tables.txt. 

 gpreload -d mytest --file data-tables.txt

*****************************************************
SEE ALSO
*****************************************************
The CREATE TABLE command in the "Greenplum Database Reference Guide."       


4. [ Added in GPDB 4.3.2.0] : The --redirect and --report-status-dir options 

The --redirect and --report-status-dir options have been added to the Greenplum Database utility gpdbrestore.

--redirect: When restoring data from a backup created with the gpcrondump utility, you can specify a the --redirectoption and a database name to restore data to a database that is different than the database specified during back up.

--report-status-dir: If you run a the gpcrondump operation with the -u option to specify the backup directory and that is read only, you can specify --report-status-dir so that gpcrondump writes the report files to a directory with write privileges. The --report-status-dir option specify the absolute path to the directory on the each Greenplum Database host (master and segment hosts) where gpdbrestore writes report status files for a restore operation.
                                                                                                             
Enhancements in Managing and Migrating Greenplum Database Objects and Data (4.3.1.0, 4.3.2.0, 4.3.3.0)
The gadget spec URL could not be found
The gadget spec URL could not be found
The gadget spec URL could not be found
Comments