189 8069 5689

kafka深度研究之路(3)-kafka与zk集群启停脚本-创新互联

编写 kafka集群 启动 和 停止脚本

创新互联专注于网站建设,为客户提供网站设计、成都网站设计、网页设计开发服务,多年建网站服务经验,各类网站都可以开发,品牌网站建设,公司官网,公司展示网站,网站设计,建网站费用,建网站多少钱,价格优惠,收费合理。
[hadoop@kafka01-55-11 scripts]$ cat kafka_cluster_stop.sh
#!/bin/bash -x
#date 20190801
#autnor majihui

clush -g all "source /etc/profile ;jps|grep Kafka|awk '{print $1}' | xargs kill -9 "

[hadoop@kafka01-55-11 scripts]$ cat kafka_cluster_start.sh    
#!/bin/bash -x
#author majihui
#date 20190801

clush -g all "source /etc/profile ;jps|grep Kafka|awk '{print $1}' | xargs kill -9 "
sleep 3
clush -g all "source /etc/profile;/home/hadoop/kafka/bin/kafka-server-start.sh -daemon /home/hadoop/kafka/config/server.properties"

他的输出日志 在

[hadoop@kafka01-55-11 scripts]$ ls -l ~/kafka/logs/
total 164
-rw-rw-r-- 1 hadoop hadoop   316 Aug  2 17:25 controller.log
-rw-rw-r-- 1 hadoop hadoop     0 Aug  2 17:25 kafka-authorizer.log
-rw-rw-r-- 1 hadoop hadoop     0 Aug  2 17:25 kafka-request.log
-rw-rw-r-- 1 hadoop hadoop  6123 Aug  2 17:25 kafkaServer-gc.log.0.current
-rw-rw-r-- 1 hadoop hadoop 54058 Aug  2 17:25 kafkaServer.out
-rw-rw-r-- 1 hadoop hadoop   172 Aug  2 17:25 log-cleaner.log
-rw-rw-r-- 1 hadoop hadoop 54058 Aug  2 17:25 server.log
-rw-rw-r-- 1 hadoop hadoop 33737 Aug  2 17:25 state-change.log

[hadoop@kafka01-55-11 scripts]$ cat /etc/clustershell/groups
all: kafka01-55-11 kafka02-55-12 kafka03-55-13
kafka_slave: kafka02-55-12 kafka03-55-13

zookeeper 启动和停止脚本

[hadoop@kafka01-55-11 scripts]$ cat zookeeper_cluster_stop.sh 
#!/bin/bash -x
#author:majihui
#date:20190801

clush -g all  "source /etc/profile; zkServer.sh stop"
[hadoop@kafka01-55-11 scripts]$ cat zookeeper_cluster_start.sh      // 这里面指定了zookeeper.out 输出到 /data/zookeeper/data/zookeeper.out 
#!/bin/bash -x
#author:majihui
#date:20190801

clush -g all  "source /etc/profile; cd /data/zookeeper/data && zkServer.sh start|sort"
sleep 3
clush -g all  "source /etc/profile; zkServer.sh status|sort"
[hadoop@kafka03-55-13 ] pwd
/data/zookeeper/data
[hadoop@kafka03-55-13 data]$ ll
total 20
-rw-rw-r-- 1 hadoop hadoop     2 Aug  1 01:04 myid
drwxrwxr-x 2 hadoop hadoop    45 Aug  1 01:33 version-2
-rw-rw-r-- 1 hadoop hadoop 11623 Aug  1 01:33 zookeeper.out
-rw-rw-r-- 1 hadoop hadoop     5 Aug  1 01:33 zookeeper_server.pid

[hadoop@kafka01-55-11 scripts]$ cat jps_cluster_check.sh 
#!/bin/bash

clush -g all "source /etc/profile;jps|sort"

以上启动脚本 编写完成
需要结合与clush

[hadoop@kafka01-55-11 scripts]$ cat /etc/clustershell/groups
all: kafka01-55-11 kafka02-55-12 kafka03-55-13
kafka_slave: kafka02-55-12 kafka03-55-13
[hadoop@kafka01-55-11 scripts]$ ll
total 28
-rw-rw-r-- 1 hadoop hadoop  57 Aug  1 15:01 jps_cluster_check.sh
-rw-rw-r-- 1 hadoop hadoop 312 Aug  1 14:51 kafka_cluster_start.sh
-rw-rw-r-- 1 hadoop hadoop 132 Aug  1 14:43 kafka_cluster_stop.sh
-rw-rw-r-- 1 hadoop hadoop 291 Aug  1 14:23 start_kafka_manager.sh
-rw-rw-r-- 1 hadoop hadoop 286 Aug  1 14:28 stop_kafka_manager.sh
-rw-rw-r-- 1 hadoop hadoop 176 Aug  1 14:57 zookeeper_cluster_start.sh
-rw-rw-r-- 1 hadoop hadoop 101 Aug  1 14:56 zookeeper_cluster_stop.sh
[hadoop@kafka01-55-11 scripts]$ chmod +x *sh
[hadoop@kafka01-55-11 scripts]$ ll
total 28
-rwxrwxr-x 1 hadoop hadoop  57 Aug  1 15:01 jps_cluster_check.sh
-rwxrwxr-x 1 hadoop hadoop 312 Aug  1 14:51 kafka_cluster_start.sh
-rwxrwxr-x 1 hadoop hadoop 132 Aug  1 14:43 kafka_cluster_stop.sh
-rwxrwxr-x 1 hadoop hadoop 291 Aug  1 14:23 start_kafka_manager.sh
-rwxrwxr-x 1 hadoop hadoop 286 Aug  1 14:28 stop_kafka_manager.sh
-rwxrwxr-x 1 hadoop hadoop 176 Aug  1 14:57 zookeeper_cluster_start.sh
-rwxrwxr-x 1 hadoop hadoop 101 Aug  1 14:56 zookeeper_cluster_stop.sh

另外有需要云服务器可以了解下创新互联scvps.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。


本文名称:kafka深度研究之路(3)-kafka与zk集群启停脚本-创新互联
转载注明:http://jkwzsj.com/article/djojdi.html

其他资讯