Created
December 22, 2017 06:59
-
-
Save sougou/27648690488fd40ed057421c1e1cba3b to your computer and use it in GitHub Desktop.
Vitess resharding commands for local example
This file contains 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
#!/bin/bash | |
# Copyright 2017 Google Inc. | |
# | |
# 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. | |
script_root=. | |
$script_root/vtgate-down.sh | |
$script_root/sharded-vttablet-down.sh | |
$script_root/vttablet-down.sh | |
$script_root/vtctld-down.sh | |
$script_root/zk-down.sh | |
rm -r $VTDATAROOT/* |
This file contains 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
#!/bin/bash | |
# Copyright 2017 Google Inc. | |
# | |
# 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. | |
set -e | |
script_root=. | |
$script_root/zk-up.sh | |
$script_root/vtctld-up.sh | |
$script_root/vttablet-up.sh | |
sleep 10s | |
$script_root/lvtctl.sh InitShardMaster -force test_keyspace/0 test-100 | |
$script_root/lvtctl.sh ApplySchema -sql "$(cat create_test_table.sql)" test_keyspace | |
$script_root/vtgate-up.sh | |
# insert some rows | |
$script_root/client.sh |
This file contains 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
#!/bin/bash | |
# Copyright 2017 Google Inc. | |
# | |
# 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. | |
set -e | |
script_root=. | |
# Apply VSchema that marks test_keyspace as sharded, and provide a primary vindex for messages. | |
$script_root/lvtctl.sh ApplyVSchema -vschema "$(cat vschema.json)" test_keyspace | |
$script_root/sharded-vttablet-up.sh | |
sleep 10s | |
$script_root/lvtctl.sh InitShardMaster -force test_keyspace/-80 test-200 | |
$script_root/lvtctl.sh InitShardMaster -force test_keyspace/80- test-300 | |
$script_root/lvtctl.sh CopySchemaShard test_keyspace/0 test_keyspace/-80 | |
$script_root/lvtctl.sh CopySchemaShard test_keyspace/0 test_keyspace/80- | |
$script_root/sharded-vtworker.sh SplitClone test_keyspace/0 | |
# Migrate serving types | |
$script_root/lvtctl.sh MigrateServedTypes -cells=test test_keyspace/0 rdonly | |
$script_root/lvtctl.sh MigrateServedTypes -cells=test test_keyspace/0 replica | |
$script_root/lvtctl.sh MigrateServedTypes test_keyspace/0 master | |
# Kill old vttablets and delete old shard |
This file contains 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
#!/bin/bash | |
# Copyright 2017 Google Inc. | |
# | |
# 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. | |
set -e | |
script_root=. | |
# Create target keyspace where messages will be migrated. | |
# served_from specifies that all queries to ks2 should be redirected to test_keyspace | |
# until resharding is complete. | |
$script_root/lvtctl.sh CreateKeyspace --served_from master:test_keyspace,replica:test_keyspace,rdonly:test_keyspace ks2 | |
# Apply VSchemas. | |
# ks2 is unsharded and claims to contain messages. | |
# test_keyspace is unsharded and claims to contain no tables. So, we don't specify a vschema for it. | |
# Queries sent to messages will target ks2, which will then be redirected to test_keyspace. | |
$script_root/lvtctl.sh ApplyVSchema -vschema "$(cat vschema-unsharded.json)" ks2 | |
KEYSPACE=ks2 SHARD=0 UID_BASE=200 $script_root/vttablet-up.sh "$@" | |
sleep 10s | |
$script_root/lvtctl.sh InitShardMaster -force ks2/0 test-200 | |
$script_root/lvtctl.sh CopySchemaShard test_keyspace/0 ks2/0 | |
$script_root/sharded-vtworker.sh VerticalSplitClone --tables=messages ks2/0 | |
# Migrate serving types | |
$script_root/lvtctl.sh MigrateServedFrom -cells=test ks2/0 rdonly | |
$script_root/lvtctl.sh MigrateServedFrom -cells=test ks2/0 replica | |
$script_root/lvtctl.sh MigrateServedFrom ks2/0 master | |
# Drop table from source | |
$script_root/lvtctl.sh ApplySchema -sql='drop table messages' test_keyspace | |
# Remove blacklist rules | |
$script_root/lvtctl.sh SetShardTabletControl -blacklisted_tables=messages -remove test_keyspace/0 rdonly | |
$script_root/lvtctl.sh SetShardTabletControl -blacklisted_tables=messages -remove test_keyspace/0 replica | |
$script_root/lvtctl.sh SetShardTabletControl -blacklisted_tables=messages -remove test_keyspace/0 master |
This file contains 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
{ | |
"sharded": false, | |
"tables": { | |
"messages": {} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment