设为首页 收藏本站
查看: 1034|回复: 0

[经验分享] Kafka-broker配置说明

[复制链接]

尚未签到

发表于 2017-5-23 17:53:49 | 显示全部楼层 |阅读模式
  配置文件在config/server.properties
  下面的一些配置可能是你需要进行修改的。
  broker.id
  整数,建议根据ip区分
  log.dirs
  kafka存放消息文件的路径,
  默认/tmp/kafka-logs
  port
  broker用于接收producer消息的端口
  zookeeper.connnect
  zookeeper连接
  格式为  ip1:port,ip2:port,ip3:port
  message.max.bytes
  单条消息的最大长度
  num.network.threads
  broker用于处理网络请求的线程数
  如不配置默认为3,server.properties默认是2
  num.io.threads
  broker用于执行网络请求的IO线程数
  如不配置默认为8,server.properties默认是2可适当增大,
  queued.max.requests
  排队等候IO线程执行的requests
  默认为500
  host.name
  broker的hostname
  默认null,建议写主机的ip,不然消费端不配置hosts会有麻烦
  num.partitions
  topic的默认分区数
  默认1
  log.retention.hours
  消息被删除前保存多少小时
  默认1周168小时
  auto.create.topics.enable
  是否可以程序自动创建Topic
  默认true,建议false
  default.replication.factor
  消息备份数目
  默认1不做复制,建议修改
  num.replica.fetchers
  用于复制leader消息到follower的IO线程数
  默认1
  下面的文档是官网给出的说明。
  The essential configurations are the following:

  • broker.id
  • log.dirs
  • zookeeper.connect
