Try   HackMD

Kafka Zookeeper

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

Criação de Usuário

sudo su

:arrow_forward: criação usuario:
adduser belem
senha: root1@

:arrow_forward: adicionando usuario ao grupo sudo
usermod -aG sudo belem

:arrow_forward: Entrar no usuario
su - belem

Instalação Java 11

sudo apt update

Instalação
sudo apt install openjdk-11-jre-headless -y

Instalação Kafka

https://www.vultr.com/docs/install-apache-kafka-on-ubuntu-20-04

mkdir ~/Downloads
cd Downloads

#DESATUALIZADO: wget https://dlcdn.apache.org/kafka/3.1.0/kafka_2.12-3.1.0.tgz
curl "https://archive.apache.org/dist/kafka/2.8.2/kafka_2.13-2.8.2.tgz" -o ~/Downloads/kafka_2.13-2.8.2.tgz

sudo mkdir /usr/local/kafka-server
sudo tar -xzf kafka_2.13-2.8.2.tgz
sudo mv kafka_2.13-2.8.2.tgz/* /usr/local/kafka-server
#sudo nano /etc/systemd/system/zookeeper.service

mkdir ~/kafka

sudo mv kafka_2.13-2.8.2/ ~/kafka

cd ~/kafka

Dar permissão de escrita:
sudo chmod a+w server.properties
.

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

.
sudo nano ~/kafka/config/server.properties

Adicionar na ultima linha do arquivo server.properties

delete.topic.enable = true
log.dirs=/home/belem/kafka/logs

:arrow_forward: Dar permissão de escrita:
sudo nano /etc/systemd/system/kafka.service

[Unit]
Requires=zookeeper.service
After=zookeeper.service

[Service]
Type=simple
User=belem
ExecStart=/bin/sh -c '/home/belem/kafka/bin/kafka-server-start.sh /home/belem/kafka/config/server.properties > /home/belem/kafka/kafka.log 2>&1'
ExecStop=/home/belem/kafka/bin/kafka-server-stop.sh
Restart=on-abnormal

[Install]
WantedBy=multi-user.target

:arrow_forward: Iniciar o Kafka:
sudo systemctl start kafka

Primeiro iniciar o Zookeeper depois o Kafka

Configuração do Zookeeper

:arrow_forward: Dar permissão de escrita:
sudo chmod a+w /etc/systemd/system/zookeeper.service

:arrow_forward: Alterar
sudo nano /etc/systemd/system/zookeeper.service
.

[Unit]
Requires=network.target remote-fs.target
After=network.target remote-fs.target

[Service]
Type=simple
User=belem
ExecStart=/home/belem/kafka/bin/zookeeper-server-start.sh /home/belem/kafka/config/zookeeper.properties
ExecStop=/home/belem/kafka/bin/zookeeper-server-stop.sh
Restart=on-abnormal

[Install]
WantedBy=multi-user.target

:triangular_flag_on_post: IMPORTANTE ESTAR NO USUARIO BELEM

https://www.confluent.io/blog/set-up-and-run-kafka-on-windows-linux-wsl-2/

cd kafka

:arrow_forward: Dar permissão de escrita
sudo chmod a+w zookeeper.properties

:arrow_forward: Alterar a porta do arquivo
sudo nano ~/kafka/config/zookeeper.properties
Alterar a porta de 2181 para 2182

Iniciar o Zookeeper

:arrow_forward: Iniciar o zookeeper
sudo bin/zookeeper-server-start.sh config/zookeeper.properties

Iniciar o Kafka

:arrow_forward: Abra outra sessão de terminal. Inicie o broker Kafka:
cd kafka
sudo bin/kafka-server-start.sh config/server.properties

:arrow_forward: Criação do tópico:
bin/kafka-topics.sh --create --topic quickstart-events --bootstrap-server localhost:9092

:arrow_forward: Abrir outra janela, iniciar producer para enviar as mensagens
bin/kafka-console-producer.sh --topic quickstart-events --bootstrap-server localhost:9092

:arrow_forward: Abrir outra janela, iniciar consumer para receber as mensagens
bin/kafka-console-consumer.sh --topic quickstart-events --from-beginning --bootstrap-server localhost:9092

tags: dbc, kafka, zookeeper