kafka的配置文件参数(server.properties)

[root@node2 config]# cat server.properties 

# broker的id,集群中必须唯一,按顺序来设置一个不重复的整数即可
broker.id=2

#监听地址和端口
#如果不设置,默认地址取java.net.InetAddress.getCanonicalHostName()的值,这个值其实就是localhost
# PLAINTEXT是监听器的名称,可以自定义,这里就保持它默认名称的即可
listeners=PLAINTEXT://192.168.118.133:9092


#将Broker的Listener信息发布到Zookeeper供客户端使用监听,是真正的对外代理地址。
#如果没有设置,会用listeners。外部连接访问这个,需要设置这个值
advertised.listeners=PLAINTEXT://192.168.118.133:9092

#将侦听器名称映射到安全协议,默认情况下它们是相同的
#listener.security.protocol.map=PLAINTEXT:PLAINTEXT,SSL:SSL,SASL_PLAINTEXT:SASL_PLAINTEXT,SASL_SSL:SASL_SSL

# 服务器用于从网络接收请求并向网络发送响应的线程数
num.network.threads=3

# 服务器用于处理请求的io线程数
num.io.threads=8

# 发送缓冲区大小
socket.send.buffer.bytes=102400

# 接收缓冲区大小
socket.receive.buffer.bytes=102400

# 可以接受的最大请求大小(防止OOM)
socket.request.max.bytes=104857600


# 设置数据目录,一定要修改默认的目录
# kafka的消息都是以日志的形式保持的,所以这个数据目录将会越来越来
log.dirs=/opt/kafka_2.13-3.3.1/kafka-logs

# 一个topic默认的分区,在创建时可以指定topic分区,不指定则默认1个分区
# 多个分区有利于备份以及提高kafka效率
num.partitions=1

#每个数据目录用于启动时日志恢复和关闭时刷新的线程数。
num.recovery.threads.per.data.dir=1

 #不知道什么意思,根据提示设置合理的值吧,反正不能设置为1
# The replication factor for the group metadata internal topics "__consumer_offsets" and "__transaction_state"
# For anything other than development testing, a value greater than 1 is recommended to ensure availability such as 3.
offsets.topic.replication.factor=1
transaction.state.log.replication.factor=1
transaction.state.log.min.isr=1



# 默认情况下消息是异步同步到文件系统的磁盘上的,下面有一些参数可以权衡
#    1. Durability: 如果不使用复制,未刷新的数据可能会丢失。
#    2. Latency: 过大的刷新间隔在发生刷新时可能会导致延迟峰值,因为需要刷新大量数据。
#    3. Throughput: 冲洗通常是最昂贵的操作,冲洗间隔过短可能导致过度的寻道。


# 每10000条消息则flush一次,即落盘,不管是否已经到了指定的时间间隔
#log.flush.interval.messages=10000

# 没1000ms消息就其中flush一次,即落盘,不管你有没有达到上面设置的消息条数
#log.flush.interval.ms=1000



# 多久删除消息数据文件,默认168小时,即7天
log.retention.hours=168

# A size-based retention policy for logs. Segments are pruned from the log unless the remaining
# segments drop below log.retention.bytes. Functions independently of log.retention.hours.
#log.retention.bytes=1073741824

# 一个segment文件的最大大小,当达到设置的值后将产生新的segment文件,默认是1GB
log.segment.bytes=1073741824

# 根据日志报存策略,周期性的检查日志数据是否可以删除,默认300000ms,即5分钟检查一下是否可以删除
#每个Kafka broker启动时,都会在后台开启一个定时任务,定期地去检查并执行所有topic日志留存
log.retention.check.interval.ms=300000



# 要连接的zookeeper集群
# 多个参数直接使用,号相隔开,可以将可选的chroot字符串附加到url中,以指定
#所有kafka znode的根目录,如"127.0.0.1:3000,127.0.0.1:3001,127.0.0.1:3002/kafka".
zookeeper.connect=192.168.118.131:2181,192.168.118.132:2181,192.168.118.133:2181

# kafka连接到zookeeper的超时时间,单位ms
zookeeper.connection.timeout.ms=18000


############################# Group Coordinator Settings #############################
#提示设置为3,那就设置为3
# The following configuration specifies the time, in milliseconds, that the GroupCoordinator will delay the initial consumer rebalance.
# The rebalance will be further delayed by the value of group.initial.rebalance.delay.ms as new members join the group, up to a maximum of max.poll.interval.ms.
# The default value for this is 3 seconds.
# We override this to 0 here as it makes for a better out-of-the-box experience for development and testing.
# However, in production environments the default value of 3 seconds is more suitable as this will help to avoid unnecessary, and potentially expensive, rebalances during application startup.
group.initial.rebalance.delay.ms=0
[root@node2 config]# 
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
kafka_2.9.2-0.8.2.1.tgz 安装 liunx环境 安装jdk vi /etc/profile在末尾追加 JAVA_HOME JRE_HOME PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib source /etc/profile使环境变量立刻生效 安装kafka 解压 tar -xzvf kafka_2.8.0-0.8.1.tgz ;rm kafka_2.8.0-0.8.1.tgz; cd kafka_2.8.0-0.8.1 修改配置 Kafka默认开启JVM压缩指针,但只是在64位的HotSpot VM受支持,如果安装了32位的HotSpot VM,需要修改/bin/kafka-run-class.sh文件 KAFKA_JVM_PERFORMANCE_OPTS="-server -XX:+UseCompressedOops -XX:+UseParNewGC -XX:+UseConcMarkSweepGC -XX:+CMSClassUnloadingEnabled -XX:+CMSScavengeBeforeRemark -XX:+DisableExplicitGC -Djava.awt.headless=true" 去除-XX:+UseCompressedOops参数 启动 bin/zookeeper-server-start.sh config/zookeeper.properties & bin/kafka-server-start.sh config/server.properties & 停止 bin/kafka-server-start.sh config/server.properties & bin/zookeeper-server-start.sh config/zookeeper.properties & create a topic bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic test 创建单partitions单replication的topic bin/kafka-topics.sh --list --zookeeper localhost:2181 查看topic 查看topic的分区 bin/kafka-topics.sh --describe --zookeeper localhost:2181 --topic test 启动生产者 bin/kafka-console-producer.sh --broker-list localhost:9092 --topic test 启动消费者 bin/kafka-console-consumer.sh --zookeeper localhost:2181 --topic test --from-beginning produce启动的时候参数使用的是kafka的端口而consumer启动的时候使用的是zookeeper的端口; 单机连通性能测试 运行producer bin/kafka-console-producer.sh --b

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值