• 常见的kafka配置文件server.properties的zookeeper连接配置

    zookeeper.connect=hostname1:2181,hostname2:2181,hostname2:2181
    log.dirs=/data01/kafka/log,/data02/kafka/log,/data03/kafka/log
    
  • 有时可能会看到类似下面的配置

    zookeeper.connect=hostname1:2181,hostname2:2181/kafka_cluster1
    

    那么我们程序或者命令中的zk连接地址必须写成--zookeeper hostname1:2181,hostname2:2181/kafka_cluster1 的形式。

    zk的连接地址中带一个路径“/kafka_cluster1”,是因为多个kafka集群注册到了一个zk集群中,不同路径代表将不同kafka集群信息注册到zk的不同节点上。

  • 这个路径叫做chroot path。kfk官方文档上提到zk的连接路径中可以带有chroot path。下面是kfk官方文档的链接以及对于zookeeper.connect参数的原文描述。
    http://kafka.apache.org/documentation/#brokerconfigs

    zookeeper.connect
    Specifies the ZooKeeper connection string in the form hostname:port where host and port are the host and port of a ZooKeeper server. To allow connecting through other ZooKeeper nodes when that ZooKeeper machine is down you can also specify multiple hosts in the form hostname1:port1,hostname2:port2,hostname3:port3.
    The server can also have a ZooKeeper chroot path as part of its ZooKeeper connection string which puts its data under some path in the global ZooKeeper namespace. For example to give a chroot path of /chroot/path you would give the connection string as hostname1:port1,hostname2:port2,hostname3:port3/chroot/path.
    
    Type:	string
    Default:	null
    Valid Values:	
    Importance:	high
    Update Mode:	read-only
    
  • chroot是linux中的一种操作,即Change Root,也就是改变程序执行时参考的根目录的位置。我理解为一种路径映射,例如将路径“/”映射为“/hello”。

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