はじめに
コミット
7924743のexamples/local/ウォークスルーに基づく。コマンドはローカルの MySQL と、ビルドした Vitess バイナリがPATHにあることを前提とする。
前提
mysqldとmysqlクライアントがローカルにインストール済み。- Vitess バイナリをビルドして
PATHに通してある。リポジトリのクローンでmake buildを実行する。 - リポジトリの
examples/local/配下のサンプルスクリプト。
インストール
git clone https://github.com/vitessio/vitess.git
cd vitess
make build
export PATH="$PWD/bin:$PATH"最初の動く構成
examples/local/ ディレクトリは、トポロジサービス・vtctld・VTGate・VTTablet を commerce keyspace 向けに立ち上げる。コマンドの要約は examples/local/README.md にある。
環境とエイリアスを設定し、初期クラスタを立ち上げる (
examples/local/README.md:9,README.md:12)。bashsource ../common/env.sh ./101_initial_cluster.shVTGate 経由でサンプルデータを挿入し読み戻す (
examples/local/README.md:15)。bashmysql < ../common/insert_commerce_data.sql mysql --table < ../common/select_commerce_data.sqlVReplication で 2 つのテーブルを新しい
customerkeyspace へ移す (examples/local/README.md:22)。bashvtctldclient MoveTables --workflow commerce2customer --target-keyspace customer create --source-keyspace commerce --tables "customer,corder"customerkeyspace を 1 シャードから 2 シャードへリシャードする (examples/local/README.md:40)。bashvtctldclient Reshard --workflow cust2cust --target-keyspace customer create --source-shards '0' --target-shards '-80,80-'
動作確認
ステップ 2 の後、mysql --table のセレクトが commerce keyspace の行を表示すれば、VTGate が実クエリを VTTablet とその MySQL バックエンドへルーティングできていることが確認できる。ワークフロー系では vtctldclient vdiff ... show last で、トラフィックを切り替える前に MoveTables や Reshard のワークフローがデータをコピーして一致させたかを確認する。
次に読むもの
Kubernetes 上の本番デプロイには vitess-operator と examples/operator/101_initial_cluster.yaml を使う。公式サイト https://vitess.io/ が HA・バックアップ・セキュリティ・スケーリングを扱う。プロジェクトの運営方法はリポジトリの GOVERNANCE.md と GUIDING_PRINCIPLES.md に書かれている。