zookeeper环境搭建
-
单机模式
不作演示
-
伪集群模式
在一台服务器上运行多个zookeeper,设置不同端口即可,与集群模式类似
-
集群模式
-
解压,比如解压到 /opt 目录下
-
在zookeeper目录下创建 data, logs目录
-
修改配置文件名 conf目录下
mv zoo_sample.cfg zoo.cfg
-
在每个data目录下创建一个myid文件,内容分别为1, 2, 3, …用于记录每个服务器的id
-
在每个zoo.cfg配置端口等信息,配置文件示例如下
# The number of milliseconds of each tick tickTime=2000 # The number of ticks that the initial # synchronization phase can take initLimit=10 # The number of ticks that can pass between # sending a request and getting an acknowledgement syncLimit=5 # the directory where the snapshot is stored. # do not use /tmp for storage, /tmp here is just # example sakes. dataDir=/opt/zookeeper/data dataLogDir=/opt/zookeeper/logs # the port at which the clients will connect clientPort=2181 # the maximum number of client connections. # increase this if you need to handle more clients #maxClientCnxns=60 # # Be sure to read the maintenance section of the # administrator guide before turning on autopurge. # # http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance # # The number of snapshots to retain in dataDir #autopurge.snapRetainCount=3 # Purge task interval in hours # Set to "0" to disable auto purge feature #autopurge.purgeInterval=1 ## Metrics Providers # # https://prometheus.io Metrics Exporter #metricsProvider.className=org.apache.zookeeper.metrics.prometheus.PrometheusMetricsProvider #metricsProvider.httpPort=7000 #metricsProvider.exportJvmInfo=true server.1=0.0.0.0:2888:3888 #当前服务器ip server.2=*.*.*.*:2888:3888 #其他服务咕咕Ip server.3=*.*.*.*:2888:3888
-
依次启动各个实例