六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 1013|回复: 0

linux(Centos)下完美部署Solr 搜索引擎

[复制链接]
 楼主| 发表于 2015-6-19 18:07:05 | 显示全部楼层 |阅读模式
linux(Centos)下完美部署Solr 搜索引擎
centos solr4.7简单安装   一、环境准备:
   
   系统环境:centos 6.2
             tomcat 7.0.47

             jdk-7u9

             solr-4.7.0

   首先将软件包上传到/tmp目录下
   1、  jdk安装
   
[root@svn-server /]# cd /tmp/              
   
[root@svn-server /]#tar zxvf  jdk-7u9-linux-x64.tar.gz
   
[root@svn-server /]#mv  jdk1.7.0_09 /usr/
   
[root@svn-server /]#vi  /etc/profile
   在最后一行复制以下代码添加如下内容:
   
JAVA_HOME=/usr/jdk1.7.0_09/
   
CLASSPATH=.JAVA_HOME/lib/tools.jar
   
PATH=$JAVA_HOME/binPATH
   
export JAVA_HOME CLASSPATH PATH
   保存退出(:wq!)后,执行下面命令生效:
   
source /etc/profile
   
   2、  tomcat安装
   将tomcat包减压到tmp目录下:
   
[root@svn-server tmp]tar zxvf apache-tomcat-7.0.47.tar.gz
   
将tomcat包移动到/usr/local/tomcat 下:
   
[root@svn-server tmp]mv apache-tomcat-7.0.47  /usr/local/tomcat
   
   二、安装solr
   1、解压solr
   
[root@svn-server tmp]tar -zxvf solr-4.7.0.tgz  
   2、将solr包移动到opt目录下:
   
[root@svn-server tmp]mv /tmp/solr-4.7.0   /opt/solr  
   3、把exmaple/webapps中的solr.war复制到tomcat
   
[root@svn-server tmp]makdir  -p /opt/tomcat/webapps
   
[root@svn-server tmp]cp /opt/solr/example/webapps/solr.war  /opt/tomcat/webapps/  
   
[root@svn-server tmp]vi  /usr/local/tomcat/conf/server.xml
   
   <host name="localhost" appbase="/opt/tomcat/webapps"
               unpackWARs="true" autoDeploy="true">
   

   如图将webapps改为/opt/tomcat/webapps 即可;
   
   4、启动tomcat,solr.war 自动解压,修改solr项目下的web.xml
   
[root@svn-server tmp]cd /usr/local/tomcat/bin/
   
[root@svn-server bin]./startup.sh
   
[root@svn-server bin]vi /opt/tomcat/webapps/solr/WEB-INF/web.xml
   
   5、修改solr home配置(注意:要把这段内容的注释去掉,否则不生效):
                  
                   solr/home  
                  /opt/solr/example/solr  
                  java.lang.String  
                  
   
   6、复制solr/example/lib/ext下的jar包到/tomcat/../solr/WEB-INF/lib/下:
   
