1. Kafka集群搭建好之后,运行一段时间Kafka节点挂掉,程序中出现以下错误java
ERROR Error while accepting connection (kafka.network.Acceptor)
java.io.IOException: Too many open files vim
使用命令:ulimit -a 查看每一个用户容许打开的最大文件数
发现系统默认的是open files (-n) 1024,问题就出如今这里。
而后执行:ulimit -n 4096
将open files (-n) 1024 设置成open files (-n) 4096
lsof -p 'kafka的进程号' | wc -l 服务器
命令行为临时修改不能持久
vim /etc/security/limits.conf
* - nofile 8192 fetch
2. 服务器磁盘空间小就二三十G,被kafka的日志文件给吃掉了this
这就须要调整kafkalog的保存时间以及segments的大小了,能够调整如下几个参数 spa
# The minimum age of a log file to be eligible for deletion
#log.retention.hours=168
log.retention.hours=1.net
# A size-based retention policy for logs. Segments are pruned from the log as long as the remaining
# segments don't drop below log.retention.bytes.
#log.retention.bytes=1073741824
log.retention.bytes=50000000命令行
# The maximum size of a log segment file. When this size is reached a new log segment will be created.
log.segment.bytes=50000000日志
3. Kafka消息过大,致使常常堵塞出现 kafka.common.MessageSizeTooLargeExceptioncode
1)producer.properties中参数 compression.codec和commpressed.topics 开启压缩功能 ;
2)server.properties 调整 message.max.bytes 大小,同时保证这个值小于 replica.fetch.max.bytes 这个参数值
3)consumer.properties 调整 fetch.message.max.bytes 大小,保证它大于message.max.bytes.
在使用java实现生产者和消费者时,参考上述调整参数大小。