Skip to content

Instantly share code, notes, and snippets.

@mattlord
Last active January 25, 2024 17:34
Show Gist options
  • Save mattlord/04c92f24913e3a3df6d120405024512f to your computer and use it in GitHub Desktop.
Save mattlord/04c92f24913e3a3df6d120405024512f to your computer and use it in GitHub Desktop.
vtctlclient and etcdctl examples
❯ vtctldclient GetTablets
zone1-0000000100 commerce 0 replica localhost:15100 localhost:17100 [] <null>
zone1-0000000101 commerce 0 primary localhost:15101 localhost:17101 [] 2023-09-28T16:37:49Z
zone1-0000000102 commerce 0 rdonly localhost:15102 localhost:17102 [] <null>
zone1-0000000200 customer 0 primary localhost:15200 localhost:17200 [] 2023-09-28T16:39:19Z
zone1-0000000201 customer 0 replica localhost:15201 localhost:17201 [] <null>
zone1-0000000202 customer 0 rdonly localhost:15202 localhost:17202 [] <null>
❯ etcdctl get --prefix /vitess/zone1/tablets/zone1-0000000100/Tablet -w protobuf | protoc --proto_path=${HOME}/git/vitess/proto --decode=topodata.Keyspace topodata.proto
1 {
1: 14841639068965178418
2: 10276657743932975437
3: 80
4: 2
}
2 {
1: "/vitess/zone1/tablets/zone1-0000000100/Tablet"
2: 12
3: 74
4: 5
5 {
1 {
1: "zone1"
2: 100
}
2: "localhost"
4 {
1: "grpc"
2: 16100
}
4 {
1: "vt"
2: 15100
}
5: "commerce"
6: "0"
8: 2
12: "localhost"
13: 17100
16: 255
}
}
4: 1
❯ kill $(cat ${VTDATAROOT}/vt_0000000100/vttablet.pid)
❯ vtctldclient GetTablets
zone1-0000000100 commerce 0 replica localhost:15100 localhost:17100 [] <null>
zone1-0000000101 commerce 0 primary localhost:15101 localhost:17101 [] 2023-09-28T16:37:49Z
zone1-0000000102 commerce 0 rdonly localhost:15102 localhost:17102 [] <null>
zone1-0000000200 customer 0 primary localhost:15200 localhost:17200 [] 2023-09-28T16:39:19Z
zone1-0000000201 customer 0 replica localhost:15201 localhost:17201 [] <null>
zone1-0000000202 customer 0 rdonly localhost:15202 localhost:17202 [] <null>
❯ vtctldclient GetTablets
zone1-0000000100 commerce 0 replica :0 :17100 [] <null>
zone1-0000000101 commerce 0 primary localhost:15101 localhost:17101 [] 2023-09-28T16:37:49Z
zone1-0000000102 commerce 0 rdonly localhost:15102 localhost:17102 [] <null>
zone1-0000000200 customer 0 primary localhost:15200 localhost:17200 [] 2023-09-28T16:39:19Z
zone1-0000000201 customer 0 replica localhost:15201 localhost:17201 [] <null>
zone1-0000000202 customer 0 rdonly localhost:15202 localhost:17202 [] <null>
❯ etcdctl get --prefix /vitess/zone1/tablets/zone1-0000000100/Tablet -w protobuf | protoc --proto_path=${HOME}/git/vitess/proto --decode=topodata.Keyspace topodata.proto
1 {
1: 14841639068965178418
2: 10276657743932975437
3: 81
4: 2
}
2 {
1: "/vitess/zone1/tablets/zone1-0000000100/Tablet"
2: 12
3: 81
4: 6
5 {
1 {
1: "zone1"
2: 100
}
5: "commerce"
6: "0"
8: 2
13: 17100
16: 255
}
}
4: 1
------------------------------------------------------------------------------------
❯ vtctldclient GetTablets
zone1-0000000100 commerce 0 replica localhost:15100 localhost:17100 [] <null>
zone1-0000000101 commerce 0 primary localhost:15101 localhost:17101 [] 2023-09-29T01:41:08Z
zone1-0000000102 commerce 0 rdonly localhost:15102 localhost:17102 [] <null>
❯ vtctldclient GetTopologyPath /zone1/keyspaces/commerce/SrvKeyspace
{
"name": "SrvKeyspace",
"path": "/zone1/keyspaces/commerce/SrvKeyspace",
"data": "partitions:{served_type:PRIMARY shard_references:{name:\"0\"}} partitions:{served_type:REPLICA shard_references:{name:\"0\"}} partitions:{served_type:RDONLY shard_references:{name:\"0\"}}",
"children": []
}
❯ vtctldclient GetTopologyPath /zone1/tablets/zone1-0000000100/Tablet
{
"name": "Tablet",
"path": "/zone1/tablets/zone1-0000000100/Tablet",
"data": "alias:{cell:\"zone1\" uid:100} hostname:\"localhost\" port_map:{key:\"grpc\" value:16100} port_map:{key:\"vt\" value:15100} keyspace:\"commerce\" shard:\"0\" type:REPLICA mysql_hostname:\"localhost\" mysql_port:17100 default_conn_collation:255",
"children": []
}
❯ kill $(cat ${VTDATAROOT}/vt_0000000100/vttablet.pid)
❯ vtctldclient GetTablets
zone1-0000000100 commerce 0 replica localhost:15100 localhost:17100 [] <null>
zone1-0000000101 commerce 0 primary localhost:15101 localhost:17101 [] 2023-09-29T01:41:08Z
zone1-0000000102 commerce 0 rdonly localhost:15102 localhost:17102 [] <null>
❯ vtctldclient GetTablets
zone1-0000000100 commerce 0 replica :0 :17100 [] <null>
zone1-0000000101 commerce 0 primary localhost:15101 localhost:17101 [] 2023-09-29T01:41:08Z
zone1-0000000102 commerce 0 rdonly localhost:15102 localhost:17102 [] <null>
❯ vtctldclient GetTopologyPath /zone1/keyspaces/commerce/SrvKeyspace
{
"name": "SrvKeyspace",
"path": "/zone1/keyspaces/commerce/SrvKeyspace",
"data": "partitions:{served_type:PRIMARY shard_references:{name:\"0\"}} partitions:{served_type:REPLICA shard_references:{name:\"0\"}} partitions:{served_type:RDONLY shard_references:{name:\"0\"}}",
"children": []
}
❯ vtctldclient GetTopologyPath /zone1/tablets/zone1-0000000100/Tablet
{
"name": "Tablet",
"path": "/zone1/tablets/zone1-0000000100/Tablet",
"data": "alias:{cell:\"zone1\" uid:100} keyspace:\"commerce\" shard:\"0\" type:REPLICA mysql_port:17100 default_conn_collation:255",
"children": []
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment