1.在linux下运行脚本目录是:/build/kafka/reset_topic.sh
下的新建好:(注意topic的服务器地址的置:KAFKA_BROKERS=192.168.0.197:9092)
qzc的文件:
#!/usr/bin/env bash
KAFKA_HOME=/home/sen/tools/kafka_2.12-2.3.0
#topic_names=(test_new_tx_qzc test_cache_qzc test_entity_qzc test_conflict_notice_qzc)
#topic_names=(btc_new_tx btc_cache btc_entity btc_conflict_notice)
#topic_names=(ltc_new_tx ltc_cache ltc_entity ltc_conflict_notice)
topic_names=(bch_new_tx bch_cache bch_entity bch_conflict_notice)
#topic_names=(btc_conflict_notice_aliyun)
#topic_names=(aml_track_result_test test_monitor_account)
for topic_name in ${topic_names[@]}
do
### 创建kafka Topic
# 删除topic
$KAFKA_HOME/bin/kafka-topics.sh --delete --zookeeper kafka-1:2181 --topic $topic_name
# 创建topic
$KAFKA_HOME/bin/kafka-topics.sh --bootstrap-server kafka-1:9092 --create --topic $topic_name --partitions 5 --replication-factor 1
# topic消息留存时间, -1为永久
$KAFKA_HOME/bin/kafka-configs.sh --zookeeper kafka-1:2181 --entity-type topics --entity-name $topic_name --alter --add-config retention.ms=-1
# topic最大存储空间
$KAFKA_HOME/bin/kafka-configs.sh --zookeeper kafka-1:2181 --entity-type topics --entity-name $topic_name --alter --add-config retention.bytes=107374182400
# 单条消息大小
$KAFKA_HOME/bin/kafka-configs.sh --zookeeper kafka-1:2181 --entity-type topics --entity-name $topic_name --alter --add-config max.message.bytes=524288000
done
2.自测在windows本地进行运行reset_topic.py :(本次是复制到桌面,右键打开git bash here): sh reset_topic.sh
#!/usr/bin/binenv bash
#KAFKA_HOME=/home/sen/tools/kafka_2.12-2.3.0
KAFKA_HOME=D:/sotfwares/kafka/kafka_2.13-2.4.1
topic_names=(test_new_tx_lxxx test_cache_lxxx test_entity_lxxx test_conflict_notice_lxxx)
#topic_names=(btc_new_tx btc_cache btc_entity btc_conflict_notice)
#topic_names=(ltc_new_tx ltc_cache ltc_entity ltc_conflict_notice)
#topic_names=(bch_new_tx bch_cache bch_entity bch_conflict_notice)
#topic_names=(btc_conflict_notice_aliyun)
#topic_names=(aml_track_result_test test_monitor_account)
for topic_name in ${topic_names[@]}
do
### 创建kafka Topic
# 删除topic
$KAFKA_HOME/bin/windows/kafka-topics.bat --delete --zookeeper localhost:2181 --topic $topic_name
# 创建topic
$KAFKA_HOME/bin/windows/kafka-topics.bat --bootstrap-server localhost:9092 --create --topic $topic_name --partitions 5 --replication-factor 1
# topic消息留存时间, -1为永久
$KAFKA_HOME/bin/windows/kafka-configs.bat --zookeeper localhost:2181 --entity-type topics --entity-name $topic_name --alter --add-config retention.ms=-1
# topic最大存储空间
$KAFKA_HOME/bin/windows/kafka-configs.bat --zookeeper localhost:2181 --entity-type topics --entity-name $topic_name --alter --add-config retention.bytes=107374182400
# 单条消息大小
$KAFKA_HOME/bin/windows/kafka-configs.bat --zookeeper localhost:2181 --entity-type topics --entity-name $topic_name --alter --add-config max.message.bytes=524288000
done
3. pychrm 配置 py文件的环境变量
1.新建一个测试启动模块的文件: test_waiter_new_tx.py
![](https://i-blog.csdnimg.cn/blog_migrate/b4daf73c5d8d8624c248a50e32e2f088.png)
![](https://i-blog.csdnimg.cn/blog_migrate/670310fc9122cda16164b5abe27f1d74.png)
"""
PYTHONUNBUFFERED=1;KAFKA_WAITER_TOPIC=test_new_tx_lx;MONGO_COLLECTION=btc_new_transactions;KAFKA_GROUP_ID_WAITER=new_tx_1;METHOD=new_tx;
PYTHONUNBUFFERED=1;KAFKA_WAITER_TOPIC=test_new_tx_qzc;MONGO_COLLECTION=btc_new_transactions;KAFKA_GROUP_ID_WAITER=new_tx_1;METHOD=new_tx;
"""
2.先在 from waiter import Waiter 处打上断点,debug运行一下,
![](https://i-blog.csdnimg.cn/blog_migrate/76cc0bdb1fa4726a9b50ba74fb0b08fb.png)
![](https://i-blog.csdnimg.cn/blog_migrate/2b8699c58c9df07d8e4a08f11e99e28b.png)
最后可以保存配置文件:
![](https://i-blog.csdnimg.cn/blog_migrate/76a0d30224bd720cead44234a8ee4909.png)