Kafka
1.安装
1.1 下载安装
# cd /opt
# wget http://mirrors.tuna.tsinghua.edu.cn/apache/kafka/1.1.0/kafka_2.11-1.1.0.tgz
# tar -xzf kafka_2.11-1.1.0.tgz
# mv kafka_2.11-1.1.0 kafka
1.2 配置
# vim config/server.config
# The address the socket server listens on. It will get the value returned from
# java.net.InetAddress.getCanonicalHostName() if not configured.
# FORMAT:
# listeners = listener_name://host_name:port
# EXAMPLE:
# listeners = PLAINTEXT://your.host.name:9092
listeners=PLAINTEXT://${ip}:9092
# A comma separated list of directories under which to store log files
log.dirs=/home/q/kafka/logs
advertised.host.name=${ip}
1.3 启动
后台启动: start_kafka.sh
/home/q/kafka/bin/kafka-server-start.sh /home/q/kafka/config/server.properties 1>/dev/null 2>&1 &
1.3 基本使用
创建Topic
> bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic test
查看Topic
> bin/kafka-topics.sh --list --zookeeper localhost:2181
test
发送消息
> bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic test --from-beginning
This is a message
This is another message