2021/07/21 기준
wsl2_kafka.bat을 사용하는 윈도우 스케줄 부분(3)은 최신 포스트에 WSL 스크립트를 활용한 더 나은 방식을 소개하였다.
apt update
apt install default-jdk
bash -c "cd ~;wget https://mirror.navercorp.com/apache/kafka/2.8.0/kafka_2.13-2.8.0.tgz;tar -xzf kafka_2.13-2.8.0.tgz;rm kafka_2.13-2.8.0.tgz;cd kafka_2.13-2.8.0/;"
vi config/server.properties
#server.property
listeners=PLAINTEXT://:9092
advertised.listeners=PLAINTEXT://${hostname}:9092
listener.security.protocol.map=PLAINTEXT:PLAINTEXT
md C:\wsl2_kafka&echo @echo off^&bash -c "cd ~/kafka_2.13-2.8.0/;sudo bin/kafka-server-stop.sh;sleep 10;sudo bin/zookeeper-server-stop.sh;sleep 10;sudo bin/zookeeper-server-start.sh -daemon config/zookeeper.properties;sleep 30;sudo bin/kafka-server-start.sh -daemon config/server.properties;" > C:\wsl2_kafka\wsl2_kafka.bat
schtasks /create /ru username /rp /sc onstart /tn wsl2_kafka /tr C:\wsl2_kafka\wsl2_kafka.bat /rl highest
bash
cd ~
su
echo "%sudo ALL=NOPASSWD: $(pwd)/kafka_2.13-2.8.0/bin/*" >> /etc/sudoers
shutdown -r -t 0