将solr-5.3.1.tgz放置在linux的/solr目录中,解压缩即可,目录为solr-5.3.1
进入solr-5.3.1目录,执行命令:./bin/solr start
通过zookeeper来进行集群管理,
进入solr-5.3.1目录,执行命令:./bin/solr start -c -z 10.88.88.19:2181
./bin/solr start -p 8394
./bin/solr start -c -p 8394 -z 10.88.99.18:2181
./bin/solr stop -p 8394
准备3台电脑A、B、C,ip分别是10.88.88.152;10.88.88.123;10.88.88.185
1.分别在三台电脑上安装solr,通过集群命令来部署,如图:
2.在A电脑/solr/solr-5.3.1/server/solr下创建一个文件夹,名字为cloudTest,然后将《集群初始配置文件及jar包》中的内容拷贝进去,如图:
3. 将配置文件上传到ZooKeeper中
执行命令:
java -classpath .:/solr/solr-5.3.1/server/solr/cloudTest/lib/* org.apache.solr.cloud.ZkCLI -cmd upconfig -zkhost 10.88.88.19:2181 -confdir /solr/solr-5.3.1/server/solr/cloudTest/conf -confname cloudTest
java -classpath .:/solr/solr-5.3.1/server/solr/cloudTest/lib/* org.apache.solr.cloud.ZkCLI -cmd linkconfig -collection cloudTest -confname cloudTest -zkhost 10.88.88.19:2181
http://10.88.88.152:8983/solr/admin/collections?action=CREATE&name=cloudTest&numShards=1&replicationFactor=1&collection.configName=cloudTest
name:数据集名称
numShards:分片数
replicationFactor:每个分片的复本数
将分片(Shards)复本(Replicas)分布在3个Solr服务器节点上
6.在浏览器中执行:
http://10.88.88.123:8983/solr/admin/cores?action=CREATE&collection=cloudTest&name=cloudTest_shard1_replica2&shard=shard1
7.在浏览器中执行:
http://10.88.88.185:8983/solr/admin/cores?action=CREATE&collection=cloudTest&name=cloudTest_shard1_replica3&shard=shard1
至此shard1就创建成功
8.在浏览器中执行:
http://10.88.88.123:8983/solr/admin/cores?action=CREATE&collection=cloudTest&name=cloudTest_shard2_replica2&shard=shard2
9.在浏览器中执行:
http://10.88.88.185:8983/solr/admin/cores?action=CREATE&collection=cloudTest&name=cloudTest_shard2_replica3&shard=shard2
10.在浏览器中执行:
http://10.88.88.152:8983/solr/admin/cores?action=CREATE&collection=cloudTest&name=cloudTest_shard2_replica1&shard=shard2
至此shard2就创建成功
11.在浏览器中执行:
http://10.88.88.185:8983/solr/admin/cores?action=CREATE&collection=cloudTest&name=cloudTest_shard3_replica3&shard=shard3
12.在浏览器中执行:
http://10.88.88.152:8983/solr/admin/cores?action=CREATE&collection=cloudTest&name=cloudTest_shard3_replica1&shard=shard3
13.在浏览器中执行:
http://10.88.88.123:8983/solr/admin/cores?action=CREATE&collection=cloudTest&name=cloudTest_shard3_replica2&shard=shard3
至此shard3就创建成功
最终结果如图: