clouderaCDH中添加solr服务(三个节点):
设置好本地solr_HOME和HDFS_HOME,连接zookeeper服务
安装完成之后就可以通过http://IP:8983/solr页面管理solr服务
创建Collection
1.生产实体配置文件:
solrctl instancedir –generate /var/lib/solr/collectionName #其中/var/lib/solr 为自己设置的一个放置生成实体配置文件的目录;collectionName 为生成的这个配置的目录名称
collectionName 为生成的这个配置的目录名称生成配置文件后会在/var/lib/solr/collectionName /conf这个目录下产生很多配置文件
我们可以根据自己的需要修改schema.xml文件,具体schema.xml的修改规则可以参看:http://wiki.apache.org/solr/SchemaXml
2.创建 collectionName实例并将配置文件上传到 zookeeper:
solrctl instancedir –createcollectionName/var/lib/solr/collectionName
可以通过下面命令查看上传的实体:
solrctl instancedir –list
也可以通过zookeeper的bin目录下zkCli.sh查看zookeeper中的文件(ls /)
上传到 zookeeper 之后,其他节点就可以从上面下载配置文件。
3.创建 collection:
solrctl collection –createcollectionName-s 3 -r 2 -m3 //-m未指定会报错(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表示设置Shard数为3,-r表示设置的replica数为2,-m表示maxShardsPerNode 为3。安装以上步骤solr的实例就算创建完毕 ,可以通过http://IP:8983/solr/#/~cloud查看创建的Collection。
安装之后的solrcloud
命令帮助
[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] –创建collection实例并将配置文件上传到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]