4.3.1 下载解压 mkdir -p /data/packages/ cd /data/packages/ wget http://mirror.bit.edu.cn/apache/zookeeper/zookeeper-3.4.10/zookeeper-3.4.10.tar.gz cd /usr/local/ tar -zxvf /data/packages/zookeeper-3.4.10.tar.gz ln -s zookeeper-3.4.10 zookeeper cd zookeeper mkdir data log cd conf/ cp zoo_sample.cfg zoo.cfg 4.3.2 修改配置文件 vim 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=/usr/local/zookeeper/data dataLogDir=/usr/local/zookeeper/log # the port at which the clients will connect clientPort=2181 server.1=192.168.33.11:2888:3888 server.2=192.168.33.12:2888:3888 server.3=192.168.33.13:2888:3888 # 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 4.3.3 添加myid文件 vim /usr/local/zookeeper/data/myid写入 1
4.3.5 启动zookeeper cd /usr/local/zookeeper/bin/ ./zkServer.sh start
4.4 安装Mycat 同样,3个节点都需要安装mycat。
cd /data/packages/ wget http://dl.mycat.io/1.6-RELEASE/Mycat-server-1.6-RELEASE-20161028204710-linux.tar.gz cd /usr/local/ tar -zxvf /data/packages/Mycat-server-1.6-RELEASE-20161028204710-linux.tar.gz 4.6 执行mycat初始化数据 3个节点Mycat都执行如下脚本
sh /usr/local/mycat/bin/init_zk_data.sh 4.7 配置mycat支持zookeeper vim /usr/local/mycat/conf/myid.properties
loadZk=true # zk集群地址,多个用","隔开 zkURL=127.0.0.1:2181 # zk集群内Mycat集群ID clusterId=mycat-cluster-1 # Mycat集群内本实例ID,禁止重复 myid=mycat_fz_01 # Mycat集群内节点个数 clusterSize=3 clusterNodes=mycat_fz_01,mycat_fz_02,mycat_fz_03 #server booster ; booster install on db same server,will reset all minCon to 1 type=server boosterDataHosts=dataHost1 4.8 用zookeeper配置mycat 使用ZooInspector工具管理ZooKeeper,以下是连接zookeeper方法。