You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Use this command to view the store information or remove a specified store.
476
+
Use this command to view the store information or remove a specified store. For a jq formatted output, see [jq-formatted-json-output-usage](#jq-formatted-json-output-usage).
477
477
478
478
Usage:
479
479
@@ -518,3 +518,92 @@ Usage:
518
518
system: 2017-10-09 05:50:59 +0800 CST
519
519
logic: 120102
520
520
```
521
+
522
+
## Jq formatted JSON output usage
523
+
524
+
### Simplify the output of `store`
525
+
526
+
```bash
527
+
» store --jq=".stores[].store | { id, address, state_name}"
### Filter Regions according to the store ID of replicas
562
+
563
+
For example, to filter out all Regions that have a replica on store30:
564
+
565
+
```bash
566
+
» region --jq=".regions[] | {id: .id, peer_stores: [.peers[].store_id] | select(any(.==30))}"
567
+
{"id":6,"peer_stores":[1,30,31]}
568
+
{"id":22,"peer_stores":[1,30,32]}
569
+
...
570
+
```
571
+
572
+
You can also find out all Regions that have a replica on store30 or store31 in the same way:
573
+
574
+
```bash
575
+
» region --jq=".regions[] | {id: .id, peer_stores: [.peers[].store_id] | select(any(.==(30,31)))}"
576
+
{"id":16,"peer_stores":[1,30,34]}
577
+
{"id":28,"peer_stores":[1,30,32]}
578
+
{"id":12,"peer_stores":[30,32]}
579
+
...
580
+
```
581
+
582
+
### Look for relevant Regions when restoring data
583
+
584
+
For example, when [store1, store30, store31] is unavailable at its downtime, you can find all Regions whose Down replicas are more than normal replicas:
585
+
586
+
```bash
587
+
» region --jq=".regions[] | {id: .id, peer_stores: [.peers[].store_id] | select(length as $total | map(if .==(1,30,31) then . else empty end) | length>=$total-length) }"
588
+
{"id":2,"peer_stores":[1,30,31,32]}
589
+
{"id":12,"peer_stores":[30,32]}
590
+
{"id":14,"peer_stores":[1,30,32]}
591
+
...
592
+
```
593
+
594
+
Or when [store1, store30, store31] fails to start, you can find Regions where the data can be manually removed safely on store1. In this way, you can filter out all Regions that have a replica on store1 but don't have other DownPeers:
595
+
596
+
```bash
597
+
» region --jq=".regions[] | {id: .id, peer_stores: [.peers[].store_id] | select(length>1 and any(.==1) and all(.!=(30,31)))}"
598
+
{"id":24,"peer_stores":[1,32,33]}
599
+
```
600
+
601
+
When [store30, store31] is down, find out all Regions that can be safely processed by creating the `remove-peer` Operator, that is, Regions with one and only DownPeer:
602
+
603
+
```bash
604
+
» region --jq=".regions[] | {id: .id, remove_peer: [.peers[].store_id] | select(length>1) | map(if .==(30,31) then . else empty end) | select(length==1)}"
0 commit comments