Skip to content

Instantly share code, notes, and snippets.

@pierew
Last active November 1, 2018 21:24
Show Gist options
  • Save pierew/cdf4497197fc5fdcafcf156cf5daefa1 to your computer and use it in GitHub Desktop.
Save pierew/cdf4497197fc5fdcafcf156cf5daefa1 to your computer and use it in GitHub Desktop.
Sentry Active-Passive HA on Linux CentOS 7
[Unit]
Description=Sentry Cron Container
After=docker.service
[Service]
Restart=always
ExecStart=/usr/bin/docker start -a sentry-cron
ExecStop=/usr/bin/docker stop sentry-cron
[Install]
WantedBy=local.target
[Unit]
Description=Sentry Postgres Container
After=docker.service
[Service]
Restart=always
ExecStart=/usr/bin/docker start -a sentry-postgres
ExecStop=/usr/bin/docker stop sentry-postgres
[Install]
WantedBy=local.target
[Unit]
Description=Sentry Redis Container
After=docker.service
[Service]
Restart=always
ExecStart=/usr/bin/docker start -a sentry-redis
ExecStop=/usr/bin/docker stop sentry-redis
[Install]
WantedBy=local.target
[Unit]
Description=Sentry Server Container
After=docker.service
[Service]
Restart=always
ExecStart=/usr/bin/docker start -a sentry-server
ExecStop=/usr/bin/docker stop sentry-server
[Install]
WantedBy=local.target
[Unit]
Description=Sentry Worker Container
After=docker.service
[Service]
Restart=always
ExecStart=/usr/bin/docker start -a sentry-worker-1
ExecStop=/usr/bin/docker stop sentry-worker-1
[Install]
WantedBy=local.target
[Unit]
Description=Sentry Worker Container
After=docker.service
[Service]
Restart=always
ExecStart=/usr/bin/docker start -a sentry-worker-2
ExecStop=/usr/bin/docker stop sentry-worker-2
[Install]
WantedBy=local.target
#!/bin/bash
HOST1='sentry01'
HOST2='sentry02'
passwd hacluster
pcs cluster auth ${HOST1} ${HOST2}
pcs cluster setup --name sentry_cluster ${HOST1} ${HOST2}
pcs cluster start --all
pcs property set stonith-enabled=false
pcs property set no-quorum-policy=ignore
pcs status
pvcreate /dev/sdb
vgcreate vg_drbd /dev/sdb
lvcreate -n lv_drbd0 -l +100%FREE vg_drbd
-- SETUP DRBD FIRST ---
pcs cluster cib add_drbd
pcs resource create sentry_data ocf:linbit:drbd drbd_resource=drbd0 op monitor interval=60s
pcs resource master sentry_data_sync sentry_data master-max=1 master-node-max=1 clone-max=2 clone-node-max=1 notify=true
pcs -f add_drbd resource show
pcs cluster cib-push add_drbd
chmod 777 /var/lib/pacemaker/cores
pcs cluster cib add_fs
pcs -f add_fs resource create sentry_fs Filesystem device="/dev/drbd0" directory="/var/lib/docker" fstype="xfs"
pcs -f add_fs constraint colocation add sentry_fs sentry_data_sync INFINITY with-rsc-role=Master
pcs -f add_fs constraint order promote sentry_data_
sync then start sentry_fs
pcs cluster cib-push add_fs
pcs resource create service_docker systemd:docker op monitor interval=60s
pcs constraint colocation add service_docker sentry_fs INFINITY with-rsc-role=Master
pcs constraint order sentry_fs then service_docker
docker run -d --name sentry-redis redis
docker run -d --name sentry-postgres -e POSTGRES_PASSWORD=secret -e POSTGRES_USER=sentry postgres
docker run --rm sentry config generate-secret-key
SECRET='PLACE IN OUTPUT LINE OF PREVIOUS CONTAINER'
docker run -it --rm -e SENTRY_SECRET_KEY="${SECRET}" --link sentry-postgres:postgres --link sentry-redis:redis sentry upgrade
docker run -d --name sentry-server -p 9000:9000 -e SENTRY_SECRET_KEY="${SECRET}" --link sentry-redis:redis --link sentry-postgres:postgres sentry
docker run -d --name sentry-cron -e SENTRY_SECRET_KEY="${SECRET}" --link sentry-postgres:postgres --link sentry-redis:redis sentry run cron
docker run -d --name sentry-worker-1 -e SENTRY_SECRET_KEY="${SECRET}" --link sentry-postgres:postgres --link sentry-redis:redis sentry run worker
docker run -d --name sentry-worker-2 -e SENTRY_SECRET_KEY="${SECRET}" --link sentry-postgres:postgres --link sentry-redis:redis sentry run worker
docker stop sentry-worker-2
docker stop sentry-worker-1
docker stop sentry-cron
docker stop sentry-server
docker stop sentry-postgres
docker stop sentry-redis
pcs resource create service_sentry-redis systemd:sentry-redis
pcs constraint colocation add service_sentry-redis service_docker INFINITY with-rsc-role=Master
pcs constraint order service_docker then service_sentry-redis
pcs resource create service_sentry-postgres systemd:sentry-postgres
pcs constraint colocation add service_sentry-postgres service_docker INFINITY with-rsc-role=Master
pcs constraint order service_docker then service_sentry-postgres
pcs resource create service_sentry-server systemd:sentry-server
pcs constraint colocation add service_sentry-server service_docker INFINITY with-rsc-role=Master
pcs constraint order service_sentry-postgres then service_sentry-server
pcs resource create service_sentry-cron systemd:sentry-cron
pcs constraint colocation add service_sentry-cron service_docker INFINITY with-rsc-role=Master
pcs constraint order service_sentry-server then service_sentry-cron
pcs resource create service_sentry-worker-1 systemd:sentry-worker-1
pcs constraint colocation add service_sentry-worker-1 service_docker INFINITY with-rsc-role=Master
pcs constraint order service_sentry-cron then service_sentry-worker-1
pcs resource create service_sentry-worker-2 systemd:sentry-worker-2
pcs constraint colocation add service_sentry-worker-2 service_docker INFINITY with-rsc-role=Master
pcs constraint order service_sentry-cron then service_sentry-worker-2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment