使用Systemd运行Zookeeper 3.4.12和Solr 6.5.1-Solr在启动后立即关闭

时间:2018-09-05 17:41:00

标签: solr apache-zookeeper systemd

我是新手,还是动物园管理员。请耐心等待,谢谢。 任何帮助表示赞赏!

设置:

  • Suse 12 Enterprise
  • 没有init.d,只有systemd
  • zookeeper 3.4.12通过systemd运行并在默认端口2181上侦听
  • solr 6.5.1也必须通过systemd运行,但是在启动solr之后立即出于未知原因决定关闭
  • solr.log显示在警告和关闭后不久与动物园管理员建立连接
  • zookeeper日志文件没有关于solr退出的一行

我很困惑,无法确定此问题与systemd单位文件还是zookeeper <-> solr问题有关。

问题:

  • 单位文件solr.service是否正确? (我不确定,网上的例子非常稀缺)
  • 这是系统问题还是动物园管理员问题?
  • 我可以打开哪些日志以获取更多见解?

As @MatsLindh points out this is an sytemd issue. Solr log WARN was just a coincident.

journalctl -u solr

Sep 05 16:42:36 mucs75561 systemd[1]: Started Apache Solr Service.
Sep 05 16:42:40 mucs75561 solr[15732]: [98B blob data]
Sep 05 16:42:40 mucs75561 solr[15732]: Started Solr server on port 8983 
(pid=15857). Happy searching!
Sep 05 16:42:40 mucs75561 solr[15942]: Sending stop command to Solr running on port 8983 ... 
waiting up to 180 seconds to allow Jetty process 15857 to stop gracefully.

solr.log讲述了一个不同的故事(tail -n 1000 -f /opt/xxx/solr-6.5.1/server/logs/solr.log)

cat /opt/xxx/solr-6.5.1/server/logs/solr.log
16:42:38.594 INFO  (main) [   ] o.e.j.s.Server jetty-9.3.14.v20161028
16:42:38.992 INFO  (main) [   ] o.a.s.s.SolrDispatchFilter  ___      _       Welcome to Apache Solr™ version 6.5.1
16:42:38.996 INFO  (main) [   ] o.a.s.s.SolrDispatchFilter / __| ___| |_ _   Starting in cloud mode on port 8983
16:42:38.996 INFO  (main) [   ] o.a.s.s.SolrDispatchFilter \__ \/ _ \ | '_|  Install dir: /opt/xxx/solr-6.5.1
16:42:39.016 INFO  (main) [   ] o.a.s.s.SolrDispatchFilter |___/\___/_|_|    Start time: 2018-09-05T16:42:38.998Z
16:42:39.017 INFO  (main) [   ] o.a.s.s.StartupLoggingUtils Property solr.log.muteconsole given. Muting ConsoleAppender named CONSOLE
16:42:39.035 INFO  (main) [   ] o.a.s.c.SolrResourceLoader Using system property solr.solr.home: /opt/xxx/solr-6.5.1/server/solr
16:42:39.099 INFO  (main) [   ] o.a.s.s.SolrDispatchFilter Loading solr.xml from SolrHome (not found in ZooKeeper)
16:42:39.100 INFO  (main) [   ] o.a.s.c.SolrXmlConfig Loading container configuration from /opt/xxx/solr-6.5.1/server/solr/solr.xml
16:42:39.413 INFO  (main) [   ] o.a.s.u.UpdateShardHandler Creating UpdateShardHandler HTTP client with params: socketTimeout=600000&connTimeout=60000&retry=true
16:42:39.418 INFO  (main) [   ] o.a.s.c.ZkContainer Zookeeper client=localhost:2181/solr
16:42:39.510 INFO  (main) [   ] o.a.s.c.Overseer Overseer (id=null) closing
16:42:39.514 INFO  (main) [   ] o.a.s.c.OverseerElectionContext I am going to be the leader 192.168.18.49:8983_solr
16:42:39.519 INFO  (main) [   ] o.a.s.c.Overseer Overseer (id=72167078483197975-192.168.18.49:8983_solr-n_0000000009) starting
16:42:39.616 INFO  (main) [   ] o.a.s.c.ZkController Register node as live in ZooKeeper:/live_nodes/192.168.18.49:8983_solr
16:42:39.622 INFO  (OverseerStateUpdate-72167078483197975-192.168.18.49:8983_solr-n_0000000009) [   ] o.a.s.c.c.ZkStateReader Updated live nodes from ZooKeeper... (0) -> (1)
16:42:39.812 INFO  (main) [   ] o.a.s.c.CorePropertiesLocator Found 0 core definitions underneath /opt/xxx/solr-6.5.1/server/solr
16:42:39.898 INFO  (main) [   ] o.e.j.s.Server Started @1864ms
16:42:40.549 INFO  (ShutdownMonitor) [   ] o.a.s.c.CoreContainer Shutting down CoreContainer instance=966739377
16:42:40.557 INFO  (ShutdownMonitor) [   ] o.a.s.c.Overseer Overseer (id=72167078483197975-192.168.18.49:8983_solr-n_0000000009) closing
16:42:40.558 INFO  (OverseerStateUpdate-72167078483197975-192.168.18.49:8983_solr-n_0000000009) [   ] o.a.s.c.Overseer Overseer Loop exiting : 192.168.18.49:8983_solr
16:42:40.566 WARN  (zkCallback-5-thread-1-processing-n:192.168.18.49:8983_solr) [   ] o.a.s.c.c.ZkStateReader ZooKeeper watch triggered, but Solr cannot talk to ZK: [KeeperErrorCode = Session expired for /live_nodes]
16:42:40.566 INFO  (ShutdownMonitor) [   ] o.a.s.m.SolrMetricManager Closing metric reporters for: solr.node

我的/etc/systemd/system/solr.service:

[Unit]
Description=Apache Solr Service
After=syslog.target network.target nss-lookup.target
Requires=zookeeper.service

[Service]
User=xxx
Group=tomcat
WorkingDirectory=/opt/xxx/solr-6.5.1/
Environment=SOLR_INCLUDE=/opt/xxx/solr-6.5.1/bin/solr.in.sh   
ExecStart=/opt/xxx/solr-6.5.1/bin/solr start -m 4g -c -z localhost:2181/solr
ExecStop=/opt/xxx/solr-6.5.1/bin/solr stop -all

[Install]
WantedBy=default.target

谢谢阅读!

1 个答案:

答案 0 :(得分:1)

systemd requires the service that it starts保持运行。由于Solr启动脚本在启动Solr之后退出(也就是说,它将进程守护进程并使其在后台运行),因此systemd认为它已死,并尝试停止它。

您可以使用bin/solr start -f在前台开始solr:

-f            Start Solr in foreground; default starts Solr in the background
              and sends stdout / stderr to solr-PORT-console.log