11-Zookeeper

ZK 1) 高可用: HDFS/HBase/Spark HA2) API:ZK/Curator开发:Java/Scala操作ZKKafka:offset可以存储在ZK ==> 实时流处理:Kafka+Streaming zero data lostenables highly reliable distributed coordination分布式协调服务分布式系统:NN active(x) standby(√)ZK 集群: n(>1)/2+1 3/5/7/9N REDIS/... configuration file same1: /ruozedata/conf/ruoze.confport=9999 2: watch..... download ...3: .....ZK部署1) 下载2) 解压到~/app3) 添加到环境变量export ZK_HOME=/home/hadoop/app/zookeeper-3.4.5-cdh5.7.0export PATH=$ZK_HOME/bin:$PATH4) 配置文件cp zoo_sample.cfg zoo.cfgdataDir=/home/hadoop/app/tmp/zookeeperclientPort=21815) 启动./zkServer.sh start6) 检测jps: QuorumPeerMainZK基本数据模型一个树形结构znode:临时节点:对当前session有效永久节点:特点znode: id ==> id -> pidznode data change ==> version + 1data: not bigZK常用命令lsgetls2create -e: 临时节点-s: 顺序节点pZxidset 和 delete 要注意versionZK四字命令ZK集群主从选举: 3 zk伪分布式:1台机器上搭建多个ZK节点zk001dataDir=/home/hadoop/app/tmp/zookeeper001server.1=localhost:2888:3888server.2=localhost:2889:3889server.3=localhost:2890:3890真正分布式dataDir=/home/hadoop/app/tmp/zookeeperserver.1=ruoze-hadoop000:2888:3888server.2=ruoze-hadoop001:2888:3888server.3=ruoze-hadoop002:2888:3888${dataDir}/myid watch针对每个节点的操作,都有一个监督站:watcherzk里面的watcher是一次性的 NodeDeletedNodeDataChangedNodeCreated ZK APIpom.xml3.4.5-cdh5.7.0org.apache.zookeeperzookeeper${zk.version}获取节点的孩子数量常用的Java API操作ZK的客户端zookeeperzkclient: spark streaming + kafkacurator

你可能感兴趣的:(11-Zookeeper)