安装ZooKeeper
1.3 安装ZooKeeper
1.3.1 下载ZooKeeper压缩包
wget http://mirrors.hust.edu.cn/apache/zookeeper/zookeeper-3.4.13/zookeeper-3.4.13.tar.gz
1.3.2 解压ZooKeeper压缩包
tar -zxvf zookeeper-3.4.13.tar.gz
1.3.3 删除ZooKeeper压缩包
rm -f zookeeper-3.4.13.tar.gz
1.3.4 拷贝配置文件
cd /usr/local/zookeeper-3.4.13/conf
cp zoo_sample.cfg zoo.cfg
vim zoo.cfg
这个zoo.cfg是zookeeper的配置文件,这里我搭的是单机版,如果想搭集群版也是通过修改配置文件即可。
# 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=/usr/local/zookeeper-3.4.13/data #这里最好自己设置 # 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 server.1=cnblogs01:8888:9888 #这里修改为自己的主机名或者IP server.2=cnblogs02:8888:9888 server.3=cnblogs03:8888:9888
创建/usr/local/zookeeper-3.4.13/data文件夹,新建一个myid,写入1
mkdir data
vim myid
1.3.5 启动ZooKeeper
/usr/local/zookeeper-3.4.13/bin/zkServer.sh start