Solr Cloud-5.3.1安装

原创
2017/06/20 10:03
阅读数 168

环境准备:

  • 安装并配置好Java Runtime Environment (JRE) 1.7 或更高版本。通过以下命令验证
[root@node01 ~]# java -version
java version "1.7.0_80"
Java(TM) SE Runtime Environment (build 1.7.0_80-b15)
Java HotSpot(TM) 64-Bit Server VM (build 24.80-b11, mixed mode)
  • 安装并成功启动Zookeeper集群
  • 安装过程中,会将Solr注册为系统服务,故需要以root用户执行安装

1. 下载Solr-5.3.1安装包

[root@node01 ~]# wget http://archive.apache.org/dist/lucene/solr/5.3.1/solr-5.3.1.tgz
--2017-06-20 09:01:38--  http://archive.apache.org/dist/lucene/solr/5.3.1/solr-5.3.1.tgz
Resolving archive.apache.org (archive.apache.org)... 163.172.17.199
Connecting to archive.apache.org (archive.apache.org)|163.172.17.199|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 134911094 (129M) [application/x-gzip]
Saving to: ‘solr-5.3.1.tgz’

100%[===========================================================================================================================================>] 134,911,094 5.68MB/s   in 47s

2017-06-19 09:12:30 (5.93 MB/s) - ‘solr-5.3.1.tgz’ saved [134911094/134911094]

2. 从压缩包中抽取出安装脚本

[root@node01 ~]# tar zxvf solr-5.3.1.tgz solr-5.3.1/bin/install_solr_service.sh --strip-components=2
solr-5.3.1/bin/install_solr_service.sh
[root@node01 ~]# ls
install_solr_service.sh solr-5.3.1.tgz

3. 执行安装脚本

[root@node01 ~]# sh install_solr_service.sh solr-5.3.1.tgz -i /mnt/bd/software/solr -d /mnt/bd/data/solr -u bd -s solr -p 8983
Extracting solr-5.3.1.tgz to /mnt/bd/software/solr
Creating /etc/init.d/solr script ...
NOTE: Please install lsof as this script needs it to determine if Solr is listening on port 8983.

Started Solr server on port 8983 (pid=31112). Happy searching!


Found 1 Solr nodes:

Solr process 31112 running on port 8983
{
  "solr_home":"/mnt/bd/data/solr/data/",
  "version":"5.3.1 1703449 - noble - 2015-09-17 01:48:15",
  "startTime":"2017-06-19T02:13:41.216Z",
  "uptime":"0 days, 0 hours, 0 minutes, 15 seconds",
  "memory":"59.5 MB (%12.1) of 490.7 MB"}

Service solr installed.
  • 参数说明
选项 含义
-i /mnt/bd/software/solr 指定solr的安装目录,默认为/opt。(安装时会生成指向安装目录的符号连接 /mnt/bd/software/solr/solr )
-d /mnt/bd/data/solr 指定写文件的目录,包括索引、日志、初环境变量设置等,默认为/var/solr
-u bd 指定solr文件和运行进程的所属用户, 默认为solr(安装脚本自动创建了solr账号)
-s solr solr服务的名称, 默认为solr
-p 8983 solr服务的监听端口,默认为8983

4. 修改solr的配置文件solr.in.sh(该文件位于上个步骤中-d指定的目录中),使用之前安装的zk

[root@node01 ~]# vi /mnt/bd/data/solr/solr.in.sh
# Set the ZooKeeper connection string if using an external ZooKeeper ensemble
# e.g. host1:2181,host2:2181/chroot
# Leave empty if not using SolrCloud
ZK_HOST="172.16.117.65:2181/solr"
  • ZK_HOST后需要指定一个目录,Solr会基于此目录存放文件

5. 重启solr服务,是配置生效

[root@node01 ~]# service solr restart
Sending stop command to Solr running on port 8983 ... waiting 5 seconds to allow Jetty process 12364 to stop gracefully.
NOTE: Please install lsof as this script needs it to determine if Solr is listening on port 8983.

Started Solr server on port 8983 (pid=21014). Happy searching!

6. 查看Solr服务

[root@node01 ~]# service solr status

Found 1 Solr nodes:

Solr process 28262 running on port 8983
{
  "solr_home":"/mnt/bd/data/solr/data/",
  "version":"5.3.1 1703449 - noble - 2015-09-17 01:48:15",
  "startTime":"2017-06-19T03:22:03.492Z",
  "uptime":"0 days, 1 hours, 33 minutes, 19 seconds",
  "memory":"43.4 MB (%8.8) of 490.7 MB",
  "cloud":{
    "ZooKeeper":"172.16.117.65:2181",
    "liveNodes":"1",
    "collections":"0"}}
  • 此时,只在服务器node01上成功安装并启动了Solr,故liveNodes:1。

7. 参照步骤1~6,在其他服务器上安装并启动Solr。

  • 步骤1~6是在node01上进行的,参照1~6,在node02、node03上安装并启动Solr

