Skip to content
Merged
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
12 changes: 12 additions & 0 deletions examples/common/insert_commerce_data.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
insert into customer(email) values('alice@domain.com');
insert into customer(email) values('bob@domain.com');
insert into customer(email) values('charlie@domain.com');
insert into customer(email) values('dan@domain.com');
insert into customer(email) values('eve@domain.com');
insert into product(sku, description, price) values('SKU-1001', 'Monitor', 100);
insert into product(sku, description, price) values('SKU-1002', 'Keyboard', 30);
insert into corder(customer_id, sku, price) values(1, 'SKU-1001', 100);
insert into corder(customer_id, sku, price) values(2, 'SKU-1002', 30);
insert into corder(customer_id, sku, price) values(3, 'SKU-1002', 30);
insert into corder(customer_id, sku, price) values(4, 'SKU-1002', 30);
insert into corder(customer_id, sku, price) values(5, 'SKU-1002', 30);
8 changes: 8 additions & 0 deletions examples/common/select_commerce_data.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
\! echo 'Using commerce/0'
use commerce/0;
\! echo 'Customer'
select * from customer;
\! echo 'Product'
select * from product;
\! echo 'COrder'
select * from corder;
6 changes: 6 additions & 0 deletions examples/common/select_customer-80_data.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
\! echo 'Using customer/-80'
use customer/-80;
\! echo 'Customer'
select * from customer;
\! echo 'COrder'
select * from corder;
6 changes: 6 additions & 0 deletions examples/common/select_customer0_data.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
\! echo 'Using customer/0'
use customer/0;
\! echo 'Customer'
select * from customer;
\! echo 'COrder'
select * from corder;
6 changes: 6 additions & 0 deletions examples/common/select_customer80-_data.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
\! echo 'Using customer/80-'
use customer/80-;
\! echo 'Customer'
select * from customer;
\! echo 'COrder'
select * from corder;
30 changes: 24 additions & 6 deletions examples/local/101_initial_cluster.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,38 @@
# See the License for the specific language governing permissions and
# limitations under the License.

# this scripts brings up zookeeper and all the vitess components
# this script brings up zookeeper and all the vitess components
# required for a single shard deployment.

set -e

script_root=`dirname "${BASH_SOURCE}"`
# shellcheck disable=SC2128
script_root=$(dirname "${BASH_SOURCE}")

CELL=zone1 $script_root/zk-up.sh
CELL=zone1 $script_root/vtctld-up.sh
CELL=zone1 KEYSPACE=commerce UID_BASE=100 $script_root/vttablet-up.sh
# start topo server
if [ "${TOPO}" = "etcd2" ]; then
CELL=zone1 "$script_root/etcd-up.sh"
else
CELL=zone1 "$script_root/zk-up.sh"
fi

# start vtctld
CELL=zone1 "$script_root/vtctld-up.sh"

# start vttablets for keyspace commerce
CELL=zone1 KEYSPACE=commerce UID_BASE=100 "$script_root/vttablet-up.sh"
sleep 15

# set one of the replicas to master
./lvtctl.sh InitShardMaster -force commerce/0 zone1-100

# create the schema
./lvtctl.sh ApplySchema -sql-file create_commerce_schema.sql commerce

# create the vschema
./lvtctl.sh ApplyVSchema -vschema_file vschema_commerce_initial.json commerce
CELL=zone1 $script_root/vtgate-up.sh

# start vtgate
CELL=zone1 "$script_root/vtgate-up.sh"

disown -a
3 changes: 1 addition & 2 deletions examples/local/201_customer_keyspace.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

# this scripts brings up zookeeper and all the vitess components
# required for a single shard deployment.
# this script creates a new keyspace in preparation for vertical resharding

set -e

Expand Down
10 changes: 6 additions & 4 deletions examples/local/202_customer_tablets.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,16 @@
# See the License for the specific language governing permissions and
# limitations under the License.

# this scripts brings up zookeeper and all the vitess components
# required for a single shard deployment.
# this script creates the tablets and initializes them for vertical
# resharding it also splits the vschema between the two keyspaces
# old (commerce) and new (customer)

set -e

script_root=`dirname "${BASH_SOURCE}"`
# shellcheck disable=SC2128
script_root=$(dirname "${BASH_SOURCE}")

CELL=zone1 KEYSPACE=customer UID_BASE=200 $script_root/vttablet-up.sh
CELL=zone1 KEYSPACE=customer UID_BASE=200 "$script_root/vttablet-up.sh"
sleep 15
./lvtctl.sh InitShardMaster -force customer/0 zone1-200
./lvtctl.sh CopySchemaShard -tables customer,corder commerce/0 customer/0
Expand Down
17 changes: 11 additions & 6 deletions examples/local/203_vertical_split.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,23 @@
# See the License for the specific language governing permissions and
# limitations under the License.

