5
5
# ./start_db_cluster.sh <dockerImage>
6
6
7
7
# 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
9
9
10
10
docker pull " $1 "
11
11
12
12
LOCATION=$( pwd) /$( dirname " $0 " )
13
13
14
14
docker network create arangodb --subnet 172.28.0.0/16
15
15
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
18
18
AUTHORIZATION_HEADER=$( cat " $LOCATION " /jwtHeader)
19
19
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
+
20
32
debug_container () {
21
33
running=$( docker inspect -f ' {{.State.Running}}' " $1 " )
22
34
23
- if [ " $running " = false ]; then
35
+ if [ " $running " = false ]
36
+ then
24
37
echo " $1 is not running!"
25
38
echo " ---"
26
39
docker logs " $1 "
@@ -31,58 +44,40 @@ debug_container() {
31
44
32
45
debug () {
33
46
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
42
54
done
43
55
}
44
56
45
57
wait_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
52
64
}
53
65
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..."
80
67
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
83
78
84
79
docker exec coordinator1 arangosh --server.authentication=false --javascript.execute-string=' require("org/arangodb/users").update("root", "test")'
85
80
86
- rm " $LOCATION " /jwtHeader " $LOCATION " /jwtSecret
81
+ # rm "$LOCATION"/jwtHeader "$LOCATION"/jwtSecret
87
82
88
83
echo " Done, your cluster is ready."
0 commit comments