赞
踩
1、安装jdk
yum search jdk # 查找jdk
yum install java-latest-openjdk.x86_64 # 选择jdk安装,这里选择最新的版本
下载 http://archive.apache.org/dist/kafka/
wget http://archive.apache.org/dist/kafka/2.6.0/kafka_2.12-2.6.0.tgz
2、下载kafka
去 https://mirrors.tuna.tsinghua.edu.cn/apache/kafka 找到对应版本下载
cd /usr/local
wget https://mirrors.tuna.tsinghua.edu.cn/apache/kafka/2.6.0/kafka_2.12-2.6.0.tgz
tar zxf kafka_2.12-2.6.0.tgz
mv kafka_2.12-2.6.0 kafka
3、启动kafka
cd kafka
./bin/zookeeper-server-start.sh ./config/zookeeper.properties # 先启动zookeeper
./bin/kafka-server-start.sh ./config/server.properties # 再启动kafka
1、添加/修改配置文件
vim ./config/kafka_zoo_jaas.conf
Server{
org.apache.kafka.common.security.plain.PlainLoginModule required
username="admin"
password="admin-kafka"
user_admin="admin-kafka";
};
vim ./config/kafka_server_jaas.conf
KafkaServer {
org.apache.kafka.common.security.plain.PlainLoginModule required
username="admin"
password="admin-kafka"
user_admin="admin-kafka"
user_test="test123";
};Client {
org.apache.kafka.common.security.plain.PlainLoginModule required
username="admin"
password="admin-kafka"
};KafkaClient {
org.apache.kafka.common.security.plain.PlainLoginModule required
username="admin"
password="admin-kafka"
};
vim ./bin/zookeeper-server-start.sh 在最前面加入
export KAFKA_OPTS=" -Djava.security.auth.login.config=/usr/local/kafka/config/kafka_zoo_jaas.conf -Dzookeeper.sasl.serverconfig=Server"
vim ./bin/kafka-server-start.sh 在最前面加入
export KAFKA_OPTS=" -Djava.security.auth.login.config=/usr/local/kafka/config/kafka_server_jaas.conf"
vim ./config/zookeeper.properties 在最后面加入
authProvider.1=org.apache.zookeeper.server.auth.SASLAuthenticationProvider
requireClientAuthScheme=sasl
jaasLoginRenew=3600000
vim ./config/zookeeper.properties 在最后面加入
#修改listeners
listeners=SASL_PLAINTEXT://192.168.0.106:9092
#使用的认证协议
security.inter.broker.protocol=SASL_PLAINTEXT
#SASL机制
sasl.enabled.mechanisms=PLAIN
sasl.mechanism.inter.broker.protocol=PLAIN
#完成身份验证的类
authorizer.class.name=kafka.security.auth.SimpleAclAuthorizer
#如果没有找到ACL(访问控制列表)配置,则允许任何操作。
#allow.everyone.if.no.acl.found=true
super.users=User:admindelete.topic.enable=true
auto.create.topics.enable=true
2、重启 zookeeper 和 kafka
./bin/zookeeper-server-start.sh ./config/zookeeper.properties # 先启动zookeeper
./bin/kafka-server-start.sh ./config/server.properties # 再启动kafka
kafka/
kafka/bin/
kafka/config/
kafka/config/zookeeper.properties
直接使用bin目录下自带的其他命令行客户端时,需要添加
export KAFKA_OPTS=" -Djava.security.auth.login.config=/usr/local/kafka/config/kafka_server_jaas.conf"
官网-快速开始:Kafka 中文文档 - ApacheCN
(1)zookeeper 文件
bin/zookeeper-server-start.sh
bin/zookeeper-server-stop.sh
config/zookeeper.properties
(2)启动 zookeeper
./bin/zookeeper-server-start.sh ./config/zookeeper.properties
(1)kafka 文件
bin/kafka-server-start.sh
bin/kafka-server-stop.sh
config/server.properties
(2)启动 kafka
./bin/kafka-server-start.sh ./config/server.properties
(1)文件
bin/kafka-topics.sh
config/producer.properties
(2)创建 topic
./bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic test
可以减小 kafka 内存要求:vim config/server.properties
Xmx:最大内存
Xms:初始内存
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。