Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 21 additions & 8 deletions gpMgmt/bin/gpinitsystem
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ CHK_PARAMS () {
fi

if [ x"$ETCD_HOST_CONFIG" = x"" ] || [ x"$CLUSTER_BOOT_MODE" = x"DEMO" ]; then
LOG_MSG "[WARN]:-No ETCD cluster host config provided, use default configuration."
LOG_MSG "[INFO]:-No ETCD cluster host config provided, use default configuration."
else
ETCD_HOST_MACHINE_LIST=(`$CAT $ETCD_HOST_CONFIG`)
ETCD_HOST_CONFIG_NUM=${#ETCD_HOST_MACHINE_LIST[@]}
Expand All @@ -323,7 +323,7 @@ CHK_PARAMS () {
fi

if [ x"$FTS_HOST_CONFIG" = x"" ] || [ x"$CLUSTER_BOOT_MODE" = x"DEMO" ]; then
LOG_MSG "[WARN]:-No FTS cluster host config provided, use default configuration."
LOG_MSG "[INFO]:-No FTS cluster host config provided, use default configuration."
else
FTS_HOST_MACHINE_LIST=(`$CAT $FTS_HOST_CONFIG`)
FTS_HOST_CONFIG_NUM=${#FTS_HOST_MACHINE_LIST[@]}
Expand Down Expand Up @@ -1531,11 +1531,18 @@ CREATE_STANDBY_QD () {
if [ $HBA_HOSTNAMES -eq 1 ]; then
INIT_STANDBY_ARGS+=" --hba-hostnames"
fi
if [ x"$CLUSTER_BOOT_MODE" = x"PRODUCTION" ]; then
export COORDINATOR_DATA_DIRECTORY=${COORDINATOR_DIRECTORY}/${SEG_PREFIX}-1;$INIT_STANDBY_PROG -s $STANDBY_HOSTNAME $INIT_STANDBY_ARGS -a -f $FTS_HOST_STRING_LIST
else
export COORDINATOR_DATA_DIRECTORY=${COORDINATOR_DIRECTORY}/${SEG_PREFIX}-1;$INIT_STANDBY_PROG -s $STANDBY_HOSTNAME $INIT_STANDBY_ARGS -a
fi
# -f takes the list of external FTS hosts, and only exists when the
# cluster was given one. Guard it the same way as the arguments above:
# CLUSTER_BOOT_MODE is PRODUCTION for every cluster whose coordinator
# and segments are on different hosts -- which is every real one --
# but FTS_HOST_STRING_LIST is empty unless -f/-F was passed to
# gpinitsystem, and "-f" with nothing after it makes gpinitstandby
# exit 2 on "-f option requires 1 argument" before it writes a line of
# its own log.
if [ x"" != x"$FTS_HOST_STRING_LIST" ]; then
INIT_STANDBY_ARGS+=" -f $FTS_HOST_STRING_LIST"
fi
export COORDINATOR_DATA_DIRECTORY=${COORDINATOR_DIRECTORY}/${SEG_PREFIX}-1;$INIT_STANDBY_PROG -s $STANDBY_HOSTNAME $INIT_STANDBY_ARGS -a
STANDBY_RET_CODE=$?
if [ $STANDBY_RET_CODE -eq 0 ]; then
LOG_MSG "[INFO]:-Successfully completed standby coordinator initialization" 1
Expand Down Expand Up @@ -1641,6 +1648,12 @@ FORCE_FTS_PROBE () {
if [ x"$RESULT" == x"f" ]; then
break
fi

# Ask FTS to probe now rather than waiting out gp_fts_probe_interval;
# without this the loop just re-reads an unchanged
# gp_segment_configuration sixty times in a couple of seconds and gives
# up before FTS has looked at the segments even once.
$PSQL -p $GP_PORT -d "$DEFAULTDB" -c "select gp_request_fts_probe_scan()" >> ${LOG_FILE} 2>&1
done
LOG_MSG "[INFO]:-End Function $FUNCNAME"
}
Expand Down Expand Up @@ -1994,7 +2007,7 @@ CBDB_PRECHECK() {
if [ $? -eq 0 ];then
ERROR_EXIT "[FATAL]: FTS HOST $fts has alived fts process, please cleanup the environment first."
fi
if [ -z FTS_HOST_STRING_LIST ];then
if [ -z "$FTS_HOST_STRING_LIST" ];then
FTS_HOST_STRING_LIST="$fts"
else
FTS_HOST_STRING_LIST="$FTS_HOST_STRING_LIST,$fts"
Expand Down
24 changes: 16 additions & 8 deletions gpMgmt/bin/lib/gp_bash_functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,9 @@ LOG_MSG () {
*FATAL*)
EXIT_STATUS=1
;;
*ERROR*)
EXIT_STATUS=1
;;
esac

if [ x"" == x"$DEBUG_LEVEL" ];then
Expand Down Expand Up @@ -389,9 +392,9 @@ SED_PG_CONF () {
fi
else
if [ $KEEP_PREV -eq 0 ];then
$SED -i'.bak1' -e "s/${SEARCH_TXT}/${SUB_TXT} #${SEARCH_TXT}/" $FILENAME
$SED -i'.bak1' -e "s/^[ ]*${SEARCH_TXT}[ ]*=/${SUB_TXT} #${SEARCH_TXT}/" $FILENAME
else
$SED -i'.bak1' -e "s/${SEARCH_TXT}.*/${SUB_TXT}/" $FILENAME
$SED -i'.bak1' -e "s/^[ ]*${SEARCH_TXT}[ ]*=.*/${SUB_TXT}/" $FILENAME
fi
RETVAL=$?
if [ $RETVAL -ne 0 ]; then
Expand All @@ -400,7 +403,7 @@ SED_PG_CONF () {
LOG_MSG "[INFO]:-Replaced line in $FILENAME"
$RM -f ${FILENAME}.bak1
fi
$SED -i'.bak2' -e "s/^#${SEARCH_TXT}/${SEARCH_TXT}/" $FILENAME
$SED -i'.bak2' -e "s/^[ ]*#${SEARCH_TXT}[ ]*=/${SEARCH_TXT}=/" $FILENAME
RETVAL=$?
if [ $RETVAL -ne 0 ]; then
ERROR_EXIT "[FATAL]:-Failed to replace #$SEARCH_TXT in $FILENAME"
Expand Down Expand Up @@ -431,9 +434,9 @@ SED_PG_CONF () {
fi
else
if [ $KEEP_PREV -eq 0 ];then
SED_COMMAND="s/${SEARCH_TXT}/${SUB_TXT} #${SEARCH_TXT}/"
SED_COMMAND="s/^[ ]*${SEARCH_TXT}[ ]*=/${SUB_TXT} #${SEARCH_TXT}/"
else
SED_COMMAND="s/${SEARCH_TXT}.*/${SUB_TXT}/"
SED_COMMAND="s/^[ ]*${SEARCH_TXT}[ ]*=.*/${SUB_TXT}/"
fi
$TRUSTED_SHELL $SED_HOST sed -i'.bak1' -f /dev/stdin "$FILENAME" <<< "$SED_COMMAND" > /dev/null 2>&1
if [ $RETVAL -ne 0 ]; then
Expand All @@ -443,7 +446,7 @@ SED_PG_CONF () {
$TRUSTED_SHELL $SED_HOST "$RM -f ${FILENAME}.bak1" > /dev/null 2>&1
fi

SED_COMMAND="s/^#${SEARCH_TXT}/${SEARCH_TXT}/"
SED_COMMAND="s/^[ ]*#${SEARCH_TXT}[ ]*=/${SEARCH_TXT}=/"
$TRUSTED_SHELL $SED_HOST sed -i'.bak2' -f /dev/stdin "$FILENAME" <<< "$SED_COMMAND" > /dev/null 2>&1
if [ $RETVAL -ne 0 ]; then
ERROR_EXIT "[FATAL]:-Failed to substitute #${SEARCH_TXT} in $FILENAME on $SED_HOST"
Expand Down Expand Up @@ -783,6 +786,11 @@ BUILD_COORDINATOR_PG_HBA_FILE () {
else
$ECHO "host all $USER_NAME localhost trust" >> ${GP_DIR}/$PG_HBA
$ECHO "host all $USER_NAME $COORDINATOR_HOSTNAME trust" >> ${GP_DIR}/$PG_HBA
# Also add explicit IPv4 and IPv6 loopback entries so that
# connections via 127.0.0.1 and ::1 are always accepted
# regardless of hostname resolution order.
$ECHO "host all $USER_NAME 127.0.0.1/32 trust" >> ${GP_DIR}/$PG_HBA
$ECHO "host all $USER_NAME ::1/128 trust" >> ${GP_DIR}/$PG_HBA
fi


Expand Down Expand Up @@ -1231,7 +1239,7 @@ PRECHECK_CBDB_CONFIG_FILE() {

CLEANUP_ETCD() {
if [ "$#" -ne 1 ];then
LOG_MSG "[ERROR]: RETRIVE_ETCD_CONFIG_VAL invalid params..."
LOG_MSG "[ERROR]: CLEANUP_ETCD invalid params..."
fi
local etcd_account_id=`RETRIVE_ETCD_CONFIG_VAL $ETCD_ACCOUNT_ID`
local etcd_cluster_id=`RETRIVE_ETCD_CONFIG_VAL $ETCD_CLUSTER_ID`
Expand Down Expand Up @@ -1315,7 +1323,7 @@ SETUP_FTS() {

CHECK_FTS () {
ret=1
if [ "$#" -ne 2 ];then
if [ "$#" -ne 1 ];then
LOG_MSG "[ERROR]: CHECK_FTS invalid params..."
fi
FTS_HOST=$1
Expand Down
14 changes: 14 additions & 0 deletions gpMgmt/bin/lib/gpcreateseg.sh
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,20 @@ CREATE_QES_MIRROR () {
fi
RUN_COMMAND_REMOTE ${PRIMARY_HOSTADDRESS} "${EXPORT_GPHOME}; . ${GPHOME}/cloudberry-env.sh; cat - >> ${PRIMARY_DIR}/pg_hba.conf; pg_ctl -D ${PRIMARY_DIR} reload" <<< "${PG_HBA_ENTRIES}"
RUN_COMMAND_REMOTE ${GP_HOSTADDRESS} "${EXPORT_GPHOME}; . ${GPHOME}/cloudberry-env.sh; rm -rf ${GP_DIR}; ${GPHOME}/bin/pg_basebackup --wal-method=stream --create-slot --slot='internal_wal_replication_slot' -R -c fast -E ./db_dumps -D ${GP_DIR} -h ${PRIMARY_HOSTADDRESS} -p ${PRIMARY_PORT} --target-gp-dbid ${GP_DBID};"
# pg_basebackup copies the primary's postgresql.conf verbatim, so the
# mirror would otherwise start on the primary's port. Append the right
# one before starting; the last setting in the file wins.
#
# $PORT_TXT ("#port") finds nothing in the copied file -- the port line is
# already active there -- so SED_PG_CONF takes its append path. That is
# what we want: its replace path runs an unanchored
# "s/<search>/<sub> #<search>/", which with a search string of "port"
# would also rewrite every "support", "report" and "transport" in the
# file's comments.
LOG_MSG "[INFO][$INST_COUNT]:-Configuring segment $PG_CONF"
SED_PG_CONF ${GP_DIR}/$PG_CONF "$PORT_TXT" port=$GP_PORT 0 $GP_HOSTADDRESS
RETVAL=$?
PARA_EXIT $RETVAL "Update port number to $GP_PORT"
START_QE "-w"
RETVAL=$?
PARA_EXIT $RETVAL "pg_basebackup of segment data directory from ${PRIMARY_HOSTADDRESS} to ${GP_HOSTADDRESS}"
Expand Down
10 changes: 9 additions & 1 deletion gpMgmt/test/behave/mgmt_utils/gpinitsystem.feature
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,14 @@ Feature: gpinitsystem tests
Given the user runs "gpstate"
Then gpstate should return a return code of 2

Scenario: gpinitsystem exits with status 1 when the user provides invalid option
Given create demo cluster config
When the user runs command "gpinitsystem -a -c ../gpAux/gpdemo/clusterConfigFile --ignore-warnings" eok
Then gpinitsystem should return a return code of 1
And gpinitsystem should print "Unknown option --ignore-warnings" to stdout
Given the user runs "gpstate"
Then gpstate should return a return code of 2

Scenario: gpinitsystem creates a cluster when the user confirms the dialog
Given create demo cluster config
When the user runs command "echo y | gpinitsystem -c ../gpAux/gpdemo/clusterConfigFile"
Expand Down Expand Up @@ -320,7 +328,7 @@ Feature: gpinitsystem tests

Scenario: gpinitsystem should pass the default value of trusted_shell properly to gpcreateseg
Given create demo cluster config
When the user runs command "gpinitsystem -a -c ../gpAux/gpdemo/clusterConfigFile -h ../gpAux/gpdemo/hostfile --ignore-warnings"
When the user runs command "gpinitsystem -a -c ../gpAux/gpdemo/clusterConfigFile -h ../gpAux/gpdemo/hostfile"
Then gpinitsystem should return a return code of 0
When the user runs command "grep -q '.*gpcreateseg\.sh.*Completed .*lalshell.*' ~/gpAdminLogs/gpinitsystem*log"
Then grep should return a return code of 0
Expand Down
Loading