提交 2710bc21 编写于 作者: J Jamie McAtamney 提交者: David Krieger

gpinitsystem: Change flags for mirroring and standby datadir

Because the gpinitstandby flag for passing in a standby master data directory
was changed from -F to -S, this commit changes -F to -S in gpinitsystem to
match.

-S was already in use for specifying that the cluster should have its mirrors
set up in spread configuration, so that flag is changed to --mirror-mode, which
accepts the mirror mode ('group' or 'spread') as an argument.
Co-authored-by: NJamie McAtamney <jmcatamney@pivotal.io>
Co-authored-by: NMark Sliva <msliva@pivotal.io>
(cherry picked from commit 6fa3bce8)
上级 cfec7e64
......@@ -332,7 +332,7 @@ fi
STANDBY_INIT_OPTS=""
if [ "${WITH_STANDBY}" == "true" ]; then
STANDBY_INIT_OPTS="-s ${LOCALHOST} -P ${STANDBY_DEMO_PORT} -F ${STANDBYDIR}"
STANDBY_INIT_OPTS="-s ${LOCALHOST} -P ${STANDBY_DEMO_PORT} -S ${STANDBYDIR}"
fi
if [ ! -z "${EXTRA_CONFIG}" ]; then
......
......@@ -73,7 +73,7 @@ TMP_HOSTNAME_FILE=/tmp/hostname_test_file.$$
PARALLEL_STATUS_FILE=/tmp/gpinitsystem_parallel_status_file.$$
GPCREATESEG=$WORKDIR/lib/gpcreateseg.sh
ULIMIT_WARN=0
MIRROR_TYPE=0
MIRROR_TYPE=0 # 0 = group, 1 = spread
REMOTE_HOST_COUNT=0
SINGLE_HOST_BATCH_LIMIT=4
INPUT_CONFIG=""
......@@ -135,7 +135,7 @@ USAGE () {
$ECHO " Also see gpinitsystem_INSTRUCTIONS file for greater detail on"
$ECHO " the operation and configuration of this script"
$ECHO " -e, <password>, password to set for Greenplum superuser in database [default $GP_PASSWD]"
$ECHO " -F, standby_datadir [optiona]"
$ECHO " -S, standby_datadir [optional]"
$ECHO " -h, gp_hostlist_file [optional]"
$ECHO " Contains a list of all segment instance hostnames required to participate in"
$ECHO " the new Greenplum instance. Normally set in gp_config_file."
......@@ -664,7 +664,7 @@ END_PYTHON_CODE
if [ $MIRRORING -eq 1 ] && [ $MIRROR_TYPE -eq 1 ];then
# Mirroring is on and spread mirror configuration has been requested, make sure sufficient hosts
if [ $NUM_SEP_HOSTS -eq 1 ] || [ $NUM_SEP_HOSTS -le $NUM_DATADIR ];then
LOG_MSG "[FATAL]:-Request made for spread mirroring via -S option, but insufficient hosts available" 1
LOG_MSG "[FATAL]:-Request made for spread mirroring via --mirror-mode option, but insufficient hosts available" 1
LOG_MSG "[INFO]:-Number of separate hosts must be greater than number of segment instances per host" 1
ERROR_EXIT "[FATAL]:-Unable to continue" 2
else
......@@ -672,7 +672,7 @@ END_PYTHON_CODE
fi
fi
if [ $MIRRORING -eq 0 ] && [ $MIRROR_TYPE -eq 1 ];then
LOG_MSG "[WARN]:-Option -S supplied, but no mirrors have been defined, ignoring -S option" 1
LOG_MSG "[WARN]:-Option --mirror-mode supplied, but no mirrors have been defined, ignoring --mirror-mode option" 1
MIRROR_TYPE=0
EXIT_STATUS=1
fi
......@@ -1953,11 +1953,22 @@ SET_DCA_CONFIG_SETTINGS () {
fi
}
SET_MIRROR_MODE() {
local mode=$1
if [ "$mode" == 'group' ]; then
MIRROR_TYPE=0
elif [ "$mode" == 'spread' ]; then
MIRROR_TYPE=1
else
ERROR_EXIT "[FATAL]:-'$mode' is an invalid mirroring mode. Valid options are 'group' and 'spread'." 2
fi
}
#******************************************************************************
# Main Section
#******************************************************************************
trap 'ERROR_EXIT "[FATAL]:-Received INT or TERM signal" 2' INT TERM
while getopts ":vaqe:c:l:-:p:m:h:n:s:P:F:b:DB:SI:O:" opt
while getopts ":vaqe:c:l:-:p:m:h:n:s:P:S:b:DB:I:O:" opt
do
case $opt in
v ) print_version ;;
......@@ -1972,11 +1983,10 @@ while getopts ":vaqe:c:l:-:p:m:h:n:s:P:F:b:DB:SI:O:" opt
b ) NEW_BUFFERS=$OPTARG ;;
s ) STANDBY_HOSTNAME=$OPTARG ;;
P ) STANDBY_PORT=$OPTARG ;;
F ) STANDBY_DATADIR=$OPTARG ;;
S ) STANDBY_DATADIR=$OPTARG ;;
n ) REQ_LOCALE_SETTING=$OPTARG ;;
D ) DEBUG_LEVEL=1 ;;
B ) BATCH_DEFAULT=$OPTARG ;;
S ) MIRROR_TYPE=1 ;;
I ) INPUT_CONFIG=$OPTARG ;;
O ) OUTPUT_CONFIG=$OPTARG ;;
- ) # Long options ...
......@@ -1993,6 +2003,8 @@ while getopts ":vaqe:c:l:-:p:m:h:n:s:P:F:b:DB:SI:O:" opt
"lc-monetary" ) LCMONETARY=$VAL ;;
"lc-numeric" ) LCNUMERIC=$VAL ;;
"lc-time" ) LCTIME=$VAL ;;
"mirror-mode" ) SET_MIRROR_MODE $VAL ;;
"standby-datadir" ) STANDBY_DATADIR=$VAL ;;
"help" ) USAGE "print_doc" ;;
"version" ) print_version ;;
* ) LOG_MSG "[ERROR]:-Unknown option --$NAME" 1; USAGE ;;
......
......@@ -25,7 +25,7 @@ Feature: gpinitsystem tests
And the user runs command "rm -rf /tmp/gpinitsystemtest && mkdir /tmp/gpinitsystemtest"
# stop db and make sure cluster config exists so that we can manually initialize standby
And the cluster config is generated with data_checksums "1"
When the user runs "gpinitsystem -a -c ../gpAux/gpdemo/clusterConfigFile -l /tmp/gpinitsystemtest -s localhost -P 21100 -F /wrong/path -h ../gpAux/gpdemo/hostfile"
When the user runs "gpinitsystem -a -c ../gpAux/gpdemo/clusterConfigFile -l /tmp/gpinitsystemtest -s localhost -P 21100 -S /wrong/path -h ../gpAux/gpdemo/hostfile"
Then gpinitsystem should return a return code of 1
And gpinitsystem should not print "To activate the Standby Master Segment in the event of Master" to stdout
And gpinitsystem should print "Cluster setup finished, but Standby Master failed to initialize. Review contents of log files for errors." to stdout
......@@ -67,7 +67,7 @@ Feature: gpinitsystem tests
And the user runs command "rm -rf $MASTER_DATA_DIRECTORY/newstandby"
And the user runs command "rm -rf /tmp/gpinitsystemtest && mkdir /tmp/gpinitsystemtest"
And the cluster config is generated with data_checksums "1"
When the user runs "gpinitsystem -a -c ../gpAux/gpdemo/clusterConfigFile -l /tmp/gpinitsystemtest -s localhost -P 21100 -F $MASTER_DATA_DIRECTORY/newstandby -h ../gpAux/gpdemo/hostfile"
When the user runs "gpinitsystem -a -c ../gpAux/gpdemo/clusterConfigFile -l /tmp/gpinitsystemtest -s localhost -P 21100 -S $MASTER_DATA_DIRECTORY/newstandby -h ../gpAux/gpdemo/hostfile"
Then gpinitsystem should return a return code of 0
And gpinitsystem should print "Log file scan check passed" to stdout
And sql "select * from gp_toolkit.__gp_user_namespaces" is executed in "postgres" db
......
......@@ -2493,7 +2493,7 @@ def impl(context):
@when('initialize a cluster with standby using "{config_file}"')
def impl(context, config_file):
run_gpcommand(context, 'gpinitsystem -a -I %s -l /tmp/gpinitsystemtest -s localhost -P 21100 -F $MASTER_DATA_DIRECTORY/newstandby -h ../gpAux/gpdemo/hostfile' % config_file)
run_gpcommand(context, 'gpinitsystem -a -I %s -l /tmp/gpinitsystemtest -s localhost -P 21100 -S $MASTER_DATA_DIRECTORY/newstandby -h ../gpAux/gpdemo/hostfile' % config_file)
check_return_code(context, 0)
@when('initialize a cluster using "{config_file}"')
......
......@@ -139,7 +139,7 @@ class TestCluster:
# run gpinitsystem
clean_env = 'unset MASTER_DATA_DIRECTORY; unset PGPORT;'
segment_mirroring_option = '-S' if mirroring_configuration == 'spread' else ''
segment_mirroring_option = '--mirror-mode=spread' if mirroring_configuration == 'spread' else ''
gpinitsystem_cmd = clean_env + 'gpinitsystem -a -c %s %s' % (self.init_file, segment_mirroring_option)
res = run_shell_command(gpinitsystem_cmd, 'run gpinitsystem', verbose=True)
# initsystem returns 1 for warnings and 2 for errors
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册