Guide to install pimentaCHAT as HA with mongodb replicaset as backend
Install MongoDB Replicaset
- Use https://medium.com/@gargar454/deploy-a-mongodb-cluster-in-steps-9-using-docker-49205e231319#.8dfln7n8c to setup the mongodb replicaset
- Create a user called oploguser with rights on local oplog database:
db.createUser({user: "oploguser", pwd: "password", roles: [{role: "read", db: "local"}]})
- Create pimenta user to authenticate with pimentachat database:
db.createUser({user: "pimenta", pwd: "password", roles: [{role: "readWrite", db: "pimentachat"}]})
Create pimenta.chat docker container
- Use example docker-compose.yaml in repo
- Fill the INSTANCE_IP env with the local ip of the docker-host (in a 3 node setup this is unique on every host)
- Fill the passwords from pimenta and oplogger
- Change the IP of every host in the example docker-compose.yaml -> extra_hosts inserts host entries so each pimentachat-container could resolve the others by the name
- Be sure that the instances could communicate on port 3000 with each other, this is important to see messages on other hosts directly
pimentachat:
image: pimentachat/pimenta.chat:latest
environment:
- PORT=3000
- ROOT_URL=https://chat.domain.de
- MONGO_URL=mongodb://pimenta:password@pimenta-1:27017,pimenta-2:27017,pimenta-3:27017/pimentachat?authSource=admin&replicaSet=rs0&readPreference=nearest&w=majority
- MONGO_OPLOG_URL=mongodb://oploguser:password@pimenta-1:27017,pimenta-2:27017,pimenta-3:27017/local?authSource=admin&replicaSet=rs0
- INSTANCE_IP=<ip of the local instance>
ports:
- 3000:3000
extra_hosts:
- "pimenta-1:10.250.250.13"
- "pimenta-2:10.250.250.14"
- "pimenta-3:10.250.250.17"
Create Loadbalancer
- Now setup up a reverse proxy on each host to terminate ssl on each pimenta.chat node or terminate ssl on the loadbalancer, this is up to you.
- Setup a loadbalancer to reach each instance on 443 or 3000 (depends on the choice above)