Skip to content

Instantly share code, notes, and snippets.

@aaronhurt
Created December 20, 2017 22:26
Show Gist options
  • Save aaronhurt/34dba67de4d28d5e34b1168e66be2810 to your computer and use it in GitHub Desktop.
Save aaronhurt/34dba67de4d28d5e34b1168e66be2810 to your computer and use it in GitHub Desktop.
local dual datacenter consul cluster

alias the ips...

ifconfig lo0 inet 127.0.0.100 netmask 255.255.255.0 alias
ifconfig lo0 inet 127.0.0.110 netmask 255.255.255.0 alias
ifconfig lo0 inet 127.0.0.120 netmask 255.255.255.0 alias
ifconfig lo0 inet 127.0.0.200 netmask 255.255.255.0 alias
ifconfig lo0 inet 127.0.0.210 netmask 255.255.255.0 alias
ifconfig lo0 inet 127.0.0.220 netmask 255.255.255.0 alias

build the directory structure...

mkdir -p /tmp/c{100,110,120,200,210,220}

first cluster...

consul agent -server -disable-host-node-id -bootstrap-expect=3 -datacenter=dc100 -bind=127.0.0.100 -client=127.0.0.100 -data-dir=/tmp/c100 -node=c100
consul agent -server -disable-host-node-id -bootstrap-expect=3 -datacenter=dc100 -bind=127.0.0.110 -client=127.0.0.110 -data-dir=/tmp/c110 -node=c110
consul agent -server -disable-host-node-id -bootstrap-expect=3 -datacenter=dc100 -bind=127.0.0.120 -client=127.0.0.120 -data-dir=/tmp/c120 -node=c120

second cluster...

consul agent -server -disable-host-node-id -bootstrap-expect=3 -datacenter=dc200 -bind=127.0.0.200 -client=127.0.0.200 -data-dir=/tmp/c200 -node=c200
consul agent -server -disable-host-node-id -bootstrap-expect=3 -datacenter=dc200 -bind=127.0.0.210 -client=127.0.0.210 -data-dir=/tmp/c210 -node=c210
consul agent -server -disable-host-node-id -bootstrap-expect=3 -datacenter=dc200 -bind=127.0.0.220 -client=127.0.0.220 -data-dir=/tmp/c220 -node=c220

cleanup to reset...

rm -rf /tmp/c1??/* /tmp/c2??/*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment