- Repo names: ziti-* → zt-* - Go modules: github.com/hanzozt/ziti → github.com/hanzozt/zt - Docker images: hanzozt/ziti-* → hanzozt/zt-* - C/Java/JS symbols: ziti_* → zt_* - File and directory names updated
9.1 KiB
HA Quickstart
You can explore Ziti HA by running three local processes on unique TCP ports. This interactive tutorial is self-contained, so you don't need to do anything else before or after this to have a working, local cluster.
-
Create an empty working directory. All commands are run here.
cd $(mktemp -d) -
Run the first member in the background to create the cluster.
nohup zt edge quickstart ha \ --instance-id="ctrl1" \ --ctrl-port="1281" \ --router-port="3021" \ --home="${PWD}" \ --ctrl-address="127.0.0.1" \ --router-address="127.0.0.1" \ --trust-domain="ha-quickstart" \ &> ctrl1.log &Confirm the first job is running and check the log for startup errors.
tail ctrl1.log; echo; jobsExpected output:
. . . ... logs ... . . . [1] + running nohup zt edge quickstart ha --instance-id="ctrl1" --ctrl-port="1281" & -
Run the second member and join the cluster.
nohup zt edge quickstart join \ --instance-id="ctrl2" \ --ctrl-port="1282" \ --router-port="3022" \ --home="${PWD}" \ --ctrl-address="127.0.0.1" \ --router-address="127.0.0.1" \ --trust-domain="ha-quickstart" \ --cluster-member="tls:127.0.0.1:1281" \ &> ctrl2.log &Confirm the second job is running and check the log for startup errors.
tail ctrl2.log; echo; jobsExpected output:
. . . ... logs ... . . . [1] - running nohup zt edge quickstart ha --instance-id="ctrl1" --ctrl-port="1281" & [2] + running nohup zt edge quickstart join --instance-id="ctrl2" --ctrl-port="1282" -
Run the third member and join the cluster.
nohup zt edge quickstart join \ --instance-id="ctrl3" \ --ctrl-port="1283" \ --router-port="3023" \ --home="${PWD}" \ --ctrl-address="127.0.0.1" \ --router-address="127.0.0.1" \ --trust-domain="ha-quickstart" \ --cluster-member="tls:127.0.0.1:1281" \ &> ctrl3.log &Confirm the third job is running and check the log for startup errors.
tail ctrl3.log; echo; jobsExpected output:
. . . ... logs ... . . . [1] running nohup zt edge quickstart ha --instance-id="ctrl1" --ctrl-port="1281" & [2] - running nohup zt edge quickstart join --instance-id="ctrl2" --ctrl-port="1282" [3] + running nohup zt edge quickstart join --instance-id="ctrl3" --ctrl-port="1283" -
Optionally, follow interleaved logs in another window.
tail -F -n +1 *.log -
List agent applications.
zt agent listExpected output:
╭────────┬────────────┬────────┬─────────────────────────────┬────────────┬─────────────┬───────────╮ │ PID │ EXECUTABLE │ APP ID │ UNIX SOCKET │ APP TYPE │ APP VERSION │ APP ALIAS │ ├────────┼────────────┼────────┼─────────────────────────────┼────────────┼─────────────┼───────────┤ │ 276912 │ zt │ ctrl1 │ /tmp/gops-agent.276912.sock │ controller │ v0.0.0 │ │ │ 277714 │ zt │ ctrl2 │ /tmp/gops-agent.277714.sock │ controller │ v0.0.0 │ │ │ 281490 │ zt │ ctrl3 │ /tmp/gops-agent.281490.sock │ controller │ v0.0.0 │ │ ╰────────┴────────────┴────────┴─────────────────────────────┴────────────┴─────────────┴───────────╯ -
Identify the cluster leader.
zt agent cluster list --app-id ctrl1Expected output:
╭───────┬────────────────────┬───────┬────────┬─────────┬───────────╮ │ ID │ ADDRESS │ VOTER │ LEADER │ VERSION │ CONNECTED │ ├───────┼────────────────────┼───────┼────────┼─────────┼───────────┤ │ ctrl1 │ tls:127.0.0.1:1281 │ true │ true │ v0.0.0 │ true │ │ ctrl2 │ tls:127.0.0.1:1282 │ true │ false │ v0.0.0 │ true │ │ ctrl3 │ tls:127.0.0.1:1283 │ true │ false │ v0.0.0 │ true │ ╰───────┴────────────────────┴───────┴────────┴─────────┴───────────╯ -
Simulate a member availability incident.
Identify the job number for the cluster leader. It may not be
%1.jobsJob 1 belongs to ctrl1, the current leader.
[1] running nohup zt edge quickstart ha --instance-id="ctrl1" --ctrl-port="1281" [2] - running nohup zt edge quickstart join --instance-id="ctrl3" --ctrl-port="1283" [3] + running nohup zt edge quickstart join --instance-id="ctrl2" --ctrl-port="1282"kill %1 -
Inspect the cluster via another member ID.
zt agent cluster list --app-id ctrl2Expected output:
╭───────┬────────────────────┬───────┬────────┬─────────────────┬───────────╮ │ ID │ ADDRESS │ VOTER │ LEADER │ VERSION │ CONNECTED │ ├───────┼────────────────────┼───────┼────────┼─────────────────┼───────────┤ │ ctrl1 │ tls:127.0.0.1:1281 │ true │ false │ <not connected> │ false │ │ ctrl2 │ tls:127.0.0.1:1282 │ true │ true │ v0.0.0 │ true │ │ ctrl3 │ tls:127.0.0.1:1283 │ true │ false │ v0.0.0 │ true │ ╰───────┴────────────────────┴───────┴────────┴─────────────────┴───────────╯ -
Restart any disconnected member.
Any member can be restarted with this
hasubcommand.nohup zt edge quickstart ha \ --instance-id="ctrl1" \ --home="${PWD}" \ &>> ctrl1.log & -
Inspect the cluster.
Once restarted, ctrl1 does not necessarily resume being the leader.
zt agent cluster list --app-id ctrl2Expected output:
╭───────┬────────────────────┬───────┬────────┬─────────────────┬───────────╮ │ ID │ ADDRESS │ VOTER │ LEADER │ VERSION │ CONNECTED │ ├───────┼────────────────────┼───────┼────────┼─────────────────┼───────────┤ │ ctrl1 │ tls:127.0.0.1:1281 │ true │ false │ v0.0.0 │ true │ │ ctrl2 │ tls:127.0.0.1:1282 │ true │ false │ v0.0.0 │ true │ │ ctrl3 │ tls:127.0.0.1:1283 │ true │ true │ v0.0.0 │ true │ ╰───────┴────────────────────┴───────┴────────┴─────────────────┴───────────╯ -
Stop all background jobs.
BASH
kill $(jobs -p)ZSH
kill ${${(v)jobstates##*:*:}%=*}Expected output:
[1] + done nohup zt edge quickstart ha --instance-id="ctrl1" --ctrl-port="1281" [2] done nohup zt edge quickstart join --instance-id="ctrl2" --ctrl-port="1282" [3] + done nohup zt edge quickstart join --instance-id="ctrl3" --ctrl-port="1283"