8. Solr Cloud集群安装、启动完毕,查看Solr服务

[root@node01 ~]# service solr status

Found 1 Solr nodes:

Solr process 28262 running on port 8983
{
  "solr_home":"/mnt/bd/data/solr/data/",
  "version":"5.3.1 1703449 - noble - 2015-09-17 01:48:15",
  "startTime":"2017-06-19T03:22:03.492Z",
  "uptime":"0 days, 1 hours, 33 minutes, 19 seconds",
  "memory":"43.4 MB (%8.8) of 490.7 MB",
  "cloud":{
    "ZooKeeper":"172.16.117.65:2181",
    "liveNodes":"3",
    "collections":"0"}}
  • 此时,在服务器node01、node02、node03上都成功安装并启动了Solr,故liveNodes:3。

9. Solr Cloud已成功安装,开始使用!


FAQ

  1. 异常信息:
2017-06-19 06:29:31.815 INFO  (main) [   ] o.a.s.c.c.ConnectionManager Client is connected to ZooKeeper
2017-06-19 06:29:31.815 INFO  (main) [   ] o.a.s.c.c.SolrZkClient Using default ZkACLProvider
2017-06-19 06:29:31.818 ERROR (main) [   ] o.a.s.s.SolrDispatchFilter Could not start Solr. Check solr/home property and the logs
2017-06-19 06:29:31.835 ERROR (main) [   ] o.a.s.c.SolrCore null:org.apache.solr.common.cloud.ZooKeeperException: A chroot was specified in ZkHost but the znode doesn't exist. 172.1
6.117.65:2181/solr
        at org.apache.solr.core.ZkContainer.initZooKeeper(ZkContainer.java:109)
        at org.apache.solr.core.CoreContainer.load(CoreContainer.java:392)
        at org.apache.solr.servlet.SolrDispatchFilter.createCoreContainer(SolrDispatchFilter.java:132)
        at org.apache.solr.servlet.SolrDispatchFilter.init(SolrDispatchFilter.java:109)
        at org.eclipse.jetty.servlet.FilterHolder.initialize(FilterHolder.java:138)
        at org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:852)
        at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:298)
        at org.eclipse.jetty.webapp.WebAppContext.startWebapp(WebAppContext.java:1349)
        at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1342)
        at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:741)
        at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:505)
        at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
        at org.eclipse.jetty.deploy.bindings.StandardStarter.processBinding(StandardStarter.java:41)
        at org.eclipse.jetty.deploy.AppLifeCycle.runBindings(AppLifeCycle.java:186)
        at org.eclipse.jetty.deploy.DeploymentManager.requestAppGoal(DeploymentManager.java:498)
        at org.eclipse.jetty.deploy.DeploymentManager.addApp(DeploymentManager.java:146)
        at org.eclipse.jetty.deploy.providers.ScanningAppProvider.fileAdded(ScanningAppProvider.java:180)
        at org.eclipse.jetty.deploy.providers.WebAppProvider.fileAdded(WebAppProvider.java:461)
        at org.eclipse.jetty.deploy.providers.ScanningAppProvider$1.fileAdded(ScanningAppProvider.java:64)
        at org.eclipse.jetty.util.Scanner.reportAddition(Scanner.java:609)
        at org.eclipse.jetty.util.Scanner.reportDifferences(Scanner.java:528)
        at org.eclipse.jetty.util.Scanner.scan(Scanner.java:391)
        at org.eclipse.jetty.util.Scanner.doStart(Scanner.java:313)
        at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
        at org.eclipse.jetty.deploy.providers.ScanningAppProvider.doStart(ScanningAppProvider.java:150)
        at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
        at org.eclipse.jetty.deploy.DeploymentManager.startAppProvider(DeploymentManager.java:560)
        at org.eclipse.jetty.deploy.DeploymentManager.doStart(DeploymentManager.java:235)
        at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
        at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:132)
        at org.eclipse.jetty.server.Server.start(Server.java:387)
        at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:114)
        at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:61)
        at org.eclipse.jetty.server.Server.doStart(Server.java:354)
        at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
        at org.eclipse.jetty.xml.XmlConfiguration$1.run(XmlConfiguration.java:1255)
        at java.security.AccessController.doPrivileged(Native Method)
        at org.eclipse.jetty.xml.XmlConfiguration.main(XmlConfiguration.java:1174)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at org.eclipse.jetty.start.Main.invokeMain(Main.java:321)
        at org.eclipse.jetty.start.Main.start(Main.java:817)
        at org.eclipse.jetty.start.Main.main(Main.java:112)
  • 异常原因:ZK_HOST="172.16.117.65:2181/solr"中指定的/solr节点在Zookeeper上不存在,需手动创建
  • 异常解决:执行$ZOOKEEPER_HOME/bin/zkCli.sh进入ZK客户端,创建/solr节点:create /solr null
展开阅读全文
打赏
0
0 收藏
分享
加载中
更多评论
打赏
0 评论
0 收藏
0
分享
返回顶部
顶部