本文共 5551 字,大约阅读时间需要 18 分钟。
官方地址:
redis不能保证实时一致性和强一致性(最终一致性)
ZooKeeper已订购
ZooKeeper速度很快
我们使用术语znode来明确表示在谈论ZooKeeper数据节点
同时提供了一组保证
官方地址:
选择合适的版本,我的选择
wget https://www.apache.org/dyn/closer.lua/zookeeper/zookeeper-3.6.2/apache-zookeeper-3.6.2-bin.tar.gz
官方地址:
# The number of milliseconds of each ticktickTime=2000# The number of ticks that the initial # synchronization phase can takeinitLimit=10# The number of ticks that can pass between # sending a request and getting an acknowledgementsyncLimit=5# the directory where the snapshot is stored.# do not use /tmp for storage, /tmp here is just # example sakes.dataDir=/root/apache-zookeeper-3.6.2-bin/data# the port at which the clients will connectclientPort=2181# the maximum number of client connections.# increase this if you need to handle more clients#maxClientCnxns=60## Be sure to read the maintenance section of the # administrator guide before turning on autopurge.## http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance## The number of snapshots to retain in dataDir#autopurge.snapRetainCount=3# Purge task interval in hours# Set to "0" to disable auto purge feature#autopurge.purgeInterval=1## Metrics Providers## https://prometheus.io Metrics Exporter#metricsProvider.className=org.apache.zookeeper.metrics.prometheus.PrometheusMetricsProvider#metricsProvider.httpPort=7000#metricsProvider.exportJvmInfo=true
配置结束后启动
cd bin./zkServer.sh start
格式:service.N = YYY:A:B
server.1=node01:2888:3888server.2=node02:2888:3888server.3=node03:2888:3888
在每个结点server指定的dataDir目录下创建myid文件并写入对应的服务器编号
第一个结点,填入1,第二个结点,填入2,依此类推
打开文件/etc/profile,填入自己的zooke安装目录
export ZOOKEEPER_HOME=/root/apache-zookeeper-3.6.2-binexport PATH=$PATH:$ZOOKEEPER_HOME/bin
使能
source /etc/profile
create -e 创建临时节点
create -s 持久序列
[zk: localhost:2181(CONNECTED) 3] helpZooKeeper -server host:port -client-configuration properties-file cmd args addWatch [-m mode] path # optional mode is one of [PERSISTENT, PERSISTENT_RECURSIVE] - default is PERSISTENT_RECURSIVE addauth scheme auth close config [-c] [-w] [-s] connect host:port create [-s] [-e] [-c] [-t ttl] path [data] [acl] delete [-v version] path deleteall path [-b batch size] delquota [-n|-b] path get [-s] [-w] path getAcl [-s] path getAllChildrenNumber path getEphemerals path history listquota path ls [-s] [-w] [-R] path printwatches on|off quit reconfig [-s] [-v version] [[-file path] | [-members serverID=host:port1:port2;port3[,...]*]] | [-add serverId=host:port1:port2;port3[,...]]* [-remove serverId[,...]*] redo cmdno removewatches path [-c|-d|-a] [-l] set [-s] [-v version] path data setAcl [-s] [-v version] [-R] path acl setquota -n|-b val path stat [-w] path sync path version
通过添加版本号,维护同名节点,防止重命名
转载地址:http://jojkz.baihongyu.com/