vitess.io/vitess@v0.16.2/examples/backups/start_cluster.sh (about) 1 #!/bin/bash 2 3 # Copyright 2022 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 # this script brings up new tablets for the two new shards that we will 18 # be creating in the customer keyspace and copies the schema 19 20 source ../common/env.sh 21 22 # start topo server 23 if [ "${TOPO}" = "zk2" ]; then 24 CELL=zone1 ../common/scripts/zk-up.sh 25 elif [ "${TOPO}" = "k8s" ]; then 26 CELL=zone1 ../common/scripts/k3s-up.sh 27 else 28 CELL=zone1 ../common/scripts/etcd-up.sh 29 fi 30 31 # start vtctld 32 CELL=zone1 ../common/scripts/vtctld-up.sh 33 34 35 # start vttablets for keyspace commerce 36 for i in 100 101 102; do 37 CELL=zone1 TABLET_UID=$i ../common/scripts/mysqlctl-up.sh 38 CELL=zone1 KEYSPACE=commerce TABLET_UID=$i ../common/scripts/vttablet-up.sh 39 done 40 41 # set one of the replicas to primary 42 vtctldclient InitShardPrimary --force commerce/0 zone1-100 43 44 # create the schema for commerce 45 vtctlclient ApplySchema -- --sql-file ./create_commerce_schema.sql commerce || fail "Could not apply schema for the commerce keyspace" 46 vtctlclient ApplyVSchema -- --vschema_file ../local/vschema_commerce_seq.json commerce || fail "Could not apply vschema for the commerce keyspace" 47 48 49 # start vttablets for keyspace customer 50 for i in 200 201 202; do 51 CELL=zone1 TABLET_UID=$i ../common/scripts/mysqlctl-up.sh 52 SHARD=-80 CELL=zone1 KEYSPACE=customer TABLET_UID=$i ../common/scripts/vttablet-up.sh 53 done 54 for i in 300 301 302; do 55 CELL=zone1 TABLET_UID=$i ../common/scripts/mysqlctl-up.sh 56 SHARD=80- CELL=zone1 KEYSPACE=customer TABLET_UID=$i ../common/scripts/vttablet-up.sh 57 done 58 59 # set one of the replicas to primary 60 vtctldclient InitShardPrimary --force customer/-80 zone1-200 61 vtctldclient InitShardPrimary --force customer/80- zone1-300 62 63 for shard in "-80" "80-"; do 64 wait_for_healthy_shard customer "${shard}" || exit 1 65 done 66 67 # create the schema for customer 68 vtctlclient ApplySchema -- --sql-file ./create_customer_schema.sql customer || fail "Could not apply schema for the customer keyspace" 69 vtctlclient ApplyVSchema -- --vschema_file ../local/vschema_customer_sharded.json customer || fail "Could not apply vschema for the customer keyspace" 70 71 72 # start vtgate 73 CELL=zone1 ../common/scripts/vtgate-up.sh 74 75 sleep 5 76 77 mysql < ../common/insert_commerce_data.sql