clouderaCDH中添加solr服務(wù)(三個(gè)節(jié)點(diǎn)):
設(shè)置好本地solr_HOME和HDFS_HOME,連接zookeeper服務(wù)
安裝完成之后就可以通過(guò)http://IP:8983/solr頁(yè)面管理solr服務(wù)
創(chuàng)建Collection
1.生產(chǎn)實(shí)體配置文件:
solrctl?instancedir?--generate /var/lib/solr/collectionName #其中/var/lib/solr 為自己設(shè)置的一個(gè)放置生成實(shí)體配置文件的目錄;collectionName 為生成的這個(gè)配置的目錄名稱(chēng)
collectionName 為生成的這個(gè)配置的目錄名稱(chēng)生成配置文件后會(huì)在/var/lib/solr/collectionName /conf這個(gè)目錄下產(chǎn)生很多配置文件
我們可以根據(jù)自己的需要修改schema.xml文件,具體schema.xml的修改規(guī)則可以參看:http://wiki.apache.org/solr/SchemaXml
2.創(chuàng)建 collectionName實(shí)例并將配置文件上傳到 zookeeper:
solrctl?instancedir?--createcollectionName/var/lib/solr/collectionName
可以通過(guò)下面命令查看上傳的實(shí)體:
solrctl instancedir --list
也可以通過(guò)zookeeper的bin目錄下zkCli.sh查看zookeeper中的文件(ls /)
上傳到 zookeeper 之后,其他節(jié)點(diǎn)就可以從上面下載配置文件。
3.創(chuàng)建 collection:
solrctl collection --createcollectionName-s 3 -r 2 -m3 ?//-m未指定會(huì)報(bào)錯(cuò)(Cannot create collection collectionName. Value of maxShardsPerNode is 1, and the number of live nodes is 3. This allows a maximum of 3 to be created. Value of numShards is 3 and value of replicationFactor is 2. This requires 6 shards to be created (higher than the allowed number))
其中-s表示設(shè)置Shard數(shù)為3,-r表示設(shè)置的replica數(shù)為2,-m表示maxShardsPerNode?為3。安裝以上步驟solr的實(shí)例就算創(chuàng)建完畢 ,可以通過(guò)http://IP:8983/solr/#/~cloud查看創(chuàng)建的Collection。

命令幫助
[root@sxjdb03 solr]# solrctl --help
Options:
--solr solr_uri
--zk? ?zk_ensemble
--jaas jaas.conf
--help
--quiet
Commands:
init? ? ? ? [--force]
instancedir [--generate path [-schemaless]] --生成collection試題文件,path為本地路徑
[--create name path] --創(chuàng)建collection實(shí)例并將配置文件上傳到zookeepername為collection名字,path為本地配置文件的路徑
[--update name path] --修改schema.xml文件之后,需要更新zookeeper中的文件,name為collection名字,path為本地路徑
[--get name path]
[--delete name]
[--list]
config? ? ? [--create name baseConfig [-p name=value]...]
[--delete name]
collection? [--create name -s
[-a Create collection with autoAddReplicas=true]
[-c ]
[-r ]
[-m ]
[-n ]]
[--delete name]
[--reload name] --zookeeper中的配置文件更新完之后需要重新加載shemale.xml文件 name為collection名字
[--stat name]
[--deletedocs name]
[--list]
core? ? ? ? [--create name [-p name=value]...]
[--reload name]
[--unload name]
[--status name]
cluster? ? ?[--get-solrxml file]
[--put-solrxml file]
[--set-property name value]
[--remove-property name]
[--get-clusterstate file]