Configuration cho kafka command line (Ubuntu)#

Người dùng có thể access Sun Kafka Highway qua nhiều interface, bài viết sau sẽ hướng dẫn access đến Sun Kafka Highway cluster qua giao diện command line. Bài viết đã được test với các điều kiện

Pre-condition

Bước 1: Download kafka client tool#

wget https://downloads.apache.org/kafka/3.4.0/kafka_2.13-3.4.0.tgz

Bước 2: Giải nén và cd vào thư mục bin#

tar zxvf kafka_2.13-3.4.0.tgz
cd kafka_2.13-3.4.0/bin  

Bước 3: Tạo file cấu hình kết nối config.properties#

touch config.properties

Điền các thông tin kết nối từ file <api_key>.json vào file .properties

vi config.properties
sasl.jaas.config=org.apache.kafka.common.security.scram.ScramLoginModule required username="<api-key>" password="<api-secret>";
security.protocol=SASL_SSL
sasl.mechanism=SCRAM-SHA-512
bootstrap.servers=<bootstrap-server-link>

Result:

Test kết nối với

sh kafka-topics.sh --list --bootstrap-server <boostrap-server-link> --command-config ./config.properties

Extend:

Đối với hệ điều hành windown chúng ta có thể download kafka package từ trang chủ của kafka.

Sau đó dùng một bash tool (vd: git bash) để run các command trên.

Ngoài ra bạn cùng có thể dùng cmd / powershell của window bằng cách open cmd / powershell terminal và thực hiện cd tới bin/windows

cd kafka_2.13-3.4.0/bin/windows

Và thực hiện các câu lệnh tương tự. Chú ý thay .sh = .bat