Let me write this from memory. :)
We have the following:
-A running zookeeper cluster with adminserver enabled
-One or more balancer client processes (one per datacenter), of which one
has a master role through some leader election. The master does the work,
the others do nothing.
-In our case, we work with a designated survivor datacenter (has 3
participants and the other non survivor datacenter has 2 participant and 1
observer ) , and the balancer always resides in the designated survivor
datacenter. This is not a requirement, due to above leader election.
-A balancer client configuration file with all predefined Zookeeper servers
(use it for building the client connection string and generating the server
list). Each predefined server under normal condition has a running
Zookeeper in either participant or observer role.
Balancer design:
buildDatacenterAndServerModel(configurationFile) {
enum zookeeperRole PARTICIPANT, OBSERVER, NONE, DOWN
object datacenter has servers
object server has zookeeperRole configuredRole, zookeeperRole activeRole
parse(configurationFile) into (datacenter, servers);
}
shiftMajority(designatedSurvivorDatacenter) {
designatedSurvivorDatacenter.someObserver.dynamicReconfigure(server=PARTICIPANT)
otherDatacenter.someParticipant.dynamicReconfigure(server=OBSERVER)
}
balanceServerRoles() {
if (designatedSurvivorDatacenter.hasMinimumQuorum)
someParticipant.dynamicReconfigure(server=OBSERVER)
if (quorumSize.aboveSafeLimit)
someObserver.dynamicReconfigure(server=PARTICIPANT)
//This is a lot more complicated than 2 simple commands, you need an
algorithm or define several scenarios.
}
main() {
buildDatacenterAndServerModel(configurationFile);
while (iAmLeader) {
parse(zk.getData(/zookeeper/config)) into servers.configuredRole
foreach(server) getServerRole(server:8081/commands/stat) into
servers.activeRole
foreach (server.activeRole=DOWN) dynamicReconfigure(server=OBSERVER) ;
server.setConfiguredRole(OBSERVER)
if(designatedSurvivorDatacenter != datacenter.hasMajority)
shiftMajority(designatedSurvivorDatacenter)
balanceServerRoles()
}
}
Hope this helps. If you need more details, I can check the actual code
coming week.
On Fri, Sep 27, 2019 at 5:06 AM Gao,Wei <[email protected]> wrote:
> Hi oo4load,
> Could you please tell me how to implements this to avoid the problem
> above?
> Thanks
>
>
>
> --
> Sent from: http://zookeeper-user.578899.n2.nabble.com/
>