1
2
2 installation
Stand-alone mode
Unzip, bin/zkserver.sh
Configuration file change Conf/zoo_sample.cfg to Conf/zoo.cfg
Ticktime Heartbeat
Dtatdir Data and log paths
Clientprot Port
3 cluster mode
Besides changing the top three, there's a
Initlimit:follower the number of time heartbeats that the server returns to the primary node, such as
Ticktime=2000,initlimit=5, if 2000*5=10000=10s doesn't return, the connection fails.
Synclimit: Request to answer the number of heartbeats, similar to the Initlimit calculation
Server.a=b:c:d
A machine number
b IP
C Lead and machine interaction ports
D election lead hung up after the lead communication with
And then:
Myid File Store A (service name), read at startup to determine exactly which server, path is DataDir
myID which machine will be the name of the store
4 Pseudo-Cluster mode
The same machine achieves its purpose by configuring different ports
3
Package com.zookeeper.example;
Import java.util.ArrayList;
Import java.util.List;
Import Com.sun.org.apache.bcel.internal.generic.NEW;
Import sun.security.krb5.internal.NetClient;
public class Zookeepersam {int num=20;} class zookeeper{int num;
int searchnum;
int indexnum;
String leadstate;
CGI CGI;
Leadservicemechine Leadservicemechine;
Bakleadservicemechine Bakleadservicemechine;
public void Changeleadservice () {if (leadstate== "down") {Startleadservice (bakleadservicemechine);
Changecginetandadd (CGI); }} public void Startleadservice (service service) {} public void Changecginetandadd (CGI cgi) {} public void
Run () {Buildznode ("a");
GetChildren ("a");
Getchildrenlist ();
if (Judgechange ()!=null) {}} public void Buildznode (String str) {Znode Znode = new Znode (str);
Nodes.Add (Znode);
} list<znode> nodes = new arraylist<znode> (); public void GetChildren (String name) {} public void Getchildrenlist () {} pUblic Znode Judgechange () {return null;
}} class Znode{public Znode () {} public Znode (String s) {}} class cgi{} class service{net net;
Address address; } class net{} class address{} class Leadservicemechine extends service{} class Bakleadservicemechine extends Serv
ice{} class servicemechine{String state;//5/15//state can toggle Zookeeper Zookeeper; public void Deal () {if (state== "index") {} if ("Search" ==state) {}}} class nameservice{} class Statesy ncservice{} class clustermanager{} class configuremanager{}