赞
踩
zookeeper官网地址:https://www.apache.org/dyn/closer.cgi/zookeeper/
zookeeper下载地址:https://dlcdn.apache.org/zookeeper/zookeeper-3.6.3/
下载文件apache-zookeeper-3.5.7-bin.tar.gz 才是启动zookeepr需要的,千万别下载错。
zookeeper必须下载含有bin开头的tar包,若下载的不是bin开头的tar包,则会抛出找不到主类异常。
Zookeeper:无法加载主类,org.apache.zookeeper.server.quorum.QuorumPeerMain
若启动zkServer报错:找不到或无法加载主类,肯定是tar包版本下载不对。
1.环境准备 jdk环境 2.解压 tar -zxvf zookeeper-3.4.10.tar.gz -C /opt/module/ 3.修改配置 mv zoo_sample.cfg zoo.cfg vim zoo.cfg dataDir=/opt/module/zookeeper-3.4.10/zkData 4.启动 bin/zkServer.sh start 5.查看 jps
1. 启动客户端 [atguigu@hadoop103 zookeeper-3.4.10]$ bin/zkCli.sh 2.显示所有操作命令 [zk: localhost:2181(CONNECTED) 1] help 3. 查看当前 znode 中所包含的内容 [zk: localhost:2181(CONNECTED) 0] ls / [zookeeper] 4. 查看当前节点详细数据 [zk: localhost:2181(CONNECTED) 1] ls2 / [zookeeper] 5. 分别创建 2 个普通节点 [zk: localhost:2181(CONNECTED) 3] create /sanguo "jinlian" Created /sanguo [zk: localhost:2181(CONNECTED) 4] create /sanguo/shuguo "liubei" Created /sanguo/shuguo 6.获得节点的值 [zk: localhost:2181(CONNECTED) 5] get /sanguo jinlian
参考文档:zookeeper分布式协调服务框架
下载地址:https://kafka.apache.org/downloads.html
# 1.解压到op目录下 tar -zxvf kafka_2.11-0.11.0.0.tgz -C /op # 2.修改名称 mv kafka_2.11-0.11.0.0/ kafka # 3.在/opt/module/kafka 目录下创建 logs 文件夹 mkdir logs # 4.修改配置文件,具体参考如下 cd config/ vim server.properties # 5.修改两个点,一个是kafka数据存放目录,一个zookeeper连接地址 log.dirs=/tmp/kafka-logs zookeeper.connect=localhost:2181 # 6.单机启动 # 前台运行: bin/kafka-server-start.sh config/server.properties # 后台运行: nohup bin/kafka-server-start.sh config/server.properties > kafka-run.log 2>&1 & # 验证 jps
4.创建topic 创建kafka topic: bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic test 显示kafka topic: bin/kafka-topics.sh -list -zookeeper localhost:2181 5.创建生产者和消费者 创建kafka生产者: bin/kafka-console-producer.sh --broker-list localhost:9092 --topic test 创建kafka消费者: bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic test --from-beginning 设置kafka消费组名: bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic test --from-beginning --consumer-property group.id=test-group
参考文档:消息中间件Kafka详解
http://t.zoukankan.com/CoolJayson-p-10601515.html
赞
踩
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。