kafka学习
1、kafka一主多从,从是用来提高容灾能力,并无其他用处,每次都是从拉取主获取数据
2、AR(所有副本) = ISR(从副本in-sync,在一定的滞后范围之内)+ OSR(从副本out-sync 滞后范围之外的副本)
kafka安装
1、安装zookeeper
wget -P /home/tools/ http://mirrors.hust.edu.cn/apache/zookeeper/zookeeper-3.4.14/zookeeper-3.4.14.tar.gz
cd /home/tools/
tar zxvf zookeeper-3.4.14.tar.gz
mv zookeeper-3.4.14 /usr/local/
cd /usr/local/zookeeper-3.4.14/conf
cp zoo_sample.cfg zoo.cfg
修改数据目录和日志目录
dataDir=/tmp/zookeeper/data
dataLogDir=/tmp/zookeeper/log
创建目录:
mkdir -p /tmp/zookeeper/data
mkdir -p /tmp/zookeeper/log
放入配置文件,
export ZOOKEEPER_HOME=/usr/local/zookeeper-3.4.14
export PATH=$PATH::$ZOOKEEPER_HOME/bin
source /etc/profile
启动:
zkServer.sh start
zkServer.sh status
2、kafka安装
wget -P /home/tools/ http://archive.apache.org/dist/kafka/2.0.0/kafka_2.11-2.0.0.tgz
cd /home/tools/
tar zxvf kafka_2.11-2.0.0.tgz
mv kafka_2.11-2.0.0 /usr/local/
cd /usr/local/kafka_2.11-2.0.0/config
vim server.properties
打开并改成listeners=PLAINTEXT://localhost:9092
vim /etc/profile
export KAFKA_HOME=/usr/local/kafka_2.11-2.0.0
export PATH=$PATH::$KAFKA_HOME/bin
source /etc/profile
启动:
cd ../bin
kafka-server-start.sh ../config/server.properties &
3、测试
kafka-topics.sh --create --replication-factor 1 --partitions 3 --topic test
kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 3 --topic test
kafka-topics.sh --list --zookeeper localhost:2181