GNU/Linux xterm-256color zsh 186 views

In the part 1 the nodes were restarted in a chaotic way. Here script was improved to restart only the node is a stable leader.

ZK version: 3.4.9-3+deb9u2

Restart script:

_check() {
  sleep $((RANDOM % 2 + 1))
  echo stat | nc localhost 2181 | grep 'Mode: leader'
}
i=1
while true
do [ -z "$(_check)" ] && continue
  [ -z "$(_check)" ] && continue
  printf "\rrestarts: $i"
  i=$(($i + 1))
  sudo systemctl restart zookeeper.service
done