Skip to content

Commit a8881ba

Browse files
Source backup env separately where we change topo env variables to use underscores
Signed-off-by: Rohit Nayak <[email protected]>
1 parent 9999c2b commit a8881ba

File tree

6 files changed

+94
-5
lines changed

6 files changed

+94
-5
lines changed

examples/backups/restart_tablets.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
# this script brings up new tablets for the two new shards that we will
1818
# be creating in the customer keyspace and copies the schema
1919

20-
source ../common/env.sh
20+
source ../common/backup-env.sh
2121

2222
echo "=============================== This is version 23 restart tablets ==============================="
2323
for i in 100 101 102; do

examples/backups/start_cluster.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
# be creating in the customer keyspace and copies the schema
1919

2020
echo "=============================== This is version 23 main ==============================="
21-
source ../common/env.sh
21+
source ../common/backup-env.sh
2222

2323
# start topo server
2424
if [ "${TOPO}" = "zk2" ]; then

examples/backups/stop_tablets.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
# this script brings up new tablets for the two new shards that we will
1818
# be creating in the customer keyspace and copies the schema
1919

20-
source ../common/env.sh
20+
source ../common/backup-env.sh
2121

2222
for tablet in 100 200 300; do
2323
if vtctldclient --action-timeout 1s --server localhost:15999 GetTablet zone1-$tablet >/dev/null 2>&1; then

examples/backups/take_backups.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
# this script brings up new tablets for the two new shards that we will
1818
# be creating in the customer keyspace and copies the schema
1919

20-
source ../common/env.sh
20+
source ../common/backup-env.sh
2121

2222
for shard in "customer/-80" "customer/80-" "commerce/0"; do
2323
vtctldclient BackupShard "${shard}" || fail "Failed to backup shard: ${shard}"

examples/backups/upgrade_cluster.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
# this script brings up new tablets for the two new shards that we will
1818
# be creating in the customer keyspace and copies the schema
1919

20-
source ../common/env.sh
20+
source ../common/backup-env.sh
2121

2222
# Restart the replica tablets so that they come up with new vttablet versions
2323
for i in 101 102; do

examples/common/backup-env.sh

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
#!/bin/bash
2+
3+
# Copyright 2019 The Vitess Authors.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
source "$(dirname "${BASH_SOURCE[0]:-$0}")/lib/utils.sh"
18+
19+
hostname=$(hostname -f)
20+
vtctld_web_port=15000
21+
export VTDATAROOT="${VTDATAROOT:-${PWD}/vtdataroot}"
22+
23+
if [[ $EUID -eq 0 ]]; then
24+
fail "This script refuses to be run as root. Please switch to a regular user."
25+
fi
26+
27+
# mysqld might be in /usr/sbin which will not be in the default PATH
28+
PATH="/usr/sbin:$PATH"
29+
for binary in mysqld etcd etcdctl curl vtctldclient vttablet vtgate vtctld mysqlctl; do
30+
command -v "$binary" > /dev/null || fail "${binary} is not installed in PATH. See https://vitess.io/docs/get-started/local/ for install instructions."
31+
done;
32+
33+
# vtctldclient has a separate alias setup below
34+
for binary in vttablet vtgate vtctld mysqlctl vtorc vtctl; do
35+
alias $binary="$binary --config-file-not-found-handling=ignore"
36+
done;
37+
38+
if [ "${TOPO}" = "zk2" ]; then
39+
# Each ZooKeeper server needs a list of all servers in the quorum.
40+
# Since we're running them all locally, we need to give them unique ports.
41+
# In a real deployment, these should be on different machines, and their
42+
# respective hostnames should be given.
43+
zkcfg=(\
44+
"1@$hostname:28881:38881:21811" \
45+
"2@$hostname:28882:38882:21812" \
46+
"3@$hostname:28883:38883:21813" \
47+
)
48+
printf -v zkcfg ",%s" "${zkcfg[@]}"
49+
zkcfg=${zkcfg:1}
50+
51+
zkids='1 2 3'
52+
53+
# Set topology environment parameters.
54+
ZK_SERVER="localhost:21811,localhost:21812,localhost:21813"
55+
# shellcheck disable=SC2034
56+
#TODO: Remove underscore(_) flags in v25, replace them with dashed(-) notation
57+
TOPOLOGY_FLAGS="--topo_implementation zk2 --topo_global_server_address ${ZK_SERVER} --topo_global_root /vitess/global"
58+
59+
mkdir -p "${VTDATAROOT}/tmp"
60+
elif [ "${TOPO}" = "consul" ]; then
61+
# Set up topology environment parameters.
62+
CONSUL_SERVER=127.0.0.1
63+
CONSUL_HTTP_PORT=8500
64+
CONSUL_SERVER_PORT=8300
65+
#TODO: Remove underscore(_) flags in v25, replace them with dashed(-) notation
66+
TOPOLOGY_FLAGS="--topo_implementation consul --topo_global_server_address ${CONSUL_SERVER}:${CONSUL_HTTP_PORT} --topo_global_root vitess/global/"
67+
mkdir -p "${VTDATAROOT}/consul"
68+
else
69+
ETCD_SERVER="localhost:2379"
70+
#TODO: Remove underscore(_) flags in v25, replace them with dashed(-) notation
71+
TOPOLOGY_FLAGS="--topo_implementation etcd2 --topo_global_server_address $ETCD_SERVER --topo_global_root /vitess/global"
72+
73+
mkdir -p "${VTDATAROOT}/etcd"
74+
fi
75+
76+
mkdir -p "${VTDATAROOT}/tmp"
77+
78+
# Set aliases to simplify instructions.
79+
# In your own environment you may prefer to use config files,
80+
# such as ~/.my.cnf
81+
82+
alias mysql="command mysql --no-defaults -h 127.0.0.1 -P 15306 --binary-as-hex=false"
83+
alias vtctldclient="command vtctldclient --server localhost:15999"
84+
85+
# If using bash, make sure aliases are expanded in non-interactive shell
86+
if [[ -n ${BASH} ]]; then
87+
shopt -s expand_aliases
88+
fi
89+

0 commit comments

Comments
 (0)