node | name | IP |
---|---|---|
server | consul_10 | 10.10.10.10 |
server | consul_11 | 10.10.10.11 |
client | consul_12 | 10.10.10.12 |
- Server
#!/bin/bash
mkdir -p /data/consul/{consul_d,logs}
rm -rf /data/consul/logs/*
nohup /opt/consul/consul agent -ui \
-server \
-bootstrap-expect=1 \
-log-file=/data/consul/logs/ \
-log-level=warn \
-log-rotate-bytes=102400000 \
-data-dir=/data/consul/consul_d/ \
-node=consul_10 \
-client=0.0.0.0 \
-encrypt=fPEBs8/pU4kSpu59yhqq/A== \
-retry-join=10.10.10.10 \
-retry-join=10.10.10.11 > /dev/null 2>&1 &
- Other hosts in the cluster
#!/bin/bash
mkdir -p /data/consul/{consul_d,logs}
rm -rf /data/consul/logs/*
nohup /opt/consul/consul agent -ui \
-server \
-bootstrap-expect=1 \
-log-file=/data/consul/logs/ \
-log-level=warn \
-log-rotate-bytes=102400000 \
-data-dir=/data/consul/consul_d/ \
-node=consul_11 \
-client=0.0.0.0 \
-encrypt=fPEBs8/pU4kSpu59yhqq/A== \
-retry-join=10.10.10.10 \
-retry-join=10.10.10.11 > /dev/null 2>&1 &
- Client
#!/bin/bash
mkdir -p /data/consul/{consul_d,logs}
rm -rf /data/consul/logs/*
nohup /opt/consul/consul agent -ui \
-log-file=/data/consul/logs/ \
-log-level=warn \
-log-rotate-bytes=102400000 \
-data-dir=/data/consul/consul_d/ \
-node=consul_12 \
-encrypt=fPEBs8/pU4kSpu59yhqq/A== \
-retry-join=10.10.10.10 \
-retry-join=10.10.10.11 > /dev/null 2>&1 &
Server
-bootstrap-expect
parameters are configured according to the actual number of machines cluster
server and client useconsul keygen
generated.