-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Updated local example to use new VReplication commands. Moved existin… #5910
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
3b23f16
Updated local example to use new VReplication commands. Moved existin…
rohit-nayak-ps 54d9792
Updated file names to refect new commands. Updated copyright to 2020
rohit-nayak-ps dbe35fd
Updated with renamed workflows. Changed copyright on unchanged/minima…
rohit-nayak-ps File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| name: legacy_local_example | ||
| on: [push, pull_request] | ||
| jobs: | ||
|
|
||
| build: | ||
| name: Local Example on ${{ matrix.os }} | ||
| runs-on: ${{ matrix.os }} | ||
| strategy: | ||
| matrix: | ||
| os: [ubuntu-latest] | ||
|
|
||
| steps: | ||
|
|
||
| - name: Set up Go | ||
| uses: actions/setup-go@v1 | ||
| with: | ||
| go-version: 1.13 | ||
|
|
||
| - name: Check out code | ||
| uses: actions/checkout@v2 | ||
|
|
||
| - name: Get dependencies | ||
| run: | | ||
| if [ ${{matrix.os}} = "ubuntu-latest" ]; then | ||
| sudo apt-get update | ||
| sudo apt-get install -y mysql-server mysql-client make unzip g++ etcd curl git wget eatmydata | ||
| sudo service mysql stop | ||
| sudo service etcd stop | ||
| sudo ln -s /etc/apparmor.d/usr.sbin.mysqld /etc/apparmor.d/disable/ | ||
| sudo apparmor_parser -R /etc/apparmor.d/usr.sbin.mysqld | ||
| elif [ ${{matrix.os}} = "macos-latest" ]; then | ||
| brew install mysql@5.7 make unzip etcd curl git wget | ||
| fi | ||
| go mod download | ||
|
|
||
| - name: Run make minimaltools | ||
| run: | | ||
| make minimaltools | ||
|
|
||
| - name: Build | ||
| run: | | ||
| make build | ||
|
|
||
| - name: legacy_local_example | ||
| run: | | ||
| if [ ${{matrix.os}} = "macos-latest" ]; then | ||
| export PATH="/usr/local/opt/mysql@5.7/bin:$PATH" | ||
| fi | ||
| # Make sure that testing is entirely non-reliant on config | ||
| mv config config-moved | ||
| eatmydata -- test/legacy_local_example.sh |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| #!/bin/bash | ||
|
|
||
| # Copyright 2020 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 brings up zookeeper and all the vitess components | ||
| # required for a single shard deployment. | ||
|
|
||
| source ./env.sh | ||
|
|
||
| # start topo server | ||
| if [ "${TOPO}" = "zk2" ]; then | ||
| CELL=zone1 ./scripts/zk-up.sh | ||
| else | ||
| CELL=zone1 ./scripts/etcd-up.sh | ||
| fi | ||
|
|
||
| # start vtctld | ||
| CELL=zone1 ./scripts/vtctld-up.sh | ||
|
|
||
| # start vttablets for keyspace commerce | ||
| for i in 100 101 102; do | ||
| CELL=zone1 TABLET_UID=$i ./scripts/mysqlctl-up.sh | ||
| CELL=zone1 KEYSPACE=commerce TABLET_UID=$i ./scripts/vttablet-up.sh | ||
| done | ||
|
|
||
| # set one of the replicas to master | ||
| vtctlclient -server localhost:15999 InitShardMaster -force commerce/0 zone1-100 | ||
|
|
||
| # create the schema | ||
| vtctlclient -server localhost:15999 ApplySchema -sql-file create_commerce_schema.sql commerce | ||
|
|
||
| # create the vschema | ||
| vtctlclient -server localhost:15999 ApplyVSchema -vschema_file vschema_commerce_initial.json commerce | ||
|
|
||
| # start vtgate | ||
| CELL=zone1 ./scripts/vtgate-up.sh |
2 changes: 1 addition & 1 deletion
2
examples/local/201_customer_keyspace.sh → ...les/legacy_local/201_customer_keyspace.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
examples/local/202_customer_tablets.sh → ...ples/legacy_local/202_customer_tablets.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
examples/local/203_vertical_split.sh → examples/legacy_local/203_vertical_split.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...es/local/204_vertical_migrate_replicas.sh → ...cy_local/204_vertical_migrate_replicas.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ples/local/205_vertical_migrate_master.sh → ...gacy_local/205_vertical_migrate_master.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
examples/local/206_clean_commerce.sh → examples/legacy_local/206_clean_commerce.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| #!/bin/bash | ||
|
|
||
| # Copyright 2020 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 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 | ||
|
|
||
| vtctlclient -server localhost:15999 ApplySchema -sql-file create_commerce_seq.sql commerce | ||
| vtctlclient -server localhost:15999 ApplyVSchema -vschema_file vschema_commerce_seq.json commerce | ||
| vtctlclient -server localhost:15999 ApplySchema -sql-file create_customer_sharded.sql customer | ||
| vtctlclient -server localhost:15999 ApplyVSchema -vschema_file vschema_customer_sharded.json customer |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| #!/bin/bash | ||
|
|
||
| # Copyright 2020 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 brings up new tablets for the two new shards that we will | ||
| # be creating in the customer keyspace and copies the schema | ||
|
|
||
| source ./env.sh | ||
|
|
||
| for i in 300 301 302; do | ||
| CELL=zone1 TABLET_UID=$i ./scripts/mysqlctl-up.sh | ||
| SHARD=-80 CELL=zone1 KEYSPACE=customer TABLET_UID=$i ./scripts/vttablet-up.sh | ||
| done | ||
|
|
||
| for i in 400 401 402; do | ||
| CELL=zone1 TABLET_UID=$i ./scripts/mysqlctl-up.sh | ||
| SHARD=80- CELL=zone1 KEYSPACE=customer TABLET_UID=$i ./scripts/vttablet-up.sh | ||
| done | ||
|
|
||
| vtctlclient -server localhost:15999 InitShardMaster -force customer/-80 zone1-300 | ||
| vtctlclient -server localhost:15999 InitShardMaster -force customer/80- zone1-400 | ||
| vtctlclient -server localhost:15999 CopySchemaShard customer/0 customer/-80 | ||
| vtctlclient -server localhost:15999 CopySchemaShard customer/0 customer/80- |
2 changes: 1 addition & 1 deletion
2
examples/local/303_horizontal_split.sh → ...ples/legacy_local/303_horizontal_split.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
examples/local/304_migrate_replicas.sh → ...ples/legacy_local/304_migrate_replicas.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
examples/local/305_migrate_master.sh → examples/legacy_local/305_migrate_master.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| #!/bin/bash | ||
|
|
||
| # Copyright 2020 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 brings down the tablets for customer/0 keyspace | ||
|
|
||
| for i in 200 201 202; do | ||
| CELL=zone1 TABLET_UID=$i ./scripts/vttablet-down.sh | ||
| CELL=zone1 TABLET_UID=$i ./scripts/mysqlctl-down.sh | ||
| done | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| #!/bin/bash | ||
|
|
||
| # Copyright 2020 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 | ||
|
|
||
| vtctlclient -server localhost:15999 DeleteShard -recursive customer/0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| #!/bin/bash | ||
|
|
||
| # Copyright 2020 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. | ||
|
|
||
| # We should not assume that any of the steps have been executed. | ||
| # This makes it possible for a user to cleanup at any point. | ||
|
|
||
| source ./env.sh | ||
|
|
||
| ./scripts/vtgate-down.sh | ||
|
|
||
| for tablet in 100 200 300 400; do | ||
| if vtctlclient -server localhost:15999 GetTablet zone1-$tablet >/dev/null 2>&1 ; then | ||
| # The zero tablet is up. Try to shutdown 0-2 tablet + mysqlctl | ||
| for i in 0 1 2; do | ||
| uid=$[$tablet + $i] | ||
| CELL=zone1 TABLET_UID=$uid ./scripts/vttablet-down.sh | ||
| CELL=zone1 TABLET_UID=$uid ./scripts/mysqlctl-down.sh | ||
| done | ||
| fi | ||
| done | ||
|
|
||
| ./scripts/vtctld-down.sh | ||
|
|
||
| if [ "${TOPO}" = "zk2" ]; then | ||
| CELL=zone1 ./scripts/zk-down.sh | ||
| else | ||
| CELL=zone1 ./scripts/etcd-down.sh | ||
| fi | ||
|
|
||
| # pedantic check: grep for any remaining processes | ||
|
|
||
| if [ ! -z "$VTDATAROOT" ]; then | ||
|
|
||
| if pgrep -f -l "$VTDATAROOT" > /dev/null; then | ||
| echo "ERROR: Stale processes detected! It is recommended to manuallly kill them:" | ||
| pgrep -f -l "$VTDATAROOT" | ||
| else | ||
| echo "All good! It looks like every process has shut down" | ||
| fi | ||
|
|
||
| # shellcheck disable=SC2086 | ||
| rm -r ${VTDATAROOT:?}/* | ||
|
|
||
| fi | ||
|
|
||
| disown -a |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| # Local Vitess Cluster | ||
|
|
||
| This directory contains example scripts to bring up a Vitess cluster on your | ||
| local machine, which may be useful for experimentation. These scripts can | ||
| also serve as a starting point for configuring Vitess into your preferred | ||
| deployment strategy or toolset. | ||
|
|
||
| See the [Run Vitess Locally](https://vitess.io/docs/tutorials/local/) | ||
| tutorial ("Start a Vitess cluster" section) for instructions on using these scripts. | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| { | ||
| "accessKey" : "AccessKey", | ||
| "secretKey" : "SecretKey", | ||
| "endPoint" : "URL", | ||
| "useSSL" : true | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.