以两台服务器为例:
IP地址分别为:10.0.1.201 和10.0.1.202
下载zookeeper压缩包
wget http://apache.fayea.com/zookeeper/zookeeper-3.4.9/zookeeper-3.4.9.tar.gz
在10.0.1.201服务器上:
1、进入/home/目录下(随便选择目录),将zookeeper-3.4.9.tar.gz压缩文件放入该目录下
执行命令
tar -zxvf zookeeper-3.4.9.tar.gz
解压zookeeper安装包zookeeper-3.4.9文件夹
2、接下来创建data目录,并在data目录中创建myid文件,将"1"写入到myid文件中
cd /home/zookeeper-3.4.9
mkdir data
echo 1 >> data/myid
zookeeper-3.4.9目录下创建一个存放日志的目录logs
mkdir logs
3、进入conf目录下,将zoo_sample.cfg文件重命名为zoo.cfg
cd conf
mv zoo_sample.cfg zoo.cfg
4、最后修改zoo.cfg中的参数
# The number of milliseconds of each tick
tickTime=2000
# The number of ticks that the initial
# synchronization phase can take
initLimit=5
# The number of ticks that can pass between
# sending a request and getting an acknowledgement
syncLimit=2
# the directory where the snapshot is stored.
# do not use /tmp for storage, /tmp here is just
# example sakes.
dataDir=/home/zookeeper-3.4.9/data
dataLogDir=/home/zookeeper-3.4.9/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
server.1=10.0.1.201:2881:3881
server.2=10.0.1.202:2881:3881
5、启动zookeper
/home/zookeeper-3.4.9/bin/zkServer.sh start
6、最后进入solr安装目录的bin目录下修改solr.in.sh文件,在文件中添加
SOLR_MODE=solrcloud
ZK_HOST=10.0.1.201:2181,10.0.1.202:2181
SOLR_HOST="10.0.1.201"
在10.0.1.202服务器上:
1、进入/home/目录下(随便选择目录),将zookeeper-3.4.9.tar.gz压缩文件放入该目录下
执行命令
tar -zxvf zookeeper-3.4.9.tar.gz
解压zookeeper安装包zookeeper-3.4.9文件夹
2、接下来创建data目录,并在data目录中创建myid文件,将"1"写入到myid文件中
cd /home/zookeeper-3.4.9
mkdir data
echo 2 >> data/myid
zookeeper-3.4.9目录下创建一个存放日志的目录logs
mkdir logs
3、进入conf目录下,将zoo_sample.cfg文件重命名为zoo.cfg
cd conf
mv zoo_sample.cfg zoo.cfg
4、最后修改zoo.cfg中的参数
# The number of milliseconds of each tick
tickTime=2000
# The number of ticks that the initial
# synchronization phase can take
initLimit=5
# The number of ticks that can pass between
# sending a request and getting an acknowledgement
syncLimit=2
# the directory where the snapshot is stored.
# do not use /tmp for storage, /tmp here is just
# example sakes.
dataDir=/home/zookeeper-3.4.9/data
dataLogDir=/home/zookeeper-3.4.9/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
server.1=10.0.1.201:2881:3881
server.2=10.0.1.202:2881:3881
5、启动zookeper
/home/zookeeper-3.4.9/bin/zkServer.sh start
可使用在两台服务器上查看zookeeper的运行状态
/home/zookeeper-3.4.9/bin/zkServer.sh status
6、最后进入solr安装目录的bin目录下修改solr.in.sh文件,在文件中添加
SOLR_MODE=solrcloud
ZK_HOST=10.0.1.201:2181,10.0.1.202:2181
SOLR_HOST="10.0.1.202"