Skip to content
Closed
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
51 changes: 51 additions & 0 deletions .github/workflows/legacy_local_example.yml
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
2 changes: 0 additions & 2 deletions examples/are-you-alive/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ go 1.12

require (
github.com/go-sql-driver/mysql v1.5.0
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.1 // indirect
github.com/prometheus/client_golang v1.4.1
github.com/sirupsen/logrus v1.4.2
)
48 changes: 48 additions & 0 deletions examples/legacy_local/101_initial_cluster.sh
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
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

# Copyright 2019 The Vitess Authors.
# 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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

# Copyright 2019 The Vitess Authors.
# 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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

# Copyright 2019 The Vitess Authors.
# 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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

# Copyright 2019 The Vitess Authors.
# 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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

# Copyright 2019 The Vitess Authors.
# 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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

# Copyright 2019 The Vitess Authors.
# 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.
Expand Down
26 changes: 26 additions & 0 deletions examples/legacy_local/301_customer_sharded.sh
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
35 changes: 35 additions & 0 deletions examples/legacy_local/302_new_shards.sh
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-
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

# Copyright 2019 The Vitess Authors.
# 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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

# Copyright 2019 The Vitess Authors.
# 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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

# Copyright 2019 The Vitess Authors.
# 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.
Expand Down
22 changes: 22 additions & 0 deletions examples/legacy_local/306_down_shard_0.sh
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

19 changes: 19 additions & 0 deletions examples/legacy_local/307_delete_shard_0.sh
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
59 changes: 59 additions & 0 deletions examples/legacy_local/401_teardown.sh
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
10 changes: 10 additions & 0 deletions examples/legacy_local/README.md
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.

6 changes: 6 additions & 0 deletions examples/legacy_local/ceph_backup_config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"accessKey" : "AccessKey",
"secretKey" : "SecretKey",
"endPoint" : "URL",
"useSSL" : true
}
18 changes: 18 additions & 0 deletions examples/legacy_local/create_commerce_schema.sql
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;
4 changes: 4 additions & 0 deletions examples/legacy_local/create_commerce_seq.sql
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);
2 changes: 2 additions & 0 deletions examples/legacy_local/create_customer_sharded.sql
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;
Loading