由于每次启动本机的kafka都需要打开2个cmd窗口,分别启动zookeeper服务和kafka服务,操作相对繁琐,于是想起了批处理来帮忙一键启动。
在桌面新建一个txt文件,改后缀名为.bat,并加上下面的代码。
cd/d E:\study\kafka\kafka_2.11-1.1.0 start cmd /k bin\windows\zookeeper-server-start.bat config\zookeeper.properties start cmd /k bin\windows\kafka-server-start.bat config\server.properties
代码结尾不加pause的原因是,执行完关闭窗口,因为不需要改窗口保留着,免得手动关闭。
1. start 用来启动一个应用
2. cmd /k 表示cmd后面的命令执行完后不关闭窗口。如果要在执行完成后关闭窗口可以用/c
3. cd /d 表示运行到该目录下
原文:https://www.cnblogs.com/fangjb/p/13275210.html