solr cloud的分布式部署演示

今天试了一下solr4的solrcloud部署,发现还是很方便的,借助zookeeper很容易实现高可用分布式部署,由于只是尝试,是在单机上部署,使用不同的端口实现,原理与多机器部署完全一样,本处采用独立的zookeeper集群部署,而没有使用solr集成的zookeeper,集成只能用开发环境

部署zookeeper

创建三个zookeeper实例:

cp -r zookeeper-3.4.6 zookeeper1
cp -r zookeeper-3.4.6 zookeeper2
cp -r zookeeper-3.4.6 zookeeper3

配置文件分别如下:

ookeeper1/conf/zoo.cfg

 1 # The number of milliseconds of each tick
 2 tickTime=2000
 3 # The number of ticks that the initial 
 4 # synchronization phase can take
 5 initLimit=10
 6 # The number of ticks that can pass between 
 7 # sending a request and getting an acknowledgement
 8 syncLimit=5
 9 # the directory where the snapshot is stored.
10 # do not use /tmp for storage, /tmp here is just 
11 # example sakes.
12 dataDir=/tmp/zookeeper1
13 # the port at which the clients will connect
14 clientPort=9983
15 # the maximum number of client connections.
16 # increase this if you need to handle more clients
17 #maxClientCnxns=60
18 #
19 # Be sure to read the maintenance section of the 
20 # administrator guide before turning on autopurge.
21 #
22 # http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance
23 #
24 # The number of snapshots to retain in dataDir
25 #autopurge.snapRetainCount=3
26 # Purge task interval in hours
27 # Set to "0" to disable auto purge feature
28 #autopurge.purgeInterval=1
29 server.1=localhost:2888:3888
30 server.2=localhost:4888:5888
31 server.3=localhost:6888:7888

 

ookeeper2/conf/zoo.cfg

 1 # The number of milliseconds of each tick
 2 tickTime=2000
 3 # The number of ticks that the initial 
 4 # synchronization phase can take
 5 initLimit=10
 6 # The number of ticks that can pass between 
 7 # sending a request and getting an acknowledgement
 8 syncLimit=5
 9 # the directory where the snapshot is stored.
10 # do not use /tmp for storage, /tmp here is just 
11 # example sakes.
12 dataDir=/tmp/zookeeper2
13 # the port at which the clients will connect
14 clientPort=9984
15 # the maximum number of client connections.
16 # increase this if you need to handle more clients
17 #maxClientCnxns=60
18 #
19 # Be sure to read the maintenance section of the 
20 # administrator guide before turning on autopurge.
21 #
22 # http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance
23 #
24 # The number of snapshots to retain in dataDir
25 #autopurge.snapRetainCount=3
26 # Purge task interval in hours
27 # Set to "0" to disable auto purge feature
28 #autopurge.purgeInterval=1
29 server.1=localhost:2888:3888
30 server.2=localhost:4888:5888
31 server.3=localhost:6888:7888

 

ookeeper3/conf/zoo.cfg

 1 # The number of milliseconds of each tick
 2 tickTime=2000
 3 # The number of ticks that the initial 
 4 # synchronization phase can take
 5 initLimit=10
 6 # The number of ticks that can pass between 
 7 # sending a request and getting an acknowledgement
 8 syncLimit=5
 9 # the directory where the snapshot is stored.
10 # do not use /tmp for storage, /tmp here is just 
11 # example sakes.
12 dataDir=/tmp/zookeeper3
13 # the port at which the clients will connect
14 clientPort=9985
15 # the maximum number of client connections.
16 # increase this if you need to handle more clients
17 #maxClientCnxns=60
18 #
19 # Be sure to read the maintenance section of the 
20 # administrator guide before turning on autopurge.
21 #
22 # http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance
23 #
24 # The number of snapshots to retain in dataDir
25 #autopurge.snapRetainCount=3
26 # Purge task interval in hours
27 # Set to "0" to disable auto purge feature
28 #autopurge.purgeInterval=1
29 server.1=localhost:2888:3888
30 server.2=localhost:4888:5888
31 server.3=localhost:6888:7888 

在对应的datadir目录: /tmp/zookeeper1,/tmp/zookeeper2,/tmp/zookeeper3中创建myid文件,分别输入1,2,3。然后分别启动

zookeeper1/bin/zkServer.sh start

zookeeper2/bin/zkServer.sh start

zookeeper3/bin/zkServer.sh start

部署solr

创建两个分片,启动4个solr实例

cp -r example/ solr1

cp -r example/ solr2

cp -r example/ solr3

cp -r example/ solr4

启动第一个solr实例 solr1,这个启动参数与后面稍有不同,需要注意:

cd solr1

java -DzkHost=localhost:9983,localhost:9984,localhost:9985 -DnumShards=2 -Dbootstrap_confdir=./solr/collection/conf -Dcollection.configName=myconf -jar start.jar

其余的实例启动相同:

cd solr2

java -DzkHost=localhost:9984,localhost:9983,localhost:9985 -Djetty.port=8984 -jar start.jar

 

cd solr3

java -DzkHost=localhost:9984,localhost:9983,localhost:9985 -Djetty.port=8985 -jar start.jar

cd solr4

java -DzkHost=localhost:9984,localhost:9983,localhost:9985 -Djetty.port=8986 -jar start.jar

 

最终可以通过:http://localhost:8983/solr/#/~cloud 查看solrcloud的部署情况

 

posted @ 2015-08-04 10:45  涛光  阅读(565)  评论(0)    收藏  举报