赞
踩
从名字上直译就是动物管理员,动物指的是 Hadoop 一类的分布式软件,管理员三个字体现了 ZooKeeper 的特点:维护、协调、管理、监控
是一种消息队列,主要用来处理大量数据状态下的消息队列,一般用来做日志的处理
最终一致性 可靠性 实时性 独立性 原子性
高吞吐量、低延迟 可扩展性 容错性 高并发
①在Kafka的设计中,选择了使用Zookeeper来进行所有Broker的管理
②生产者负载均衡
传统的4层负载均衡 使用zookeeper进行负载均衡
③消费者的负载均衡和生产负载均衡类似
④记录消息分区于消费者的关系,都是通过创建修改zookeeper上相应的节点实现
⑤记录消息消费进度Offset记录,都是通过创建修改zookeeper上相应的节点实现
解压:
tar -zxvf apache-zookeeper-3.8.3-bin (9).tar.gz -C ../server
创建软连接:
ln -s zookeeper-3.8.3/ zookeeper
vim /etc/profile
export ZOOKEEPER_HOME=/opt/server/apache-zookeeper-3.8.3-bin
export PATH=$PATH:$ZOOKEEPER_HOME/bin
scp -r /etc/profile root@192.168.229.112(113): /etc/profile (xsync /etc/profile)
cd /opt/server/zookeeper/conf
mv zoo_sample.cfg zoo.cfg
vim zoo.cfg
dataDir=/opt/server/zookeeper/zkdata
###########cluster#########
server.1=192.168.229.111:2888:3888
server.2=192.168.229.112:2888:3888
server.3=192.168.229.113:2888:3888
mkdir zkdata
vim myid
echo > 1 myid
scp -r zookeeper-3.8.3/ root@192.168.229.12(113): /opt/server
hadoop2:echo > 2 myid
hadoop3:echo > 3 myid
cd /opt/server/zookeeper/bin/
./zkServer.sh start
需要3台集群都启动ZK,才能查看状态,查看进程不一定代表zk启动了,zk的状态才能代表zk的启动
./zkServer.sh status
jps
./zkServer.sh stop
cd /opt/script/
vim zk.sh
#./bin/base
case $1 in
"start"){
for i in hadoop1 hadoop2 hadoop3
do
echo "------------- $1 --------------"
ssh $1 "/opt/server/zookeeper-3.8.3/bin/zkServer.sh start"
done
};;
"stop"){
for i in hadoop1 hadoop2 hadoop3
do
echo "------------- $1 --------------"
ssh $1 "/opt/server/zookeeper-3.8.3/bin/zkServer.sh stop"
done
};;
"status"){
for i in hadoop1 hadoop2 hadoop3
do
echo "------------- $1 --------------"
ssh $1 "/opt/server/zookeeper-3.8.3/bin/zkServer.sh status"
done
};;
esac
chmod 777 zk.sh
./zk.sh start
jps
./zk.sh status
./zk.sh stop
./zk.sh status
解压
tar -zxvf kafka_2.11-2.4.1.tgz -C ../server/
创建软连接
ln -s kafka_2.11-2.4.1/ kafka
vim /etc/profile
export KAFKA_HOME=/opt/server/kafka_2.11-2.4.1
export PATH=$PATH:$KAFKA_HOME/bin
scp -r /etc/profile root@192.168.229.112(113): /etc/profile (xsync /etc/profile)
cd /opt/server/kafka/config/
vim server.properties
broker.id=0
log.dirs=/opt/server/kafka-2.11-2.4.1
zookeeper.connect=hadoop1:2181,hadoop2:2181,hadoop3:2181/kafka
mkdir logs
scp -r kafka_2.11-2.4.1/ root@192.168.229.112(113): /opt/server/
Hadoop2
Hadoop3
./zk.sh start
./zk.sh status
cd /opt/server/kafka/bin/
kafka-server-start.sh -daemon ../config/server.properties
jps
kafka-server-stop.sh -daemon ../config/server.properties
务必确保kafka服务完全停止,再关闭ZK服务,否则可能会丢失数据
cd /opt/script/
vim kf.sh
#!/bin/bash
case $1 in
"start"){
for i in hadoop1 hadoop2 hadoop3
do
echo -------------------------------- $i kafka 启动 ---------------------------
ssh $i "source /etc/profile;/opt/server/kafka/bin/kafka-server-start.sh -daemon /opt/server/kafka/config/server.properties"
done
}
;;
"stop"){
for i in hadoop1 hadoop2 hadoop3
do
echo -------------------------------- $i kafka 停止 ---------------------------
ssh $i "/opt/server/kafka/bin/kafka-server-stop.sh"
done
}
;;
esac
chmod 777 kf.sh
./zk.sh start
./zk.sh status
./kf.sh start
./xcall.sh jps
./kf.sh stop
./zk.sh stop
谢谢观看
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。