55# ./start_db_cluster.sh <dockerImage>
66
77# EXAMPLE:
8- # ./start_db_cluster.sh docker.io/arangodb/arangodb:3.5.1
8+ # ./start_db_cluster.sh docker.io/arangodb/arangodb:3.5.3
99
1010docker pull " $1 "
1111
1212LOCATION=$( pwd) /$( dirname " $0 " )
1313
1414docker network create arangodb --subnet 172.28.0.0/16
1515
16- echo " Averysecretword" > " $LOCATION " /jwtSecret
17- docker run --rm -v " $LOCATION " /jwtSecret:/jwtSecret " $1 " arangodb auth header --auth.jwt-secret /jwtSecret > " $LOCATION " /jwtHeader
16+ echo " Averysecretword" > " $LOCATION " /jwtSecret
17+ docker run --rm -v " $LOCATION " /jwtSecret:/jwtSecret " $1 " arangodb auth header --auth.jwt-secret /jwtSecret > " $LOCATION " /jwtHeader
1818AUTHORIZATION_HEADER=$( cat " $LOCATION " /jwtHeader)
1919
20+ echo " Starting containers..."
21+
22+ docker run -d -v " $LOCATION " /jwtSecret:/jwtSecret -e ARANGO_LICENSE_KEY=" $ARANGO_LICENSE_KEY " --network arangodb --ip 172.28.1.1 --name agent1 " $1 " arangodb --cluster.start-dbserver false --cluster.start-coordinator false --auth.jwt-secret /jwtSecret
23+ docker run -d -v " $LOCATION " /jwtSecret:/jwtSecret -e ARANGO_LICENSE_KEY=" $ARANGO_LICENSE_KEY " --network arangodb --ip 172.28.1.2 --name agent2 " $1 " arangodb --cluster.start-dbserver false --cluster.start-coordinator false --starter.join agent1 --auth.jwt-secret /jwtSecret
24+ docker run -d -v " $LOCATION " /jwtSecret:/jwtSecret -e ARANGO_LICENSE_KEY=" $ARANGO_LICENSE_KEY " --network arangodb --ip 172.28.1.3 --name agent3 " $1 " arangodb --cluster.start-dbserver false --cluster.start-coordinator false --starter.join agent1 --auth.jwt-secret /jwtSecret
25+
26+ docker run -d -v " $LOCATION " /jwtSecret:/jwtSecret -e ARANGO_LICENSE_KEY=" $ARANGO_LICENSE_KEY " --network arangodb --ip 172.28.2.1 --name dbserver1 " $1 " arangodb --cluster.start-dbserver true --cluster.start-coordinator false --starter.join agent1 --auth.jwt-secret /jwtSecret
27+ docker run -d -v " $LOCATION " /jwtSecret:/jwtSecret -e ARANGO_LICENSE_KEY=" $ARANGO_LICENSE_KEY " --network arangodb --ip 172.28.2.2 --name dbserver2 " $1 " arangodb --cluster.start-dbserver true --cluster.start-coordinator false --starter.join agent1 --auth.jwt-secret /jwtSecret
28+
29+ docker run -d -v " $LOCATION " /jwtSecret:/jwtSecret -e ARANGO_LICENSE_KEY=" $ARANGO_LICENSE_KEY " --network arangodb --ip 172.28.3.1 --name coordinator1 " $1 " arangodb --cluster.start-dbserver false --cluster.start-coordinator true --starter.join agent1 --auth.jwt-secret /jwtSecret
30+ docker run -d -v " $LOCATION " /jwtSecret:/jwtSecret -e ARANGO_LICENSE_KEY=" $ARANGO_LICENSE_KEY " --network arangodb --ip 172.28.3.2 --name coordinator2 " $1 " arangodb --cluster.start-dbserver false --cluster.start-coordinator true --starter.join agent1 --auth.jwt-secret /jwtSecret
31+
2032debug_container () {
2133 running=$( docker inspect -f ' {{.State.Running}}' " $1 " )
2234
23- if [ " $running " = false ]; then
35+ if [ " $running " = false ]
36+ then
2437 echo " $1 is not running!"
2538 echo " ---"
2639 docker logs " $1 "
@@ -31,58 +44,40 @@ debug_container() {
3144
3245debug () {
3346 for c in agent1 \
34- agent2 \
35- agent3 \
36- dbserver1 \
37- dbserver2 \
38- dbserver3 \
39- coordinator1 \
40- coordinator2; do
41- debug_container $c
47+ agent2 \
48+ agent3 \
49+ dbserver1 \
50+ dbserver2 \
51+ coordinator1 \
52+ coordinator2 ; do
53+ debug_container $c
4254 done
4355}
4456
4557wait_server () {
46- # shellcheck disable=SC2091
47- until $( curl --output /dev/null --silent --head --fail -i -H " $AUTHORIZATION_HEADER " " http://$1 /_api/version" ) ; do
48- printf ' .'
49- debug
50- sleep 1
51- done
58+ # shellcheck disable=SC2091
59+ until $( curl --output /dev/null --silent --head --fail -i -H " $AUTHORIZATION_HEADER " " http://$1 /_api/version" ) ; do
60+ printf ' .'
61+ debug
62+ sleep 1
63+ done
5264}
5365
54- echo " Starting containers..."
55-
56- docker run -d -v " $LOCATION " /jwtSecret:/jwtSecret -e ARANGO_LICENSE_KEY=" $ARANGO_LICENSE_KEY " --network arangodb --ip 172.28.1.1 --name agent1 " $1 " arangodb --cluster.start-dbserver false --cluster.start-coordinator false --auth.jwt-secret /jwtSecret
57- docker run -d -v " $LOCATION " /jwtSecret:/jwtSecret -e ARANGO_LICENSE_KEY=" $ARANGO_LICENSE_KEY " --network arangodb --ip 172.28.1.2 --name agent2 " $1 " arangodb --cluster.start-dbserver false --cluster.start-coordinator false --starter.join agent1 --auth.jwt-secret /jwtSecret
58- docker run -d -v " $LOCATION " /jwtSecret:/jwtSecret -e ARANGO_LICENSE_KEY=" $ARANGO_LICENSE_KEY " --network arangodb --ip 172.28.1.3 --name agent3 " $1 " arangodb --cluster.start-dbserver false --cluster.start-coordinator false --starter.join agent1 --auth.jwt-secret /jwtSecret
59-
60- echo " Waiting for agents..."
61- wait_server 172.28.1.1:8531
62- wait_server 172.28.1.2:8531
63- wait_server 172.28.1.3:8531
64-
65- docker run -d -v " $LOCATION " /jwtSecret:/jwtSecret -e ARANGO_LICENSE_KEY=" $ARANGO_LICENSE_KEY " --network arangodb --ip 172.28.2.1 --name dbserver1 " $1 " arangodb --cluster.start-dbserver true --cluster.start-coordinator false --starter.join agent1 --auth.jwt-secret /jwtSecret
66- docker run -d -v " $LOCATION " /jwtSecret:/jwtSecret -e ARANGO_LICENSE_KEY=" $ARANGO_LICENSE_KEY " --network arangodb --ip 172.28.2.2 --name dbserver2 " $1 " arangodb --cluster.start-dbserver true --cluster.start-coordinator false --starter.join agent1 --auth.jwt-secret /jwtSecret
67- docker run -d -v " $LOCATION " /jwtSecret:/jwtSecret -e ARANGO_LICENSE_KEY=" $ARANGO_LICENSE_KEY " --network arangodb --ip 172.28.2.3 --name dbserver3 " $1 " arangodb --cluster.start-dbserver true --cluster.start-coordinator false --starter.join agent1 --auth.jwt-secret /jwtSecret
68-
69- docker run -d -v " $LOCATION " /jwtSecret:/jwtSecret -e ARANGO_LICENSE_KEY=" $ARANGO_LICENSE_KEY " --network arangodb --ip 172.28.3.1 --name coordinator1 " $1 " arangodb --cluster.start-dbserver false --cluster.start-coordinator true --starter.join agent1 --auth.jwt-secret /jwtSecret
70- docker run -d -v " $LOCATION " /jwtSecret:/jwtSecret -e ARANGO_LICENSE_KEY=" $ARANGO_LICENSE_KEY " --network arangodb --ip 172.28.3.2 --name coordinator2 " $1 " arangodb --cluster.start-dbserver false --cluster.start-coordinator true --starter.join agent1 --auth.jwt-secret /jwtSecret
71- docker run -d -v " $LOCATION " /jwtSecret:/jwtSecret -e ARANGO_LICENSE_KEY=" $ARANGO_LICENSE_KEY " --network arangodb --ip 172.28.3.3 --name coordinator3 " $1 " arangodb --cluster.start-dbserver false --cluster.start-coordinator true --starter.join agent1 --auth.jwt-secret /jwtSecret
72-
73- echo " Waiting for dbservers and coordinators..."
74- wait_server 172.28.2.1:8530
75- wait_server 172.28.2.2:8530
76- wait_server 172.28.2.3:8530
77- wait_server 172.28.3.1:8529
78- wait_server 172.28.3.2:8529
79- wait_server 172.28.3.3:8529
66+ echo " Waiting..."
8067
81- # wait for port mappings
82- wait_server 127.0.0.1:8529
68+ # Wait for agents:
69+ for a in 172.28.1.1:8531 \
70+ 172.28.1.2:8531 \
71+ 172.28.1.3:8531 \
72+ 172.28.2.1:8530 \
73+ 172.28.2.2:8530 \
74+ 172.28.3.1:8529 \
75+ 172.28.3.2:8529 ; do
76+ wait_server $a
77+ done
8378
8479docker exec coordinator1 arangosh --server.authentication=false --javascript.execute-string=' require("org/arangodb/users").update("root", "test")'
8580
86- rm " $LOCATION " /jwtHeader " $LOCATION " /jwtSecret
81+ # rm "$LOCATION"/jwtHeader "$LOCATION"/jwtSecret
8782
8883echo " Done, your cluster is ready."
0 commit comments