Vitess MySQL/MariaDB Cluster
Vitess MySQL Cluster是基于Kubernetes的MySQL集群解决方案,支持 MariaDB,Youtube、京东在使用。
$ sudo docker run -ti vitess/base bash
[email protected]:/vt/src/vitess.io/vitess$ make build
[email protected]:/$ export VTROOT=/vt
[email protected]:/$ export VTDATAROOT=/vt/vtdataroot
[email protected]:/$ cd $VTROOT/src/vitess.io/vitess/examples/local
[email protected]:/vt/src/vitess.io/vitess/examples/local$ ./zk-up.sh
$ ./vtctld-up.sh
$ ./lvtctl.sh help
$ ./vttablet-up.sh
Starting MySQL for tablet test-0000000100...
Starting MySQL for tablet test-0000000101...
Starting MySQL for tablet test-0000000102...
Starting MySQL for tablet test-0000000103...
Starting MySQL for tablet test-0000000104...
Starting vttablet for test-0000000100...
Access tablet test-0000000100 at http://f6357772e357:15100/debug/status
Starting vttablet for test-0000000101...
Access tablet test-0000000101 at http://f6357772e357:15101/debug/status
Starting vttablet for test-0000000102...
Access tablet test-0000000102 at http://f6357772e357:15102/debug/status
Starting vttablet for test-0000000103...
Access tablet test-0000000103 at http://f6357772e357:15103/debug/status
Starting vttablet for test-0000000104...
Access tablet test-0000000104 at http://f6357772e357:15104/debug/status
初始化数据库
$ ./lvtctl.sh InitShardMaster -force test_keyspace/0 test-100
测试数据库
$ ./lvtctl.sh ListAllTablets test
test-0000000100 test_keyspace 0 master f6357772e357:15100 f6357772e357:17100 []
test-0000000101 test_keyspace 0 replica f6357772e357:15101 f6357772e357:17101 []
test-0000000102 test_keyspace 0 replica f6357772e357:15102 f6357772e357:17102 []
test-0000000103 test_keyspace 0 rdonly f6357772e357:15103 f6357772e357:17103 []
test-0000000104 test_keyspace 0 rdonly f6357772e357:15104 f6357772e357:17104 []
运行了5个MySQL实例:一个Master、两个复制、两个只读
创建一个表
$ ./lvtctl.sh ApplySchema -sql "$(cat create_test_table.sql)" test_keyspace