diff --git a/examples/local/101_initial_cluster.sh b/examples/local/101_initial_cluster.sh new file mode 100755 index 00000000000..a325f9ad2a0 --- /dev/null +++ b/examples/local/101_initial_cluster.sh @@ -0,0 +1,33 @@ +#!/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 scripts brings up zookeeper and all the vitess components +# required for a single shard deployment. + +set -e + +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 +sleep 15 +./lvtctl.sh InitShardMaster -force commerce/0 zone1-100 +./lvtctl.sh ApplySchema -sql-file create_commerce_schema.sql commerce +./lvtctl.sh ApplyVSchema -vschema_file vschema_commerce_initial.json commerce +CELL=zone1 $script_root/vtgate-up.sh + +disown -a diff --git a/examples/local/201_customer_keyspace.sh b/examples/local/201_customer_keyspace.sh new file mode 100755 index 00000000000..0aedba25fe7 --- /dev/null +++ b/examples/local/201_customer_keyspace.sh @@ -0,0 +1,24 @@ +#!/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 scripts brings up zookeeper and all the vitess components +# required for a single shard deployment. + +set -e + +./lvtctl.sh CreateKeyspace -served_from='master:commerce,replica:commerce,rdonly:commerce' customer + +disown -a diff --git a/examples/local/202_customer_tablets.sh b/examples/local/202_customer_tablets.sh new file mode 100755 index 00000000000..235b76fd4f0 --- /dev/null +++ b/examples/local/202_customer_tablets.sh @@ -0,0 +1,31 @@ +#!/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 scripts brings up zookeeper and all the vitess components +# required for a single shard deployment. + +set -e + +script_root=`dirname "${BASH_SOURCE}"` + +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 +./lvtctl.sh ApplyVSchema -vschema_file vschema_commerce_vsplit.json commerce +./lvtctl.sh ApplyVSchema -vschema_file vschema_customer_vsplit.json customer + +disown -a diff --git a/examples/local/sharded-vttablet-up.sh b/examples/local/203_vertical_split.sh similarity index 59% rename from examples/local/sharded-vttablet-up.sh rename to examples/local/203_vertical_split.sh index c7072ced079..053a97f7b38 100755 --- a/examples/local/sharded-vttablet-up.sh +++ b/examples/local/203_vertical_split.sh @@ -1,6 +1,6 @@ #!/bin/bash -# Copyright 2017 Google Inc. +# 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. @@ -14,16 +14,20 @@ # See the License for the specific language governing permissions and # limitations under the License. -# This is an example script that creates a sharded vttablet deployment. +# this scripts brings up zookeeper and all the vitess components +# required for a single shard deployment. set -e script_root=`dirname "${BASH_SOURCE}"` +source $script_root/env.sh -# Shard -80 contains all entries whose keyspace ID has a first byte < 0x80. -# See: http://vitess.io/overview/concepts/#keyspace-id -SHARD=-80 UID_BASE=200 $script_root/vttablet-up.sh "$@" - -# Shard 80- contains all entries whose keyspace ID has a first byte >= 0x80. -SHARD=80- UID_BASE=300 $script_root/vttablet-up.sh "$@" +$VTROOT/bin/vtworker \ + $TOPOLOGY_FLAGS \ + -cell zone1 \ + -log_dir $VTDATAROOT/tmp \ + -alsologtostderr \ + -use_v3_resharding_mode \ + VerticalSplitClone -min_healthy_rdonly_tablets=1 -tables=customer,corder customer/0 +disown -a diff --git a/examples/local/sharded-vtworker.sh b/examples/local/204_vertical_migrate_replicas.sh similarity index 68% rename from examples/local/sharded-vtworker.sh rename to examples/local/204_vertical_migrate_replicas.sh index d8b64df8a6b..4c9acc38445 100755 --- a/examples/local/sharded-vtworker.sh +++ b/examples/local/204_vertical_migrate_replicas.sh @@ -1,6 +1,6 @@ #!/bin/bash -# Copyright 2017 Google Inc. +# 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. @@ -14,19 +14,14 @@ # See the License for the specific language governing permissions and # limitations under the License. -# This is an example script that runs vtworker. +# this scripts brings up zookeeper and all the vitess components +# required for a single shard deployment. set -e script_root=`dirname "${BASH_SOURCE}"` -source $script_root/env.sh -echo "Starting vtworker..." -exec $VTROOT/bin/vtworker \ - $TOPOLOGY_FLAGS \ - -cell test \ - -log_dir $VTDATAROOT/tmp \ - -alsologtostderr \ - -use_v3_resharding_mode \ - "$@" +./lvtctl.sh MigrateServedFrom customer/0 rdonly +./lvtctl.sh MigrateServedFrom customer/0 replica +disown -a diff --git a/examples/local/sharded-vttablet-down.sh b/examples/local/205_vertical_migrate_master.sh similarity index 72% rename from examples/local/sharded-vttablet-down.sh rename to examples/local/205_vertical_migrate_master.sh index 1b6ca861442..a21c1bf6848 100755 --- a/examples/local/sharded-vttablet-down.sh +++ b/examples/local/205_vertical_migrate_master.sh @@ -1,6 +1,6 @@ #!/bin/bash -# Copyright 2017 Google Inc. +# 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. @@ -14,11 +14,13 @@ # See the License for the specific language governing permissions and # limitations under the License. -# This is an example script that stops the mysqld and vttablet instances -# created by sharded-vttablet-up.sh +# this scripts brings up zookeeper and all the vitess components +# required for a single shard deployment. + +set -e script_root=`dirname "${BASH_SOURCE}"` -UID_BASE=200 $script_root/vttablet-down.sh "$@" -UID_BASE=300 $script_root/vttablet-down.sh "$@" +./lvtctl.sh MigrateServedFrom customer/0 master +disown -a diff --git a/examples/local/206_clean_commerce.sh b/examples/local/206_clean_commerce.sh new file mode 100755 index 00000000000..010bd8ba999 --- /dev/null +++ b/examples/local/206_clean_commerce.sh @@ -0,0 +1,29 @@ +#!/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 scripts brings up zookeeper and all the vitess components +# required for a single shard deployment. + +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 +./lvtctl.sh SetShardTabletControl -blacklisted_tables=customer,corder -remove commerce/0 master + +disown -a diff --git a/examples/local/301_customer_sharded.sh b/examples/local/301_customer_sharded.sh new file mode 100755 index 00000000000..a1774158b30 --- /dev/null +++ b/examples/local/301_customer_sharded.sh @@ -0,0 +1,29 @@ +#!/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 scripts brings up zookeeper and all the vitess components +# required for a single shard deployment. + +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 +./lvtctl.sh ApplyVSchema -vschema_file vschema_customer_sharded.json customer + +disown -a diff --git a/examples/local/302_new_shards.sh b/examples/local/302_new_shards.sh new file mode 100755 index 00000000000..de480e1494e --- /dev/null +++ b/examples/local/302_new_shards.sh @@ -0,0 +1,32 @@ +#!/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 scripts brings up zookeeper and all the vitess components +# required for a single shard deployment. + +set -e + +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 +sleep 15 +./lvtctl.sh InitShardMaster -force customer/-80 zone1-300 +./lvtctl.sh InitShardMaster -force customer/80- zone1-400 +./lvtctl.sh CopySchemaShard customer/0 customer/-80 +./lvtctl.sh CopySchemaShard customer/0 customer/80- + +disown -a diff --git a/examples/local/303_horizontal_split.sh b/examples/local/303_horizontal_split.sh new file mode 100755 index 00000000000..8859b5dcf0a --- /dev/null +++ b/examples/local/303_horizontal_split.sh @@ -0,0 +1,33 @@ +#!/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 scripts brings up zookeeper and all the vitess components +# required for a single shard deployment. + +set -e + +script_root=`dirname "${BASH_SOURCE}"` +source $script_root/env.sh + +$VTROOT/bin/vtworker \ + $TOPOLOGY_FLAGS \ + -cell zone1 \ + -log_dir $VTDATAROOT/tmp \ + -alsologtostderr \ + -use_v3_resharding_mode \ + SplitClone -min_healthy_rdonly_tablets=1 customer/0 + +disown -a diff --git a/examples/local/304_migrate_replicas.sh b/examples/local/304_migrate_replicas.sh new file mode 100755 index 00000000000..6722e21e2f2 --- /dev/null +++ b/examples/local/304_migrate_replicas.sh @@ -0,0 +1,28 @@ +#!/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 scripts brings up zookeeper and all the vitess components +# required for a single shard deployment. + +set -e + +script_root=`dirname "${BASH_SOURCE}"` + +./lvtctl.sh MigrateServedTypes customer/0 rdonly +./lvtctl.sh MigrateServedTypes customer/0 replica + + +disown -a diff --git a/examples/local/305_migrate_master.sh b/examples/local/305_migrate_master.sh new file mode 100755 index 00000000000..ede4e3c970f --- /dev/null +++ b/examples/local/305_migrate_master.sh @@ -0,0 +1,26 @@ +#!/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 scripts brings up zookeeper and all the vitess components +# required for a single shard deployment. + +set -e + +script_root=`dirname "${BASH_SOURCE}"` + +./lvtctl.sh MigrateServedTypes customer/0 master + +disown -a diff --git a/examples/local/306_down_shard_0.sh b/examples/local/306_down_shard_0.sh new file mode 100755 index 00000000000..e8fe8112ddf --- /dev/null +++ b/examples/local/306_down_shard_0.sh @@ -0,0 +1,26 @@ +#!/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 scripts brings up zookeeper and all the vitess components +# required for a single shard deployment. + +set -e + +script_root=`dirname "${BASH_SOURCE}"` + +./lvtctl.sh DeleteShard -recursive customer/0 + +disown -a diff --git a/examples/local/401_teardown.sh b/examples/local/401_teardown.sh new file mode 100755 index 00000000000..dc58874c4f6 --- /dev/null +++ b/examples/local/401_teardown.sh @@ -0,0 +1,32 @@ +#!/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 scripts brings up zookeeper and all the vitess components +# required for a single shard deployment. + +set -e + +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 +./vtctld-down.sh +./zk-down.sh + +disown -a diff --git a/examples/local/create_commerce_schema.sql b/examples/local/create_commerce_schema.sql new file mode 100644 index 00000000000..e62e7d2e8bf --- /dev/null +++ b/examples/local/create_commerce_schema.sql @@ -0,0 +1,18 @@ +create table product( + sku varbinary(128), + description varbinary(128), + price bigint, + primary key(sku) +) ENGINE=InnoDB; +create table customer( + customer_id bigint not null auto_increment, + email varbinary(128), + primary key(customer_id) +) ENGINE=InnoDB; +create table corder( + order_id bigint not null auto_increment, + customer_id bigint, + sku varbinary(128), + price bigint, + primary key(order_id) +) ENGINE=InnoDB; diff --git a/examples/local/create_commerce_seq.sql b/examples/local/create_commerce_seq.sql new file mode 100644 index 00000000000..b4e66c771b6 --- /dev/null +++ b/examples/local/create_commerce_seq.sql @@ -0,0 +1,4 @@ +create table customer_seq(id int, next_id bigint, cache bigint, primary key(id)) comment 'vitess_sequence'; +insert into customer_seq(id, next_id, cache) values(0, 1000, 100); +create table order_seq(id int, next_id bigint, cache bigint, primary key(id)) comment 'vitess_sequence'; +insert into order_seq(id, next_id, cache) values(0, 1000, 100); diff --git a/examples/local/create_customer_sharded.sql b/examples/local/create_customer_sharded.sql new file mode 100644 index 00000000000..9d3931c7c94 --- /dev/null +++ b/examples/local/create_customer_sharded.sql @@ -0,0 +1,2 @@ +alter table customer change customer_id customer_id bigint not null; +alter table corder change order_id order_id bigint not null; diff --git a/examples/local/drop_commerce_tables.sql b/examples/local/drop_commerce_tables.sql new file mode 100644 index 00000000000..3393ac8141a --- /dev/null +++ b/examples/local/drop_commerce_tables.sql @@ -0,0 +1,2 @@ +drop table customer; +drop table corder; diff --git a/examples/local/etcd-up.sh b/examples/local/etcd-up.sh index dd6e77d3690..7d68dae9f27 100755 --- a/examples/local/etcd-up.sh +++ b/examples/local/etcd-up.sh @@ -17,6 +17,7 @@ # This is an example script that creates a quorum of ZooKeeper servers. set -e +cell=${CELL:-'test'} script_root=$(dirname "${BASH_SOURCE[0]}") @@ -33,18 +34,18 @@ echo "add /vitess/global" "${VTROOT}"/dist/etcd/etcd-"${ETCD_VERSION}"-linux-amd64/etcdctl --endpoints "http://${ETCD_SERVER}" mkdir /vitess/global & -echo "add /vitess/test" -"${VTROOT}"/dist/etcd/etcd-"${ETCD_VERSION}"-linux-amd64/etcdctl --endpoints "http://${ETCD_SERVER}" mkdir /vitess/test & +echo "add /vitess/$cell" +"${VTROOT}"/dist/etcd/etcd-"${ETCD_VERSION}"-linux-amd64/etcdctl --endpoints "http://${ETCD_SERVER}" mkdir /vitess/$cell & # And also add the CellInfo description for the 'test' cell. # If the node already exists, it's fine, means we used existing data. -echo "add test CellInfo" +echo "add $cell CellInfo" set +e # shellcheck disable=SC2086 "${VTROOT}"/bin/vtctl $TOPOLOGY_FLAGS AddCellInfo \ - -root /vitess/test \ + -root /vitess/$cell \ -server_address "${ETCD_SERVER}" \ - test + $cell set -e echo "etcd start done..." diff --git a/examples/local/vschema_commerce_initial.json b/examples/local/vschema_commerce_initial.json new file mode 100644 index 00000000000..0d1bae44428 --- /dev/null +++ b/examples/local/vschema_commerce_initial.json @@ -0,0 +1,7 @@ +{ + "tables": { + "product": {}, + "customer": {}, + "corder": {} + } +} diff --git a/examples/local/vschema_commerce_seq.json b/examples/local/vschema_commerce_seq.json new file mode 100644 index 00000000000..2e564fa6c96 --- /dev/null +++ b/examples/local/vschema_commerce_seq.json @@ -0,0 +1,11 @@ +{ + "tables": { + "customer_seq": { + "type": "sequence" + }, + "order_seq": { + "type": "sequence" + }, + "product": {} + } +} diff --git a/examples/local/vschema_commerce_vsplit.json b/examples/local/vschema_commerce_vsplit.json new file mode 100644 index 00000000000..30f34172e31 --- /dev/null +++ b/examples/local/vschema_commerce_vsplit.json @@ -0,0 +1,5 @@ +{ + "tables": { + "product": {} + } +} diff --git a/examples/local/vschema_customer_sharded.json b/examples/local/vschema_customer_sharded.json new file mode 100644 index 00000000000..3109e2a2f3c --- /dev/null +++ b/examples/local/vschema_customer_sharded.json @@ -0,0 +1,34 @@ +{ + "sharded": true, + "vindexes": { + "hash": { + "type": "hash" + } + }, + "tables": { + "customer": { + "column_vindexes": [ + { + "column": "customer_id", + "name": "hash" + } + ], + "auto_increment": { + "column": "customer_id", + "sequence": "customer_seq" + } + }, + "corder": { + "column_vindexes": [ + { + "column": "customer_id", + "name": "hash" + } + ], + "auto_increment": { + "column": "order_id", + "sequence": "order_seq" + } + } + } +} diff --git a/examples/local/vschema_customer_vsplit.json b/examples/local/vschema_customer_vsplit.json new file mode 100644 index 00000000000..b113a9adc9e --- /dev/null +++ b/examples/local/vschema_customer_vsplit.json @@ -0,0 +1,6 @@ +{ + "tables": { + "customer": {}, + "corder": {} + } +} diff --git a/examples/local/vtctld-up.sh b/examples/local/vtctld-up.sh index 28857214cc6..0fb089718d8 100755 --- a/examples/local/vtctld-up.sh +++ b/examples/local/vtctld-up.sh @@ -18,7 +18,7 @@ set -e -cell='test' +cell=${CELL:-'test'} grpc_port=15999 script_root=`dirname "${BASH_SOURCE}"` diff --git a/examples/local/vtgate-up.sh b/examples/local/vtgate-up.sh index 71d2d6eb474..f79a4d9dc6d 100755 --- a/examples/local/vtgate-up.sh +++ b/examples/local/vtgate-up.sh @@ -18,7 +18,7 @@ set -e -cell='test' +cell=${CELL:-'test'} web_port=15001 grpc_port=15991 mysql_server_port=15306 diff --git a/examples/local/vttablet-down.sh b/examples/local/vttablet-down.sh index 66191b4f44c..0a903e5293e 100755 --- a/examples/local/vttablet-down.sh +++ b/examples/local/vttablet-down.sh @@ -17,7 +17,7 @@ # This is an example script that stops the mysqld and vttablet instances # created by vttablet-up.sh -cell='test' +cell=${CELL:-'test'} uid_base=${UID_BASE:-'100'} script_root=`dirname "${BASH_SOURCE}"` @@ -25,7 +25,7 @@ source $script_root/env.sh # Stop 3 vttablets by default. # Pass a list of UID indices on the command line to override. -uids=${@:-'0 1 2 3 4'} +uids=${@:-'0 1 2'} wait_pids='' diff --git a/examples/local/vttablet-up.sh b/examples/local/vttablet-up.sh index fc7d40a9764..b5ccd4a2e43 100755 --- a/examples/local/vttablet-up.sh +++ b/examples/local/vttablet-up.sh @@ -18,7 +18,7 @@ set -e -cell='test' +cell=${CELL:-'test'} keyspace=${KEYSPACE:-'test_keyspace'} shard=${SHARD:-'0'} uid_base=${UID_BASE:-'100'} @@ -38,12 +38,16 @@ source $script_root/env.sh init_db_sql_file="$VTROOT/config/init_db.sql" +export EXTRA_MY_CNF=$VTROOT/config/mycnf/default-fast.cnf + case "$MYSQL_FLAVOR" in "MySQL56") - export EXTRA_MY_CNF=$VTROOT/config/mycnf/master_mysql56.cnf + export EXTRA_MY_CNF=$EXTRA_MY_CNF:$VTROOT/config/mycnf/master_mysql56.cnf +# export EXTRA_MY_CNF=$VTROOT/config/mycnf/master_mysql56.cnf ;; "MariaDB") - export EXTRA_MY_CNF=$VTROOT/config/mycnf/master_mariadb.cnf + export EXTRA_MY_CNF=$EXTRA_MY_CNF:$VTROOT/config/mycnf/master_mariadb.cnf +# export EXTRA_MY_CNF=$VTROOT/config/mycnf/master_mariadb.cnf ;; *) echo "Please set MYSQL_FLAVOR to MySQL56 or MariaDB." @@ -55,7 +59,7 @@ mkdir -p $VTDATAROOT/backups # Start 5 vttablets by default. # Pass TABLETS_UIDS indices as env variable to change -uids=${TABLETS_UIDS:-'0 1 2 3 4'} +uids=${TABLETS_UIDS:-'0 1 2'} # Start all mysqlds in background. for uid_index in $uids; do @@ -71,7 +75,7 @@ for uid_index in $uids; do export MYSQL_PORT=$mysql_port tablet_type=replica - if [[ $uid_index -gt 2 ]]; then + if [[ $uid_index -gt 1 ]]; then tablet_type=rdonly fi @@ -110,7 +114,7 @@ for uid_index in $uids; do printf -v tablet_dir 'vt_%010d' $uid printf -v tablet_logfile 'vttablet_%010d_querylog.txt' $uid tablet_type=replica - if [[ $uid_index -gt 2 ]]; then + if [[ $uid_index -gt 1 ]]; then tablet_type=rdonly fi diff --git a/examples/local/vtworker-up.sh b/examples/local/vtworker-up.sh index 29a95f0342b..b13b3dfc48b 100755 --- a/examples/local/vtworker-up.sh +++ b/examples/local/vtworker-up.sh @@ -18,13 +18,14 @@ set -e +cell=${CELL:-'test'} script_root=`dirname "${BASH_SOURCE}"` source $script_root/env.sh echo "Starting vtworker..." exec $VTROOT/bin/vtworker \ $TOPOLOGY_FLAGS \ - -cell test \ + -cell $cell \ -log_dir $VTDATAROOT/tmp \ -alsologtostderr \ -service_map=grpc-vtworker \ diff --git a/examples/local/zk-up.sh b/examples/local/zk-up.sh index e10507c0924..3cf1bfc97be 100755 --- a/examples/local/zk-up.sh +++ b/examples/local/zk-up.sh @@ -18,6 +18,8 @@ set -e +cell=${CELL:-'test'} + script_root=`dirname "${BASH_SOURCE}"` source $script_root/env.sh @@ -50,14 +52,14 @@ done echo "Started zk servers." -# Add the CellInfo description for the 'test' cell. +# Add the CellInfo description for the $CELL cell. # If the node already exists, it's fine, means we used existing data. set +e # shellcheck disable=SC2086 $VTROOT/bin/vtctl $TOPOLOGY_FLAGS AddCellInfo \ - -root /vitess/test \ + -root /vitess/$cell \ -server_address $ZK_SERVER \ - test + $cell set -e echo "Configured zk servers."