A sample application demonstrating how to configure a sharded cluster.
To run the cluster, go to the sharding
directory in the terminal and perform the following steps:
-
Install dependencies defined in the
*.rockspec
file:$ tt build sharded_cluster
-
Run the cluster:
$ tt start sharded_cluster
-
Connect to the router:
$ tt connect sharded_cluster:router-a-001
-
Call
vshard.router.bootstrap()
to perform the initial cluster bootstrap:sharded_cluster:router-a-001> vshard.router.bootstrap() --- - true ...
-
Insert test data:
sharded_cluster:router-a-001> insert_data() --- ...
-
Connect to storages in different replica sets to see how data is distributed across nodes:
a.
storage-a-001
:sharded_cluster:storage-a-001> box.space.bands:select() --- - - [1, 614, 'Roxette', 1986] - [2, 986, 'Scorpions', 1965] - [5, 755, 'Pink Floyd', 1965] - [7, 998, 'The Doors', 1965] - [8, 762, 'Nirvana', 1987] ...
b.
storage-b-001
:sharded_cluster:storage-b-001> box.space.bands:select() --- - - [3, 11, 'Ace of Base', 1987] - [4, 42, 'The Beatles', 1960] - [6, 55, 'The Rolling Stones', 1962] - [9, 299, 'Led Zeppelin', 1968] - [10, 167, 'Queen', 1970] ...