PropertyDefaultDescriptionbroker.id Each broker is uniquely identified by a non-negative integer id. This id serves as the brokers "name", and allows the broker to be moved to a different host/port without confusing consumers. You can choose any number you like so long as it is unique.log.dirs/tmp/kafka-logsA comma-separated list of one or more directories in which Kafka data is stored. Each new partition that is created will be placed in the directory which currently has the fewest partitions.port6667The port on which the server accepts client connections.zookeeper.connectnullSpecifies the zookeeper connection string in the form hostname:port, where hostname and port are the host and port for a node in your zookeeper cluster. To allow connecting through other zookeeper nodes when that host is down you can also specify multiple hosts in the formhostname1:port1,hostname2:port2,hostname3:port3.  Zookeeper also allows you to add a "chroot" path which will make all kafka data for this cluster appear under a particular path. This is a way to setup multiple Kafka clusters or other applications on the same zookeeper cluster. To do this give a connection string in the formhostname1:port1,hostname2:port2,hostname3:port3/chroot/pathwhich would put all this cluster's data under the path /chroot/path. Note that you must create this path yourself prior to starting the broker and consumers must use the same connection string.
message.max.bytes1000000The maximum size of a message that the server can receive. It is important that this property be in sync with the maximum fetch size your consumers use or else an unruly consumer will be able to publish messages too large for consumers to consume.num.network.threads3The number of network threads that the server uses for handling network requests. You probably don't need to change this.num.io.threads8The number of I/O threads that the server uses for executing requests. You should have at least as many threads as you have disks.queued.max.requests500The number of requests that can be queued up for processing by the I/O threads before the network threads stop reading in new requests.host.namenull  Hostname of broker. If this is set, it will only bind to this address. If this is not set, it will bind to all interfaces, and publish one to ZK.
socket.send.buffer.bytes100 * 1024The SO_SNDBUFF buffer the server prefers for socket connections.socket.receive.buffer.bytes100 * 1024The SO_RCVBUFF buffer the server prefers for socket connections.socket.request.max.bytes100 * 1024 * 1024  The maximum request size the server will allow. This prevents the server from running out of memory and should be smaller than the Java heap size.
num.partitions1The default number of partitions per topic.log.segment.bytes1024 * 1024 * 1024The log for a topic partition is stored as a directory of segment files. This setting controls the size to which a segment file will grow before a new segment is rolled over in the log.log.segment.bytes.per.topic""This setting allows overriding log.segment.bytes on a per-topic basislog.roll.hours24 * 7This setting will force Kafka to roll a new log segment even if the log.segment.bytes size has not been reached.log.roll.hours.per.topic""This setting allows overriding log.roll.hours on a per-topic basis.log.retention.hours24 * 7The number of hours to keep a log segment before it is deleted, i.e. the default data retention window for all topics. Note that if both log.retention.hours and log.retention.bytes are both set we delete a segment when either limit is exceeded.log.retention.hours.per.topic""A per-topic override for log.retention.hours.log.retention.bytes-1The amount of data to retain in the log for each topic-partitions. Note that this is the limit per-partition so multiple by the number of partitions to get the total data retained for the topic. Also note that if both log.retention.hours and log.retention.bytes are both set we delete a segment when either limit is exceeded.log.retention.bytes.per.topic""A per-topic override for log.retention.bytes.log.cleanup.interval.mins10The frequency in minutes that the log cleaner checks whether any log segment is eligible for deletion to meet the retention policies.log.index.size.max.bytes10 * 1024 * 1024The maximum size in bytes we allow for the offset index for each log segment. Note that we will always pre-allocate a sparse file with this much space and shrink it down when the log rolls. If the index fills up we will roll a new log segment even if we haven't reached the log.segment.bytes limit.log.index.interval.bytes4096The byte interval at which we add an entry to the offset index. When executing a fetch request the server must do a linear scan for up to this many bytes to find the correct position in the log to begin and end the fetch. So setting this value to be larger will mean larger index files (and a bit more memory usage) but less scanning. However the server will never add more than one index entry per log append (even if more than log.index.interval worth of messages are appended). In general you probably don't need to mess with this value.log.flush.interval.messages10000The number of messages written to a log partition before we force an fsync on the log. Setting this higher will improve performance a lot but will increase the window of data at risk in the event of a crash (though that is usually best addressed through replication). If both this setting and log.flush.interval.ms are both used the log will be flushed when either criteria is met.log.flush.interval.ms.per.topic""The per-topic override for log.flush.interval.messages, e.g., topic1:3000,topic2:6000log.flush.scheduler.interval.ms3000The frequency in ms that the log flusher checks whether any log is eligible to be flushed to disk.log.flush.interval.ms3000The maximum time between fsync calls on the log. If used in conjuction with log.flush.interval.messages the log will be flushed when either criteria is met.auto.create.topics.enabletrueEnable auto creation of topic on the server. If this is set to true then attempts to produce, consume, or fetch metadata for a non-existent topic will automatically create it with the default replication factor and number of partitions.controller.socket.timeout.ms30000The socket timeout for commands from the partition management controller to the replicas.controller.message.queue.size10The buffer size for controller-to-broker-channelsdefault.replication.factor1The default replication factor for automatically created topics.replica.lag.time.max.ms10000If a follower hasn't sent any fetch requests for this window of time, the leader will remove the follower from ISR and treat it as dead.replica.lag.max.messages4000If a replica falls more than this many messages behind the leader, the leader will remove the follower from ISR and treat it as dead.replica.socket.timeout.ms30 * 1000The socket timeout for network requests to the leader for replicating data.replica.socket.receive.buffer.bytes64 * 1024The socket receive buffer for network requests to the leader for replicating data.replica.fetch.max.bytes1024 * 1024The number of byes of messages to attempt to fetch for each partition in the fetch requests the replicas send to the leader.replica.fetch.wait.max.ms500The maximum amount of time to wait time for data to arrive on the leader in the fetch requests sent by the replicas to the leader.replica.fetch.min.bytes1Minimum bytes expected for each fetch response for the fetch requests from the replica to the leader. If not enough bytes, wait up to replica.fetch.wait.max.ms for this many bytes to arrive.num.replica.fetchers1  Number of threads used to replicate messages from leaders. Increasing this value can increase the degree of I/O parallelism in the follower broker.
replica.high.watermark.checkpoint.interval.ms5000The frequency with which each replica saves its high watermark to disk to handle recovery.fetch.purgatory.purge.interval.requests10000The purge interval (in number of requests) of the fetch request purgatory.producer.purgatory.purge.interval.requests10000The purge interval (in number of requests) of the producer request purgatory.zookeeper.session.timeout.ms6000Zookeeper session timeout. If the server fails to heartbeat to zookeeper within this period of time it is considered dead. If you set this too low the server may be falsely considered dead; if you set it too high it may take too long to recognize a truly dead server.zookeeper.connection.timeout.ms6000The max time that the client waits to establish a connection to zookeeper.zookeeper.sync.time.ms2000How far a ZK follower can be behind a ZK leadercontrolled.shutdown.enablefalseEnable controlled shutdown of the broker. If enabled, the broker will move all leaders on it to some other brokers before shutting itself down. This reduces the unavailability window during shutdown.controlled.shutdown.max.retries3Number of retries to complete the controlled shutdown successfully before executing an unclean shutdown.controlled.shutdown.retry.backoff.ms5000Backoff time between shutdown retries.More details about broker configuration can be found in the scala class kafka.server.KafkaConfig.

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-379943-1-1.html 上篇帖子: 【Kafka六】Kafka Producer和Consumer多Broker、多Partition场景 下篇帖子: Kafka Consumer的底层API- SimpleConsumer
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表