提交 21fafe8f 编写于 作者: J Jacob Champion

test_upgrade: factor out hardcoded assumptions

The following concepts are different between Concourse and a local
deployment:

- master hostname
- data directory locations and prefix
- gpinitsystem configuration location

Give them their own variables in preparation for supporting local runs.
Co-authored-by: NDavid Krieger <dkrieger@pivotal.io>
上级 dc5d3b2a
......@@ -10,6 +10,26 @@ DEBUG_UPGRADE=${DEBUG_UPGRADE:-}
./ccp_src/scripts/setup_ssh_to_cluster.sh
# The host running the master GPDB segment.
MASTER_HOST=mdw
# The GPHOME directories (containing greenplum_path.sh, the bin/ directory, and
# so on) for the old and new clusters, respectively.
OLD_GPHOME=/usr/local/greenplum-db-devel
NEW_GPHOME=/usr/local/gpdb_master
# The old and new clusters' master data directories.
OLD_MASTER_DATA_DIRECTORY=/data/gpdata/master/gpseg-1
NEW_MASTER_DATA_DIRECTORY=/data/gpdata/master-new/gpseg-1
# The data directory prefix, assumed to be shared by all segments across the
# cluster.
DATADIR_PREFIX=/data/gpdata
# The locations of the gpinitsystem configuration and hostfile.
GPINITSYSTEM_CONFIG=gpinitsystem_config
GPINITSYSTEM_HOSTFILE=segment_host_list
DIRNAME=$(dirname "$0")
cat << EOF
......@@ -34,9 +54,9 @@ load_old_db_data() {
echo 'Loading test database...'
scp "$dumpfile" mdw:/tmp/dump.sql.xz
ssh -n mdw '
source /usr/local/greenplum-db-devel/greenplum_path.sh
scp "$dumpfile" ${MASTER_HOST}:/tmp/dump.sql.xz
ssh -n ${MASTER_HOST} '
source '"${OLD_GPHOME}"'/greenplum_path.sh
unxz < /tmp/dump.sql.xz | '"${psql_env}"' psql '"${psql_opts}"' -f - postgres
'
}
......@@ -45,8 +65,8 @@ dump_cluster() {
# Dump the entire cluster contents to file, using the new pg_dumpall.
local dumpfile=$1
ssh -n mdw "
source /usr/local/gpdb_master/greenplum_path.sh
ssh -n ${MASTER_HOST} "
source ${NEW_GPHOME}/greenplum_path.sh
pg_dumpall -f '$dumpfile'
"
}
......@@ -60,10 +80,10 @@ extract_gpdb_tarball() {
# the naming convention.
scp ${tarball_dir}/*.tar.gz $node_hostname:/tmp/gpdb_binary.tar.gz
ssh -ttn $node_hostname "sudo bash -c \"\
mkdir -p /usr/local/gpdb_master; \
tar -xf /tmp/gpdb_binary.tar.gz -C /usr/local/gpdb_master; \
chown -R gpadmin:gpadmin /usr/local/gpdb_master; \
sed -ie 's|^GPHOME=.*|GPHOME=/usr/local/gpdb_master|' /usr/local/gpdb_master/greenplum_path.sh ; \
mkdir -p ${NEW_GPHOME}; \
tar -xf /tmp/gpdb_binary.tar.gz -C ${NEW_GPHOME}; \
chown -R gpadmin:gpadmin ${NEW_GPHOME}; \
sed -ie 's|^GPHOME=.*|GPHOME=${NEW_GPHOME}|' ${NEW_GPHOME}/greenplum_path.sh ; \
\""
}
......@@ -73,7 +93,7 @@ create_new_datadir() {
# Create a -new directory for every data directory that already exists.
# This is what we'll be init'ing the new database into.
ssh -ttn "$node_hostname" 'sudo bash -c '\''
for dir in $(find /data/gpdata/* -maxdepth 0 -type d); do
for dir in $(find '"${DATADIR_PREFIX}"'/* -maxdepth 0 -type d); do
newdir="${dir}-new"
mkdir -p "$newdir"
......@@ -88,17 +108,17 @@ gpinitsystem_for_upgrade() {
# FIXME: the checksum/string settings below need to be pulled from the
# previous database, not hardcoded. And long-term, we need to decide how
# Greenplum clusters should be upgraded when GUC settings' defaults change.
ssh -ttn mdw '
source /usr/local/greenplum-db-devel/greenplum_path.sh
gpstop -a -d /data/gpdata/master/gpseg-1
ssh -ttn ${MASTER_HOST} '
source '"${OLD_GPHOME}"'/greenplum_path.sh
gpstop -a -d '"${OLD_MASTER_DATA_DIRECTORY}"'
source /usr/local/gpdb_master/greenplum_path.sh
sed -e '\''s|\(/data/gpdata/\w\+\)|\1-new|g'\'' gpinitsystem_config > gpinitsystem_config_new
source '"${NEW_GPHOME}"'/greenplum_path.sh
sed -e '\''s|\('"${DATADIR_PREFIX}"'/\w\+\)|\1-new|g'\'' '"${GPINITSYSTEM_CONFIG}"' > gpinitsystem_config_new
# echo "HEAP_CHECKSUM=off" >> gpinitsystem_config_new
# echo "standard_conforming_strings = off" >> upgrade_addopts
# echo "escape_string_warning = off" >> upgrade_addopts
gpinitsystem -a -c ~gpadmin/gpinitsystem_config_new -h ~gpadmin/segment_host_list # -p ~gpadmin/upgrade_addopts
gpstop -a -d /data/gpdata/master-new/gpseg-1
gpinitsystem -a -c gpinitsystem_config_new -h '"${GPINITSYSTEM_HOSTFILE}"' # -p ~gpadmin/upgrade_addopts
gpstop -a -d '"${NEW_MASTER_DATA_DIRECTORY}"'
'
}
......@@ -119,18 +139,18 @@ run_upgrade() {
fi
ssh -ttn "$hostname" '
source /usr/local/gpdb_master/greenplum_path.sh
source '"${NEW_GPHOME}"'/greenplum_path.sh
time pg_upgrade '"${upgrade_opts}"' '"$*"' \
-b /usr/local/greenplum-db-devel/bin/ -B /usr/local/gpdb_master/bin/ \
-b '"${OLD_GPHOME}"'/bin/ -B '"${NEW_GPHOME}"'/bin/ \
-d '"$datadir"' \
-D '"$(sed -e 's|\(/data/gpdata/\w\+\)|\1-new|g' <<< "$datadir")"
-D '"$(sed -e 's|\('"${DATADIR_PREFIX}"'/\w\+\)|\1-new|g' <<< "$datadir")"
}
dump_old_master_query() {
# Prints the rows generated by the given SQL query to stdout. The query is
# run on the old master, pre-upgrade.
ssh -n mdw '
source /usr/local/greenplum-db-devel/greenplum_path.sh
ssh -n ${MASTER_HOST} '
source '"${OLD_GPHOME}"'/greenplum_path.sh
psql postgres --quiet --no-align --tuples-only -F"'$'\t''" -c "'$1'"
'
}
......@@ -150,10 +170,10 @@ get_segment_datadirs() {
}
start_upgraded_cluster() {
ssh -n mdw '
source /usr/local/gpdb_master/greenplum_path.sh
MASTER_DATA_DIRECTORY=/data/gpdata/master-new/gpseg-1 gpstart -a -v
'
ssh -n ${MASTER_HOST} "
source ${NEW_GPHOME}/greenplum_path.sh
MASTER_DATA_DIRECTORY='${NEW_MASTER_DATA_DIRECTORY}' gpstart -a -v
"
}
apply_sql_fixups() {
......@@ -172,8 +192,8 @@ apply_sql_fixups() {
# FIXME: we need a generic way for gp_upgrade to figure out which SQL fixup
# files need to be applied to the cluster before it is used.
ssh -n mdw '
source /usr/local/gpdb_master/greenplum_path.sh
ssh -n ${MASTER_HOST} '
source '"${NEW_GPHOME}"'/greenplum_path.sh
if [ -f reindex_all.sql ]; then
'"${psql_env}"' psql '"${psql_opts}"' -f reindex_all.sql template1
fi
......@@ -186,9 +206,9 @@ compare_dumps() {
local old_dump=$1
local new_dump=$2
scp "$DIRNAME/dumpsort.gawk" mdw:~
scp "$DIRNAME/dumpsort.gawk" ${MASTER_HOST}:~
ssh -n mdw "
ssh -n ${MASTER_HOST} "
diff -U3 --speed-large-files --ignore-space-change \
<(gawk -f ~/dumpsort.gawk < '$old_dump') \
<(gawk -f ~/dumpsort.gawk < '$new_dump')
......@@ -235,14 +255,17 @@ get_segment_datadirs > /tmp/segment_datadirs.txt
gpinitsystem_for_upgrade
# TODO: we need to switch the mode argument according to GPDB version
echo "Upgrading master at mdw..."
run_upgrade mdw "/data/gpdata/master/gpseg-1" --mode=dispatcher
echo "Upgrading master at ${MASTER_HOST}..."
run_upgrade ${MASTER_HOST} "${OLD_MASTER_DATA_DIRECTORY}" --mode=dispatcher
while read -u30 hostname datadir; do
echo "Upgrading segment at '$hostname' ($datadir)..."
newdatadir=$(sed -e 's|\(/data/gpdata/\w\+\)|\1-new|g' <<< "$datadir")
ssh -n mdw rsync -r --delete /data/gpdata/master-new/gpseg-1/ "$hostname:$newdatadir" \
newdatadir=$(sed -e 's|\('"${DATADIR_PREFIX}"'/\w\+\)|\1-new|g' <<< "$datadir")
# NOTE: the trailing slash on the rsync source directory is important! It
# means to transfer the directory's contents and not the directory itself.
ssh -n ${MASTER_HOST} rsync -r --delete "${NEW_MASTER_DATA_DIRECTORY}/" "$hostname:$newdatadir" \
--exclude /postgresql.conf \
--exclude /pg_hba.conf \
--exclude /postmaster.opts \
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册