|
| 1 | +# Sharded cluster |
| 2 | + |
| 3 | +A sample application demonstrating how to configure a [sharded](https://www.tarantool.io/en/doc/latest/concepts/sharding/) cluster. |
| 4 | + |
| 5 | +## Running |
| 6 | + |
| 7 | +To run the cluster, go to the `sharding` directory in the terminal and perform the following steps: |
| 8 | + |
| 9 | +1. Install `vshard`: |
| 10 | + |
| 11 | + ```console |
| 12 | + $ tt rocks install vshard |
| 13 | + ``` |
| 14 | + |
| 15 | +2. Run the cluster: |
| 16 | + |
| 17 | + ```console |
| 18 | + $ tt start sharded_cluster |
| 19 | + ``` |
| 20 | + |
| 21 | +3. Connect to the router: |
| 22 | + |
| 23 | + ```console |
| 24 | + $ tt connect sharded_cluster:router-a-001 |
| 25 | + ``` |
| 26 | + |
| 27 | +4. Insert test data: |
| 28 | + |
| 29 | + ```console |
| 30 | + sharded_cluster:router-a-001> insert_data() |
| 31 | + --- |
| 32 | + ... |
| 33 | + ``` |
| 34 | + |
| 35 | +5. Connect to storages in different replica sets to see how data is distributed across nodes: |
| 36 | + |
| 37 | + a. `storage-a-001`: |
| 38 | + |
| 39 | + ```console |
| 40 | + sharded_cluster:storage-a-001> box.space.bands:select() |
| 41 | + --- |
| 42 | + - - [1, 614, 'Roxette', 1986] |
| 43 | + - [2, 986, 'Scorpions', 1965] |
| 44 | + - [5, 755, 'Pink Floyd', 1965] |
| 45 | + - [7, 998, 'The Doors', 1965] |
| 46 | + - [8, 762, 'Nirvana', 1987] |
| 47 | + ... |
| 48 | + ``` |
| 49 | + |
| 50 | + b. `storage-b-001`: |
| 51 | + |
| 52 | + ```console |
| 53 | + sharded_cluster:storage-b-001> box.space.bands:select() |
| 54 | + --- |
| 55 | + - - [3, 11, 'Ace of Base', 1987] |
| 56 | + - [4, 42, 'The Beatles', 1960] |
| 57 | + - [6, 55, 'The Rolling Stones', 1962] |
| 58 | + - [9, 299, 'Led Zeppelin', 1968] |
| 59 | + - [10, 167, 'Queen', 1970] |
| 60 | + ... |
| 61 | + ``` |
0 commit comments