大橙子网站建设,新征程启航

为企业提供网站建设、域名注册、服务器等服务

kafka配置

1.三节点主机环境:
#Red Hat Enterprise Linux Server release 7.5
192.168.154.128   my1.db.com   my1
192.168.154.129   my2.db.com   my2
192.168.154.130   my3.db.com   my3

2.配置jdk:
tar xvzf jdk-8u201-linux-x64.tar.gz
mv jdk1.8.0_201 /usr/local/jdk
vi .bash_profile
JAVA_HOME=/usr/local/jdk
PATH=$PATH:$HOME/bin:$JAVA_HOME/bin
source .bash_profile

3.下载zookeeper:
http://zookeeper.apache.org/releases.html
tar xvzf zookeeper-3.4.13.tar.gz
mv zookeeper-3.4.13 /usr/local/zookeeper

4.配置zookeeper:

编辑配置文件:
vi /usr/local/zookeeper/conf/zoo.cfg
tickTime=2000
dataDir=/usr/local/zookeeper/data
clientPort=2181
initLimit=5
syncLimit=2
dataLogDir=/usr/local/zookeeper/log
server.1=my1:2888:3888
server.2=my2:2888:3888
server.3=my3:2888:3888

创建目录:
mkdir -p /usr/local/zookeeper/data/
mkdir -p /usr/local/zookeeper/log/

echo 1 > /usr/local/zookeeper/data/myid
echo 2 > /usr/local/zookeeper/data/myid
echo 3 > /usr/local/zookeeper/data/myid

5.启动zookeeper:
/usr/local/zookeeper/bin/zkServer.sh start /usr/local/zookeeper/conf/zoo.cfg

查看状态:
/usr/local/zookeeper/bin/zkServer.sh status /usr/local/zookeeper/conf/zoo.cfg


6.下载kafka:
http://kafka.apache.org/downloads
tar xvzf kafka_2.12-2.0.0.tgz
mv kafka_2.12-2.0.0 /usr/local/kafka

mkdir -p /usr/local/kafka/data

编辑配置文件:
vi /usr/local/kafka/config/server.properties
broker.id=1
listeners=PLAINTEXT://my1:9092
zookeeper.connect=192.168.154.128:2181,192.168.154.129:2181,192.168.154.130:2181
delete.topic.enable=true

启动kafka:
/usr/local/kafka/bin/kafka-server-start.sh -daemon /usr/local/kafka/config/server.properties

查看确认:
jps

7.测试kafka:
创建一个测试topic:
/usr/local/kafka/bin/kafka-topics.sh --zookeeper 192.168.154.128:2181,192.168.154.129:2181,192.168.154.130:2181 --create --topic test-topic --partitions 3 --replication-factor 3
查看topic:
/usr/local/kafka/bin/kafka-topics.sh --zookeeper 192.168.154.128:2181,192.168.154.129:2181,192.168.154.130:2181 --list
/usr/local/kafka/bin/kafka-topics.sh --zookeeper 192.168.154.128:2181,192.168.154.129:2181,192.168.154.130:2181 --describe --topic test-topic

删除topic:
/usr/local/kafka/bin/kafka-topics.sh --zookeeper 192.168.154.128:2181,192.168.154.129:2181,192.168.154.130:2181 --delete --topic test-topic

producer发送消息:
/usr/local/kafka/bin/kafka-console-producer.sh --broker-list my1:9092,my2:9092,my3:9092 --topic test-topic

consumer消费消息:
/usr/local/kafka/bin/kafka-console-consumer.sh --bootstrap-server my1:9092,my2:9092,my3:9092 --topic test-topic --from-beginning

生产者吞吐量测试:
/usr/local/kafka/bin/kafka-producer-perf-test.sh --topic test-topic --num-records 500000 --record-size 200 --throughput -1 --producer-props bootstrap.servers=192.168.154.128:9092,192.168.154.129:9092,192.168.154.130:9092 acks=1

千山网站制作公司哪家好,找创新互联公司!从网页设计、网站建设、微信开发、APP开发、响应式网站开发等网站项目制作,到程序开发,运营维护。创新互联公司公司2013年成立到现在10年的时间,我们拥有了丰富的建站经验和运维经验,来保证我们的工作的顺利进行。专注于网站建设就选创新互联公司


新闻名称:kafka配置
当前链接:http://dzwzjz.com/article/pchodd.html
在线咨询
服务热线
服务热线:028-86922220
TOP