compose

command
v3.0.0-rc.2+incompatible Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 9, 2018 License: Apache-2.0 Imports: 6 Imported by: 0

README

Local Vitess cluster using docker-compose

This directory have a docker-compose sample application. To understand it better, you can run it.

First you will need to install docker-compose.

Start the cluster

To start Consul(which saves the topology config), vtctld, vtgate and a few vttablets with MySQL running on them.

vitess/examples/compose$ docker-compose up -d

Note that the vtgate container will likely fail to start.

Load the schema

We need to create a few tables into our new cluster. To do that, we can run the ApplySchema command.

vitess/examples/compose$ ./lvtctl.sh ApplySchema -sql "$(cat create_test_table.sql)" test_keyspace
Complete starting the cluster

Now that schema has been loaded a second start will bring vtgate up as well.

vitess/examples/compose$ docker-compose up -d
Run the client to insert and read some data

This will build and run the client.go file. It will insert and read data from the master and from the replica.

vitess/examples/compose$ ./client.sh
Connect to vgate and run queries

vtgate responds to the MySQL protocol, so we can connect to it using the default MySQL client command line.

$ mysql --port=15306 --host=127.0.0.1
Play around with vtctl commands
vitess/examples/compose$ ./lvtctl.sh Help

Exploring

Troubleshooting

If the cluster gets in a bad state, you most likely will have to stop and kill the containers. Note: you will lose all the data.

vitess/examples/compose$ docker-compose kill
vitess/examples/compose$ docker-compose rm

Documentation

Overview

client.go is a sample for using the Vitess Go SQL driver.

Before running this, start up a local example cluster as described in the README.md file.

Then run: vitess$ . dev.env vitess$ cd examples/local vitess/examples/local$ go run client.go -server=localhost:15991

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL