|
| 1 | +# Sharded cluster with CRUD |
| 2 | + |
| 3 | +A sample application demonstrating how to set up a sharded cluster with the [crud](https://github.com/tarantool/crud) module. |
| 4 | + |
| 5 | +## Running |
| 6 | + |
| 7 | +Before running the cluster, execute the `tt build` command in the [sharding](../../../sharding) directory: |
| 8 | + |
| 9 | +```shell |
| 10 | +$ tt build sharded_cluster_crud |
| 11 | +``` |
| 12 | + |
| 13 | +Then, start all instances in the cluster using `tt start`: |
| 14 | + |
| 15 | +```shell |
| 16 | +$ tt start sharded_cluster_crud |
| 17 | +``` |
| 18 | + |
| 19 | +## Bootstrapping a cluster |
| 20 | + |
| 21 | +After starting instances, you need to bootstrap the cluster. |
| 22 | +Connect to the router instance using `tt connect`: |
| 23 | + |
| 24 | +```shell |
| 25 | +$ tt connect sharded_cluster_crud:router-a-001 |
| 26 | + • Connecting to the instance... |
| 27 | + • Connected to sharded_cluster_crud:router-a-001 |
| 28 | +``` |
| 29 | + |
| 30 | +Call `vshard.router.bootstrap()` to perform the initial cluster bootstrap: |
| 31 | + |
| 32 | +```shell |
| 33 | +sharded_cluster_crud:router-a-001> vshard.router.bootstrap() |
| 34 | +--- |
| 35 | +- true |
| 36 | +... |
| 37 | +``` |
| 38 | + |
| 39 | + |
| 40 | +## Inserting data |
| 41 | + |
| 42 | +To insert sample data, call `crud.insert_many()` on the router: |
| 43 | + |
| 44 | +```lua |
| 45 | +crud.insert_many('bands', { |
| 46 | + { 1, box.NULL, 'Roxette', 1986 }, |
| 47 | + { 2, box.NULL, 'Scorpions', 1965 }, |
| 48 | + { 3, box.NULL, 'Ace of Base', 1987 }, |
| 49 | + { 4, box.NULL, 'The Beatles', 1960 }, |
| 50 | + { 5, box.NULL, 'Pink Floyd', 1965 }, |
| 51 | + { 6, box.NULL, 'The Rolling Stones', 1962 }, |
| 52 | + { 7, box.NULL, 'The Doors', 1965 }, |
| 53 | + { 8, box.NULL, 'Nirvana', 1987 }, |
| 54 | + { 9, box.NULL, 'Led Zeppelin', 1968 }, |
| 55 | + { 10, box.NULL, 'Queen', 1970 } |
| 56 | +}) |
| 57 | +``` |
0 commit comments