文章目录
一、部署规划
1.1 版本说明
软硬件信息 | 参数 |
---|---|
配置 | 2C2G |
操作系统版本 | CentOS Linux release 7.7.1908 (Core) |
java版本 | java version “1.8.0_251” |
Hadoop版本 | Hadoop 3.3.0 |
kafka版本 | kafka 2.5.0 |
1.2 服务器规划
服务器 | IP | 角色 |
---|---|---|
node1 | 192.168.137.86 | zk、namenode、zkfc、datanode、nodemanager、journalnode、kafka |
node2 | 192.168.137.87 | zk、namenode、zkfc、datanode、nodemanager、resourcemanager、journalnode、kafka |
node3 | 192.168.137.88 | zk、datanode、nodemanager、resourcemanager、journalnode、kafka |
1.3 配置目录规划
软件 | 目录 |
---|---|
kafka消息存放的目录 | /data/hadoop/log/kafka-logs |
二、kafka部署
2.1 解压安装包并配置环境变量
tar xf kafka_2.12-2.5.0.tgz -C /usr/local/
mv /usr/local/kafka_2.12-2.5.0/ /usr/local/kafka
chown -R hadoop.hadoop /usr/local/kafka/
cat>>/etc/profile <<EOF
PATH=/usr/local/kafka/bin:$PATH
export PATH
EOF
source /etc/profile
2.2 修改核心配置文件
cd /usr/local/kafka/config
2.2.1 配置 server.properties
//当前机器在集群中的唯一标识,和zookeeper的myid性质一样
broker.id=1
//当前kafka对外提供服务的端口默认是9092
port=9092
//这个参数默认是关闭的,在0.8.1有个bug,DNS解析问题,失败率的问题。
host.name=node1
//这个是borker进行网络处理的线程数
num.network.threads=3
//这个是borker进行I/O处理的线程数
num.io.threads=8
//发送缓冲区buffer大小,数据不是一下子就发送的,先回存储到缓冲区了到达一定的大小后在发送,能提高性能
socket.send.buffer.bytes=102400
//kafka接收缓冲区大小,当数据到达一定大小后在序列化到磁盘
socket.receive.buffer.bytes=102400
//这个参数是向kafka请求消息或者向kafka发送消息的请请求的最大数,这个值不能超过java的堆栈大小
socket.request.max.bytes=104857600
//消息存放的目录,这个目录可以配置为,逗号分割的表达式,上面的num.io.threads要大于这个目录的个数这个目录,
//如果配置多个目录,新创建的topic他把消息持久化的地方是,当前以逗号分割的目录中,那个分区数最少就放那一个
log.dirs=/data/hadoop/log/kafka-logs
//默认的分区数,一个topic默认1个分区数
num.partitions=1
//每个数据目录用来日志恢复的线程数目
num.recovery.threads.per.data.dir=1
//默认消息的最大持久化时间,168小时,7天
log.retention.hours=168
//这个参数是:因为kafka的消息是以追加的形式落地到文件,当超过这个值的时候,kafka会新起一个文件
log.segment.bytes=1073741824
//每隔300000毫秒去检查上面配置的log失效时间
log.retention.check.interval.ms=300000
//是否启用log压缩,一般不用启用,启用的话可以提高性能
log.cleaner.enable=false
//设置zookeeper的连接端口
zookeeper.connect=192.168.137.86:2181,192.168.137.87:2181,192.168.137.88:2181
//设置zookeeper的连接超时时间
zookeeper.connection.timeout.ms=6000
2.2.2 配置 producer.properties
metadata.broker.list=192.168.137.86:9092,192.168.137.87:9092,192.168.137.88:9092
2.2.3 配置 server.properties
[hadoop@node1 config]$ cat consumer.properties
zookeeper.connect=192.168.137.86:2181,192.168.137.87:2181,192.168.137.88:2181
2.3 启动 kafka
[hadoop@node1 local]$ kafka-server-start.sh /usr/local/kafka/config/server.properties &
[1] 7435
[hadoop@node1 local]$ [2020-07-28 21:29:50,351] INFO Registered kafka:type=kafka.Log4jController MBean (kafka.utils.Log4jControllerRegistration$)
[2020-07-28 21:29:50,815] INFO Setting -D jdk.tls.rejectClientInitiatedRenegotiation=true to disable client-initiated TLS renegotiation (org.apache.zookeeper.common.X509Util)
[2020-07-28 21:29:50,847] INFO Registered signal handlers for TERM, INT, HUP (org.apache.kafka.common.utils.LoggingSignalHandler)
[2020-07-28 21:29:50,851] INFO starting (kafka.server.KafkaServer)
[2020-07-28 21:29:50,851] INFO Connecting to zookeeper on 192.168.137.86:2181,192.168.137.87:2181,192.168.137.88:2181 (kafka.server.KafkaServer)
[2020-07-28 21:29:50,865] INFO [ZooKeeperClient Kafka server] Initializing a new session to 192.168.137.86:2181,192.168.137.87:2181,192.168.137.88:2181. (kafka.zookeeper.ZooKeeperClient)
[2020-07-28 21:29:50,869] INFO Client environment:zookeeper.version=3.5.7-f0fdd52973d373ffd9c86b81d99842dc2c7f660e, built on 02/10/2020 11:30 GMT (org.apache.zookeeper.ZooKeeper)
[2020-07-28 21:29:50,869] INFO Client environment:host.name=node1 (org.apache.zookeeper.ZooKeeper)
[2020-07-28 21:29:50,869] INFO Client environment:java.version=1.8.0_251 (org.apache.zookeeper.ZooKeeper)
[2020-07-28 21:29:50,869] INFO Client environment:java.vendor=Oracle Corporation (org.apache.zookeeper.ZooKeeper)
[2020-07-28 21:29:50,869] INFO Client environment:java.home=/usr/java/jdk1.8.0_251-amd64/jre (org.apache.zookeeper.ZooKeeper)
[2020-07-28 21:29:50,869] INFO Client environment:java.class.path=/usr/local/kafka/bin/../libs/activation-1.1.1.jar:/usr/local/kafka/bin/../libs/aopalliance-repackaged-2.5.0.jar:/usr/local/kafka/bin/../libs/argparse4j-0.7.0.jar:/usr/local/kafka/bin/../libs/audience-annotations-0.5.0.jar:/usr/local/kafka/bin/../libs/commons-cli-1.4.jar:/usr/local/kafka/bin/../libs/commons-lang3-3.8.1.jar:/usr/local/kafka/bin/../libs/connect-api-2.5.0.jar:/usr/local/kafka/bin/../libs/connect-basic-auth-extension-2.5.0.jar:/usr/local/kafka/bin/../libs/connect-file-2.5.0.jar:/usr/local/kafka/bin/../libs/connect-json-2.5.0.jar:/usr/local/kafka/bin/../libs/connect-mirror-2.5.0.jar:/usr/local/kafka/bin/../libs/connect-mirror-client-2.5.0.jar:/usr/local/kafka/bin/../libs/connect-runtime-2.5.0.jar:/usr/local/kafka/bin/../libs/connect-transforms-2.5.0.jar:/usr/local/kafka/bin/../libs/hk2-api-2.5.0.jar:/usr/local/kafka/bin/../libs/hk2-locator-2.5.0.jar:/usr/local/kafka/bin/../libs/hk2-utils-2.5.0.jar:/usr/local/kafka/bin/../libs/jackson-annotations-2.10.2.jar:/usr/local/kafka/bin/../libs/jackson-core-2.10.2.jar:/usr/local/kafka/bin/../libs/jackson-databind-2.10.2.jar:/usr/local/kafka/bin/../libs/jackson-dataformat-csv-2.10.2.jar:/usr/local/kafka/bin/../libs/jackson-datatype-jdk8-2.10.2.jar:/usr/local/kafka/bin/../libs/jackson-jaxrs-base-2.10.2.jar:/usr/local/kafka/bin/../libs/jackson-jaxrs-json-provider-2.10.2.jar:/usr/local/kafka/bin/../libs/jackson-module-jaxb-annotations-2.10.2.jar:/usr/local/kafka/bin/../libs/jackson-module-paranamer-2.10.2.jar:/usr/local/kafka/bin/../libs/jackson-module-scala_2.12-2.10.2.jar:/usr/local/kafka/bin/../libs/jakarta.activation-api-1.2.1.jar:/usr/local/kafka/bin/../libs/jakarta.annotation-api-1.3.4.jar:/usr/local/kafka/bin/../libs/jakarta.inject-2.5.0.jar:/usr/local/kafka/bin/../libs/jakarta.ws.rs-api-2.1.5.jar:/usr/local/kafka/bin/../libs/jakarta.xml.bind-api-2.3.2.jar:/usr/local/kafka/bin/../libs/javassist-3.22.0-CR2.jar:/usr/local/kafka/bin/../libs/javassist-3.26.0-GA.jar:/usr/local/kafka/bin/../libs/javax.servlet-api-3.1.0.jar:/usr/local/kafka/bin/../libs/javax.ws.rs-api-2.1.1.jar:/usr/local/kafka/bin/../libs/jaxb-api-2.3.0.jar:/usr/local/kafka/bin/../libs/jersey-client-2.28.jar:/usr/local/kafka/bin/../libs/jersey-common-2.28.jar:/usr/local/kafka/bin/../libs/jersey-container-servlet-2.28.jar:/usr/local/kafka/bin/../libs/jersey-container-servlet-core-2.28.jar:/usr/local/kafka/bin/../libs/jersey-hk2-2.28.jar:/usr/local/kafka/bin/../libs/jersey-media-jaxb-2.28.jar:/usr/local/kafka/bin/../libs/jersey-server-2.28.jar:/usr/local/kafka/bin/../libs/jetty-client-9.4.24.v20191120.jar:/usr/local/kafka/bin/../libs/jetty-continuation-9.4.24.v20191120.jar:/usr/local/kafka/bin/../libs/jetty-http-9.4.24.v20191120.jar:/usr/local/kafka/bin/../libs/jetty-io-9.4.24.v20191120.jar:/usr/local/kafka/bin/../libs/jetty-security-9.4.24.v20191120.jar:/usr/local/kafka/bin/../libs/jetty-server-9.4.24.v20191120.jar:/usr/local/kafka/bin/../libs/jetty-servlet-9.4.24.v20191120.jar:/usr/local/kafka/bin/../libs/jetty-servlets-9.4.24.v20191120.jar:/usr/local/kafka/bin/../libs/jetty-util-9.4.24.v20191120.jar:/usr/local/kafka/bin/../libs/jopt-simple-5.0.4.jar:/usr/local/kafka/bin/../libs/kafka_2.12-2.5.0.jar:/usr/local/kafka/bin/../libs/kafka_2.12-2.5.0-sources.jar:/usr/local/kafka/bin/../libs/kafka-clients-2.5.0.jar:/usr/local/kafka/bin/../libs/kafka-log4j-appender-2.5.0.jar:/usr/local/kafka/bin/../libs/kafka-streams-2.5.0.jar:/usr/local/kafka/bin/../libs/kafka-streams-examples-2.5.0.jar:/usr/local/kafka/bin/../libs/kafka-streams-scala_2.12-2.5.0.jar:/usr/local/kafka/bin/../libs/kafka-streams-test-utils-2.5.0.jar:/usr/local/kafka/bin/../libs/kafka-tools-2.5.0.jar:/usr/local/kafka/bin/../libs/log4j-1.2.17.jar:/usr/local/kafka/bin/../libs/lz4-java-1.7.1.jar:/usr/local/kafka/bin/../libs/maven-artifact-3.6.3.jar:/usr/local/kafka/bin/../libs/metrics-core-2.2.0.jar:/usr/local/kafka/bin/../libs/netty-buffer-4.1.45.Final.jar:/usr/local/kafka/bin/../libs/netty-codec-4.1.45.Final.jar:/usr/local/kafka/bin/../libs/netty-common-4.1.45.Final.jar:/usr/local/kafka/bin/../libs/netty-handler-4.1.45.Final.jar:/usr/local/kafka/bin/../libs/netty-resolver-4.1.45.Final.jar:/usr/local/kafka/bin/../libs/netty-transport-4.1.45.Final.jar:/usr/local/kafka/bin/../libs/netty-transport-native-epoll-4.1.45.Final.jar:/usr/local/kafka/bin/../libs/netty-transport-native-unix-common-4.1.45.Final.jar:/usr/local/kafka/bin/../libs/osgi-resource-locator-1.0.1.jar:/usr/local/kafka/bin/../libs/paranamer-2.8.jar:/usr/local/kafka/bin/../libs/plexus-utils-3.2.1.jar:/usr/local/kafka/bin/../libs/reflections-0.9.12.jar:/usr/local/kafka/bin/../libs/rocksdbjni-5.18.3.jar:/usr/local/kafka/bin/../libs/scala-collection-compat_2.12-2.1.3.jar:/usr/local/kafka/bin/../libs/scala-java8-compat_2.12-0.9.0.jar:/usr/local/kafka/bin/../libs/scala-library-2.12.10.jar:/usr/local/kafka/bin/../libs/scala-logging_2.12-3.9.2.jar:/usr/local/kafka/bin/../libs/scala-reflect-2.12.10.jar:/usr/local/kafka/bin/../libs/slf4j-api-1.7.30.jar:/usr/local/kafka/bin/../libs/slf4j-log4j12-1.7.30.jar:/usr/local/kafka/bin/../libs/snappy-java-1.1.7.3.jar:/usr/local/kafka/bin/../libs/validation-api-2.0.1.Final.jar:/usr/local/kafka/bin/../libs/zookeeper-3.5.7.jar:/usr/local/kafka/bin/../libs/zookeeper-jute-3.5.7.jar:/usr/local/kafka/bin/../libs/zstd-jni-1.4.4-7.jar (org.apache.zookeeper.ZooKeeper)
[2020-07-28 21:29:50,869] INFO Client environment:java.library.path=/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib (org.apache.zookeeper.ZooKeeper)
[2020-07-28 21:29:50,869] INFO Client environment:java.io.tmpdir=/tmp (org.apache.zookeeper.ZooKeeper)
[2020-07-28 21:29:50,869] INFO Client environment:java.compiler=<NA> (org.apache.zookeeper.ZooKeeper)
[2020-07-28 21:29:50,869] INFO Client environment:os.name=Linux (org.apache.zookeeper.ZooKeeper)
[2020-07-28 21:29:50,869] INFO Client environment:os.arch=amd64 (org.apache.zookeeper.ZooKeeper)
[2020-07-28 21:29:50,869] INFO Client environment:os.version=3.10.0-1062.el7.x86_64 (org.apache.zookeeper.ZooKeeper)
[2020-07-28 21:29:50,869] INFO Client environment:user.name=hadoop (org.apache.zookeeper.ZooKeeper)
[2020-07-28 21:29:50,869] INFO Client environment:user.home=/home/hadoop (org.apache.zookeeper.ZooKeeper)
[2020-07-28 21:29:50,869] INFO Client environment:user.dir=/usr/local (org.apache.zookeeper.ZooKeeper)
[2020-07-28 21:29:50,869] INFO Client environment:os.memory.free=979MB (org.apache.zookeeper.ZooKeeper)
[2020-07-28 21:29:50,869] INFO Client environment:os.memory.max=1024MB (org.apache.zookeeper.ZooKeeper)
[2020-07-28 21:29:50,869] INFO Client environment:os.memory.total=1024MB (org.apache.zookeeper.ZooKeeper)
[2020-07-28 21:29:50,871] INFO Initiating client connection, connectString=192.168.137.86:2181,192.168.137.87:2181,192.168.137.88:2181 sessionTimeout=18000 watcher=kafka.zookeeper.ZooKeeperClient$ZooKeeperClientWatcher$@291ae (org.apache.zookeeper.ZooKeeper)
[2020-07-28 21:29:50,874] INFO jute.maxbuffer value is 4194304 Bytes (org.apache.zookeeper.ClientCnxnSocket)
[2020-07-28 21:29:50,879] INFO zookeeper.request.timeout value is 0. feature enabled= (org.apache.zookeeper.ClientCnxn)
[2020-07-28 21:29:50,883] INFO Opening socket connection to server node1/192.168.137.86:2181. Will not attempt to authenticate using SASL (unknown error) (org.apache.zookeeper.ClientCnxn)
[2020-07-28 21:29:50,883] INFO [ZooKeeperClient Kafka server] Waiting until connected. (kafka.zookeeper.ZooKeeperClient)
[2020-07-28 21:29:50,886] INFO Socket connection established, initiating session, client: /192.168.137.86:56456, server: node1/192.168.137.86:2181 (org.apache.zookeeper.ClientCnxn)
[2020-07-28 21:29:50,891] INFO Session establishment complete on server node1/192.168.137.86:2181, sessionid = 0x100000726780002, negotiated timeout = 18000 (org.apache.zookeeper.ClientCnxn)
[2020-07-28 21:29:50,894] INFO [ZooKeeperClient Kafka server] Connected. (kafka.zookeeper.ZooKeeperClient)
[2020-07-28 21:29:51,097] INFO Cluster ID = 72BzoO2gQjmmQ0Ozyo4ZsQ (kafka.server.KafkaServer)
[2020-07-28 21:29:51,148] INFO KafkaConfig values:
advertised.host.name = null
advertised.listeners = null
advertised.port = null
alter.config.policy.class.name = null
alter.log.dirs.replication.quota.window.num = 11
alter.log.dirs.replication.quota.window.size.seconds = 1
authorizer.class.name =
auto.create.topics.enable = true
auto.leader.rebalance.enable = true
background.threads = 10
broker.id = 1
broker.id.generation.enable = true
broker.rack = null
client.quota.callback.class = null
compression.type = producer
connection.failed.authentication.delay.ms = 100
connections.max.idle.ms = 600000
connections.max.reauth.ms = 0
control.plane.listener.name = null
controlled.shutdown.enable = true
controlled.shutdown.max.retries = 3
controlled.shutdown.retry.backoff.ms = 5000
controller.socket.timeout.ms = 30000
create.topic.policy.class.name = null
default.replication.factor = 1
delegation.token.expiry.check.interval.ms = 3600000
delegation.token.expiry.time.ms = 86400000
delegation.token.master.key = null
delegation.token.max.lifetime.ms = 604800000
delete.records.purgatory.purge.interval.requests = 1
delete.topic.enable = true
fetch.max.bytes = 57671680
fetch.purgatory.purge.interval.requests = 1000
group.initial.rebalance.delay.ms = 3000
group.max.session.timeout.ms = 1800000
group.max.size = 2147483647
group.min.session.timeout.ms = 6000
host.name = node1
inter.broker.listener.name = null
inter.broker.protocol.version = 2.5-IV0
kafka.metrics.polling.interval.secs = 10
kafka.metrics.reporters = []
leader.imbalance.check.interval.seconds = 300
leader.imbalance.per.broker.percentage = 10
listener.security.protocol.map = PLAINTEXT:PLAINTEXT,SSL:SSL,SASL_PLAINTEXT:SASL_PLAINTEXT,SASL_SSL:SASL_SSL
listeners = null
log.cleaner.backoff.ms = 15000
log.cleaner.dedupe.buffer.size = 134217728
log.cleaner.delete.retention.ms = 86400000
log.cleaner.enable = false
log.cleaner.io.buffer.load.factor = 0.9
log.cleaner.io.buffer.size = 524288
log.cleaner.io.max.bytes.per.second = 1.7976931348623157E308
log.cleaner.max.compaction.lag.ms = 9223372036854775807
log.cleaner.min.cleanable.ratio = 0.5
log.cleaner.min.compaction.lag.ms = 0
log.cleaner.threads = 1
log.cleanup.policy = [delete]
log.dir = /tmp/kafka-logs
log.dirs = /data/hadoop/log/kafka-logs
log.flush.interval.messages = 9223372036854775807
log.flush.interval.ms = null
log.flush.offset.checkpoint.interval.ms = 60000
log.flush.scheduler.interval.ms = 9223372036854775807
log.flush.start.offset.checkpoint.interval.ms = 60000
log.index.interval.bytes = 4096
log.index.size.max.bytes = 10485760
log.message.downconversion.enable = true
log.message.format.version = 2.5-IV0
log.message.timestamp.difference.max.ms = 9223372036854775807
log.message.timestamp.type = CreateTime
log.preallocate = false
log.retention.bytes = -1
log.retention.check.interval.ms = 300000
log.retention.hours = 168
log.retention.minutes = null
log.retention.ms = null
log.roll.hours = 168
log.roll.jitter.hours = 0
log.roll.jitter.ms = null
log.roll.ms = null
log.segment.bytes = 1073741824
log.segment.delete.delay.ms = 60000
max.connections = 2147483647
max.connections.per.ip = 2147483647
max.connections.per.ip.overrides =
max.incremental.fetch.session.cache.slots = 1000
message.max.bytes = 1048588
metric.reporters = []
metrics.num.samples = 2
metrics.recording.level = INFO
metrics.sample.window.ms = 30000
min.insync.replicas = 1
num.io.threads = 8
num.network.threads = 3
num.partitions = 1
num.recovery.threads.per.data.dir = 1
num.replica.alter.log.dirs.threads = null
num.replica.fetchers = 1
offset.metadata.max.bytes = 4096
offsets.commit.required.acks = -1
offsets.commit.timeout.ms = 5000
offsets.load.buffer.size = 5242880
offsets.retention.check.interval.ms = 600000
offsets.retention.minutes = 10080
offsets.topic.compression.codec = 0
offsets.topic.num.partitions = 50
offsets.topic.replication.factor = 3
offsets.topic.segment.bytes = 104857600
password.encoder.cipher.algorithm = AES/CBC/PKCS5Padding
password.encoder.iterations = 4096
password.encoder.key.length = 128
password.encoder.keyfactory.algorithm = null
password.encoder.old.secret = null
password.encoder.secret = null
port = 9092
principal.builder.class = null
producer.purgatory.purge.interval.requests = 1000
queued.max.request.bytes = -1
queued.max.requests = 500
quota.consumer.default = 9223372036854775807
quota.producer.default = 9223372036854775807
quota.window.num = 11
quota.window.size.seconds = 1
replica.fetch.backoff.ms = 1000
replica.fetch.max.bytes = 1048576
replica.fetch.min.bytes = 1
replica.fetch.response.max.bytes = 10485760
replica.fetch.wait.max.ms = 500
replica.high.watermark.checkpoint.interval.ms = 5000
replica.lag.time.max.ms = 30000
replica.selector.class = null
replica.socket.receive.buffer.bytes = 65536
replica.socket.timeout.ms = 30000
replication.quota.window.num = 11
replication.quota.window.size.seconds = 1
request.timeout.ms = 30000
reserved.broker.max.id = 1000
sasl.client.callback.handler.class = null
sasl.enabled.mechanisms = [GSSAPI]
sasl.jaas.config = null
sasl.kerberos.kinit.cmd = /usr/bin/kinit
sasl.kerberos.min.time.before.relogin = 60000
sasl.kerberos.principal.to.local.rules = [DEFAULT]
sasl.kerberos.service.name = null
sasl.kerberos.ticket.renew.jitter = 0.05
sasl.kerberos.ticket.renew.window.factor = 0.8
sasl.login.callback.handler.class = null
sasl.login.class = null
sasl.login.refresh.buffer.seconds = 300
sasl.login.refresh.min.period.seconds = 60
sasl.login.refresh.window.factor = 0.8
sasl.login.refresh.window.jitter = 0.05
sasl.mechanism.inter.broker.protocol = GSSAPI
sasl.server.callback.handler.class = null
security.inter.broker.protocol = PLAINTEXT
security.providers = null
socket.receive.buffer.bytes = 102400
socket.request.max.bytes = 104857600
socket.send.buffer.bytes = 102400
ssl.cipher.suites = []
ssl.client.auth = none
ssl.enabled.protocols = [TLSv1.2]
ssl.endpoint.identification.algorithm = https
ssl.key.password = null
ssl.keymanager.algorithm = SunX509
ssl.keystore.location = null
ssl.keystore.password = null
ssl.keystore.type = JKS
ssl.principal.mapping.rules = DEFAULT
ssl.protocol = TLSv1.2
ssl.provider = null
ssl.secure.random.implementation = null
ssl.trustmanager.algorithm = PKIX
ssl.truststore.location = null
ssl.truststore.password = null
ssl.truststore.type = JKS
transaction.abort.timed.out.transaction.cleanup.interval.ms = 10000
transaction.max.timeout.ms = 900000
transaction.remove.expired.transaction.cleanup.interval.ms = 3600000
transaction.state.log.load.buffer.size = 5242880
transaction.state.log.min.isr = 2
transaction.state.log.num.partitions = 50
transaction.state.log.replication.factor = 3
transaction.state.log.segment.bytes = 104857600
transactional.id.expiration.ms = 604800000
unclean.leader.election.enable = false
zookeeper.clientCnxnSocket = null
zookeeper.connect = 192.168.137.86:2181,192.168.137.87:2181,192.168.137.88:2181
zookeeper.connection.timeout.ms = 6000
zookeeper.max.in.flight.requests = 10
zookeeper.session.timeout.ms = 18000
zookeeper.set.acl = false
zookeeper.ssl.cipher.suites = null
zookeeper.ssl.client.enable = false
zookeeper.ssl.crl.enable = false
zookeeper.ssl.enabled.protocols = null
zookeeper.ssl.endpoint.identification.algorithm = HTTPS
zookeeper.ssl.keystore.location = null
zookeeper.ssl.keystore.password = null
zookeeper.ssl.keystore.type = null
zookeeper.ssl.ocsp.enable = false
zookeeper.ssl.protocol = TLSv1.2
zookeeper.ssl.truststore.location = null
zookeeper.ssl.truststore.password = null
zookeeper.ssl.truststore.type = null
zookeeper.sync.time.ms = 2000
(kafka.server.KafkaConfig)
[2020-07-28 21:29:51,157] INFO KafkaConfig values:
advertised.host.name = null
advertised.listeners = null
advertised.port = null
alter.config.policy.class.name = null
alter.log.dirs.replication.quota.window.num = 11
alter.log.dirs.replication.quota.window.size.seconds = 1
authorizer.class.name =
auto.create.topics.enable = true
auto.leader.rebalance.enable = true
background.threads = 10
broker.id = 1
broker.id.generation.enable = true
broker.rack = null
client.quota.callback.class = null
compression.type = producer
connection.failed.authentication.delay.ms = 100
connections.max.idle.ms = 600000
connections.max.reauth.ms = 0
control.plane.listener.name = null
controlled.shutdown.enable = true
controlled.shutdown.max.retries = 3
controlled.shutdown.retry.backoff.ms = 5000
controller.socket.timeout.ms = 30000
create.topic.policy.class.name = null
default.replication.factor = 1
delegation.token.expiry.check.interval.ms = 3600000
delegation.token.expiry.time.ms = 86400000
delegation.token.master.key = null
delegation.token.max.lifetime.ms = 604800000
delete.records.purgatory.purge.interval.requests = 1
delete.topic.enable = true
fetch.max.bytes = 57671680
fetch.purgatory.purge.interval.requests = 1000
group.initial.rebalance.delay.ms = 3000
group.max.session.timeout.ms = 1800000
group.max.size = 2147483647
group.min.session.timeout.ms = 6000
host.name = node1
inter.broker.listener.name = null
inter.broker.protocol.version = 2.5-IV0
kafka.metrics.polling.interval.secs = 10
kafka.metrics.reporters = []
leader.imbalance.check.interval.seconds = 300
leader.imbalance.per.broker.percentage = 10
listener.security.protocol.map = PLAINTEXT:PLAINTEXT,SSL:SSL,SASL_PLAINTEXT:SASL_PLAINTEXT,SASL_SSL:SASL_SSL
listeners = null
log.cleaner.backoff.ms = 15000
log.cleaner.dedupe.buffer.size = 134217728
log.cleaner.delete.retention.ms = 86400000
log.cleaner.enable = false
log.cleaner.io.buffer.load.factor = 0.9
log.cleaner.io.buffer.size = 524288
log.cleaner.io.max.bytes.per.second = 1.7976931348623157E308
log.cleaner.max.compaction.lag.ms = 9223372036854775807
log.cleaner.min.cleanable.ratio = 0.5
log.cleaner.min.compaction.lag.ms = 0
log.cleaner.threads = 1
log.cleanup.policy = [delete]
log.dir = /tmp/kafka-logs
log.dirs = /data/hadoop/log/kafka-logs
log.flush.interval.messages = 9223372036854775807
log.flush.interval.ms = null
log.flush.offset.checkpoint.interval.ms = 60000
log.flush.scheduler.interval.ms = 9223372036854775807
log.flush.start.offset.checkpoint.interval.ms = 60000
log.index.interval.bytes = 4096
log.index.size.max.bytes = 10485760
log.message.downconversion.enable = true
log.message.format.version = 2.5-IV0
log.message.timestamp.difference.max.ms = 9223372036854775807
log.message.timestamp.type = CreateTime
log.preallocate = false
log.retention.bytes = -1
log.retention.check.interval.ms = 300000
log.retention.hours = 168
log.retention.minutes = null
log.retention.ms = null
log.roll.hours = 168
log.roll.jitter.hours = 0
log.roll.jitter.ms = null
log.roll.ms = null
log.segment.bytes = 1073741824
log.segment.delete.delay.ms = 60000
max.connections = 2147483647
max.connections.per.ip = 2147483647
max.connections.per.ip.overrides =
max.incremental.fetch.session.cache.slots = 1000
message.max.bytes = 1048588
metric.reporters = []
metrics.num.samples = 2
metrics.recording.level = INFO
metrics.sample.window.ms = 30000
min.insync.replicas = 1
num.io.threads = 8
num.network.threads = 3
num.partitions = 1
num.recovery.threads.per.data.dir = 1
num.replica.alter.log.dirs.threads = null
num.replica.fetchers = 1
offset.metadata.max.bytes = 4096
offsets.commit.required.acks = -1
offsets.commit.timeout.ms = 5000
offsets.load.buffer.size = 5242880
offsets.retention.check.interval.ms = 600000
offsets.retention.minutes = 10080
offsets.topic.compression.codec = 0
offsets.topic.num.partitions = 50
offsets.topic.replication.factor = 3
offsets.topic.segment.bytes = 104857600
password.encoder.cipher.algorithm = AES/CBC/PKCS5Padding
password.encoder.iterations = 4096
password.encoder.key.length = 128
password.encoder.keyfactory.algorithm = null
password.encoder.old.secret = null
password.encoder.secret = null
port = 9092
principal.builder.class = null
producer.purgatory.purge.interval.requests = 1000
queued.max.request.bytes = -1
queued.max.requests = 500
quota.consumer.default = 9223372036854775807
quota.producer.default = 9223372036854775807
quota.window.num = 11
quota.window.size.seconds = 1
replica.fetch.backoff.ms = 1000
replica.fetch.max.bytes = 1048576
replica.fetch.min.bytes = 1
replica.fetch.response.max.bytes = 10485760
replica.fetch.wait.max.ms = 500
replica.high.watermark.checkpoint.interval.ms = 5000
replica.lag.time.max.ms = 30000
replica.selector.class = null
replica.socket.receive.buffer.bytes = 65536
replica.socket.timeout.ms = 30000
replication.quota.window.num = 11
replication.quota.window.size.seconds = 1
request.timeout.ms = 30000
reserved.broker.max.id = 1000
sasl.client.callback.handler.class = null
sasl.enabled.mechanisms = [GSSAPI]
sasl.jaas.config = null
sasl.kerberos.kinit.cmd = /usr/bin/kinit
sasl.kerberos.min.time.before.relogin = 60000
sasl.kerberos.principal.to.local.rules = [DEFAULT]
sasl.kerberos.service.name = null
sasl.kerberos.ticket.renew.jitter = 0.05
sasl.kerberos.ticket.renew.window.factor = 0.8
sasl.login.callback.handler.class = null
sasl.login.class = null
sasl.login.refresh.buffer.seconds = 300
sasl.login.refresh.min.period.seconds = 60
sasl.login.refresh.window.factor = 0.8
sasl.login.refresh.window.jitter = 0.05
sasl.mechanism.inter.broker.protocol = GSSAPI
sasl.server.callback.handler.class = null
security.inter.broker.protocol = PLAINTEXT
security.providers = null
socket.receive.buffer.bytes = 102400
socket.request.max.bytes = 104857600
socket.send.buffer.bytes = 102400
ssl.cipher.suites = []
ssl.client.auth = none
ssl.enabled.protocols = [TLSv1.2]
ssl.endpoint.identification.algorithm = https
ssl.key.password = null
ssl.keymanager.algorithm = SunX509
ssl.keystore.location = null
ssl.keystore.password = null
ssl.keystore.type = JKS
ssl.principal.mapping.rules = DEFAULT
ssl.protocol = TLSv1.2
ssl.provider = null
ssl.secure.random.implementation = null
ssl.trustmanager.algorithm = PKIX
ssl.truststore.location = null
ssl.truststore.password = null
ssl.truststore.type = JKS
transaction.abort.timed.out.transaction.cleanup.interval.ms = 10000
transaction.max.timeout.ms = 900000
transaction.remove.expired.transaction.cleanup.interval.ms = 3600000
transaction.state.log.load.buffer.size = 5242880
transaction.state.log.min.isr = 2
transaction.state.log.num.partitions = 50
transaction.state.log.replication.factor = 3
transaction.state.log.segment.bytes = 104857600
transactional.id.expiration.ms = 604800000
unclean.leader.election.enable = false
zookeeper.clientCnxnSocket = null
zookeeper.connect = 192.168.137.86:2181,192.168.137.87:2181,192.168.137.88:2181
zookeeper.connection.timeout.ms = 6000
zookeeper.max.in.flight.requests = 10
zookeeper.session.timeout.ms = 18000
zookeeper.set.acl = false
zookeeper.ssl.cipher.suites = null
zookeeper.ssl.client.enable = false
zookeeper.ssl.crl.enable = false
zookeeper.ssl.enabled.protocols = null
zookeeper.ssl.endpoint.identification.algorithm = HTTPS
zookeeper.ssl.keystore.location = null
zookeeper.ssl.keystore.password = null
zookeeper.ssl.keystore.type = null
zookeeper.ssl.ocsp.enable = false
zookeeper.ssl.protocol = TLSv1.2
zookeeper.ssl.truststore.location = null
zookeeper.ssl.truststore.password = null
zookeeper.ssl.truststore.type = null
zookeeper.sync.time.ms = 2000
(kafka.server.KafkaConfig)
[2020-07-28 21:29:51,179] INFO [ThrottledChannelReaper-Fetch]: Starting (kafka.server.ClientQuotaManager$ThrottledChannelReaper)
[2020-07-28 21:29:51,179] INFO [ThrottledChannelReaper-Produce]: Starting (kafka.server.ClientQuotaManager$ThrottledChannelReaper)
[2020-07-28 21:29:51,183] INFO [ThrottledChannelReaper-Request]: Starting (kafka.server.ClientQuotaManager$ThrottledChannelReaper)
[2020-07-28 21:29:51,201] INFO Loading logs. (kafka.log.LogManager)
[2020-07-28 21:29:51,207] INFO Logs loading complete in 6 ms. (kafka.log.LogManager)
[2020-07-28 21:29:51,212] INFO Starting log cleanup with a period of 300000 ms. (kafka.log.LogManager)
[2020-07-28 21:29:51,214] INFO Starting log flusher with a default period of 9223372036854775807 ms. (kafka.log.LogManager)
[2020-07-28 21:29:51,554] INFO Awaiting socket connections on node1:9092. (kafka.network.Acceptor)
[2020-07-28 21:29:51,587] INFO [SocketServer brokerId=1] Created data-plane acceptor and processors for endpoint : EndPoint(node1,9092,ListenerName(PLAINTEXT),PLAINTEXT) (kafka.network.SocketServer)
[2020-07-28 21:29:51,588] INFO [SocketServer brokerId=1] Started 1 acceptor threads for data-plane (kafka.network.SocketServer)
[2020-07-28 21:29:51,617] INFO [ExpirationReaper-1-Produce]: Starting (kafka.server.DelayedOperationPurgatory$ExpiredOperationReaper)
[2020-07-28 21:29:51,619] INFO [ExpirationReaper-1-Fetch]: Starting (kafka.server.DelayedOperationPurgatory$ExpiredOperationReaper)
[2020-07-28 21:29:51,620] INFO [ExpirationReaper-1-DeleteRecords]: Starting (kafka.server.DelayedOperationPurgatory$ExpiredOperationReaper)
[2020-07-28 21:29:51,630] INFO [ExpirationReaper-1-ElectLeader]: Starting (kafka.server.DelayedOperationPurgatory$ExpiredOperationReaper)
[2020-07-28 21:29:51,635] INFO [LogDirFailureHandler]: Starting (kafka.server.ReplicaManager$LogDirFailureHandler)
[2020-07-28 21:29:51,671] INFO Creating /brokers/ids/1 (is it secure? false) (kafka.zk.KafkaZkClient)
[2020-07-28 21:29:51,684] INFO Stat of the created znode at /brokers/ids/1 is: 34359738433,34359738433,1595856591855,1595856591855,1,0,0,72057624748097538,180,0,34359738433
(kafka.zk.KafkaZkClient)
[2020-07-28 21:29:51,684] INFO Registered broker 1 at path /brokers/ids/1 with addresses: ArrayBuffer(EndPoint(node1,9092,ListenerName(PLAINTEXT),PLAINTEXT)), czxid (broker epoch): 34359738433 (kafka.zk.KafkaZkClient)
[2020-07-28 21:29:51,731] INFO [ExpirationReaper-1-topic]: Starting (kafka.server.DelayedOperationPurgatory$ExpiredOperationReaper)
[2020-07-28 21:29:51,736] INFO [ExpirationReaper-1-Heartbeat]: Starting (kafka.server.DelayedOperationPurgatory$ExpiredOperationReaper)
[2020-07-28 21:29:51,738] INFO [ExpirationReaper-1-Rebalance]: Starting (kafka.server.DelayedOperationPurgatory$ExpiredOperationReaper)
[2020-07-28 21:29:51,767] INFO [GroupCoordinator 1]: Starting up. (kafka.coordinator.group.GroupCoordinator)
[2020-07-28 21:29:51,768] INFO [GroupCoordinator 1]: Startup complete. (kafka.coordinator.group.GroupCoordinator)
[2020-07-28 21:29:51,774] INFO [GroupMetadataManager brokerId=1] Removed 0 expired offsets in 4 milliseconds. (kafka.coordinator.group.GroupMetadataManager)
[2020-07-28 21:29:51,786] INFO [ProducerId Manager 1]: Acquired new producerId block (brokerId:1,blockStartProducerId:1000,blockEndProducerId:1999) by writing to Zk with path version 2 (kafka.coordinator.transaction.ProducerIdManager)
[2020-07-28 21:29:51,808] INFO [TransactionCoordinator id=1] Starting up. (kafka.coordinator.transaction.TransactionCoordinator)
[2020-07-28 21:29:51,811] INFO [TransactionCoordinator id=1] Startup complete. (kafka.coordinator.transaction.TransactionCoordinator)
[2020-07-28 21:29:51,824] INFO [Transaction Marker Channel Manager 1]: Starting (kafka.coordinator.transaction.TransactionMarkerChannelManager)
[2020-07-28 21:29:51,837] INFO [ExpirationReaper-1-AlterAcls]: Starting (kafka.server.DelayedOperationPurgatory$ExpiredOperationReaper)
[2020-07-28 21:29:51,868] INFO [/config/changes-event-process-thread]: Starting (kafka.common.ZkNodeChangeNotificationListener$ChangeEventProcessThread)
[2020-07-28 21:29:51,893] INFO [SocketServer brokerId=1] Started data-plane processors for 1 acceptors (kafka.network.SocketServer)
[2020-07-28 21:29:51,916] INFO Kafka version: 2.5.0 (org.apache.kafka.common.utils.AppInfoParser)
[2020-07-28 21:29:51,916] INFO Kafka commitId: 66563e712b0b9f84 (org.apache.kafka.common.utils.AppInfoParser)
[2020-07-28 21:29:51,916] INFO Kafka startTimeMs: 1595942991894 (org.apache.kafka.common.utils.AppInfoParser)
[2020-07-28 21:29:51,916] INFO [KafkaServer id=1] started (kafka.server.KafkaServer)
2.4 基本操作
创建topic
[hadoop@node1 local]$ kafka-topics.sh --create --zookeeper 192.168.137.86:2181 --replication-factor 3 --partitions 3 --topic topic1
Created topic topic1.
[2020-07-28 21:37:19,217] INFO [ReplicaFetcherManager on broker 1] Removed fetcher for partitions Set(topic1-2) (kafka.server.ReplicaFetcherManager)
[2020-07-28 21:37:19,222] INFO [Log partition=topic1-2, dir=/data/hadoop/log/kafka-logs] Loading producer state till offset 0 with message format version 2 (kafka.log.Log)
[2020-07-28 21:37:19,223] INFO [Log partition=topic1-2, dir=/data/hadoop/log/kafka-logs] Completed load of log with 1 segments, log start offset 0 and log end offset 0 in 2 ms (kafka.log.Log)
[2020-07-28 21:37:19,223] INFO Created log for partition topic1-2 in /data/hadoop/log/kafka-logs/topic1-2 with properties {compression.type -> producer, message.downconversion.enable -> true, min.insync.replicas -> 1, segment.jitter.ms -> 0, cleanup.policy -> [delete], flush.ms -> 9223372036854775807, segment.bytes -> 1073741824, retention.ms -> 604800000, flush.messages -> 9223372036854775807, message.format.version -> 2.5-IV0, file.delete.delay.ms -> 60000, max.compaction.lag.ms -> 9223372036854775807, max.message.bytes -> 1048588, min.compaction.lag.ms -> 0, message.timestamp.type -> CreateTime, preallocate -> false, min.cleanable.dirty.ratio -> 0.5, index.interval.bytes -> 4096, unclean.leader.election.enable -> false, retention.bytes -> -1, delete.retention.ms -> 86400000, segment.ms -> 604800000, message.timestamp.difference.max.ms -> 9223372036854775807, segment.index.bytes -> 10485760}. (kafka.log.LogManager)
[2020-07-28 21:37:19,224] INFO [Partition topic1-2 broker=1] Log loaded for partition topic1-2 with initial high watermark 0 (kafka.cluster.Partition)
[2020-07-28 21:37:19,225] INFO [Partition topic1-2 broker=1] topic1-2 starts at leader epoch 0 from offset 0 with high watermark 0. Previous leader epoch was -1. (kafka.cluster.Partition)
[2020-07-28 21:37:19,337] INFO [Log partition=topic1-0, dir=/data/hadoop/log/kafka-logs] Loading producer state till offset 0 with message format version 2 (kafka.log.Log)
[2020-07-28 21:37:19,337] INFO [Log partition=topic1-0, dir=/data/hadoop/log/kafka-logs] Completed load of log with 1 segments, log start offset 0 and log end offset 0 in 1 ms (kafka.log.Log)
[2020-07-28 21:37:19,337] INFO Created log for partition topic1-0 in /data/hadoop/log/kafka-logs/topic1-0 with properties {compression.type -> producer, message.downconversion.enable -> true, min.insync.replicas -> 1, segment.jitter.ms -> 0, cleanup.policy -> [delete], flush.ms -> 9223372036854775807, segment.bytes -> 1073741824, retention.ms -> 604800000, flush.messages -> 9223372036854775807, message.format.version -> 2.5-IV0, file.delete.delay.ms -> 60000, max.compaction.lag.ms -> 9223372036854775807, max.message.bytes -> 1048588, min.compaction.lag.ms -> 0, message.timestamp.type -> CreateTime, preallocate -> false, min.cleanable.dirty.ratio -> 0.5, index.interval.bytes -> 4096, unclean.leader.election.enable -> false, retention.bytes -> -1, delete.retention.ms -> 86400000, segment.ms -> 604800000, message.timestamp.difference.max.ms -> 9223372036854775807, segment.index.bytes -> 10485760}. (kafka.log.LogManager)
[2020-07-28 21:37:19,338] INFO [Partition topic1-0 broker=1] Log loaded for partition topic1-0 with initial high watermark 0 (kafka.cluster.Partition)
[2020-07-28 21:37:19,341] INFO [Log partition=topic1-1, dir=/data/hadoop/log/kafka-logs] Loading producer state till offset 0 with message format version 2 (kafka.log.Log)
[2020-07-28 21:37:19,342] INFO [Log partition=topic1-1, dir=/data/hadoop/log/kafka-logs] Completed load of log with 1 segments, log start offset 0 and log end offset 0 in 3 ms (kafka.log.Log)
[2020-07-28 21:37:19,343] INFO Created log for partition topic1-1 in /data/hadoop/log/kafka-logs/topic1-1 with properties {compression.type -> producer, message.downconversion.enable -> true, min.insync.replicas -> 1, segment.jitter.ms -> 0, cleanup.policy -> [delete], flush.ms -> 9223372036854775807, segment.bytes -> 1073741824, retention.ms -> 604800000, flush.messages -> 9223372036854775807, message.format.version -> 2.5-IV0, file.delete.delay.ms -> 60000, max.compaction.lag.ms -> 9223372036854775807, max.message.bytes -> 1048588, min.compaction.lag.ms -> 0, message.timestamp.type -> CreateTime, preallocate -> false, min.cleanable.dirty.ratio -> 0.5, index.interval.bytes -> 4096, unclean.leader.election.enable -> false, retention.bytes -> -1, delete.retention.ms -> 86400000, segment.ms -> 604800000, message.timestamp.difference.max.ms -> 9223372036854775807, segment.index.bytes -> 10485760}. (kafka.log.LogManager)
[2020-07-28 21:37:19,343] INFO [Partition topic1-1 broker=1] Log loaded for partition topic1-1 with initial high watermark 0 (kafka.cluster.Partition)
[2020-07-28 21:37:19,343] INFO [ReplicaFetcherManager on broker 1] Removed fetcher for partitions Set(topic1-1, topic1-0) (kafka.server.ReplicaFetcherManager)
[2020-07-28 21:37:19,346] INFO [ReplicaFetcherManager on broker 1] Added fetcher to broker 2 for partitions Map(topic1-0 -> (offset=0, leaderEpoch=0)) (kafka.server.ReplicaFetcherManager)
[2020-07-28 21:37:19,350] INFO [ReplicaFetcher replicaId=1, leaderId=2, fetcherId=0] Starting (kafka.server.ReplicaFetcherThread)
[2020-07-28 21:37:19,351] INFO [ReplicaFetcher replicaId=1, leaderId=2, fetcherId=0] Truncating partition topic1-0 to local high watermark 0 (kafka.server.ReplicaFetcherThread)
[2020-07-28 21:37:19,351] INFO [Log partition=topic1-0, dir=/data/hadoop/log/kafka-logs] Truncating to 0 has no effect as the largest offset in the log is -1 (kafka.log.Log)
[2020-07-28 21:37:19,355] INFO [ReplicaFetcherManager on broker 1] Added fetcher to broker 3 for partitions Map(topic1-1 -> (offset=0, leaderEpoch=0)) (kafka.server.ReplicaFetcherManager)
[2020-07-28 21:37:19,359] INFO [ReplicaFetcher replicaId=1, leaderId=3, fetcherId=0] Starting (kafka.server.ReplicaFetcherThread)
[2020-07-28 21:37:19,359] INFO [ReplicaFetcher replicaId=1, leaderId=3, fetcherId=0] Truncating partition topic1-1 to local high watermark 0 (kafka.server.ReplicaFetcherThread)
[2020-07-28 21:37:19,359] INFO [Log partition=topic1-1, dir=/data/hadoop/log/kafka-logs] Truncating to 0 has no effect as the largest offset in the log is -1 (kafka.log.Log)
查看topic
[hadoop@node1 local]$ kafka-topics.sh --describe --zookeeper 192.168.137.86:2181 --topic topic1
Topic: topic1 PartitionCount: 3 ReplicationFactor: 3 Configs:
Topic: topic1 Partition: 0 Leader: 2 Replicas: 2,3,1 Isr: 2,3,1
Topic: topic1 Partition: 1 Leader: 3 Replicas: 3,1,2 Isr: 3,1,2
Topic: topic1 Partition: 2 Leader: 1 Replicas: 1,2,3 Isr: 1,2,3
生产者生产数据
>[hadoop@node1 local]$ kafka-console-producer.sh --broker-list 192.168.137.86:9092 --topic topic1
>hello
>zijie
消费者消费数据
[hadoop@node2 ~]$ kafka-console-consumer.sh --bootstrap-server 192.168.137.86:9092 --topic topic1
hello
zijie