This guide illustrates how to run a local testing Vitess setup via Docker. The Vitess environment is identical to the local setup, but without having to install software on one’s host other than Docker.
Check out the vitessio/vitess repository
Clone the GitHub repository via:
git clone firstname.lastname@example.org:vitessio/vitess.git, or:
git clone https://github.com/vitessio/vitess.git
Build the docker image
In your shell, execute:
This creates a docker image named
Run the docker image
This will set up a MySQL replication topology, as well as
vtgatelistens on http://127.0.0.1:15001/debug/status
vtctldlistens on http://127.0.0.1:15000/debug/status
- Control panel is available at http://localhost:15000/app/
From within the docker shell, aliases are set up for your convenience. Try the following
mysql commands to connect to various tablets:
You will find that Vitess runs a single keyspace, single shard cluster.
In this example, we deployed a single unsharded keyspace named
commerce. Unsharded keyspaces have a single shard named
0. The following schema reflects a common ecommerce scenario that was created by the script:
create table product ( sku varbinary(128), description varbinary(128), price bigint, primary key(sku) ); create table customer ( customer_id bigint not null auto_increment, email varbinary(128), primary key(customer_id) ); create table corder ( order_id bigint not null auto_increment, customer_id bigint, sku varbinary(128), price bigint, primary key(order_id) );
The schema has been simplified to include only those fields that are significant to the example:
producttable contains the product information for all of the products.
customertable has a
customer_idthat has an
auto_increment. A typical customer table would have a lot more columns, and sometimes additional detail tables.
cordertable (named so because
orderis an SQL reserved word) has an
order_idauto-increment column. It also has foreign keys into
You can now proceed with MoveTables.
Exiting the docker shell terminates and destroys the vitess cluster.