File tree Expand file tree Collapse file tree 3 files changed +47
-5
lines changed Expand file tree Collapse file tree 3 files changed +47
-5
lines changed Original file line number Diff line number Diff line change @@ -50,12 +50,12 @@ define TEST_ENV
50
50
TEST_MONGODB_S1_PRIMARY_PORT=$(TEST_MONGODB_S1_PRIMARY_PORT ) \
51
51
TEST_MONGODB_S1_SECONDARY1_PORT=$(TEST_MONGODB_S1_SECONDARY1_PORT ) \
52
52
TEST_MONGODB_S1_SECONDARY2_PORT=$(TEST_MONGODB_S1_SECONDARY2_PORT ) \
53
- TEST_MONGODB_S1_ARTBITER_PORT=$(TEST_MONGODB_S1_ARTBITER_PORT ) \
53
+ TEST_MONGODB_S1_ARTBITER_PORT=$(TEST_MONGODB_S1_ARBITER_PORT ) \
54
54
TEST_MONGODB_S2_RS=$(TEST_MONGODB_S2_RS ) \
55
55
TEST_MONGODB_S2_PRIMARY_PORT=$(TEST_MONGODB_S2_PRIMARY_PORT ) \
56
56
TEST_MONGODB_S2_SECONDARY1_PORT=$(TEST_MONGODB_S2_SECONDARY1_PORT ) \
57
57
TEST_MONGODB_S2_SECONDARY2_PORT=$(TEST_MONGODB_S2_SECONDARY2_PORT ) \
58
- TEST_MONGODB_S2_ARTBITER_PORT=$(TEST_MONGODB_S2_ARTBITER_PORT ) \
58
+ TEST_MONGODB_S2_ARTBITER_PORT=$(TEST_MONGODB_S2_ARBITER_PORT ) \
59
59
TEST_MONGODB_CONFIGSVR_RS=$(TEST_MONGODB_CONFIGSVR_RS ) \
60
60
TEST_MONGODB_CONFIGSVR1_PORT=$(TEST_MONGODB_CONFIGSVR1_PORT ) \
61
61
TEST_MONGODB_CONFIGSVR2_PORT=$(TEST_MONGODB_CONFIGSVR2_PORT ) \
Original file line number Diff line number Diff line change @@ -151,7 +151,7 @@ services:
151
151
- MONGO3=mongo-cnf-3
152
152
- RS=cnf-serv
153
153
- PORT=27017
154
- entrypoint : [ "/scripts/setup.sh" ]
154
+ entrypoint : [ "/scripts/setup.sh","cnf_servers" ]
155
155
156
156
mongos :
157
157
container_name : " mongos"
Original file line number Diff line number Diff line change 16
16
echo " Started.."
17
17
18
18
echo setup.sh time now: ` date +" %T" `
19
- mongo --host ${mongodb1} :${port} << EOF
20
- var cfg = {
19
+
20
+
21
+ function cnf_servers() {
22
+ echo " setup cnf servers"
23
+ mongo --host ${mongodb1} :${port} << EOF
24
+ var cfg = {
25
+ "_id": "${RS} ",
26
+ "protocolVersion": 1,
27
+ "configsvr": true,
28
+ "members": [
29
+ {
30
+ "_id": 0,
31
+ "host": "${mongodb1} :${port} "
32
+ },
33
+ {
34
+ "_id": 1,
35
+ "host": "${mongodb2} :${port} "
36
+ },
37
+ {
38
+ "_id": 2,
39
+ "host": "${mongodb3} :${port} "
40
+ }
41
+ ]
42
+ };
43
+ rs.initiate(cfg, { force: true });
44
+ rs.reconfig(cfg, { force: true });
45
+ EOF
46
+ }
47
+
48
+ function general_servers() {
49
+ echo " setup servers"
50
+ mongo --host ${mongodb1} :${port} << EOF
51
+ var cfg = {
21
52
"_id": "${RS} ",
22
53
"protocolVersion": 1,
23
54
"members": [
@@ -40,4 +71,15 @@ mongo --host ${mongodb1}:${port} <<EOF
40
71
41
72
rs.addArb("${arbiter} :${port} ")
42
73
EOF
74
+ }
43
75
76
+ case $1 in
77
+ cnf_servers)
78
+ cnf_servers
79
+ shift
80
+ ;;
81
+ * )
82
+ general_servers
83
+ shift
84
+ ;;
85
+ esac
You can’t perform that action at this time.
0 commit comments