1.将zookeeper包上传到服务器
2.在/usr/下创建solr-cloud文件夹,将压缩包解压三份放到该文件夹下
分别为zookeeper01,zookeeper02,zookeeper03
3.进到zookeeper01文件夹下,创建data文件夹
4.进到data文件夹中创建myid文件
#touch myid
#vim myid
内容为1(内容就是每个实例的id。例如1、2、3)
5.进到conf目录下,
#/usr/solr-cloud/zookeeper01/conf
#cp zoo_sample.cfg zoo.cfg
6.编辑zoo.cfg,修改dataDir为data的目录
dataDir=/usr/solr-cloud/zookeeper01/data/
并在最后追加(ip为当前服务器ip地址,两个端口号分别为zookeeper内部通讯端口和投票选举的端口)(此处若为真实服务器,记得要在云管理器中开启端口号)
server.1=127.0.0.1:2881:3881
server.2=127.0.0.1:2882:3882
server.3=127.0.0.1:2883:3883
7.同理设置zookeeper02和zookeeper03:
#mkdir zookeeper02/data
#cd zookeeper02/data
#echo 2 >myid
同第五步,第六步,再加上修改clientPort为2182
8.配置zookeeper03
9.编写启动脚本,启动zookeeper集群:
#vim start-all.sh
cd zookeeper01/bin
./zkServer.sh start
cd ../../
cd zookeeper02/bin
./zkServer.sh start
cd ../../
cd zookeeper03/bin
./zkServer.sh start
cd ../../
#chmod u+x start-all.sh
#./start-all.sh
10.启动后查看zookeeper启动状态
#cd ../../zookeeper03/bin/
#./zkServer.sh status
发现,两从,一主:
zookeeper01:
JMX enabled by default
Using config: /usr/solr-cloud/zookeeper01/bin/../conf/zoo.cfg
Mode: follower
zookeeper02:
JMX enabled by default
Using config: /usr/solr-cloud/zookeeper02/bin/../conf/zoo.cfg
Mode: leader
zookeeper03:
JMX enabled by default
Using config: /usr/solr-cloud/zookeeper03/bin/../conf/zoo.cfg
Mode: follower
11.配置完成