[root@svn-server tmp]cp /opt/solr/example/lib/ext/*.jar  /opt/tomcat/webapps/solr/WEB-INF/lib/  
   7、在tomcat solr下创建classpath,并把example/resources/log4j.properties复制到classpath中:
   
[root@svn-server tmp]mkdir -p /opt/tomcat/webapps/solr/classpath  
   
[root@svnserver tmp]cp/opt/solr/example/resources/log4j.properties /opt/tomcat/webapps/solr/classpath/  
   8、配置完成重启tomcat
   
/usr/local/tomcat/bin/shutdown.sh
   
/usr/local/tomcat/bin/startup.sh
   9、浏览器输入http://192.168.1.196:8080/solr/进入solr admin画面
   

   [/url]
   
   
   
   四、简单的安装完毕!
   

   五、安装分词工具:IK Analyzer 2012FF_hf1
   

       1)把下载好的IKAnalyzer2012FF_u1.jar 上传到/opt/tomcat/webapps/solr/WEB-INF/lib
          [root@localhost lib]# pwd
           /opt/tomcat/webapps/solr/WEB-INF/lib
   
        2)设置IKAnalyzer中文分词
   修改/opt/solr/example/solr/collection1/conf 中的schema.xml,在中增加如下                内容:
   
           
                  
                  
           
   
   

   六、接下来重启tomcat 即可:
   
   [root@localhost yuanxiaoku]# /usr/local/tomcat/bin/shutdown.sh
   [root@localhost yuanxiaoku]# /usr/local/tomcat/bin/start.sh
   
   以上内容亲自测试N遍 !没有一点问题的哦!!!!欢迎大家评论
   
   七、公司需求新建Core :
       点击Add Core 名称命名完毕后会报错的  
   [url=http://s3.51cto.com/wyfs02/M00/22/7A/wKiom1MfF2OzyDYhAAEhlehNzNo106.jpg]

   
   

   这个问题找了好久的原因 ,通过日志分析,可能是找不要源路径,路径匹配不对,该如何解决呢,版主有如下思路即可解决此问题:
   
   [root@localhost solr]# pwd
   /opt/solr/example/solr
   看到以上的路径在solr下 将 collection1 目录里的文件copy 到你新建的Core 里(注:不需要拷贝data目录)
   
   我以我的yuanxiaoku 为例:
   
   [root@localhost solr]# ll
   total 24
   drwxr-xr-x. 2 root root 4096 Feb 18  2014 bin
   drwxr-xr-x. 4 root root 4096 Nov  8 10:55 collection1
   -rw-r--r--. 1 root root 2473 Feb 18  2014 README.txt
   -rw-r--r--. 1 root root 1715 Feb 18  2014 solr.xml
   drwxr-xr-x. 2 root root 4096 Nov  8 13:28 yuanxiaoku
   -rw-r--r--. 1 root root  501 Feb 18  2014 zoo.cfg
   [root@localhost solr]# cd collection1/
   [root@localhost collection1]# ll
   total 16
   drwxr-xr-x. 6 root root 4096 Nov  8 10:49 conf
   -rw-r--r--. 1 root root   16 Feb 18  2014 core.properties
   drwxr-xr-x. 4 root root 4096 Nov  8 10:55 data
   -rw-r--r--. 1 root root 2146 Feb 18  2014 README.txt
   [root@localhost collection1]# cp -r conf ../yuanxiaoku/
   [root@localhost collection1]#
   [root@localhost collection1]#
   [root@localhost collection1]# cp -r README.txt ../yuanxiaoku/
   

   将conf 和 README.txt 拷贝到 yuanxiaoku 目录下即可;
   
   [root@localhost solr]# cd yuanxiaoku/
   [root@localhost yuanxiaoku]# ll
   total 24
   drwxr-xr-x. 6 root root 4096 Nov  8 13:31 conf
   -rw-r--r--. 1 root root  133 Nov  8 11:00 core.properties
   drwxr-xr-x. 4 root root 4096 Nov  8 13:33 data
   -rw-r--r--. 1 root root 2146 Nov  8 13:32 README.txt
   -rw-------. 1 root root 6447 Nov  8 10:51 server.xml
   
   看到以上的结果,我们就可以重启tomcat 了!!激动人心的时刻到了
   
   [root@localhost yuanxiaoku]# /usr/local/tomcat/bin/shutdown.sh
   [root@localhost yuanxiaoku]# /usr/local/tomcat/bin/start.sh
    现在通过访问:http://192.168.250.105:8080/solr/
   [/url]
   
   


   看到yuanxiaoku 的Core 已经可以正常调用数据库了!到了现在说明我们所做的已经成功了!
   

   备注:大家一定要注意防火墙!!!添加默认允许端口就可以,或者是内网直接关闭防火墙即可
   [root@solr-server ~]# service iptables stop
   

   如有问题及时回复本贴进行交流!!!
   摘自:[url=http://tonyping.blog.51cto.com/7725720/1372076]http://tonyping.blog.51cto.com/7725720/1372076


linux(Centos)下完美部署Solr 搜索引擎

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?立即注册 新浪微博账号登陆

x
该会员没有填写今日想说内容.
您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表