Solr(5.2.1)安装、启动和建立索引
2015-08-12 19:58
537 查看
总结solr的下载、安装、启动和建立索引的过程。
下载:
官网查找最新版本的下载地址:http://lucene.apache.org/solr/
# wget http://mirror.bit.edu.cn/apache/lucene/solr/5.2.1/solr-5.2.1.tgz
解压:
# tar zxvf solr-5.2.1.tgz
如果是下载zip文件,解压:
# unzip solr-5.2.1.zip
确保系统中已经安装了JRE1.7或以上版本
Cloud模式启动:
查看启动命令的参数:
# bin/solr --help
-e:example,启动一个自带的实例
-noprompt:不提示输入参数,所有都是缺省的
启动一个自带例子(solrCloud):
# bin/solr start -e cloud -noprompt
提示摘要:
Waiting to see Solr listening on port 8983 [/]
Started Solr server on port 8983 (pid=10344). Happy searching!
Waiting to see Solr listening on port 7574 [/]
Started Solr server on port 7574 (pid=10502). Happy searching!
Connecting to ZooKeeper at localhost:9983
Uploading /opt/app/solr-5.2.1/server/solr/configsets/data_driven_schema_configs/conf for config gettingstarted to ZooKeeper at localhost:9983
Creating new collection 'gettingstarted' using command:
http://192.168.0.31:8983/solr/admin/collections?action=CREATE&name=gettingstarted&numShards=2&replicationFactor=2&maxShardsPerNode=2&collection.configName=gettingstarted
SolrCloud example running, please visit http://localhost:8983/solr
上面链接就是Solr的管理界面(把localhost替换成真实ip),如果打不开,可能是端口被防火墙禁用了:
查看端口开放状态:
> iptables -S
添加端口:
> iptables -I INPUT -p tcp --dport 8983 -j ACCEPT
(SUSE添加防火墙端口):
> vi /etc/sysconfig/SuSEfirewall2
FW_SERVICES_EXT_TCP=”22″中添加端口
> rcSuSEfirewall2 restart
这样,就启动了一个下图的实例:
查看该实例的状态:
# bin/solr healthcheck -c gettingstarted
为文档建索引:
# bin/post -c gettingstarted docs/
或:
# bin/post -c gettingstarted example/exampledocs/*.xml
-c gettingstarted:collection
最后那个参数:文档或文档所在的目录
查看具体的索引结果:
http://192.168.0.31:8983/solr/gettingstarted/browse
其他collection的链接: http://<ip>:8983/solr/<collection_name>/browse
搜索方法例子:
curl "http://localhost:8983/solr/collection1/select?wt=json&indent=true&q=foundation"
curl "http://localhost:8983/solr/collection1/select?wt=json&indent=true&q=name:foundation"
更多参数说明:/article/2598125.html
停止solr:
bin/solr stop -all
删除启动时创建的目录:
rm -Rf example/cloud/
启动Cloud参考文档:http://lucene.apache.org/solr/quickstart.html
DIH创建索引的方法:
https://cwiki.apache.org/confluence/display/solr/Uploading+Structured+Data+Store+Data+with+the+Data+Import+Handler
Standalone模式启动:
启动:$ bin/solr start
此时,solr会在后台启动,监听8983端口。启动成功后提示:
Started Solr server on port 8983 (pid=8756). Happy searching!
(注:可能要先修改为可可执行文件:$ chmod +x solr)
查看端口是否已经在监听:$ netstat -lnp
相关命令:
$ bin/solr -help (命令概况)
$ bin/solr start -help (start命令详情)
$ bin/solr start -f (非后台启动)
$ bin/solr start -p 8984 (指定端口启动)
$ bin/solr stop -p 8983 (停止一个后台运行的solr,注:需要指定端口号,停止非后台运行的solr可以用ctrl+c)
$ bin/solr stop -all (停止所有后台运行的solr)
$ bin/solr -e techproducts (启动例子techproducts,可用的例子还有:dih, schemaless, cloud)
访问管理界面:http://<ip>:8983/solr/
注:可能需要先在防火墙中打开8983端口
此时,界面显示“No cores available”,需要创建一个core。
创建一个core:
$ ./solr create -c <name>
创建的core所在路径:./server/solr/<core_name>,solr启动的时候会搜索./server/solr下的子目录,如果其中有core.properties文件,就当做一个core来启动。
加入文件并建立索引:
$ ./post -c <core_name> <file_dir>/<file_name>
(原创文章,转载请注明转自Clement-Xu的博客)
下载:
官网查找最新版本的下载地址:http://lucene.apache.org/solr/
# wget http://mirror.bit.edu.cn/apache/lucene/solr/5.2.1/solr-5.2.1.tgz
解压:
# tar zxvf solr-5.2.1.tgz
如果是下载zip文件,解压:
# unzip solr-5.2.1.zip
确保系统中已经安装了JRE1.7或以上版本
Cloud模式启动:
查看启动命令的参数:
# bin/solr --help
-e:example,启动一个自带的实例
-noprompt:不提示输入参数,所有都是缺省的
启动一个自带例子(solrCloud):
# bin/solr start -e cloud -noprompt
提示摘要:
Waiting to see Solr listening on port 8983 [/]
Started Solr server on port 8983 (pid=10344). Happy searching!
Waiting to see Solr listening on port 7574 [/]
Started Solr server on port 7574 (pid=10502). Happy searching!
Connecting to ZooKeeper at localhost:9983
Uploading /opt/app/solr-5.2.1/server/solr/configsets/data_driven_schema_configs/conf for config gettingstarted to ZooKeeper at localhost:9983
Creating new collection 'gettingstarted' using command:
http://192.168.0.31:8983/solr/admin/collections?action=CREATE&name=gettingstarted&numShards=2&replicationFactor=2&maxShardsPerNode=2&collection.configName=gettingstarted
SolrCloud example running, please visit http://localhost:8983/solr
上面链接就是Solr的管理界面(把localhost替换成真实ip),如果打不开,可能是端口被防火墙禁用了:
查看端口开放状态:
> iptables -S
添加端口:
> iptables -I INPUT -p tcp --dport 8983 -j ACCEPT
(SUSE添加防火墙端口):
> vi /etc/sysconfig/SuSEfirewall2
FW_SERVICES_EXT_TCP=”22″中添加端口
> rcSuSEfirewall2 restart
这样,就启动了一个下图的实例:
查看该实例的状态:
# bin/solr healthcheck -c gettingstarted
为文档建索引:
# bin/post -c gettingstarted docs/
或:
# bin/post -c gettingstarted example/exampledocs/*.xml
-c gettingstarted:collection
最后那个参数:文档或文档所在的目录
查看具体的索引结果:
http://192.168.0.31:8983/solr/gettingstarted/browse
其他collection的链接: http://<ip>:8983/solr/<collection_name>/browse
搜索方法例子:
curl "http://localhost:8983/solr/collection1/select?wt=json&indent=true&q=foundation"
curl "http://localhost:8983/solr/collection1/select?wt=json&indent=true&q=name:foundation"
更多参数说明:/article/2598125.html
停止solr:
bin/solr stop -all
删除启动时创建的目录:
rm -Rf example/cloud/
启动Cloud参考文档:http://lucene.apache.org/solr/quickstart.html
DIH创建索引的方法:
https://cwiki.apache.org/confluence/display/solr/Uploading+Structured+Data+Store+Data+with+the+Data+Import+Handler
Standalone模式启动:
启动:$ bin/solr start
此时,solr会在后台启动,监听8983端口。启动成功后提示:
Started Solr server on port 8983 (pid=8756). Happy searching!
(注:可能要先修改为可可执行文件:$ chmod +x solr)
查看端口是否已经在监听:$ netstat -lnp
相关命令:
$ bin/solr -help (命令概况)
$ bin/solr start -help (start命令详情)
$ bin/solr start -f (非后台启动)
$ bin/solr start -p 8984 (指定端口启动)
$ bin/solr stop -p 8983 (停止一个后台运行的solr,注:需要指定端口号,停止非后台运行的solr可以用ctrl+c)
$ bin/solr stop -all (停止所有后台运行的solr)
$ bin/solr -e techproducts (启动例子techproducts,可用的例子还有:dih, schemaless, cloud)
访问管理界面:http://<ip>:8983/solr/
注:可能需要先在防火墙中打开8983端口
此时,界面显示“No cores available”,需要创建一个core。
创建一个core:
$ ./solr create -c <name>
创建的core所在路径:./server/solr/<core_name>,solr启动的时候会搜索./server/solr下的子目录,如果其中有core.properties文件,就当做一个core来启动。
加入文件并建立索引:
$ ./post -c <core_name> <file_dir>/<file_name>
(原创文章,转载请注明转自Clement-Xu的博客)
相关文章推荐
- 线段树模板
- hdu 2819 Swap
- ObjC第三节:内存管理
- 杭电 1301 Jungle Roads 【最小生成树&&Kruskal】
- 【Baltic2007】【BZOJ1345】序列问题Sequence
- JAVA多线程编程
- Objective-C:在类中设置不同协议
- _00024 尼娜抹微笑伊拉克_云计算ClouderaManager以及CHD5.1.0群集部署安装文档V1.0
- 解决:LNMP架构下访问php页面出现500错误
- 问题-jdbc连接不上mysql,windows下开启两个mysql服务
- Win2008 R2 标准版升级企业版
- OC的nil, Nil, NSNull, NULL和nullptr. 以及josn转换后的(null)和<null>
- 【DP】 HDOJ 5370 Tree Maker
- ShareSDK的使用
- [HDU 2121] Ice_cream’s world II 最小树形图
- HDU 1116 Play on Words
- 快速幂。素数筛选。辗转相除。
- fd to filename
- hdu 1181 变形课 DFS
- JS中如何实现每点击一次按钮,显示一条信息