Skip to content

Commit

Permalink
Add mongo replicaset example (#340)
Browse files Browse the repository at this point in the history
  • Loading branch information
satterly committed Nov 22, 2021
1 parent 80e0d94 commit 2d75b24
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 131 deletions.
43 changes: 0 additions & 43 deletions RUNBOOK.md

This file was deleted.

26 changes: 0 additions & 26 deletions docker-compose.alerta.yml

This file was deleted.

31 changes: 0 additions & 31 deletions docker-compose.mongo-replica.yml

This file was deleted.

10 changes: 0 additions & 10 deletions docker-compose.mongo.yml

This file was deleted.

14 changes: 0 additions & 14 deletions docker-compose.postgres.yml

This file was deleted.

4 changes: 2 additions & 2 deletions docker-compose.yml
@@ -1,8 +1,7 @@
version: '3.1'
services:
web:
build: .
# image: alerta/alerta-web
image: alerta/alerta-web
# volumes:
# - $PWD/config/config.json:/web/config.json
ports:
Expand All @@ -19,6 +18,7 @@ services:
- ADMIN_KEY_MAXAGE=500
# - PLUGINS=remote_ip,reject,heartbeat,blackout,normalise,enhance
restart: always

db:
image: postgres
volumes:
Expand Down
21 changes: 21 additions & 0 deletions examples/mongo/README.md
@@ -0,0 +1,21 @@
# Alerta with MongoDB Replica Set Example

Once the mongo containers have started, run an interactive shell in one of the mongoDB containers, like so:

$ docker exec -ti mongo_db0_1 mongo

To initiate the replicaset, at the `mongo` prompt ">" run:

```
rs.initiate(
{
_id: "rs0",
version: 1,
members: [
{ _id: 0, host : "db0:27017" },
{ _id: 1, host : "db1:27017" },
{ _id: 2, host : "db2:27017" }
]
}
)
```
35 changes: 30 additions & 5 deletions examples/mongo/docker-compose.yml
Expand Up @@ -12,19 +12,44 @@ services:
volumes:
- $PWD/config/alertad.conf:/app/alertad.conf
depends_on:
- db
- db0
environment:
# - DEBUG=1 # remove this line to turn DEBUG off
- DATABASE_URL=mongodb://db:27017/monitoring
- DATABASE_URL=mongodb://db0:27017/monitoring?replicaSet=rs0
- MONGO_INITDB_DATABASE=monitoring
- AUTH_REQUIRED=True
- ADMIN_USERS=admin@alerta.io,devops@alerta.io
- ADMIN_PASSWORD=super-secret # default is "alerta"
- ADMIN_KEY=demo-key # assigned to first user in ADMIN_USERS
- ADMIN_KEY_MAXAGE=500
# - PLUGINS=remote_ip,reject,heartbeat,blackout,normalise,enhance
restart: always
db:

db0:
image: mongo
ports:
- 27017
volumes:
- ./mongodb/0:/data/db
command: ["--replSet", "rs0", "--bind_ip_all"]
restart: always

db1:
image: mongo
ports:
- 27017
volumes:
- ./mongodb/1:/data/db
command: ["--replSet", "rs0", "--bind_ip_all" ]
restart: always

db2:
image: mongo
ports:
- 27017
volumes:
- ./data/mongodb:/data/db
- ./mongodb/2:/data/db
command: ["--replSet", "rs0", "--bind_ip_all" ]
restart: always

networks:
net:

0 comments on commit 2d75b24

Please sign in to comment.