配置文件在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
Property | Default | Description |
---|---|---|
broker.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-logs | A 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. |
port | 6667 | The port on which the server accepts client connections. |
zookeeper.connect | null | Specifies 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 form |