9 node multi-region CockroachDB cluster with HAProxy acting as load balancer per region
crdb-0
- EU CockroachDB nodecrdb-0a
- EU CockroachDB nodecrdb-0b
- EU CockroachDB nodecrdb-1
- US CockroachDB nodecrdb-1a
- US CockroachDB nodecrdb-1b
- US CockroachDB nodecrdb-2
- APAC CockroachDB nodecrdb-2a
- APAC CockroachDB nodecrdb-2b
- APAC CockroachDB nodelb_eu
- HAProxy acting as load balancer for EU Regionlb_us
- HAProxy acting as load balancer for US Regionlb_apac
- HAProxy acting as load balancer for APAC Region
- run
docker-compose up
- visit the CockroachDB UI
- http://localhost:8080 for EU Region
- http://localhost:8090 for US Region
- http://localhost:8070 for APAC Region
- visit the HAProxy UI
- http://localhost:8081 for EU Region
- http://localhost:8082 for US Region
- http://localhost:8083 for APAC Region
- have fun!
Use the following to execute arbitrary SQL on the CockroachDB cluster. The following creates a database called test
.
docker-compose exec crdb-0 /cockroach/cockroach sql --insecure --execute="CREATE DATABASE test;"
docker exec -ti crdb-0 /bin/bash
docker exec -ti crdb-0a /bin/bash
docker exec -ti crdb-0b /bin/bash
docker exec -ti crdb-1 /bin/bash
docker exec -ti crdb-1a /bin/bash
docker exec -ti crdb-1b /bin/bash
docker exec -ti crdb-2 /bin/bash
docker exec -ti crdb-2a /bin/bash
docker exec -ti crdb-2b /bin/bash
docker exec -ti lb_eu /bin/sh
docker exec -ti lb_us /bin/sh
docker exec -ti lb_apac /bin/sh
docker-compose stop crdb-0
docker-compose stop crdb-0a
docker-compose stop crdb-0b
docker-compose stop crdb-1
docker-compose stop crdb-1a
docker-compose stop crdb-1b
docker-compose stop crdb-2
docker-compose stop crdb-2a
docker-compose stop crdb-2b
To do a demonstration of pinning data to certain cluster nodes, see this guide.