Solr单机版安装 有更新!

  益达MIM味

本教程使用Centos 7.0作为安装环境

转载请标明出处:
http://www.zousiliang.com/articles/2017/03/26/1490530343779.html

本文出自益达MIM味

第一步. 安装jdk、安装tomcat

第二步.解压solr缩包

solr下载地址
链接: http://pan.baidu.com/s/1geNjgnp 密码: k36w

第三步:把dist/solr-4.10.3.war部署到tomcat下

[root@localhost ~]# cd solr-4.10.3/dist/
[root@localhost dist]# mv solr-4.10.3.war /usr/local/solr/tomcat7/webapps/

第四步:解压缩war包。启动tomcat解压

[root@localhost bin]# ./startup.sh

第五步:需要把solr-4.10.3/example/lib/ext目录下的所有的jar包添加到tomcat下的solr工程中

[root@localhost ext]# pwd
/root/solr-4.10.3/example/lib/ext
[root@localhost ext]# cp * /usr/local/solr/tomcat7/webapps/solr/WEB-INF/lib/

第六步:创建solrhome。把/root/solr-4.10.3/example/solr文件夹复制一份作为solrhome。

[root@localhost example]# cp -r solr /usr/local/solr/solrhome

第七步:告诉solr服务solrhome的位置。需要修改web.xml

[root@localhost WEB-INF]# pwd
/usr/local/solr/tomcat7/webapps/solr/WEB-INF
[root@localhost WEB-INF]# vim web.xml

去掉注释 修改成这样
env-entry-value为你的solrhome路径

    <env-entry>
       <env-entry-name>solr/home</env-entry-name>
       <env-entry-value>/usr/local/solr/solrhome</env-entry-value>
       <env-entry-type>java.lang.String</env-entry-type>
    </env-entry>

第八步:启动tomcat

[root@localhost tomcat7]# bin/startup.sh 
[root@localhost tomcat7]# tail -f logs/catalina.out 
Mar 26, 2017 5:00:22 AM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Mar 26, 2017 5:00:22 AM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.47
Mar 26, 2017 5:00:22 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /usr/local/solr/tomcat7/webapps/docs
Mar 26, 2017 5:00:24 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /usr/local/solr/tomcat7/webapps/examples
Mar 26, 2017 5:00:25 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /usr/local/solr/tomcat7/webapps/solr
log4j:WARN No appenders could be found for logger (org.apache.solr.client.solrj.impl.HttpClientUtil).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
Mar 26, 2017 5:00:42 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /usr/local/solr/tomcat7/webapps/manager
Mar 26, 2017 5:00:42 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /usr/local/solr/tomcat7/webapps/host-manager
Mar 26, 2017 5:00:42 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /usr/local/solr/tomcat7/webapps/ROOT
Mar 26, 2017 5:00:42 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8080"]
Mar 26, 2017 5:00:42 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-bio-8009"]
Mar 26, 2017 5:00:42 AM org.apache.catalina.startup.Catalina start
INFO: Server startup in 20684 ms

第九步:访问solr

http://192.168.136.135:8080/solr/#/

image

==如果访问失败可能是你防火墙关闭了==

CentOS Linux开启和关闭防火墙命令有两种,一种是临时的,重启即复原;另外一种是永久性的,重启不会复原。

1) 临时生效,重启后复原
开启: service iptables start
关闭: service iptables stop
 
2) 永久性生效,重启后不会复原
开启: chkconfig iptables on
关闭: chkconfig iptables off