├── .gitignore
├── README.md
├── example-apache-druid
├── README.md
├── docker-compose.yml
├── down.sh
├── environment
├── prune.sh
└── up.sh
├── example-enterprise-backup
├── README.md
├── docker-compose.yml
├── down.sh
├── fileserver
│ ├── Dockerfile
│ └── nginx.conf
├── prune.sh
└── up.sh
├── example-haproxy-with-init
├── README.md
├── docker-compose.yml
├── down.sh
├── prune.sh
└── up.sh
├── example-haproxy-with-workload
├── README.md
├── docker-compose.yml
├── down.sh
├── prune.sh
└── up.sh
├── example-haproxy
├── README.md
├── docker-compose.yml
├── down.sh
├── prune.sh
└── up.sh
├── example-jeager
└── docker-compose.yml
├── example-netflix-genie
├── README.md
├── clean.sh
├── docker-compose.yml
├── down.sh
├── genie
│ ├── Dockerfile
│ └── application-crdb.yml
├── prune.sh
└── up.sh
├── example-nginx
├── README.md
├── docker-compose.yml
├── down.sh
├── nginx
│ ├── Dockerfile
│ └── nginx.conf
├── prune.sh
└── up.sh
├── example-oltpbench
├── README.md
├── docker-compose.yml
├── down.sh
├── oltp-bench
│ ├── Dockerfile
│ ├── crdb_tpcc_config.xml
│ ├── crdb_tpch_config.xml
│ ├── crdb_ycsb_config.xml
│ └── entrypoint.sh
├── prune.sh
└── up.sh
├── example-secure-nginx
├── README.md
├── docker-compose.yml
├── down.sh
├── nginx
│ ├── Dockerfile
│ └── nginx.conf
├── prune.sh
├── roach-cert
│ ├── Dockerfile
│ └── README.md
└── up.sh
├── example-secure
├── README.md
├── docker-compose.yml
├── down.sh
├── prune.sh
└── up.sh
├── example-single-node
├── README.md
└── docker-compose.yml
└── example-ycsb
├── README.md
├── docker-compose.yml
├── down.sh
├── prune.sh
├── up.sh
└── ycsb
├── Dockerfile
├── db.properties
├── entrypoint.sh
├── workload-a-cockroach
├── workload-b-cockroach
├── workload-c-cockroach
├── workload-d-cockroach
├── workload-e-cockroach
└── workload-f-cockroach
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 |
3 | .idea
4 |
5 | *.crt
6 | *.key
7 | *.pk8
8 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # CockroachDB Docker Examples
2 |
3 | ## Examples
4 | * [Single Node Example](example-single-node/README.md) - Single node CockroachDB instance
5 | * [NGINX Example](example-nginx/README.md) - Simple 3 node cluster with `NGINX` as the load balancer
6 | * [NGINX Example - Secure](example-secure-nginx/README.md) - A **secure** 3 node cluster with `NGINX` as the load balancer
7 | * [HAProxy Example](example-haproxy/README.md) - Simple 3 node cluster with `HAProxy` as the load balancer
8 | * [HAProxy Example - Secure](example-secure/README.md) - A **secure** 3 node cluster with `HAProxy` as the load balancer
9 | * [HAProxy Example with Workload](example-haproxy-with-workload/README.md) - Simple 3 node cluster with `HAProxy` as the load balancer and a `client` node running the `tpcc` workload
10 | * [Enterprise Backup Example](example-enterprise-backup/README.md) - CockroachDB Enterprise `BACKUP` to `NGINX` based "File Server"
11 | * [YCSB Functional Example](example-ycsb/README.md) - Building and running [YCSB](https://github.com/brianfrankcooper/YCSB) against a 3 node CockroachDB cluster
12 | * [OLTPBench Functional Example](example-oltpbench/README.md) - [DEPRECATED] Building and running a fork of [OLTPBench](https://github.com/timveil-cockroach/oltpbench) against a 3 node CockroachDB cluster
13 | * [Netflix Genie Metastore Example](example-netflix-genie) - Example using CockroachDB as the metastore for [Netflix Genie](https://github.com/Netflix/genie)
14 | * [Apache Druid Metastore Example](example-apache-druid) - Example using CockroachDB as the metastore for [Apache Druid](https://druid.apache.org/docs/latest/design/index.html)
15 |
16 |
17 | ## Useful commands
18 |
19 | ### Generate and Download Debug Archive
20 | Generate `debug.zip` file on `crdb-0`. For more details see https://www.cockroachlabs.com/docs/stable/debug-zip.html
21 | ```bash
22 | docker compose exec crdb-0 /cockroach/cockroach debug zip ./cockroach-data/logs/debug.zip --insecure
23 | ```
24 |
25 | Copy `debug.zip` from `crdb-0` to current local directory
26 | ```bash
27 | docker cp crdb-0:/cockroach/cockroach-data/logs/debug.zip .
28 | ```
29 |
30 | ### Prune Docker Images, etc.
31 | Prune all images matching label
32 | ```bash
33 | docker system prune -a -f --volumes --filter "label=maintainer=tjveil@gmail.com"
34 | ```
35 |
36 | Prune all images
37 | ```bash
38 | docker system prune -a -f --volumes
39 | ```
40 |
41 |
--------------------------------------------------------------------------------
/example-apache-druid/README.md:
--------------------------------------------------------------------------------
1 | # CockroachDB + Apache Druid
2 | A single node CRDB instance serving as the metadata store for Apache Druid instead of Postgres or MySQL.
3 |
4 | ## Services
5 | * `crdb` - CockroachDB node
6 | * `crdb-init` - Executes some commands against CockroachDB and shuts down. See [here](https://github.com/timveil-cockroach/cockroachdb-remote-client).
7 | * `zookeeper` - Apache Druid required service
8 | * `coordinator` - Apache Druid required service
9 | * `historical` - Apache Druid required service
10 | * `middlemanager` - Apache Druid required service
11 | * `router` - Apache Druid required service
12 |
13 | ## Getting started
14 | 1) run `docker compose up`
15 | 2) visit the CockroachDB UI @ http://localhost:8080
16 | 3) visit the Apache Druid UI @ http://localhost:8888
17 | 4) have fun!
--------------------------------------------------------------------------------
/example-apache-druid/docker-compose.yml:
--------------------------------------------------------------------------------
1 | #
2 | # Licensed to the Apache Software Foundation (ASF) under one
3 | # or more contributor license agreements. See the NOTICE file
4 | # distributed with this work for additional information
5 | # regarding copyright ownership. The ASF licenses this file
6 | # to you under the Apache License, Version 2.0 (the
7 | # "License"); you may not use this file except in compliance
8 | # with the License. You may obtain a copy of the License at
9 | #
10 | # http://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing,
13 | # software distributed under the License is distributed on an
14 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | # KIND, either express or implied. See the License for the
16 | # specific language governing permissions and limitations
17 | # under the License.
18 | #
19 | version: "2.2"
20 |
21 | volumes:
22 | metadata_data: {}
23 | middle_var: {}
24 | historical_var: {}
25 | broker_var: {}
26 | coordinator_var: {}
27 | router_var: {}
28 |
29 |
30 | services:
31 | crdb:
32 | container_name: crdb
33 | hostname: crdb
34 | image: cockroachdb/cockroach:latest
35 | command: start-single-node --cluster-name=example-single-node --logtostderr=WARNING --log-file-verbosity=WARNING --insecure
36 | ports:
37 | - "26257:26257"
38 | - "8080:8080"
39 |
40 | crdb-init:
41 | container_name: crdb-init
42 | hostname: crdb-init
43 | image: timveil/cockroachdb-remote-client:latest
44 | environment:
45 | - COCKROACH_HOST=crdb:26257
46 | - COCKROACH_INSECURE=true
47 | - DATABASE_NAME=druid
48 | depends_on:
49 | - crdb
50 |
51 | # Need 3.5 or later for container nodes
52 | zookeeper:
53 | container_name: zookeeper
54 | image: zookeeper:3.5
55 | environment:
56 | - ZOO_MY_ID=1
57 |
58 | coordinator:
59 | image: apache/druid:0.20.1
60 | container_name: coordinator
61 | volumes:
62 | - ./storage:/opt/data
63 | - coordinator_var:/opt/druid/var
64 | depends_on:
65 | - zookeeper
66 | - crdb
67 | ports:
68 | - "8081:8081"
69 | command:
70 | - coordinator
71 | env_file:
72 | - environment
73 |
74 | broker:
75 | image: apache/druid:0.20.1
76 | container_name: broker
77 | volumes:
78 | - broker_var:/opt/druid/var
79 | depends_on:
80 | - zookeeper
81 | - crdb
82 | - coordinator
83 | ports:
84 | - "8082:8082"
85 | command:
86 | - broker
87 | env_file:
88 | - environment
89 |
90 | historical:
91 | image: apache/druid:0.20.1
92 | container_name: historical
93 | volumes:
94 | - ./storage:/opt/data
95 | - historical_var:/opt/druid/var
96 | depends_on:
97 | - zookeeper
98 | - crdb
99 | - coordinator
100 | ports:
101 | - "8083:8083"
102 | command:
103 | - historical
104 | env_file:
105 | - environment
106 |
107 | middlemanager:
108 | image: apache/druid:0.20.1
109 | container_name: middlemanager
110 | volumes:
111 | - ./storage:/opt/data
112 | - middle_var:/opt/druid/var
113 | depends_on:
114 | - zookeeper
115 | - crdb
116 | - coordinator
117 | ports:
118 | - "8091:8091"
119 | command:
120 | - middleManager
121 | env_file:
122 | - environment
123 |
124 | router:
125 | image: apache/druid:0.20.1
126 | container_name: router
127 | volumes:
128 | - router_var:/opt/druid/var
129 | depends_on:
130 | - zookeeper
131 | - crdb
132 | - coordinator
133 | ports:
134 | - "8888:8888"
135 | command:
136 | - router
137 | env_file:
138 | - environment
139 |
--------------------------------------------------------------------------------
/example-apache-druid/down.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | docker compose down --remove-orphans --volumes
--------------------------------------------------------------------------------
/example-apache-druid/environment:
--------------------------------------------------------------------------------
1 | #
2 | # Licensed to the Apache Software Foundation (ASF) under one
3 | # or more contributor license agreements. See the NOTICE file
4 | # distributed with this work for additional information
5 | # regarding copyright ownership. The ASF licenses this file
6 | # to you under the Apache License, Version 2.0 (the
7 | # "License"); you may not use this file except in compliance
8 | # with the License. You may obtain a copy of the License at
9 | #
10 | # http://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing,
13 | # software distributed under the License is distributed on an
14 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | # KIND, either express or implied. See the License for the
16 | # specific language governing permissions and limitations
17 | # under the License.
18 | #
19 |
20 | # Java tuning
21 | DRUID_XMX=1g
22 | DRUID_XMS=1g
23 | DRUID_MAXNEWSIZE=250m
24 | DRUID_NEWSIZE=250m
25 | DRUID_MAXDIRECTMEMORYSIZE=6172m
26 |
27 | druid_emitter_logging_logLevel=debug
28 |
29 | druid_extensions_loadList=["druid-histogram", "druid-datasketches", "druid-lookups-cached-global", "postgresql-metadata-storage"]
30 |
31 | druid_zk_service_host=zookeeper
32 |
33 | druid_metadata_storage_host=
34 | druid_metadata_storage_type=postgresql
35 | druid_metadata_storage_connector_connectURI=jdbc:postgresql://crdb:26257/druid
36 | druid_metadata_storage_connector_user=root
37 |
38 | druid_coordinator_balancer_strategy=cachingCost
39 |
40 | druid_indexer_runner_javaOptsArray=["-server", "-Xmx1g", "-Xms1g", "-XX:MaxDirectMemorySize=3g", "-Duser.timezone=UTC", "-Dfile.encoding=UTF-8", "-Djava.util.logging.manager=org.apache.logging.log4j.jul.LogManager"]
41 | druid_indexer_fork_property_druid_processing_buffer_sizeBytes=268435456
42 |
43 | druid_storage_type=local
44 | druid_storage_storageDirectory=/opt/data/segments
45 | druid_indexer_logs_type=file
46 | druid_indexer_logs_directory=/opt/data/indexing-logs
47 |
48 | druid_processing_numThreads=2
49 | druid_processing_numMergeBuffers=2
50 |
51 | DRUID_LOG4J=
52 |
--------------------------------------------------------------------------------
/example-apache-druid/prune.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | docker system prune -a -f --volumes
--------------------------------------------------------------------------------
/example-apache-druid/up.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | docker compose up -d
--------------------------------------------------------------------------------
/example-enterprise-backup/README.md:
--------------------------------------------------------------------------------
1 | # Enterprise Backup with NGINX File Server
2 | Demonstrates backing up a 3 node cluster to a remote file server using NGINX. The relevant documentation can be found here:
3 |
4 | * https://www.cockroachlabs.com/docs/stable/backup-and-restore.html
5 | * https://www.cockroachlabs.com/docs/stable/backup.html
6 | * https://www.cockroachlabs.com/docs/stable/create-a-file-server.html
7 |
8 | ## Services
9 | * `crdb-0` - CockroachDB node
10 | * `crdb-1` - CockroachDB node
11 | * `crdb-2` - CockroachDB node
12 | * `lb` - HAProxy acting as load balancer
13 | * `fileserver` - NGINX acting as remote file server
14 |
15 | ## Getting started
16 | 1) because operation order is important, execute `./up.sh CRDB_ORG CRDB_LICENSE_KEY` instead of `docker compose up` where `CRDB_ORG` is your CockroachDB Enterprise License Organization and `CRDB_LICENSE_KEY` is your CockroachDB Enterprise License Key.
17 | 2) visit the CockroachDB UI @ http://localhost:8080
18 | 3) visit the HAProxy UI @ http://localhost:8081
19 | 4) run the following command to view the contents of the `backup` directory... `docker exec -t fileserver ls -la /mnt/cockroach-backups/bank-backup`
20 |
21 | ## Helpful Commands
22 |
23 | ### Open Interactive Shells
24 | ```bash
25 | docker compose exec crdb-0 /bin/bash
26 | docker compose exec crdb-1 /bin/bash
27 | docker compose exec crdb-2 /bin/bash
28 | docker compose exec lb /bin/sh
29 | docker compose exec fileserver /bin/sh
30 | ```
--------------------------------------------------------------------------------
/example-enterprise-backup/docker-compose.yml:
--------------------------------------------------------------------------------
1 | version: '3.8'
2 |
3 | volumes:
4 | backup:
5 |
6 | services:
7 |
8 | crdb-0:
9 | container_name: crdb-0
10 | hostname: crdb-0
11 | image: cockroachdb/cockroach:latest
12 | command: start --cluster-name=example-enterprise-backup --logtostderr=WARNING --log-file-verbosity=WARNING --insecure --join=crdb-0
13 |
14 | crdb-1:
15 | container_name: crdb-1
16 | hostname: crdb-1
17 | image: cockroachdb/cockroach:latest
18 | command: start --cluster-name=example-enterprise-backup --logtostderr=WARNING --log-file-verbosity=WARNING --insecure --join=crdb-0
19 | depends_on:
20 | - crdb-0
21 |
22 | crdb-2:
23 | container_name: crdb-2
24 | hostname: crdb-2
25 | image: cockroachdb/cockroach:latest
26 | command: start --cluster-name=example-enterprise-backup --logtostderr=WARNING --log-file-verbosity=WARNING --insecure --join=crdb-0
27 | depends_on:
28 | - crdb-0
29 |
30 | lb:
31 | container_name: lb
32 | hostname: lb
33 | image: timveil/dynamic-haproxy:latest
34 | ports:
35 | - "26257:26257"
36 | - "8080:8080"
37 | - "8081:8081"
38 | environment:
39 | - NODES=crdb-0 crdb-1 crdb-2
40 | depends_on:
41 | - crdb-0
42 | - crdb-1
43 | - crdb-2
44 |
45 | crdb-init:
46 | container_name: crdb-init
47 | hostname: crdb-init
48 | image: timveil/cockroachdb-remote-client:latest
49 | environment:
50 | - COCKROACH_HOST=crdb-0:26257
51 | - COCKROACH_INSECURE=true
52 | - COCKROACH_INIT=true
53 | - DATABASE_NAME=test
54 | depends_on:
55 | - lb
56 |
57 | fileserver:
58 | container_name: fileserver
59 | hostname: fileserver
60 | build: fileserver
61 | volumes:
62 | - backup:/mnt/cockroach-backups
63 | ports:
64 | - "20150:20150"
65 |
--------------------------------------------------------------------------------
/example-enterprise-backup/down.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | docker compose down --remove-orphans --volumes
--------------------------------------------------------------------------------
/example-enterprise-backup/fileserver/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM nginx:alpine
2 |
3 | LABEL maintainer="tjveil@gmail.com"
4 |
5 | COPY nginx.conf /etc/nginx/nginx.conf
6 |
7 | RUN mkdir -p /mnt/cockroach-backups/bank-backup
8 | RUN chmod -R 777 /mnt/cockroach-backups
9 |
10 | EXPOSE 20150
11 |
12 | CMD ["nginx", "-g", "daemon off;"]
--------------------------------------------------------------------------------
/example-enterprise-backup/fileserver/nginx.conf:
--------------------------------------------------------------------------------
1 | events { worker_connections 4096; }
2 |
3 | http {
4 |
5 | server {
6 | listen 20150;
7 |
8 | location / {
9 | dav_methods PUT DELETE;
10 | root /mnt/cockroach-backups;
11 | sendfile on;
12 | client_max_body_size 128m;
13 | }
14 |
15 | }
16 |
17 | }
--------------------------------------------------------------------------------
/example-enterprise-backup/prune.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | docker system prune -a -f --volumes
--------------------------------------------------------------------------------
/example-enterprise-backup/up.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | CRDB_ORG=$1
4 | CRDB_LICENSE_KEY=$2
5 |
6 | if [[ -z "$CRDB_ORG" ]]; then
7 | echo "Must provide CRDB_ORG as the first parameter. Example './up.sh CRDB_ORG CRDB_LICENSE_KEY'." 1>&2
8 | exit 1
9 | fi
10 |
11 | if [[ -z "$CRDB_LICENSE_KEY" ]]; then
12 | echo "Must provide CRDB_LICENSE_KEY as the second parameter. Example './up.sh CRDB_ORG CRDB_LICENSE_KEY'." 1>&2
13 | exit 1
14 | fi
15 |
16 | docker compose build --no-cache
17 | docker compose up -d
18 |
19 | echo "waiting for cluster to come up..."
20 | sleep 20
21 |
22 | echo "configuring cluster and database with cluster.organization = ${CRDB_ORG} and enterprise.license = ${CRDB_LICENSE_KEY}"
23 | docker compose exec crdb-0 /cockroach/cockroach sql --insecure --execute="SET CLUSTER SETTING cluster.organization = '${CRDB_ORG}';"
24 | docker compose exec crdb-0 /cockroach/cockroach sql --insecure --execute="SET CLUSTER SETTING enterprise.license = '${CRDB_LICENSE_KEY}';"
25 |
26 | echo "executing workload to generate tables and data..."
27 | docker compose exec crdb-0 /cockroach/cockroach workload init bank 'postgresql://root@localhost:26257?sslmode=disable'
28 | docker compose exec crdb-0 /cockroach/cockroach workload run bank --duration=1m 'postgresql://root@localhost:26257?sslmode=disable'
29 |
30 | echo "waiting before executing backup..."
31 | sleep 20
32 |
33 | echo "executing backup..."
34 | docker compose exec crdb-0 /cockroach/cockroach sql --insecure --execute="BACKUP DATABASE bank TO 'http://fileserver:20150/bank-backup' AS OF SYSTEM TIME '-10s';"
35 |
--------------------------------------------------------------------------------
/example-haproxy-with-init/README.md:
--------------------------------------------------------------------------------
1 | # Basic CockroachDB Cluster with HAProxy + init
2 | Simple 3 node CockroachDB cluster with HAProxy acting as load balancer. Unlike other examples that use `start-single-node` on the first node to initialize the cluster, this example uses `crdb-init` to execute the `init` command against the CockroachDB cluster.
3 |
4 | ## Services
5 | * `crdb-0` - CockroachDB node
6 | * `crdb-1` - CockroachDB node
7 | * `crdb-2` - CockroachDB node
8 | * `lb` - HAProxy acting as load balancer
9 | * `crdb-init` - Executes some commands against CockroachDB and shuts down. See [here](https://github.com/timveil-cockroach/cockroachdb-remote-client).
10 |
11 | ## Getting started
12 | 1) run `docker compose up`
13 | 2) visit the CockroachDB UI @ http://localhost:8080
14 | 3) visit the HAProxy UI @ http://localhost:8081
15 | 4) have fun!
16 |
17 | ## Helpful Commands
18 |
19 | ### Execute SQL
20 | Use the following to execute arbitrary SQL on the CockroachDB cluster. The following creates a database called `test`.
21 | ```bash
22 | docker compose exec crdb-0 /cockroach/cockroach sql --insecure --execute="CREATE DATABASE test;"
23 | ```
24 |
25 | ### Initialize and Run the TPC-C Workload
26 | Use the following commands to initialize and run the `tpcc` sample `workload`. For more details see [this](https://www.cockroachlabs.com/docs/stable/cockroach-workload.html#run-the-tpcc-workload).
27 |
28 | to initialize...
29 | ```bash
30 | docker compose exec crdb-0 /cockroach/cockroach workload init tpcc "postgresql://root@localhost:26257?sslmode=disable"
31 | ```
32 |
33 | to run for `10m`...
34 | ```bash
35 | docker compose exec crdb-0 /cockroach/cockroach workload run tpcc --duration=10m "postgresql://root@localhost:26257?sslmode=disable"
36 | ```
37 |
38 | ### Open Interactive Shells
39 | ```bash
40 | docker compose exec crdb-0 /bin/bash
41 | docker compose exec crdb-1 /bin/bash
42 | docker compose exec crdb-2 /bin/bash
43 | docker compose exec lb /bin/sh
44 | ```
45 |
46 | ### Stop Individual nodes
47 | ```bash
48 | docker compose stop crdb-0
49 | docker compose stop crdb-1
50 | docker compose stop crdb-2
51 | ```
52 |
--------------------------------------------------------------------------------
/example-haproxy-with-init/docker-compose.yml:
--------------------------------------------------------------------------------
1 | version: '3.8'
2 |
3 | services:
4 |
5 | crdb-0:
6 | container_name: crdb-0
7 | hostname: crdb-0
8 | image: cockroachdb/cockroach:latest
9 | command: start --cluster-name=example-haproxy-with-init --logtostderr=WARNING --log-file-verbosity=WARNING --insecure --join=crdb-0
10 |
11 | crdb-1:
12 | container_name: crdb-1
13 | hostname: crdb-1
14 | image: cockroachdb/cockroach:latest
15 | command: start --cluster-name=example-haproxy-with-init --logtostderr=WARNING --log-file-verbosity=WARNING --insecure --join=crdb-0
16 | depends_on:
17 | - crdb-0
18 |
19 | crdb-2:
20 | container_name: crdb-2
21 | hostname: crdb-2
22 | image: cockroachdb/cockroach:latest
23 | command: start --cluster-name=example-haproxy-with-init --logtostderr=WARNING --log-file-verbosity=WARNING --insecure --join=crdb-0
24 | depends_on:
25 | - crdb-0
26 |
27 | lb:
28 | container_name: lb
29 | hostname: lb
30 | image: timveil/dynamic-haproxy:latest
31 | ports:
32 | - "26257:26257"
33 | - "8080:8080"
34 | - "8081:8081"
35 | environment:
36 | - NODES=crdb-0 crdb-1 crdb-2
37 | depends_on:
38 | - crdb-0
39 | - crdb-1
40 | - crdb-2
41 |
42 | crdb-init:
43 | container_name: crdb-init
44 | hostname: crdb-init
45 | image: timveil/cockroachdb-remote-client:latest
46 | environment:
47 | - COCKROACH_HOST=crdb-0:26257
48 | - COCKROACH_INSECURE=true
49 | - COCKROACH_INIT=true
50 | - DATABASE_NAME=test
51 | depends_on:
52 | - lb
--------------------------------------------------------------------------------
/example-haproxy-with-init/down.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | docker compose down --remove-orphans --volumes
--------------------------------------------------------------------------------
/example-haproxy-with-init/prune.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | docker system prune -a -f --volumes
--------------------------------------------------------------------------------
/example-haproxy-with-init/up.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | docker compose up -d
--------------------------------------------------------------------------------
/example-haproxy-with-workload/README.md:
--------------------------------------------------------------------------------
1 | # Basic CockroachDB Cluster with HAProxy
2 | Simple 3 node CockroachDB cluster with HAProxy acting as load balancer
3 |
4 | ## Services
5 | * `crdb-0` - CockroachDB node
6 | * `crdb-1` - CockroachDB node
7 | * `crdb-2` - CockroachDB node
8 | * `workload-client` - CockroachDB node serving as the `workload` client
9 | * `lb` - HAProxy acting as load balancer
10 |
11 | ## Getting started
12 | 1) run `./up.sh`
13 | 2) visit the CockroachDB UI @ http://localhost:8080
14 | 3) visit the HAProxy UI @ http://localhost:8081
15 | 4) have fun!
16 |
17 | ## Helpful Commands
18 |
19 | ### Run the TPC-C Workload
20 | While `.up.sh` will automatically initialize and run the `tpcc` workload, you can use the following command to restart the `tpcc` sample `workload` for 10 minutes. For more details see [this](https://www.cockroachlabs.com/docs/stable/cockroach-workload.html#run-the-tpcc-workload).
21 |
22 | ```bash
23 | docker compose exec workload-client /cockroach/cockroach workload run tpcc --tolerate-errors --warehouses=3 --duration=10m "postgresql://root@lb:26257?sslmode=disable"
24 | ```
25 |
26 | ### Open Interactive Shells
27 | ```bash
28 | docker compose exec crdb-0 /bin/bash
29 | docker compose exec crdb-1 /bin/bash
30 | docker compose exec crdb-2 /bin/bash
31 | docker compose exec workload-client /bin/bash
32 | docker compose exec lb /bin/sh
33 | ```
34 |
35 | ### Stop Individual nodes
36 | ```bash
37 | docker compose stop crdb-0
38 | docker compose stop crdb-1
39 | docker compose stop crdb-2
40 | ```
--------------------------------------------------------------------------------
/example-haproxy-with-workload/docker-compose.yml:
--------------------------------------------------------------------------------
1 | version: '3.8'
2 |
3 | services:
4 |
5 | crdb-0:
6 | container_name: crdb-0
7 | hostname: crdb-0
8 | image: cockroachdb/cockroach:latest
9 | command: start --cluster-name=example-haproxy-with-workload --logtostderr=WARNING --log-file-verbosity=WARNING --insecure --join=crdb-0
10 |
11 | crdb-1:
12 | container_name: crdb-1
13 | hostname: crdb-1
14 | image: cockroachdb/cockroach:latest
15 | command: start --cluster-name=example-haproxy-with-workload --logtostderr=WARNING --log-file-verbosity=WARNING --insecure --join=crdb-0
16 | depends_on:
17 | - crdb-0
18 |
19 | crdb-2:
20 | container_name: crdb-2
21 | hostname: crdb-2
22 | image: cockroachdb/cockroach:latest
23 | command: start --cluster-name=example-haproxy-with-workload --logtostderr=WARNING --log-file-verbosity=WARNING --insecure --join=crdb-0
24 | depends_on:
25 | - crdb-0
26 |
27 | lb:
28 | container_name: lb
29 | hostname: lb
30 | image: timveil/dynamic-haproxy:latest
31 | ports:
32 | - "26257:26257"
33 | - "8080:8080"
34 | - "8081:8081"
35 | environment:
36 | - NODES=crdb-0 crdb-1 crdb-2
37 | depends_on:
38 | - crdb-0
39 | - crdb-1
40 | - crdb-2
41 |
42 | crdb-init:
43 | container_name: crdb-init
44 | hostname: crdb-init
45 | image: timveil/cockroachdb-remote-client:latest
46 | environment:
47 | - COCKROACH_HOST=crdb-0:26257
48 | - COCKROACH_INSECURE=true
49 | - COCKROACH_INIT=true
50 | depends_on:
51 | - lb
52 |
53 | workload-client:
54 | container_name: workload-client
55 | hostname: workload-client
56 | image: cockroachdb/cockroach:latest
57 | entrypoint: ["tail", "-f", "/dev/null"]
58 | depends_on:
59 | - crdb-init
--------------------------------------------------------------------------------
/example-haproxy-with-workload/down.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | docker compose down --remove-orphans --volumes
--------------------------------------------------------------------------------
/example-haproxy-with-workload/prune.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | docker system prune -a -f --volumes
--------------------------------------------------------------------------------
/example-haproxy-with-workload/up.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | docker compose build --no-cache
4 |
5 | docker compose up -d
6 |
7 | sleep 30
8 |
9 | docker compose exec workload-client /cockroach/cockroach workload init --warehouses=1 tpcc "postgresql://root@lb:26257?sslmode=disable"
10 |
11 | sleep 10
12 |
13 | docker compose exec workload-client /cockroach/cockroach workload run --warehouses=1 tpcc --tolerate-errors --duration=30m "postgresql://root@lb:26257?sslmode=disable"
14 |
--------------------------------------------------------------------------------
/example-haproxy/README.md:
--------------------------------------------------------------------------------
1 | # Basic CockroachDB Cluster with HAProxy
2 | Simple 3 node CockroachDB cluster with HAProxy acting as load balancer
3 |
4 | ## Services
5 | * `crdb-0` - CockroachDB node
6 | * `crdb-1` - CockroachDB node
7 | * `crdb-2` - CockroachDB node
8 | * `lb` - HAProxy acting as load balancer
9 | * `crdb-init` - Executes some commands against CockroachDB and shuts down. See [here](https://github.com/timveil-cockroach/cockroachdb-remote-client).
10 |
11 | ## Getting started
12 | 1) run `docker compose up`
13 | 2) visit the CockroachDB UI @ http://localhost:8080
14 | 3) visit the HAProxy UI @ http://localhost:8081
15 | 4) have fun!
16 |
17 | ## Helpful Commands
18 |
19 | ### Execute SQL
20 | Use the following to execute arbitrary SQL on the CockroachDB cluster. The following creates a database called `test`.
21 | ```bash
22 | docker compose exec crdb-0 /cockroach/cockroach sql --insecure --execute="CREATE DATABASE test;"
23 | ```
24 |
25 | ### Initialize and Run the TPC-C Workload
26 | Use the following commands to initialize and run the `tpcc` sample `workload`. For more details see [this](https://www.cockroachlabs.com/docs/stable/cockroach-workload.html#run-the-tpcc-workload).
27 |
28 | to initialize...
29 | ```bash
30 | docker compose exec crdb-0 /cockroach/cockroach workload init tpcc "postgresql://root@localhost:26257?sslmode=disable"
31 | ```
32 |
33 | to run for `10m`...
34 | ```bash
35 | docker compose exec crdb-0 /cockroach/cockroach workload run tpcc --duration=10m "postgresql://root@localhost:26257?sslmode=disable"
36 | ```
37 |
38 | ### Open Interactive Shells
39 | ```bash
40 | docker compose exec crdb-0 /bin/bash
41 | docker compose exec crdb-1 /bin/bash
42 | docker compose exec crdb-2 /bin/bash
43 | docker compose exec lb /bin/sh
44 | ```
45 |
46 | ### Stop Individual nodes
47 | ```bash
48 | docker compose stop crdb-0
49 | docker compose stop crdb-1
50 | docker compose stop crdb-2
51 | ```
--------------------------------------------------------------------------------
/example-haproxy/docker-compose.yml:
--------------------------------------------------------------------------------
1 | version: '3.8'
2 |
3 | services:
4 |
5 | crdb-0:
6 | container_name: crdb-0
7 | hostname: crdb-0
8 | image: cockroachdb/cockroach:latest
9 | command: start --cluster-name=example-haproxy --logtostderr=WARNING --log-file-verbosity=WARNING --insecure --join=crdb-0
10 |
11 | crdb-1:
12 | container_name: crdb-1
13 | hostname: crdb-1
14 | image: cockroachdb/cockroach:latest
15 | command: start --cluster-name=example-haproxy --logtostderr=WARNING --log-file-verbosity=WARNING --insecure --join=crdb-0
16 | depends_on:
17 | - crdb-0
18 |
19 | crdb-2:
20 | container_name: crdb-2
21 | hostname: crdb-2
22 | image: cockroachdb/cockroach:latest
23 | command: start --cluster-name=example-haproxy --logtostderr=WARNING --log-file-verbosity=WARNING --insecure --join=crdb-0
24 | depends_on:
25 | - crdb-0
26 |
27 | lb:
28 | container_name: lb
29 | hostname: lb
30 | image: timveil/dynamic-haproxy:latest
31 | ports:
32 | - "26257:26257"
33 | - "8080:8080"
34 | - "8081:8081"
35 | environment:
36 | - NODES=crdb-0 crdb-1 crdb-2
37 | depends_on:
38 | - crdb-0
39 | - crdb-1
40 | - crdb-2
41 |
42 | crdb-init:
43 | container_name: crdb-init
44 | hostname: crdb-init
45 | image: timveil/cockroachdb-remote-client:latest
46 | environment:
47 | - COCKROACH_HOST=crdb-0:26257
48 | - COCKROACH_INSECURE=true
49 | - COCKROACH_INIT=true
50 | - DATABASE_NAME=test
51 | depends_on:
52 | - lb
--------------------------------------------------------------------------------
/example-haproxy/down.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | docker compose down --remove-orphans --volumes
--------------------------------------------------------------------------------
/example-haproxy/prune.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | docker system prune -a -f --volumes
--------------------------------------------------------------------------------
/example-haproxy/up.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | docker compose up -d
--------------------------------------------------------------------------------
/example-jeager/docker-compose.yml:
--------------------------------------------------------------------------------
1 | version: "2"
2 |
3 | services:
4 | crdb:
5 | container_name: crdb
6 | hostname: crdb
7 | image: cockroachdb/cockroach:latest
8 | command: start-single-node --cluster-name=example-single-node --logtostderr=WARNING --log-file-verbosity=WARNING --insecure
9 | ports:
10 | - "26257:26257"
11 | - "8081:8080"
12 |
13 | crdb-init:
14 | container_name: crdb-init
15 | hostname: crdb-init
16 | image: timveil/cockroachdb-remote-client:latest
17 | environment:
18 | - COCKROACH_HOST=crdb:26257
19 | - COCKROACH_INSECURE=true
20 | - DATABASE_NAME=genie
21 | depends_on:
22 | - crdb
23 |
24 | jeager:
25 | container_name: jeager
26 | hostname: jeager
27 | image: jaegertracing/all-in-one:latest
28 | ports:
29 | - "16686:16686"
30 | depends_on:
31 | - crdb
--------------------------------------------------------------------------------
/example-netflix-genie/README.md:
--------------------------------------------------------------------------------
1 | # Running Netflix Genie with CockroachDB
2 | Single node CockroachDB instance running as the metastore for [Netflix Genie](https://github.com/Netflix/genie)
3 |
4 | ## Services
5 | * `crdb` - CockroachDB node
6 | * `crdb-init` - ephemeral CockroachDB node used to create database
7 | * `genie` - Genie app instance
8 |
9 | ## Testing
10 | 1) run `./up.sh`
11 | 2) from a local shell run the following to test...
12 | ```
13 | curl 'http://localhost:8080/api/v3/applications' -i -X POST -H 'Content-Type: application/json; charset=UTF-8' -d '{
14 | "id" : null,
15 | "created" : null,
16 | "updated" : null,
17 | "version" : "1.5.1",
18 | "user" : "genie",
19 | "name" : "spark",
20 | "description" : "Spark for Genie",
21 | "metadata" : { "hi": "bye" },
22 | "tags" : [ "type:spark", "ver:1.5.1" ],
23 | "configs" : [ "s3://mybucket/spark/1.5.1/spark-env.sh" ],
24 | "dependencies" : [ "s3://mybucket/spark/1.5.1/spark.tar.gz" ],
25 | "setupFile" : "s3://mybucket/spark/1.5.1/setupBase-spark.sh",
26 | "status" : "ACTIVE",
27 | "type" : "spark"
28 | }'
29 | ```
30 |
31 | ## Helpful Commands
32 |
33 | ### Open Interactive Shells
34 | ```bash
35 | docker compose exec crdb /bin/bash
36 | docker compose exec genie /bin/bash
37 | ```
38 |
39 |
40 |
--------------------------------------------------------------------------------
/example-netflix-genie/clean.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | docker rmi example-netflix-genie_genie
4 |
5 | docker rmi -f $(docker images -a -q "netflixoss/*")
6 |
--------------------------------------------------------------------------------
/example-netflix-genie/docker-compose.yml:
--------------------------------------------------------------------------------
1 | version: "2"
2 |
3 | services:
4 | crdb:
5 | container_name: crdb
6 | hostname: crdb
7 | image: cockroachdb/cockroach:latest
8 | command: start-single-node --cluster-name=example-single-node --logtostderr=WARNING --log-file-verbosity=WARNING --insecure
9 | ports:
10 | - "26257:26257"
11 | - "8081:8080"
12 |
13 | crdb-init:
14 | container_name: crdb-init
15 | hostname: crdb-init
16 | image: timveil/cockroachdb-remote-client:latest
17 | environment:
18 | - COCKROACH_HOST=crdb:26257
19 | - COCKROACH_INSECURE=true
20 | - DATABASE_NAME=genie
21 | depends_on:
22 | - crdb
23 |
24 | genie:
25 | build: genie
26 | ports:
27 | - "8080:8080"
28 | depends_on:
29 | - crdb
30 | tty: true
31 | container_name: genie
32 | hostname: genie
--------------------------------------------------------------------------------
/example-netflix-genie/down.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | docker compose down --remove-orphans --volumes
--------------------------------------------------------------------------------
/example-netflix-genie/genie/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM netflixoss/genie-app:latest.candidate
2 |
3 | LABEL maintainer="tjveil@gmail.com"
4 |
5 | COPY application-crdb.yml /usr/local/bin/application-crdb.yml
6 |
7 | EXPOSE 8080
8 |
9 | WORKDIR /usr/local/bin
10 |
11 | ENTRYPOINT ["java", \
12 | "-Djava.security.egd=file:/dev/./urandom", \
13 | "-Dgenie.agent.launcher.local.agent-jar-path=genie-agent.jar", \
14 | "-Dgenie.jobs.agent-execution.agent-probability=1.0", \
15 | "-jar", \
16 | "genie-server.jar", \
17 | "--spring.profiles.active=crdb" \
18 | ]
19 |
20 |
--------------------------------------------------------------------------------
/example-netflix-genie/genie/application-crdb.yml:
--------------------------------------------------------------------------------
1 | ##
2 | #
3 | # Copyright 2016 Netflix, Inc.
4 | #
5 | # Licensed under the Apache License, Version 2.0 (the "License");
6 | # you may not use this file except in compliance with the License.
7 | # You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing, software
12 | # distributed under the License is distributed on an "AS IS" BASIS,
13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | # See the License for the specific language governing permissions and
15 | # limitations under the License.
16 | #
17 | ##
18 |
19 | spring:
20 |
21 | flyway:
22 | enabled: false
23 | locations: classpath:db/migration/postgresql
24 |
25 | datasource:
26 | platform: postgresql
27 | url: jdbc:postgresql://crdb:26257/genie?sslmode=disable&ApplicationName=genie&reWriteBatchedInserts=true
28 | username: root
29 | password:
30 |
31 | jpa:
32 | properties:
33 | hibernate:
34 | dialect: org.hibernate.dialect.CockroachDB201Dialect
35 | hibernate:
36 | ddl-auto: create
37 |
38 | profiles:
39 | active: crdb
40 |
41 |
--------------------------------------------------------------------------------
/example-netflix-genie/prune.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | docker system prune -a -f --volumes
--------------------------------------------------------------------------------
/example-netflix-genie/up.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | docker compose build --no-cache
4 | docker compose up -d
--------------------------------------------------------------------------------
/example-nginx/README.md:
--------------------------------------------------------------------------------
1 | # Basic CockroachDB Cluster with NGINX
2 | Simple 3 node CockroachDB cluster with NGINX acting as load balancer
3 |
4 | ## Services
5 | * `crdb-0` - CockroachDB node
6 | * `crdb-1` - CockroachDB node
7 | * `crdb-2` - CockroachDB node
8 | * `lb` - NGINX acting as load balancer
9 |
10 | ## Getting started
11 | 1) run `docker compose up`
12 | 2) visit the CockroachDB UI @ http://localhost:8080
13 | 3) have fun!
14 |
15 | ## Helpful Commands
16 |
17 | ### Execute SQL
18 | Use the following to execute arbitrary SQL on the CockroachDB cluster. The following creates a database called `test`.
19 | ```bash
20 | docker compose exec crdb-0 /cockroach/cockroach sql --insecure --execute="CREATE DATABASE test;"
21 | ```
22 |
23 | ### Open Interactive Shells
24 | ```bash
25 | docker compose exec crdb-0 /bin/bash
26 | docker compose exec crdb-1 /bin/bash
27 | docker compose exec crdb-2 /bin/bash
28 | docker compose exec lb /bin/bash
29 | ```
--------------------------------------------------------------------------------
/example-nginx/docker-compose.yml:
--------------------------------------------------------------------------------
1 | version: '3.8'
2 |
3 | services:
4 |
5 | crdb-0:
6 | container_name: crdb-0
7 | hostname: crdb-0
8 | image: cockroachdb/cockroach:latest
9 | command: start --cluster-name=example-nginx --logtostderr=WARNING --log-file-verbosity=WARNING --insecure --join=crdb-0
10 |
11 | crdb-1:
12 | container_name: crdb-1
13 | hostname: crdb-1
14 | image: cockroachdb/cockroach:latest
15 | command: start --cluster-name=example-nginx --logtostderr=WARNING --log-file-verbosity=WARNING --insecure --join=crdb-0
16 | depends_on:
17 | - crdb-0
18 |
19 | crdb-2:
20 | container_name: crdb-2
21 | hostname: crdb-2
22 | image: cockroachdb/cockroach:latest
23 | command: start --cluster-name=example-nginx --logtostderr=WARNING --log-file-verbosity=WARNING --insecure --join=crdb-0
24 | depends_on:
25 | - crdb-0
26 |
27 | lb:
28 | container_name: lb
29 | hostname: lb
30 | build: ./nginx
31 | ports:
32 | - "26257:26257"
33 | - "8080:8080"
34 | depends_on:
35 | - crdb-0
36 | - crdb-1
37 | - crdb-2
38 |
39 | crdb-init:
40 | container_name: crdb-init
41 | hostname: crdb-init
42 | image: timveil/cockroachdb-remote-client:latest
43 | environment:
44 | - COCKROACH_HOST=crdb-0:26257
45 | - COCKROACH_INSECURE=true
46 | - COCKROACH_INIT=true
47 | - DATABASE_NAME=test
48 | depends_on:
49 | - lb
--------------------------------------------------------------------------------
/example-nginx/down.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | docker compose down --remove-orphans --volumes
--------------------------------------------------------------------------------
/example-nginx/nginx/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM nginx:alpine
2 |
3 | LABEL maintainer="tjveil@gmail.com"
4 |
5 | COPY nginx.conf /etc/nginx/nginx.conf
6 |
7 | EXPOSE 26257
8 | EXPOSE 8080
9 |
10 | CMD ["nginx", "-g", "daemon off;"]
--------------------------------------------------------------------------------
/example-nginx/nginx/nginx.conf:
--------------------------------------------------------------------------------
1 | events { worker_connections 4096; }
2 |
3 | stream {
4 |
5 | upstream crdb-backend {
6 | server crdb-0:26257;
7 | server crdb-1:26257;
8 | server crdb-2:26257;
9 | }
10 |
11 | server {
12 | listen 26257;
13 | proxy_pass crdb-backend;
14 | }
15 |
16 | upstream crdb-ui {
17 | server crdb-0:8080;
18 | server crdb-1:8080;
19 | server crdb-2:8080;
20 | }
21 |
22 | server {
23 | listen 8080;
24 | proxy_pass crdb-ui;
25 | }
26 |
27 |
28 | }
--------------------------------------------------------------------------------
/example-nginx/prune.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | docker system prune -a -f --volumes
--------------------------------------------------------------------------------
/example-nginx/up.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | docker compose build --no-cache
4 | docker compose up -d
--------------------------------------------------------------------------------
/example-oltpbench/README.md:
--------------------------------------------------------------------------------
1 | # Running OLTP-Bench Suite Fork (DEPRECATED)
2 |
3 | > This example is deprecated as OLTP-Bench is no longer active. Please see [Benchbase](https://github.com/cmu-db/benchbase) instead.
4 |
5 | Demonstrates building and executing a fork of the `OLTP-Bench` suite against a 3 node CockroachDB cluster. More information on the `OLTP-Bench` fork can be found here: https://github.com/timveil-cockroach/oltpbench.
6 |
7 | > This is included here as a functional example. This configuration should not be considered the basis for a performance evaluation.
8 |
9 | ## Services
10 | * `crdb-0` - CockroachDB node
11 | * `crdb-1` - CockroachDB node
12 | * `crdb-2` - CockroachDB node
13 | * `lb` - HAProxy acting as load balancer
14 | * `oltp-bench` - `OLTP-Bench` client container responsible for executing benchmark workloads
15 |
16 | ## Getting started
17 | 1) because operation order is important, execute `./up.sh` instead of `docker compose up`
18 | 2) visit the CockroachDB UI @ http://localhost:8080
19 | 3) visit the HAProxy UI @ http://localhost:8081
20 | 4) have fun!
21 |
22 | ## Basic Configuration
23 | The following `environment` variables in `docker-compose.yml` control workload execution...
24 | * `BENCHMARK_NAME` - The name of the workload to run. The default value is `tpcc`.
25 | * Supported Values:
26 | * `tpcc`
27 | * `tpch`
28 | * `ycsb`
29 | * `BENCHMARK_CONFIG_FILE` - The benchmark configuration file. The default is `crdb_tpcc_config.xml`.
30 |
31 | ## Helpful Commands
32 |
33 | ### Execute SQL
34 | ```bash
35 | docker compose exec crdb-0 /cockroach/cockroach sql --insecure --execute="create database tpcc;"
36 | ```
37 |
38 | ### Open Interactive Shells
39 | ```bash
40 | docker compose exec crdb-0 /bin/bash
41 | docker compose exec crdb-1 /bin/bash
42 | docker compose exec crdb-2 /bin/bash
43 | docker compose exec lb /bin/sh
44 | docker compose exec oltp-bench /bin/bash
45 | ```
46 |
--------------------------------------------------------------------------------
/example-oltpbench/docker-compose.yml:
--------------------------------------------------------------------------------
1 | version: '3.8'
2 |
3 | services:
4 |
5 | crdb-0:
6 | container_name: crdb-0
7 | hostname: crdb-0
8 | image: cockroachdb/cockroach:latest
9 | command: start --cluster-name=example-oltpbench --logtostderr=WARNING --log-file-verbosity=WARNING --insecure --join=crdb-0 --max-sql-memory=4GB
10 |
11 | crdb-1:
12 | container_name: crdb-1
13 | hostname: crdb-1
14 | image: cockroachdb/cockroach:latest
15 | command: start --cluster-name=example-oltpbench --logtostderr=WARNING --log-file-verbosity=WARNING --insecure --join=crdb-0 --max-sql-memory=4GB
16 | depends_on:
17 | - crdb-0
18 |
19 | crdb-2:
20 | container_name: crdb-2
21 | hostname: crdb-2
22 | image: cockroachdb/cockroach:latest
23 | command: start --cluster-name=example-oltpbench --logtostderr=WARNING --log-file-verbosity=WARNING --insecure --join=crdb-0 --max-sql-memory=4GB
24 | depends_on:
25 | - crdb-0
26 |
27 | lb:
28 | container_name: lb
29 | hostname: lb
30 | image: timveil/dynamic-haproxy:latest
31 | ports:
32 | - "26257:26257"
33 | - "8080:8080"
34 | - "8081:8081"
35 | environment:
36 | - NODES=crdb-0 crdb-1 crdb-2
37 | depends_on:
38 | - crdb-0
39 | - crdb-1
40 | - crdb-2
41 |
42 | crdb-init:
43 | container_name: crdb-init
44 | hostname: crdb-init
45 | image: timveil/cockroachdb-remote-client:latest
46 | environment:
47 | - COCKROACH_HOST=crdb-0:26257
48 | - COCKROACH_INSECURE=true
49 | - COCKROACH_INIT=true
50 | - DATABASE_NAME=oltpbench
51 | depends_on:
52 | - lb
53 |
54 | oltp-bench:
55 | container_name: oltp-bench
56 | hostname: oltp-bench
57 | build:
58 | context: oltp-bench
59 | environment:
60 | - BENCHMARK_NAME=tpcc
61 | - BENCHMARK_CONFIG_FILE=crdb_tpcc_config.xml
--------------------------------------------------------------------------------
/example-oltpbench/down.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | docker compose down --remove-orphans --volumes
--------------------------------------------------------------------------------
/example-oltpbench/oltp-bench/Dockerfile:
--------------------------------------------------------------------------------
1 | ####################################
2 | # Multi-stage build
3 | # 1. build oltpbench
4 | # 2. run oltpbench client
5 | ####################################
6 |
7 | # Stage 1 - Build oltpbench
8 |
9 | FROM maven:3-jdk-11 as benchmark-builder
10 |
11 | LABEL maintainer="tjveil@gmail.com"
12 |
13 | ARG GIT_BRANCH=maven
14 |
15 | RUN mkdir -v /opt/oltpbench \
16 | && git clone https://github.com/timveil-cockroach/oltpbench.git /opt/oltpbench \
17 | && cd /opt/oltpbench \
18 | && git checkout -f ${GIT_BRANCH} \
19 | && mvn clean package -DskipTests=true
20 |
21 |
22 | # Stage 2 - run oltpbench client
23 |
24 | FROM openjdk:11-jdk-slim
25 |
26 | LABEL maintainer="tjveil@gmail.com"
27 |
28 | RUN apt-get update \
29 | && mkdir -v /opt/oltpbench
30 |
31 | COPY --from=benchmark-builder /opt/oltpbench/target/*.tgz /opt/oltpbench/oltpbench.tgz
32 |
33 | RUN tar -xvf /opt/oltpbench/oltpbench.tgz -C /opt/oltpbench --strip-components=1 \
34 | && rm -rf /opt/oltpbench/oltpbench.tgz
35 |
36 | COPY crdb_tpcc_config.xml /opt/oltpbench/config/crdb_tpcc_config.xml
37 | COPY crdb_tpch_config.xml /opt/oltpbench/config/crdb_tpch_config.xml
38 | COPY crdb_ycsb_config.xml /opt/oltpbench/config/crdb_ycsb_config.xml
39 |
40 | ADD entrypoint.sh /entrypoint.sh
41 | RUN chmod a+x /entrypoint.sh
42 |
43 | ENTRYPOINT ["/entrypoint.sh"]
44 |
45 |
46 |
--------------------------------------------------------------------------------
/example-oltpbench/oltp-bench/crdb_tpcc_config.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | COCKROACHDB
6 | org.postgresql.Driver
7 | jdbc:postgresql://lb:26257/oltpbench?sslmode=disable&ApplicationName=tpcc&reWriteBatchedInserts=true
8 | root
9 |
10 | TRANSACTION_SERIALIZABLE
11 | 128
12 |
13 |
14 | 1
15 |
16 |
17 | 1
18 |
19 |
20 |
21 | 10000
22 | 45,43,4,4,4
23 |
24 |
25 |
26 |
27 |
28 |
29 | NewOrder
30 |
31 |
32 | Payment
33 |
34 |
35 | OrderStatus
36 |
37 |
38 | Delivery
39 |
40 |
41 | StockLevel
42 |
43 |
44 |
45 |
--------------------------------------------------------------------------------
/example-oltpbench/oltp-bench/crdb_tpch_config.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | COCKROACHDB
6 | org.postgresql.Driver
7 | jdbc:postgresql://lb:26257/oltpbench?sslmode=disable&ApplicationName=tpch&reWriteBatchedInserts=true
8 | root
9 |
10 | TRANSACTION_SERIALIZABLE
11 | 128
12 |
13 |
14 | data/tpch
15 |
16 |
17 |
18 | tbl
19 |
20 |
21 | 1
22 |
23 |
24 | 1
25 |
26 |
27 | true
28 | unlimited
29 | all
30 |
31 |
32 | true
33 | unlimited
34 | even
35 |
36 |
37 | true
38 | unlimited
39 | odd
40 |
41 |
42 |
43 |
44 |
45 |
46 | odd
47 | 1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0
48 |
49 |
50 | even
51 | 0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1
52 |
53 |
54 |
55 | Q1
56 | 1
57 |
58 |
59 | Q2
60 | 2
61 |
62 |
63 | Q3
64 | 3
65 |
66 |
67 | Q4
68 | 4
69 |
70 |
71 | Q5
72 | 5
73 |
74 |
75 | Q6
76 | 6
77 |
78 |
79 | Q7
80 | 7
81 |
82 |
83 | Q8
84 | 8
85 |
86 |
87 | Q9
88 | 9
89 |
90 |
91 | Q10
92 | 10
93 |
94 |
95 | Q11
96 | 11
97 |
98 |
99 | Q12
100 | 12
101 |
102 |
103 | Q13
104 | 13
105 |
106 |
107 | Q14
108 | 14
109 |
110 |
111 | Q15
112 | 15
113 |
114 |
115 | Q16
116 | 16
117 |
118 |
119 | Q17
120 | 17
121 |
122 |
123 | Q18
124 | 18
125 |
126 |
127 | Q19
128 | 19
129 |
130 |
131 | Q20
132 | 20
133 |
134 |
135 | Q21
136 | 21
137 |
138 |
139 | Q22
140 | 22
141 |
142 |
143 |
144 |
--------------------------------------------------------------------------------
/example-oltpbench/oltp-bench/crdb_ycsb_config.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | COCKROACHDB
6 | org.postgresql.Driver
7 | jdbc:postgresql://lb:26257/oltpbench?sslmode=disable&ApplicationName=ycsb&reWriteBatchedInserts=true
8 | root
9 |
10 | TRANSACTION_SERIALIZABLE
11 | 128
12 |
13 |
14 | 1
15 |
16 |
17 | 1
18 |
19 |
20 |
21 | 10000
22 | 50,5,15,10,10,10
23 |
24 |
25 |
26 |
27 |
28 |
29 | ReadRecord
30 |
31 |
32 | InsertRecord
33 |
34 |
35 | ScanRecord
36 |
37 |
38 | UpdateRecord
39 |
40 |
41 | DeleteRecord
42 |
43 |
44 | ReadModifyWriteRecord
45 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/example-oltpbench/oltp-bench/entrypoint.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | set -eu
3 |
4 | if [[ "${1-}" = "bash" ]]; then
5 | shift
6 |
7 | echo "****** entrypoint.sh: executing bash with [$@]"
8 | exec /bin/bash "$@"
9 |
10 | else
11 |
12 | if [[ -v "BENCHMARK_NAME" ]] && [[ -v "BENCHMARK_CONFIG_FILE" ]]; then
13 |
14 | echo "****** entrypoint.sh: executing OLTP Benchmark: benchmark = [${BENCHMARK_NAME}] using config file = [${BENCHMARK_CONFIG_FILE}]..."
15 |
16 | cd /opt/oltpbench
17 |
18 | java -jar oltpbench2.jar -b ${BENCHMARK_NAME} -c config/${BENCHMARK_CONFIG_FILE} --create=true --load=true --execute=true -s 5
19 |
20 | else
21 |
22 | echo "****** entrypoint.sh: BENCHMARK_NAME and BENCHMARK_CONFIG_FILE not specified."
23 | tail -f /dev/null
24 |
25 | fi
26 |
27 | fi
28 |
--------------------------------------------------------------------------------
/example-oltpbench/prune.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | docker system prune -a -f --volumes
--------------------------------------------------------------------------------
/example-oltpbench/up.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | docker compose build --no-cache
4 |
5 | docker compose up --no-start
6 | docker compose start crdb-0
7 | docker compose start crdb-1
8 | docker compose start crdb-2
9 | docker compose start lb
10 | docker compose start crdb-init
11 |
12 | sleep 5
13 |
14 | docker compose start oltp-bench
15 |
--------------------------------------------------------------------------------
/example-secure-nginx/README.md:
--------------------------------------------------------------------------------
1 | # Secure CockroachDB Cluster
2 | Simple 3 node *secure* CockroachDB cluster with NGINX acting as load balancer
3 |
4 | #### todo: remove ip's from this example
5 |
6 | ## Services
7 | * `roach-0` - CockroachDB node
8 | * `roach-1` - CockroachDB node
9 | * `roach-2` - CockroachDB node
10 | * `lb` - NGINX acting as load balancer
11 | * `roach-cert` - Holds certificates as volume mounts
12 | * `roach-init` - Executes some commands against CockroachDB and shuts down. See [here](https://github.com/timveil-cockroach/cockroachdb-remote-client).
13 |
14 | ## Getting started
15 | >If you are using Google Chrome as your browser, you may want to navigate here `chrome://flags/#allow-insecure-localhost` and set this flag to `Enabled`.
16 |
17 | 1) execute `./up.sh` to start the cluster
18 | 2) visit the CockroachDB UI @ https://localhost:8080 and login with username `test` and password `password`
19 | 3) have fun!
20 |
21 | ## Helpful Commands
22 |
23 | ### Open Interactive Shells
24 | ```bash
25 | docker compose exec roach-0 /bin/bash
26 | docker compose exec roach-1 /bin/bash
27 | docker compose exec roach-2 /bin/bash
28 | docker compose exec lb /bin/sh
29 | docker compose exec roach-cert /bin/sh
30 | ```
31 |
32 | ### Copy Client Certificate and Key
33 | Use these commands to copy `client.root.*` files from the `roach-cert` docker image to your local machine
34 | ```bash
35 | docker cp roach-cert:/certs/client/client.root.crt .
36 | docker cp roach-cert:/certs/client/client.root.key .
37 | docker cp roach-cert:/certs/client/client.root.key.pk8 .
38 | ```
39 |
--------------------------------------------------------------------------------
/example-secure-nginx/docker-compose.yml:
--------------------------------------------------------------------------------
1 | version: '3.8'
2 |
3 | volumes:
4 | certs-roach-0:
5 | certs-roach-1:
6 | certs-roach-2:
7 | certs-client:
8 |
9 | services:
10 |
11 | roach-cert:
12 | container_name: roach-cert
13 | hostname: roach-cert
14 | build: roach-cert
15 | volumes:
16 | - certs-roach-0:/certs/roach-0
17 | - certs-roach-1:/certs/roach-1
18 | - certs-roach-2:/certs/roach-2
19 | - certs-client:/certs/client
20 |
21 | roach-0:
22 | container_name: roach-0
23 | hostname: roach-0
24 | image: cockroachdb/cockroach:latest
25 | command: start --cluster-name=example-secure-nginx --logtostderr=WARNING --log-file-verbosity=WARNING --certs-dir=/certs --join=roach-0
26 | volumes:
27 | - certs-roach-0:/certs
28 | depends_on:
29 | - roach-cert
30 |
31 | roach-1:
32 | container_name: roach-1
33 | hostname: roach-1
34 | image: cockroachdb/cockroach:latest
35 | command: start --cluster-name=example-secure-nginx --logtostderr=WARNING --log-file-verbosity=WARNING --certs-dir=/certs --join=roach-0
36 | volumes:
37 | - certs-roach-1:/certs
38 | depends_on:
39 | - roach-cert
40 | - roach-0
41 |
42 | roach-2:
43 | container_name: roach-2
44 | hostname: roach-2
45 | image: cockroachdb/cockroach:latest
46 | command: start --cluster-name=example-secure-nginx --logtostderr=WARNING --log-file-verbosity=WARNING --certs-dir=/certs --join=roach-0
47 | volumes:
48 | - certs-roach-2:/certs
49 | depends_on:
50 | - roach-cert
51 | - roach-0
52 |
53 | lb:
54 | container_name: lb
55 | hostname: lb
56 | build: nginx
57 | ports:
58 | - "26257:26257"
59 | - "8080:8080"
60 | depends_on:
61 | - roach-0
62 | - roach-1
63 | - roach-2
64 |
65 |
66 | roach-init:
67 | container_name: roach-init
68 | hostname: roach-init
69 | image: timveil/cockroachdb-remote-client:latest
70 | environment:
71 | - COCKROACH_HOST=roach-0:26257
72 | - COCKROACH_INSECURE=false
73 | - COCKROACH_CERTS_DIR=/certs
74 | - COCKROACH_INIT=true
75 | - DATABASE_NAME=test
76 | - DATABASE_USER=test
77 | - DATABASE_PASSWORD=password
78 | volumes:
79 | - certs-client:/certs
80 | depends_on:
81 | - lb
82 | - roach-cert
--------------------------------------------------------------------------------
/example-secure-nginx/down.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | docker compose down --remove-orphans --volumes
--------------------------------------------------------------------------------
/example-secure-nginx/nginx/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM nginx:alpine
2 |
3 | LABEL maintainer="tjveil@gmail.com"
4 |
5 | COPY nginx.conf /etc/nginx/nginx.conf
6 |
7 | EXPOSE 26257
8 | EXPOSE 8080
9 |
10 | CMD ["nginx", "-g", "daemon off;"]
--------------------------------------------------------------------------------
/example-secure-nginx/nginx/nginx.conf:
--------------------------------------------------------------------------------
1 | events { worker_connections 4096; }
2 |
3 | stream {
4 |
5 | upstream crdb-backend {
6 | server roach-0:26257;
7 | server roach-1:26257;
8 | server roach-2:26257;
9 | }
10 |
11 | server {
12 | listen 26257;
13 | proxy_pass crdb-backend;
14 | }
15 |
16 | upstream crdb-ui {
17 | server roach-0:8080;
18 | server roach-1:8080;
19 | server roach-2:8080;
20 | }
21 |
22 | server {
23 | listen 8080;
24 | proxy_pass crdb-ui;
25 | }
26 |
27 |
28 | }
--------------------------------------------------------------------------------
/example-secure-nginx/prune.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | docker system prune -a -f --volumes
--------------------------------------------------------------------------------
/example-secure-nginx/roach-cert/Dockerfile:
--------------------------------------------------------------------------------
1 | ####################################
2 | # Multi-stage build
3 | # 1. generate certs
4 | # 2. share certs
5 | ####################################
6 |
7 | # Stage 1 - generate certs
8 |
9 | FROM cockroachdb/cockroach:latest as generator
10 |
11 | LABEL maintainer="tjveil@gmail.com"
12 |
13 | RUN mkdir -pv /tmp/certs/ca /tmp/certs/roach-0 /tmp/certs/roach-1 /tmp/certs/roach-2 /tmp/safe /tmp/certs/client
14 |
15 | RUN ./cockroach cert create-ca --certs-dir=/tmp/certs/ca --ca-key=/tmp/safe/ca.key \
16 | && cp -v /tmp/certs/ca/ca.crt /tmp/certs/client \
17 | && cp -v /tmp/certs/ca/ca.crt /tmp/certs/roach-0 \
18 | && cp -v /tmp/certs/ca/ca.crt /tmp/certs/roach-1 \
19 | && cp -v /tmp/certs/ca/ca.crt /tmp/certs/roach-2
20 |
21 | RUN ./cockroach cert create-client root --certs-dir=/tmp/certs/client --ca-key=/tmp/safe/ca.key --also-generate-pkcs8-key
22 |
23 | RUN cp -v /tmp/certs/client/client.* /tmp/certs/roach-0 \
24 | && cp -v /tmp/certs/client/client.* /tmp/certs/roach-1 \
25 | && cp -v /tmp/certs/client/client.* /tmp/certs/roach-2
26 |
27 | RUN ./cockroach cert create-node roach-0 localhost lb --certs-dir=/tmp/certs/roach-0 --ca-key=/tmp/safe/ca.key
28 | RUN ./cockroach cert create-node roach-1 localhost lb --certs-dir=/tmp/certs/roach-1 --ca-key=/tmp/safe/ca.key
29 | RUN ./cockroach cert create-node roach-2 localhost lb --certs-dir=/tmp/certs/roach-2 --ca-key=/tmp/safe/ca.key
30 |
31 | # Stage 2 - share certs
32 |
33 | FROM alpine:latest
34 |
35 | LABEL maintainer="tjveil@gmail.com"
36 |
37 | RUN mkdir -pv /certs/roach-0 /certs/roach-1 /certs/roach-2 /certs/client
38 |
39 | COPY --from=generator /tmp/certs/roach-0/* /certs/roach-0/
40 | COPY --from=generator /tmp/certs/roach-1/* /certs/roach-1/
41 | COPY --from=generator /tmp/certs/roach-2/* /certs/roach-2/
42 | COPY --from=generator /tmp/certs/client/* /certs/client/
43 |
44 | CMD tail -f /dev/null
45 |
--------------------------------------------------------------------------------
/example-secure-nginx/roach-cert/README.md:
--------------------------------------------------------------------------------
1 | docker build --no-cache -t roach-cert .
2 |
3 | docker run -it roach-cert
4 |
5 | docker exec -it roach-cert /bin/bash
--------------------------------------------------------------------------------
/example-secure-nginx/up.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | docker compose build --no-cache
4 | docker compose up -d
--------------------------------------------------------------------------------
/example-secure/README.md:
--------------------------------------------------------------------------------
1 | # Secure CockroachDB Cluster
2 | Simple 3 node *secure* CockroachDB cluster with HAProxy acting as load balancer
3 |
4 | ## Services
5 | * `roach-0` - CockroachDB node
6 | * `roach-1` - CockroachDB node
7 | * `roach-2` - CockroachDB node
8 | * `lb` - HAProxy acting as load balancer
9 | * `roach-cert` - Holds certificates as volume mounts
10 | * `roach-init` - Executes some commands against CockroachDB and shuts down. See [here](https://github.com/timveil-cockroach/cockroachdb-remote-client).
11 |
12 | ## Getting started
13 | >If you are using Google Chrome as your browser, you may want to navigate here `chrome://flags/#allow-insecure-localhost` and set this flag to `Enabled`.
14 |
15 | 1) execute `./up.sh` to start the cluster
16 | 2) visit the CockroachDB UI @ https://localhost:8080 and login with username `test` and password `password`
17 | 3) visit the HAProxy UI @ http://localhost:8081
18 | 4) have fun!
19 |
20 | ## Helpful Commands
21 |
22 | ### Open Interactive Shells
23 | ```bash
24 | docker compose exec roach-0 /bin/bash
25 | docker compose exec roach-1 /bin/bash
26 | docker compose exec roach-2 /bin/bash
27 | docker compose exec lb /bin/sh
28 | docker compose exec roach-cert /bin/sh
29 | ```
30 | ### Copy CA Certificate
31 | ```bash
32 | docker cp roach-cert:/.cockroach-certs/ca.crt .
33 | ```
34 |
35 | ### Copy Client Certificate and Key
36 | Use these commands to copy `client.root.*` files from the `roach-cert` docker image to your local machine
37 | ```bash
38 | docker cp roach-cert:/.cockroach-certs/client.root.crt .
39 | docker cp roach-cert:/.cockroach-certs/client.root.key .
40 | docker cp roach-cert:/.cockroach-certs/client.root.key.pk8 .
41 | ```
42 |
--------------------------------------------------------------------------------
/example-secure/docker-compose.yml:
--------------------------------------------------------------------------------
1 | version: '3.8'
2 |
3 | volumes:
4 | certs:
5 |
6 | services:
7 |
8 | roach-cert:
9 | container_name: roach-cert
10 | hostname: roach-cert
11 | image: timveil/cockroachdb-dynamic-certs:latest
12 | volumes:
13 | - certs:/.cockroach-certs
14 | environment:
15 | - NODE_ALTERNATIVE_NAMES=*.crdb.io localhost
16 |
17 | roach-0:
18 | container_name: roach-0
19 | hostname: roach-0.crdb.io
20 | image: cockroachdb/cockroach:latest
21 | command: start --cluster-name=example-secure --logtostderr=WARNING --log-file-verbosity=WARNING --certs-dir=/certs --listen-addr=roach-0.crdb.io:26257 --advertise-addr=roach-0.crdb.io:26257 --join=roach-0.crdb.io
22 | volumes:
23 | - certs:/certs:ro
24 | depends_on:
25 | - roach-cert
26 |
27 | roach-1:
28 | container_name: roach-1
29 | hostname: roach-1.crdb.io
30 | image: cockroachdb/cockroach:latest
31 | command: start --cluster-name=example-secure --logtostderr=WARNING --log-file-verbosity=WARNING --certs-dir=/certs --listen-addr=roach-1.crdb.io:26257 --advertise-addr=roach-1.crdb.io:26257 --join=roach-0.crdb.io
32 | volumes:
33 | - certs:/certs:ro
34 | depends_on:
35 | - roach-cert
36 | - roach-0
37 |
38 | roach-2:
39 | container_name: roach-2
40 | hostname: roach-2.crdb.io
41 | image: cockroachdb/cockroach:latest
42 | command: start --cluster-name=example-secure --logtostderr=WARNING --log-file-verbosity=WARNING --certs-dir=/certs --listen-addr=roach-2.crdb.io:26257 --advertise-addr=roach-2.crdb.io:26257 --join=roach-0.crdb.io
43 | volumes:
44 | - certs:/certs:ro
45 | depends_on:
46 | - roach-cert
47 | - roach-0
48 |
49 | lb:
50 | container_name: lb
51 | hostname: lb.crdb.io
52 | image: timveil/dynamic-haproxy:latest
53 | ports:
54 | - "26257:26257"
55 | - "8080:8080"
56 | - "8081:8081"
57 | environment:
58 | - NODES=roach-0.crdb.io roach-1.crdb.io roach-2.crdb.io
59 | depends_on:
60 | - roach-0
61 | - roach-1
62 | - roach-2
63 |
64 | roach-init:
65 | container_name: roach-init
66 | hostname: roach-init
67 | image: timveil/cockroachdb-remote-client:latest
68 | environment:
69 | - COCKROACH_HOST=roach-0.crdb.io:26257
70 | - COCKROACH_INSECURE=false
71 | - COCKROACH_INIT=true
72 | - COCKROACH_CERTS_DIR=/certs
73 | - DATABASE_NAME=test
74 | - DATABASE_USER=test
75 | - DATABASE_PASSWORD=password
76 | volumes:
77 | - certs:/certs:ro
78 | depends_on:
79 | - lb
80 | - roach-cert
--------------------------------------------------------------------------------
/example-secure/down.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | docker compose down --remove-orphans --volumes
--------------------------------------------------------------------------------
/example-secure/prune.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | docker system prune -a -f --volumes
--------------------------------------------------------------------------------
/example-secure/up.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | docker compose up --no-start
4 |
5 | docker compose start roach-cert
6 |
7 | sleep 5
8 |
9 | docker compose start roach-0
10 |
11 | sleep 5
12 |
13 | docker compose start roach-1
14 | docker compose start roach-2
15 | docker compose start lb
16 |
17 | sleep 5
18 |
19 | docker compose start roach-init
--------------------------------------------------------------------------------
/example-single-node/README.md:
--------------------------------------------------------------------------------
1 | # Single CockroachDB instance
2 | Simple single node CockroachDB instance.
3 |
4 | ## Services
5 | * `crdb` - CockroachDB node
6 |
7 | ## Getting started
8 | 1) run `docker compose up`
9 | 2) visit the CockroachDB UI @ http://localhost:8080
10 | 3) have fun!
11 |
12 | ## Helpful Commands
13 |
14 | ### Open Interactive Shells
15 | ```bash
16 | docker compose exec crdb /bin/bash
17 | ```
--------------------------------------------------------------------------------
/example-single-node/docker-compose.yml:
--------------------------------------------------------------------------------
1 | version: '3.8'
2 |
3 | services:
4 |
5 | crdb:
6 | container_name: crdb
7 | hostname: crdb
8 | image: cockroachdb/cockroach:latest
9 | command: start-single-node --cluster-name=example-single-node --logtostderr=WARNING --log-file-verbosity=WARNING --insecure
10 | ports:
11 | - "26257:26257"
12 | - "8080:8080"
13 |
14 | crdb-init:
15 | container_name: crdb-init
16 | hostname: crdb-init
17 | image: timveil/cockroachdb-remote-client:latest
18 | environment:
19 | - COCKROACH_HOST=crdb:26257
20 | - COCKROACH_INSECURE=true
21 | - DATABASE_NAME=test
22 | depends_on:
23 | - crdb
--------------------------------------------------------------------------------
/example-ycsb/README.md:
--------------------------------------------------------------------------------
1 | # Running Original YCSB Workload
2 | Demonstrates building and executing the original YCSB workload against a 3 node CockroachDB cluster. More information on YCSB can be found here: https://github.com/brianfrankcooper/YCSB/wiki.
3 |
4 | > This is included here as a functional example. This configuration should not be considered the basis for a performance evaluation.
5 |
6 | ## Services
7 | * `crdb-0` - CockroachDB node
8 | * `crdb-1` - CockroachDB node
9 | * `crdb-2` - CockroachDB node
10 | * `lb` - HAProxy acting as load balancer
11 | * `crdb-init` - Executes some commands against CockroachDB and shuts down. See [here](https://github.com/timveil-cockroach/cockroachdb-remote-client).
12 | * `ycsb` - YCSB client container responsible for executing benchmark workload
13 |
14 | ## Getting started
15 | 1) because operation order is important, execute `./up.sh` instead of `docker compose up`
16 | 2) visit the CockroachDB UI @ http://localhost:8080
17 | 3) visit the HAProxy UI @ http://localhost:8081
18 | 4) have fun!
19 |
20 | ## Basic Configuration
21 | The following `environment` variables in `docker-compose.yml` control workload execution...
22 | * `WORKLOAD_NAME` - The name of the workload to run. The default value is `workload-b-cockroach`.
23 | * `WORKLOAD_TARGET_OPS` - The target Operations per Second (OPS). The default value is `100`.
24 | * `WORKLOAD_RECORD_COUNT` - The number of records to load into the database. The default value is `20000`.
25 |
26 | ## Advanced Configuration
27 | For database configuration information, see [db.properties](ycsb/db.properties).
28 |
29 | The following `args` in `docker-compose.yml` are used to control the versions of the Postgres JDBC driver and YCSB. Feel free to modify if necessary.
30 | * `POSTGRESQL_JDBC_VERSION` - The version of the Postgres JDBC driver to download and use. The default value is `42.2.12`.
31 | * `GIT_BRANCH` - The version of YCSB to checkout from `git`. The default value is `master`.
32 |
33 |
34 | ### db.properties
35 | ```properties
36 | db.driver=org.postgresql.Driver
37 | db.url=jdbc:postgresql://lb:26257/ycsb?sslmode=disable&application_name=ycsb&reWriteBatchedInserts=true
38 | db.user=root
39 | db.passwd=
40 | db.batchsize=128
41 | jdbc.fetchsize=10
42 | jdbc.autocommit=true
43 | jdbc.batchupdateapi=true
44 | ```
45 |
46 | ### Included Workloads
47 |
48 | * [workload-a-cockroach](ycsb/workload-a-cockroach)
49 | * [workload-b-cockroach](ycsb/workload-b-cockroach) (default)
50 | * [workload-c-cockroach](ycsb/workload-c-cockroach)
51 | * [workload-d-cockroach](ycsb/workload-d-cockroach)
52 | * [workload-e-cockroach](ycsb/workload-e-cockroach)
53 | * [workload-f-cockroach](ycsb/workload-f-cockroach)
54 |
55 | ## Helpful Commands
56 |
57 | ### Execute SQL
58 | Use the following to execute arbitrary SQL on the CockroachDB cluster.
59 | ```bash
60 | docker compose exec crdb-0 /cockroach/cockroach sql --insecure --execute="select count(*) from ycsb.usertable;"
61 | ```
62 |
63 | ### Open Interactive Shells
64 | ```bash
65 | docker compose exec crdb-0 /bin/bash
66 | docker compose exec crdb-1 /bin/bash
67 | docker compose exec crdb-2 /bin/bash
68 | docker compose exec lb /bin/sh
69 | docker compose exec ycsb /bin/bash
70 | ```
--------------------------------------------------------------------------------
/example-ycsb/docker-compose.yml:
--------------------------------------------------------------------------------
1 | version: '3.8'
2 |
3 | services:
4 |
5 | crdb-0:
6 | container_name: crdb-0
7 | hostname: crdb-0
8 | image: cockroachdb/cockroach:latest
9 | command: start --cluster-name=example-ycsb --logtostderr=WARNING --log-file-verbosity=WARNING --insecure --join=crdb-0
10 |
11 | crdb-1:
12 | container_name: crdb-1
13 | hostname: crdb-1
14 | image: cockroachdb/cockroach:latest
15 | command: start --cluster-name=example-ycsb --logtostderr=WARNING --log-file-verbosity=WARNING --insecure --join=crdb-0
16 | depends_on:
17 | - crdb-0
18 |
19 | crdb-2:
20 | container_name: crdb-2
21 | hostname: crdb-2
22 | image: cockroachdb/cockroach:latest
23 | command: start --cluster-name=example-ycsb --logtostderr=WARNING --log-file-verbosity=WARNING --insecure --join=crdb-0
24 | depends_on:
25 | - crdb-0
26 |
27 | lb:
28 | container_name: lb
29 | hostname: lb
30 | image: timveil/dynamic-haproxy:latest
31 | ports:
32 | - "26257:26257"
33 | - "8080:8080"
34 | - "8081:8081"
35 | environment:
36 | - NODES=crdb-0 crdb-1 crdb-2
37 | depends_on:
38 | - crdb-0
39 | - crdb-1
40 | - crdb-2
41 |
42 | crdb-init:
43 | container_name: crdb-init
44 | hostname: crdb-init
45 | image: timveil/cockroachdb-remote-client:latest
46 | environment:
47 | - COCKROACH_HOST=crdb-0:26257
48 | - COCKROACH_INSECURE=true
49 | - COCKROACH_INIT=true
50 | - DATABASE_NAME=ycsb
51 | depends_on:
52 | - lb
53 |
54 | ycsb:
55 | container_name: ycsb
56 | hostname: ycsb
57 | build:
58 | context: ycsb
59 | args:
60 | - POSTGRESQL_JDBC_VERSION=42.2.13
61 | - GIT_BRANCH=master
62 | environment:
63 | - WORKLOAD_NAME=workload-b-cockroach
64 | - WORKLOAD_TARGET_OPS=100
65 | - WORKLOAD_RECORD_COUNT=20000
66 |
--------------------------------------------------------------------------------
/example-ycsb/down.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | docker compose down --remove-orphans --volumes
--------------------------------------------------------------------------------
/example-ycsb/prune.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | docker system prune -a -f --volumes
--------------------------------------------------------------------------------
/example-ycsb/up.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | docker compose build --no-cache
4 |
5 | docker compose up --no-start
6 | docker compose start crdb-0
7 | docker compose start crdb-1
8 | docker compose start crdb-2
9 | docker compose start lb
10 | docker compose start crdb-init
11 |
12 | sleep 5
13 |
14 | echo "starting ycsb..."
15 | docker compose start ycsb
16 |
--------------------------------------------------------------------------------
/example-ycsb/ycsb/Dockerfile:
--------------------------------------------------------------------------------
1 | ####################################
2 | # Multi-stage build
3 | # 1. build ycsb
4 | # 2. build ycsb client
5 | ####################################
6 |
7 | # Stage 1 - Build YCSB
8 |
9 | FROM maven:3.5 as ycsb-builder
10 |
11 | LABEL maintainer="tjveil@gmail.com"
12 |
13 | ARG GIT_BRANCH=master
14 |
15 | RUN mkdir -v /opt/ycsb \
16 | && git clone https://github.com/brianfrankcooper/YCSB.git /opt/ycsb \
17 | && cd /opt/ycsb \
18 | && git checkout -f ${GIT_BRANCH} \
19 | && mvn -pl site.ycsb:jdbc-binding -am clean package -DskipTests=true
20 |
21 |
22 | # Stage 2 - Build YCSB client
23 |
24 | FROM openjdk:8-jdk-slim
25 |
26 | LABEL maintainer="tjveil@gmail.com"
27 |
28 | ARG POSTGRESQL_JDBC_VERSION=42.2.12
29 |
30 | RUN apt-get update \
31 | && apt-get install -y python curl \
32 | && mkdir -v /opt/ycsb
33 |
34 | COPY --from=ycsb-builder /opt/ycsb/jdbc/target/ycsb-jdbc-binding-*.tar.gz /opt/ycsb/ycsb.tar.gz
35 |
36 | RUN tar -xvf /opt/ycsb/ycsb.tar.gz -C /opt/ycsb --strip-components=1 \
37 | && rm -rfv /opt/ycsb/ycsb.tar.gz \
38 | && curl -fSL https://jdbc.postgresql.org/download/postgresql-$POSTGRESQL_JDBC_VERSION.jar -o /opt/ycsb/lib/postgresql-jdbc.jar \
39 | && ln -s /opt/ycsb/lib/jdbc-binding-*.jar /opt/ycsb/lib/jdbc-binding.jar
40 |
41 | COPY db.properties /opt/ycsb/conf/db.properties
42 | COPY workload-a-cockroach /opt/ycsb/workloads/workload-a-cockroach
43 | COPY workload-b-cockroach /opt/ycsb/workloads/workload-b-cockroach
44 | COPY workload-c-cockroach /opt/ycsb/workloads/workload-c-cockroach
45 | COPY workload-d-cockroach /opt/ycsb/workloads/workload-d-cockroach
46 | COPY workload-e-cockroach /opt/ycsb/workloads/workload-e-cockroach
47 | COPY workload-f-cockroach /opt/ycsb/workloads/workload-f-cockroach
48 |
49 | ADD entrypoint.sh /entrypoint.sh
50 | RUN chmod a+x /entrypoint.sh
51 |
52 | ENTRYPOINT ["/entrypoint.sh"]
53 |
54 |
55 |
--------------------------------------------------------------------------------
/example-ycsb/ycsb/db.properties:
--------------------------------------------------------------------------------
1 | db.driver=org.postgresql.Driver
2 | db.url=jdbc:postgresql://lb:26257/ycsb?sslmode=disable&ApplicationName=ycsb&reWriteBatchedInserts=true
3 | db.user=root
4 | db.passwd=
5 | db.batchsize=128
6 | jdbc.fetchsize=10
7 | jdbc.autocommit=true
8 | jdbc.batchupdateapi=true
--------------------------------------------------------------------------------
/example-ycsb/ycsb/entrypoint.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | set -eu
3 |
4 | if [[ "${1-}" = "shell" ]]; then
5 | shift
6 |
7 | echo "****** entrypoint.sh: executing shell..."
8 | exec /bin/sh "$@"
9 | else
10 | echo "****** entrypoint.sh: creating table..."
11 | java -cp /opt/ycsb/lib/jdbc-binding.jar:/opt/ycsb/lib/postgresql-jdbc.jar site.ycsb.db.JdbcDBCreateTable -P /opt/ycsb/conf/db.properties -n usertable
12 |
13 | echo "****** entrypoint.sh: loading data based on ${WORKLOAD_NAME} with ${WORKLOAD_RECORD_COUNT} records..."
14 | /opt/ycsb/bin/ycsb load jdbc -P /opt/ycsb/workloads/${WORKLOAD_NAME} -P /opt/ycsb/conf/db.properties -p recordcount=${WORKLOAD_RECORD_COUNT}
15 |
16 | echo "****** entrypoint.sh: executing benchmark for workload ${WORKLOAD_NAME}, target OPS is ${WORKLOAD_TARGET_OPS}"
17 | exec /opt/ycsb/bin/ycsb run jdbc -target ${WORKLOAD_TARGET_OPS} -s -P /opt/ycsb/workloads//${WORKLOAD_NAME} -P /opt/ycsb/conf/db.properties
18 | fi
19 |
--------------------------------------------------------------------------------
/example-ycsb/ycsb/workload-a-cockroach:
--------------------------------------------------------------------------------
1 | # Copyright (c) 2010 Yahoo! Inc. All rights reserved.
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License"); you
4 | # may not use this file except in compliance with the License. You
5 | # may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
12 | # implied. See the License for the specific language governing
13 | # permissions and limitations under the License. See accompanying
14 | # LICENSE file.
15 |
16 |
17 | # Yahoo! Cloud System Benchmark
18 | # Workload A: Update heavy workload
19 | # Application example: Session store recording recent actions
20 | #
21 | # Read/update ratio: 50/50
22 | # Default data size: 1 KB records (10 fields, 100 bytes each, plus key)
23 | # Request distribution: zipfian
24 |
25 | recordcount=1000
26 | operationcount=1000
27 | workload=site.ycsb.workloads.CoreWorkload
28 |
29 | readallfields=true
30 |
31 | readproportion=0.5
32 | updateproportion=0.5
33 | scanproportion=0
34 | insertproportion=0
35 |
36 | requestdistribution=zipfian
--------------------------------------------------------------------------------
/example-ycsb/ycsb/workload-b-cockroach:
--------------------------------------------------------------------------------
1 | # Copyright (c) 2010 Yahoo! Inc. All rights reserved.
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License"); you
4 | # may not use this file except in compliance with the License. You
5 | # may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
12 | # implied. See the License for the specific language governing
13 | # permissions and limitations under the License. See accompanying
14 | # LICENSE file.
15 |
16 | # Yahoo! Cloud System Benchmark
17 | # Workload B: Read mostly workload
18 | # Application example: photo tagging; add a tag is an update, but most operations are to read tags
19 | #
20 | # Read/update ratio: 95/5
21 | # Default data size: 1 KB records (10 fields, 100 bytes each, plus key)
22 | # Request distribution: zipfian
23 |
24 | recordcount=1000
25 | operationcount=1000
26 | workload=site.ycsb.workloads.CoreWorkload
27 |
28 | readallfields=true
29 |
30 | readproportion=0.95
31 | updateproportion=0.05
32 | scanproportion=0
33 | insertproportion=0
34 |
35 | requestdistribution=zipfian
--------------------------------------------------------------------------------
/example-ycsb/ycsb/workload-c-cockroach:
--------------------------------------------------------------------------------
1 | # Copyright (c) 2010 Yahoo! Inc. All rights reserved.
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License"); you
4 | # may not use this file except in compliance with the License. You
5 | # may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
12 | # implied. See the License for the specific language governing
13 | # permissions and limitations under the License. See accompanying
14 | # LICENSE file.
15 |
16 | # Yahoo! Cloud System Benchmark
17 | # Workload C: Read only
18 | # Application example: user profile cache, where profiles are constructed elsewhere (e.g., Hadoop)
19 | #
20 | # Read/update ratio: 100/0
21 | # Default data size: 1 KB records (10 fields, 100 bytes each, plus key)
22 | # Request distribution: zipfian
23 |
24 | recordcount=1000
25 | operationcount=1000
26 | workload=site.ycsb.workloads.CoreWorkload
27 |
28 | readallfields=true
29 |
30 | readproportion=1
31 | updateproportion=0
32 | scanproportion=0
33 | insertproportion=0
34 |
35 | requestdistribution=zipfian
--------------------------------------------------------------------------------
/example-ycsb/ycsb/workload-d-cockroach:
--------------------------------------------------------------------------------
1 | # Copyright (c) 2010 Yahoo! Inc. All rights reserved.
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License"); you
4 | # may not use this file except in compliance with the License. You
5 | # may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
12 | # implied. See the License for the specific language governing
13 | # permissions and limitations under the License. See accompanying
14 | # LICENSE file.
15 |
16 | # Yahoo! Cloud System Benchmark
17 | # Workload D: Read latest workload
18 | # Application example: user status updates; people want to read the latest
19 | #
20 | # Read/update/insert ratio: 95/0/5
21 | # Default data size: 1 KB records (10 fields, 100 bytes each, plus key)
22 | # Request distribution: latest
23 |
24 | # The insert order for this is hashed, not ordered. The "latest" items may be
25 | # scattered around the keyspace if they are keyed by userid.timestamp. A workload
26 | # which orders items purely by time, and demands the latest, is very different than
27 | # workload here (which we believe is more typical of how people build systems.)
28 |
29 | recordcount=1000
30 | operationcount=1000
31 | workload=site.ycsb.workloads.CoreWorkload
32 |
33 | readallfields=true
34 |
35 | readproportion=0.95
36 | updateproportion=0
37 | scanproportion=0
38 | insertproportion=0.05
39 |
40 | requestdistribution=latest
--------------------------------------------------------------------------------
/example-ycsb/ycsb/workload-e-cockroach:
--------------------------------------------------------------------------------
1 | # Copyright (c) 2010 Yahoo! Inc. All rights reserved.
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License"); you
4 | # may not use this file except in compliance with the License. You
5 | # may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
12 | # implied. See the License for the specific language governing
13 | # permissions and limitations under the License. See accompanying
14 | # LICENSE file.
15 |
16 | # Yahoo! Cloud System Benchmark
17 | # Workload E: Short ranges
18 | # Application example: threaded conversations, where each scan is for the posts in a given thread (assumed to be clustered by thread id)
19 | #
20 | # Scan/insert ratio: 95/5
21 | # Default data size: 1 KB records (10 fields, 100 bytes each, plus key)
22 | # Request distribution: zipfian
23 |
24 | # The insert order is hashed, not ordered. Although the scans are ordered, it does not necessarily
25 | # follow that the data is inserted in order. For example, posts for thread 342 may not be inserted contiguously, but
26 | # instead interspersed with posts from lots of other threads. The way the YCSB client works is that it will pick a start
27 | # key, and then request a number of records; this works fine even for hashed insertion.
28 |
29 | recordcount=1000
30 | operationcount=1000
31 | workload=site.ycsb.workloads.CoreWorkload
32 |
33 | readallfields=true
34 |
35 | readproportion=0
36 | updateproportion=0
37 | scanproportion=0.95
38 | insertproportion=0.05
39 |
40 | requestdistribution=zipfian
41 |
42 | maxscanlength=100
43 |
44 | scanlengthdistribution=uniform
--------------------------------------------------------------------------------
/example-ycsb/ycsb/workload-f-cockroach:
--------------------------------------------------------------------------------
1 | # Copyright (c) 2010 Yahoo! Inc. All rights reserved.
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License"); you
4 | # may not use this file except in compliance with the License. You
5 | # may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
12 | # implied. See the License for the specific language governing
13 | # permissions and limitations under the License. See accompanying
14 | # LICENSE file.
15 |
16 | # Yahoo! Cloud System Benchmark
17 | # Workload F: Read-modify-write workload
18 | # Application example: user database, where user records are read and modified by the user or to record user activity.
19 | #
20 | # Read/read-modify-write ratio: 50/50
21 | # Default data size: 1 KB records (10 fields, 100 bytes each, plus key)
22 | # Request distribution: zipfian
23 |
24 | recordcount=1000
25 | operationcount=1000
26 | workload=site.ycsb.workloads.CoreWorkload
27 |
28 | readallfields=true
29 |
30 | readproportion=0.5
31 | updateproportion=0
32 | scanproportion=0
33 | insertproportion=0
34 | readmodifywriteproportion=0.5
35 |
36 | requestdistribution=zipfian
--------------------------------------------------------------------------------