# this scripts brings up zookeeper and all the vitess components
# required for a single shard deployment.
# this script copies over all the data from commerce keyspace to
# customer keyspace for the customer and corder tables

set -e

script_root=`dirname "${BASH_SOURCE}"`
source $script_root/env.sh
# shellcheck disable=SC2128
script_root=$(dirname "${BASH_SOURCE}")

$VTROOT/bin/vtworker \
# shellcheck source=./env.sh
# shellcheck disable=SC1091
source "$script_root/env.sh"

# shellcheck disable=SC2086
"$VTROOT"/bin/vtworker \
$TOPOLOGY_FLAGS \
-cell zone1 \
-log_dir $VTDATAROOT/tmp \
-log_dir "$VTDATAROOT"/tmp \
-alsologtostderr \
-use_v3_resharding_mode \
VerticalSplitClone -min_healthy_rdonly_tablets=1 -tables=customer,corder customer/0
Expand Down
6 changes: 2 additions & 4 deletions examples/local/204_vertical_migrate_replicas.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.

# this scripts brings up zookeeper and all the vitess components
# required for a single shard deployment.
# this script migrates traffic for the new customer keyspace to the new
# tablets of types rdonly and replica

set -e

script_root=`dirname "${BASH_SOURCE}"`

./lvtctl.sh MigrateServedFrom customer/0 rdonly
./lvtctl.sh MigrateServedFrom customer/0 replica

Expand Down
6 changes: 2 additions & 4 deletions examples/local/205_vertical_migrate_master.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.

# this scripts brings up zookeeper and all the vitess components
# required for a single shard deployment.
# this script migrates master traffic for the customer keyspace to the
# new master tablet

set -e

script_root=`dirname "${BASH_SOURCE}"`

./lvtctl.sh MigrateServedFrom customer/0 master

disown -a
6 changes: 2 additions & 4 deletions examples/local/206_clean_commerce.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.

# this scripts brings up zookeeper and all the vitess components
# required for a single shard deployment.
# this script removes the customer and corder tables from the commerce
# keyspace

set -e

script_root=`dirname "${BASH_SOURCE}"`

./lvtctl.sh ApplySchema -sql-file drop_commerce_tables.sql commerce
./lvtctl.sh SetShardTabletControl -blacklisted_tables=customer,corder -remove commerce/0 rdonly
./lvtctl.sh SetShardTabletControl -blacklisted_tables=customer,corder -remove commerce/0 replica
Expand Down
9 changes: 5 additions & 4 deletions examples/local/301_customer_sharded.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@
# See the License for the specific language governing permissions and
# limitations under the License.

# this scripts brings up zookeeper and all the vitess components
# required for a single shard deployment.
# this script creates vitess sequences for the auto_increment fields
# and alters the fields to no longer be auto_increment in preparation
# for horizontal sharding
# it also changes the customer vschema from unsharded to sharded and
# sets up the necessary vindexes

set -e

script_root=`dirname "${BASH_SOURCE}"`

./lvtctl.sh ApplySchema -sql-file create_commerce_seq.sql commerce
./lvtctl.sh ApplyVSchema -vschema_file vschema_commerce_seq.json commerce
./lvtctl.sh ApplySchema -sql-file create_customer_sharded.sql customer
Expand Down
11 changes: 6 additions & 5 deletions examples/local/302_new_shards.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,16 @@
# See the License for the specific language governing permissions and
# limitations under the License.

# this scripts brings up zookeeper and all the vitess components
# required for a single shard deployment.
# this script brings up new tablets for the two new shards that we will
# be creating in the customer keyspace and copies the schema

set -e

script_root=`dirname "${BASH_SOURCE}"`
# shellcheck disable=SC2128
script_root=$(dirname "${BASH_SOURCE}")

SHARD=-80 CELL=zone1 KEYSPACE=customer UID_BASE=300 $script_root/vttablet-up.sh
SHARD=80- CELL=zone1 KEYSPACE=customer UID_BASE=400 $script_root/vttablet-up.sh
SHARD=-80 CELL=zone1 KEYSPACE=customer UID_BASE=300 "$script_root/vttablet-up.sh"
SHARD=80- CELL=zone1 KEYSPACE=customer UID_BASE=400 "$script_root/vttablet-up.sh"
sleep 15
./lvtctl.sh InitShardMaster -force customer/-80 zone1-300
./lvtctl.sh InitShardMaster -force customer/80- zone1-400
Expand Down
17 changes: 11 additions & 6 deletions examples/local/303_horizontal_split.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,23 @@
# See the License for the specific language governing permissions and
# limitations under the License.

