亚洲激情专区-91九色丨porny丨老师-久久久久久久女国产乱让韩-国产精品午夜小视频观看

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

kafka zookeeper配置初步

發布時間:2020-06-28 04:22:19 來源:網絡 閱讀:1769 作者:pgmia 欄目:開發技術

1.軟件需求

CentOS 7.2 X64

jdk-8u121-linux-x64.rpm

zookeeper-3.4.9.tar.gz

kafka_2.11-0.10.1.0.tgz

setuptools-33.1.1.zip 

kafka-python-1.3.2.tar.gz


2.安裝zookeeper、kafka

1).zookeeper

# tar -zxf zookeeper-3.4.9.tar.gz

# mv zookeeper-3.4.9 /usr/local/zookeeper

# mkdir -p /var/lib/zookeeper

# cat > /usr/local/zookeeper/conf/zoo.cfg << EOF

tickTime=2000

dataDir=/var/lib/zookeeper

clientPort=2181

EOF


# /usr/local/zookeeper/bin/zkServer.sh start

ZooKeeper JMX enabled by default

Using config: /usr/local/zookeeper/bin/../conf/zoo.cfg

Starting zookeeper ... STARTED

#


2).kafka

# tar -zxf kafka_2.11-0.10.1.0.tgz

# mv kafka_2.11-0.10.1.0 /usr/local/kafka

# mkdir /tmp/kafka-logs


# /usr/local/kafka/bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic telematics

fCreated topic "telematics".

#


3.create topics

# /usr/local/kafka/bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic telematics


4.topic操作

1).list topic

# /usr/local/kafka/bin/kafka-topics.sh --zookeeper localhost:2181 --list

telematics


2).describe topic

# /usr/local/kafka/bin/kafka-topics.sh --zookeeper localhost:2181 --describe --topic telematics

Topic:telematics        PartitionCount:1        ReplicationFactor:1     Configs:

        Topic: telematics       Partition: 0    Leader: 0       Replicas: 0     Isr: 0

#

3).delete topic

#/usr/local/kafka/bin/kafka-topics.sh --zookeeper localhost:2181 --delete --topic telematics


5.添加選項執行刪除命令時生效,否則只是標記為刪除

/usr/local/kafka/config/server.properties

delete.topic.enable=true


6.測試腳本

1). producer.py 

#!/usr/bin/python


from kafka import KafkaProducer

producer = KafkaProducer(bootstrap_servers='192.168.1.201:9092')


producer = KafkaProducer(key_serializer=str.encode, value_serializer=str.encode)

producer.send('telematics', key='ping', value=b'1234')


2). consumer.py

from kafka import KafkaConsumer

# To consume latest messages and auto-commit offsets

consumer = KafkaConsumer('telematics',bootstrap_servers=['192.168.1.201:9092'])

for message in consumer:

    # message value and key are raw bytes -- decode if necessary!

    # e.g., for unicode: `message.value.decode('utf-8')`

    print ("%s:%d:%d: key=%s value=%s" % (message.topic, message.partition,

                                          message.offset, message.key,

                                          message.value))



向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

平乡县| 农安县| 东安县| 翁源县| 江西省| 铜鼓县| 泰州市| 甘泉县| 阳江市| 昔阳县| 普宁市| 苏尼特左旗| 沧源| 乌拉特后旗| 邳州市| 宁河县| 黔江区| 吉木乃县| 大石桥市| 阆中市| 景洪市| 洞口县| 邓州市| 长白| 新河县| 台州市| 河津市| 松原市| 南宫市| 泽库县| 翁源县| 沭阳县| 嵩明县| 闵行区| 丹东市| 炉霍县| 阿拉善右旗| 全南县| 大姚县| 二连浩特市| 江津市|