Zookeeper--复制模式安装
参考:
https://www.cnblogs.com/lsdb/p/7297731.html
https://zookeeper.apache.org/doc/r3.4.13/zookeeperStarted.html#sc_RunningReplicatedZooKeeper
前提
JDK 6及其以上
安装
下载安装文件并上传到各目标机器
将下载好的 zookeeper-x.x.x.tar.gz 分别上传到目标机器,如 /usr/local/src ,当前下载的版本为3.4.9
我的目标机器
在各目标机器分别解压
在各目标机器创建软连接
在各目标机器创建配置文件
写入各目标机器的myid
(分别写入不同的myid, myid中的内容对应相关的server.x,即写入相应的ip的server的x值.如:192.168.10.130的myid配置成3)
打开各目标机器相应端口
分别启动
查看状态
相关配置解释(官方链接)
initLimit
initLimit is timeouts ZooKeeper uses to limit the length of time the ZooKeeper servers in quorum have to connect to a leader.
syncLimit
syncLimit limits how far out of date a server can be from a leader.
tickTime
the basic time unit in milliseconds used by ZooKeeper.(In this example, the timeout for initLimit is 5 ticks at 2000 milleseconds a tick, or 10 seconds. => initLimit timeout = initLimit * tickTime)
server.x=ip:port1:port2
Finally, note the two port numbers after each server name: " 2888" and "3888". Peers use the former port to connect to other peers. Such a connection is necessary so that peers can communicate, for example, to agree upon the order of updates. More specifically, a ZooKeeper server uses this port to connect followers to the leader. When a new leader arises, a follower opens a TCP connection to the leader using this port. Because the default leader election also uses TCP, we currently require another port for leader election. This is the second port in the server entry.
dataLogDir
The dataLogDir parameters indicates a different directory to use for the transaction logs.
myid
The entries of the form server.X list the servers that make up the ZooKeeper service. When the server starts up, it knows which server it is by looking for the file myid in the data directory. That file has the contains the server number, in ASCII.
在一台机器上部署复制模式的zookeeper(人们口中的伪集群)
If you want to test multiple servers on a single machine, specify the servername as localhost with unique quorum & leader election ports (i.e. 2888:3888, 2889:3889, 2890:3890 in the example above) for each server.X in that server's config file. Of course separate dataDirs and distinct clientPorts are also necessary (in the above replicated example, running on a single localhost, you would still have three config files).
Please be aware that setting up multiple servers on a single machine will not create any redundancy. If something were to happen which caused the machine to die, all of the zookeeper servers would be offline. Full redundancy requires that each server have its own machine. It must be a completely separate physical server. Multiple virtual machines on the same physical host are still vulnerable to the complete failure of that host.