Solr的安装
下载http://archive.apache.org/dist/lucene/solr/6.4.0/
或者直接去官网下载最新版本
网页指导 https://cwiki.apache.org/confluence/display/solr/Getting+Started
其中在root用户下需要使用 -force
[risktest@zk-datanode-01 solr]$ bin/solr -e cloud -noprompt
Welcome to the SolrCloud example!
Starting up 2 Solr nodes for your example SolrCloud cluster.
Creating Solr home directory /home/risktest/solr/example/cloud/node1/solr
Cloning /home/risktest/solr/example/cloud/node1 into
/home/risktest/solr/example/cloud/node2
Starting up Solr on port 8983 using command:
bin/solr start -cloud -p 8983 -s "example/cloud/node1/solr"
NOTE: Please install lsof as this script needs it to determine if Solr is listening on port 8983.
Started Solr server on port 8983 (pid=17023). Happy searching!
Starting up Solr on port 7574 using command:
bin/solr start -cloud -p 7574 -s "example/cloud/node2/solr" -z localhost:9983
NOTE: Please install lsof as this script needs it to determine if Solr is listening on port 7574.
Started Solr server on port 7574 (pid=17244). Happy searching!
INFO - 2017-06-21 15:01:52.861; org.apache.solr.client.solrj.impl.ZkClientClusterStateProvider; Cluster at localhost:9983 ready
Connecting to ZooKeeper at localhost:9983 ...
INFO - 2017-06-21 15:01:52.937; org.apache.solr.client.solrj.impl.ZkClientClusterStateProvider; Cluster at localhost:9983 ready
Uploading /home/risktest/solr/server/solr/configsets/data_driven_schema_configs/conf for config gettingstarted to ZooKeeper at localhost:9983
Creating new collection 'gettingstarted' using command:
http://localhost:8983/solr/admin/collections?action=CREATE&name=gettingstarted&numShards=2&replicationFactor=2&maxShardsPerNode=2&collection.configName=gettingstarted
{ "responseHeader":{ "status":0, "QTime":5615}, "success":{ "192.168.46.160:8983_solr":{ "responseHeader":{ "status":0, "QTime":4329}, "core":"gettingstarted_shard1_replica2"}, "192.168.46.160:7574_solr":{ "responseHeader":{ "status":0, "QTime":4326}, "core":"gettingstarted_shard2_replica1"}}}
Enabling auto soft-commits with maxTime 3 secs using the Config API
POSTing request to Config API: http://localhost:8983/solr/gettingstarted/config
{"set-property":{"updateHandler.autoSoftCommit.maxTime":"3000"}}
Successfully set-property updateHandler.autoSoftCommit.maxTime to 3000
SolrCloud example running, please visit: http://localhost:8983/solr
==============================================================================
启动solr cloud命令:
bin/solr start -cloud -s server/solr -p 8983 -z zk-datanode-01:2181,zk-datanode-02:2181,zk-datanode-03:2181
通过zookeeper管理配置文件
./server/scripts/cloud-scripts/zkcli.sh -zkhost zk-datanode-01:2181,zk-datanode-02:2181,zk-datanode-03:2181 -cmd upconfig -confname my_config -confdir server/solr/configsets/basic_configs/conf
通过url创建相应的collection
http://192.168.46.160:8987/solr/admin/collections?action=CREATE&name=gettingstarted&numShards=2&replicationFactor=2&maxShardsPerNode=2&collection.configName=my_config