# this scripts brings up zookeeper and all the vitess components
# required for a single shard deployment.
# this script copies the data from customer/0 to customer/-80 and customer/80-
# each row will be copied to exactly one shard based on the vindex value

set -e

script_root=`dirname "${BASH_SOURCE}"`
source $script_root/env.sh
# shellcheck disable=SC2128
script_root=$(dirname "${BASH_SOURCE}")

$VTROOT/bin/vtworker \
# shellcheck source=./env.sh
# shellcheck disable=SC1091
source "${script_root}/env.sh"

# shellcheck disable=SC2086
"$VTROOT"/bin/vtworker \
$TOPOLOGY_FLAGS \
-cell zone1 \
-log_dir $VTDATAROOT/tmp \
-log_dir "$VTDATAROOT"/tmp \
-alsologtostderr \
-use_v3_resharding_mode \
SplitClone -min_healthy_rdonly_tablets=1 customer/0
Expand Down
6 changes: 1 addition & 5 deletions examples/local/304_migrate_replicas.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.

# this scripts brings up zookeeper and all the vitess components
# required for a single shard deployment.
# this script migrates traffic for the rdonly and replica tablets

set -e

script_root=`dirname "${BASH_SOURCE}"`

./lvtctl.sh MigrateServedTypes customer/0 rdonly
./lvtctl.sh MigrateServedTypes customer/0 replica


disown -a
6 changes: 2 additions & 4 deletions examples/local/305_migrate_master.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.

# this scripts brings up zookeeper and all the vitess components
# required for a single shard deployment.
# this script migrates traffic for the master tablet

set -e

script_root=`dirname "${BASH_SOURCE}"`

./lvtctl.sh MigrateServedTypes customer/0 master
# data has been copied over to shards, and databases for the new shards are now available

disown -a
8 changes: 4 additions & 4 deletions examples/local/306_down_shard_0.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
# See the License for the specific language governing permissions and
# limitations under the License.

# this scripts brings up zookeeper and all the vitess components
# required for a single shard deployment.
# this script brings down the tablets for customer/0 keyspace

set -e

script_root=`dirname "${BASH_SOURCE}"`
# shellcheck disable=SC2128
script_root=$(dirname "${BASH_SOURCE}")

./lvtctl.sh DeleteShard -recursive customer/0
CELL=zone1 UID_BASE=100 "$script_root/vttablet-down.sh"

disown -a
23 changes: 23 additions & 0 deletions examples/local/307_delete_shard_0.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash

# Copyright 2018 The Vitess Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# this script deletes the old shard 0 which has been replaced by 2 shards

set -e

./lvtctl.sh DeleteShard -recursive customer/0

disown -a
23 changes: 15 additions & 8 deletions examples/local/401_teardown.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,26 @@
# See the License for the specific language governing permissions and
# limitations under the License.

# this scripts brings up zookeeper and all the vitess components
# required for a single shard deployment.
# this script brings down zookeeper and all the vitess components
# we brought up in the example
# optionally, you may want to delete everything that was created
# by the example from $VTDATAROOT

set -e

script_root=`dirname "${BASH_SOURCE}"`
# shellcheck disable=SC2128
script_root=$(dirname "${BASH_SOURCE}")

./vtgate-down.sh
CELL=zone1 UID_BASE=100 $script_root/vttablet-down.sh
CELL=zone1 UID_BASE=200 $script_root/vttablet-down.sh
CELL=zone1 UID_BASE=300 $script_root/vttablet-down.sh
CELL=zone1 UID_BASE=400 $script_root/vttablet-down.sh
CELL=zone1 UID_BASE=200 "$script_root/vttablet-down.sh"
CELL=zone1 UID_BASE=300 "$script_root/vttablet-down.sh"
CELL=zone1 UID_BASE=400 "$script_root/vttablet-down.sh"
./vtctld-down.sh
./zk-down.sh

if [ "${TOPO}" = "etcd2" ]; then
CELL=zone1 "$script_root/etcd-down.sh"
else
CELL=zone1 "$script_root/zk-down.sh"
fi

disown -a
9 changes: 9 additions & 0 deletions examples/local/env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,15 @@ if [ -z "$VT_MYSQL_ROOT" ]; then
export VT_MYSQL_ROOT=$(dirname `dirname $mysql_path`)
fi

# restore MYSQL_FLAVOR, saved by bootstrap.sh
if [ -r "$VTROOT/dist/MYSQL_FLAVOR" ]; then
MYSQL_FLAVOR=$(cat "$VTROOT/dist/MYSQL_FLAVOR")
export MYSQL_FLAVOR
fi

if [ -z "$MYSQL_FLAVOR" ]; then
export MYSQL_FLAVOR=MySQL56
fi

if [ "${TOPO}" = "etcd2" ]; then
echo "enter etcd2 env"
Expand Down
Loading