yb-docker-ctl

AttentionThis page documents an earlier version. Go to the latest (v2.1)version.

yb-docker-ctl is a simple command line interface for administering local Docker clusters. It manages the yb-master and yb-tserver containers to perform the necessary administration.

Download


1. $ mkdir ~/yugabyte && cd ~/yugabyte


1. $ wget https://raw.githubusercontent.com/yugabyte/yugabyte-db/master/bin/yb-docker-ctl && chmod +x yb-docker-ctl

Help command

Use the —help option to see all the commands supported.


1. $ ./yb-docker-ctl -h


1. usage: yb-docker-ctl [-h] {create,status,destroy,add_node,remove_node} ...

3. Yugabyte Docker Container Control

5. positional arguments:
6. {create,status,destroy,add_node,remove_node}
7. Commands
8. create              Create Yugabyte Cluster
9. status              Check Yugabyte Cluster status
10. destroy             Destroy Yugabyte Cluster
11. add_node            Add a new Yugabyte Cluster Node
12. remove_node         Stop a Yugabyte Cluster Node

14. optional arguments:
15. -h, --help            show this help message and exit

Create cluster

  • Create a 3 node local cluster with replication factor 3.

Each of these initial nodes run a yb-tserver process and a yb-master process. Note that the number of yb-masters in a cluster has to equal to the replication factor for the cluster to be considered as operating normally and the number of yb-tservers is equal to be the number of nodes.

Note that the create command pulls the latest yugabytedb/yugabyte image at the outset in case the image is not yet downloaded or is not the latest.


1. $ ./yb-docker-ctl create


1. docker run --name yb-master-n1 --privileged -p 7000:7000 --net yb-net --detach yugabytedb/yugabyte:latest /home/yugabyte/yb-master --fs_data_dirs=/mnt/disk0,/mnt/disk1 --master_addresses=yb-master-n1:7100,yb-master-n2:7100,yb-master-n3:7100 --rpc_bind_addresses=yb-master-n1:7100
2. Adding node yb-master-n1
3. docker run --name yb-master-n2 --privileged --net yb-net --detach yugabytedb/yugabyte:latest /home/yugabyte/yb-master --fs_data_dirs=/mnt/disk0,/mnt/disk1 --master_addresses=yb-master-n1:7100,yb-master-n2:7100,yb-master-n3:7100 --rpc_bind_addresses=yb-master-n2:7100
4. Adding node yb-master-n2
5. docker run --name yb-master-n3 --privileged --net yb-net --detach yugabytedb/yugabyte:latest /home/yugabyte/yb-master --fs_data_dirs=/mnt/disk0,/mnt/disk1 --master_addresses=yb-master-n1:7100,yb-master-n2:7100,yb-master-n3:7100 --rpc_bind_addresses=yb-master-n3:7100
6. Adding node yb-master-n3
7. docker run --name yb-tserver-n1 --privileged -p 9000:9000 -p 9042:9042 -p 6379:6379 --net yb-net --detach yugabytedb/yugabyte:latest /home/yugabyte/yb-tserver --fs_data_dirs=/mnt/disk0,/mnt/disk1 --tserver_master_addrs=yb-master-n1:7100,yb-master-n2:7100,yb-master-n3:7100 --rpc_bind_addresses=yb-tserver-n1:9100
8. Adding node yb-tserver-n1
9. docker run --name yb-tserver-n2 --privileged --net yb-net --detach yugabytedb/yugabyte:latest /home/yugabyte/yb-tserver --fs_data_dirs=/mnt/disk0,/mnt/disk1 --tserver_master_addrs=yb-master-n1:7100,yb-master-n2:7100,yb-master-n3:7100 --rpc_bind_addresses=yb-tserver-n2:9100
10. Adding node yb-tserver-n2
11. docker run --name yb-tserver-n3 --privileged --net yb-net --detach yugabytedb/yugabyte:latest /home/yugabyte/yb-tserver --fs_data_dirs=/mnt/disk0,/mnt/disk1 --tserver_master_addrs=yb-master-n1:7100,yb-master-n2:7100,yb-master-n3:7100 --rpc_bind_addresses=yb-tserver-n3:9100
12. Adding node yb-tserver-n3
13. PID        Type       Node                 URL                       Status          Started At
14. 11818      tserver    yb-tserver-n3        http://172.19.0.7:9000    Running         2017-11-28T23:33:00.369124907Z
15. 11632      tserver    yb-tserver-n2        http://172.19.0.6:9000    Running         2017-11-28T23:32:59.874963849Z
16. 11535      tserver    yb-tserver-n1        http://172.19.0.5:9000    Running         2017-11-28T23:32:59.444064946Z
17. 11350      master     yb-master-n3         http://172.19.0.4:9000    Running         2017-11-28T23:32:58.899308826Z
18. 11231      master     yb-master-n2         http://172.19.0.3:9000    Running         2017-11-28T23:32:58.403788411Z
19. 11133      master     yb-master-n1         http://172.19.0.2:9000    Running         2017-11-28T23:32:57.905097927Z

  • Create a 5 node local cluster with replication factor 5.

The number of nodes created with the initial create command is always equal to the replication factor in order to ensure that all the replicas for a given tablet can be placed on different nodes. With the add_node and remove_node commands the size of the cluster can thereafter be expanded or shrinked as necessary.


1. $ ./yb-docker-ctl create --rf 5

Check cluster status

Get the status of the local cluster including the URLs for the admin UIs for the YB-Master and YB-TServer.


1. $ ./yb-docker-ctl status


1. PID        Type       Node                 URL                       Status          Started At
2. 11818      tserver    yb-tserver-n3        http://172.19.0.7:9000    Running         2017-11-28T23:33:00.369124907Z
3. 11632      tserver    yb-tserver-n2        http://172.19.0.6:9000    Running         2017-11-28T23:32:59.874963849Z
4. 11535      tserver    yb-tserver-n1        http://172.19.0.5:9000    Running         2017-11-28T23:32:59.444064946Z
5. 11350      master     yb-master-n3         http://172.19.0.4:9000    Running         2017-11-28T23:32:58.899308826Z
6. 11231      master     yb-master-n2         http://172.19.0.3:9000    Running         2017-11-28T23:32:58.403788411Z
7. 11133      master     yb-master-n1         http://172.19.0.2:9000    Running         2017-11-28T23:32:57.905097927Z

Add a node

Add a new node to the cluster. This will start a new yb-tserver process and give it a new node_id for tracking purposes.


1. $ ./yb-docker-ctl add_node


1. docker run --name yb-tserver-n4 --net yb-net --detach yugabytedb/yugabyte:latest /home/yugabyte/yb-tserver --fs_data_dirs=/mnt/disk0,/mnt/disk1 --tserver_master_addrs=04:7100,04:7100,04:7100 --rpc_bind_addresses=yb-tserver-n4:9100
2. Adding node yb-tserver-n4

Remove a node

Remove a node from the cluster by executing the following command. The command takes the node_id of the node to be removed as input.

Help


1. $ ./yb-docker-ctl remove_node --help


1. usage: yb-docker-ctl remove_node [-h] node

3. positional arguments:
4. node_id        Index of the node to remove

6. optional arguments:
7. -h, --help  show this help message and exit

Example


1. $ ./yb-docker-ctl remove_node 3


1. Stopping node :yb-tserver-n3

Destroy cluster

Destroy the cluster which includes deleting the data directories.


1. $ ./yb-docker-ctl destroy

Upgrade container image

Upgrade the YugabyteDB image to the latest version.


1. $ docker pull yugabytedb/yugabyte