Skip to content

Instantly share code, notes, and snippets.

@mattlord
Last active April 4, 2023 20:11
Show Gist options
  • Save mattlord/043943112fa6a74f93bfddeeef3cf870 to your computer and use it in GitHub Desktop.
Save mattlord/043943112fa6a74f93bfddeeef3cf870 to your computer and use it in GitHub Desktop.
#!/bin/bash
#
# From within ./examples/local/
#
pushd "${VTROOT}/examples/local"
source ../common/env.sh
CELL=zone1 ../common/scripts/etcd-up.sh
CELL=zone1 ../common/scripts/vtctld-up.sh
vtctldclient --server localhost:15999 CreateKeyspace commerce
for i in 100 101 102; do
CELL=zone1 TABLET_UID=$i ../common/scripts/mysqlctl-up.sh
SHARD=-40 CELL=zone1 KEYSPACE=commerce TABLET_UID=$i ../common/scripts/vttablet-up.sh
done
for i in 200 201 202; do
CELL=zone1 TABLET_UID=$i ../common/scripts/mysqlctl-up.sh
SHARD=40-80 CELL=zone1 KEYSPACE=commerce TABLET_UID=$i ../common/scripts/vttablet-up.sh
done
for i in 300 301 302; do
CELL=zone1 TABLET_UID=$i ../common/scripts/mysqlctl-up.sh
SHARD=80-c0 CELL=zone1 KEYSPACE=commerce TABLET_UID=$i ../common/scripts/vttablet-up.sh
done
for i in 400 401 402; do
CELL=zone1 TABLET_UID=$i ../common/scripts/mysqlctl-up.sh
SHARD=c0- CELL=zone1 KEYSPACE=commerce TABLET_UID=$i ../common/scripts/vttablet-up.sh
done
vtctldclient InitShardPrimary --force commerce/-40 zone1-100
vtctldclient InitShardPrimary --force commerce/40-80 zone1-200
vtctldclient InitShardPrimary --force commerce/80-c0 zone1-300
vtctldclient InitShardPrimary --force commerce/c0- zone1-400
vtctldclient ApplySchema --sql-file ~/Downloads/vdiff_bug/schema.sql commerce || fail "could not load schema"
vtctldclient ApplyVSchema --vschema-file ~/Downloads/vdiff_bug/vschema.json commerce || fail "could not load vschema"
CELL=zone1 ../common/scripts/vtgate-up.sh
sleep 10
for file in ~/Downloads/vdiff_bug/shard_*.sql; do
echo "Loading data from ${file} ..."
mysql commerce < "${file}" || fail "could not load data from ${file}"
done
for i in 500 501 502; do
CELL=zone1 TABLET_UID=$i ../common/scripts/mysqlctl-up.sh
SHARD=-33 CELL=zone1 KEYSPACE=commerce TABLET_UID=$i ../common/scripts/vttablet-up.sh
done
for i in 600 601 602; do
CELL=zone1 TABLET_UID=$i ../common/scripts/mysqlctl-up.sh
SHARD=33-66 CELL=zone1 KEYSPACE=commerce TABLET_UID=$i ../common/scripts/vttablet-up.sh
done
for i in 700 701 702; do
CELL=zone1 TABLET_UID=$i ../common/scripts/mysqlctl-up.sh
SHARD=66-99 CELL=zone1 KEYSPACE=commerce TABLET_UID=$i ../common/scripts/vttablet-up.sh
done
for i in 800 801 802; do
CELL=zone1 TABLET_UID=$i ../common/scripts/mysqlctl-up.sh
SHARD=99-cc CELL=zone1 KEYSPACE=commerce TABLET_UID=$i ../common/scripts/vttablet-up.sh
done
for i in 900 901 902; do
CELL=zone1 TABLET_UID=$i ../common/scripts/mysqlctl-up.sh
SHARD=cc- CELL=zone1 KEYSPACE=commerce TABLET_UID=$i ../common/scripts/vttablet-up.sh
done
vtctldclient InitShardPrimary --force commerce/-33 zone1-500
vtctldclient InitShardPrimary --force commerce/33-66 zone1-600
vtctldclient InitShardPrimary --force commerce/66-99 zone1-700
vtctldclient InitShardPrimary --force commerce/99-cc zone1-800
vtctldclient InitShardPrimary --force commerce/cc- zone1-900
vtctlclient Reshard -- --source_shards '-40,40-80,80-c0,c0-' --target_shards '-33,33-66,66-99,99-cc,cc-' Create commerce.4to5
# Wait until all streams are in the running state
vtctlclient Reshard Progress commerce.4to5
# ...
#vtctlclient VDiff -- --format=json commerce.4to5 create
#vtctlclient VDiff -- --format=json commerce.4to5 show last
popd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment