使所选版本的 Elasticsearch 作为 Linux 中的服务运行
我对 ES 的更高版本有问题,因此目前必须使用 7.10.2。
这意味着我之前用来将 ES 安装为服务的方法(即 apt-get)不起作用。您无法通过这种方式选择旧版本:它当前安装的是 7.16.3。
因此,我按照 此页面 7.10 上的程序进行操作:一切正常:我能够将 ES 作为应用程序和“守护进程”运行。显然,我可以简单地将“守护程序”启动行放在启动时运行的脚本中。
但是,将这种“守护进程安排”转变为可以使用 systemctl 控制并在计算机启动时自动启动的服务的最佳方法是什么?
PS我不想参与Docker。我确信这是一件有用的事情,但我相信有一种更简单的方法可以做到这一点,即使用可用的 Linux 系统工具。
I have an issue with later versions of ES, so have to use 7.10.2 currently.
This means that the previous method I used to install ES as a service, i.e. apt-get
, doesn't work You can't choose an older version this way: it currently installs 7.16.3.
So I followed the procedure on this page for 7.10: everything worked: I was able to run ES as an app and also as a "daemon". Clearly I could simply put the "daemon" startup line in a script which runs on boot.
But what's the optimum way of turning this "daemon arrangement" into a service which you can control with systemctl
, and which starts automatically when the machine boots?
PS I don't want to get involved with Docker. I'm sure that's a useful thing but I'm convinced there is a simpler way of doing it, using available Linux sys tools.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我找到了一个解决方法...这实际上并没有创建可以由 systemctl 控制的“systemd”类型的服务。似乎有一两个问题使得这件事变得不平凡。
1)你不能以root身份启动ES!我假设(不确定)大多数服务都是由 root 运行的。无论如何,这是我找不到解决方案的事情。
2) 我不确定是否允许服务调用的 shell 脚本文件结束...或者应该无限地继续:最初我认为这就足够了。这是一个 shell 脚本 (run_es_daemon.sh),当在终端中手动运行时,它确实会启动 ES(作为守护进程)。脚本结束然后关闭终端这一事实没有问题:守护进程继续运行:
...但它从未使用 /etc/systemd/system/ 中的 xxx.service 文件工作(也许因为上面的 1))。所以我也尝试在上面的行下添加这些行:
...也不起作用。
最后我发现一个简单的解决方案是使用 crontab 启动守护进程:
...但我仍然想知道如何将其设置为真正的服务,该服务启动启动时...
I found a workaround... this doesn't in fact create a service of the "systemd" type which can be controlled by
systemctl
. There seem to be one or two problems which make this non-trivial.1) You can't start ES as root! I assume (not sure) that most services are being run by root. Anyway this was something I couldn't find a solution to.
2) I am not sure whether a shell script file called by a service is allowed to end... or should continue endlessly: initially I thought this would be sufficient. This is a shell script (run_es_daemon.sh) which does indeed start up ES (as a daemon process) when run by manually in a terminal. There is no issue to do with the fact that the script ends and you then close the terminal: the daemon process continues to run:
... but it never worked using a xxx.service file in /etc/systemd/system/ (maybe because of 1) above). So I also tried adding these lines under the above ones:
... didn't work either.
In the end I found a simple workaround solution was to start up the daemon process by using
crontab
:... but I'd still like to know how to set it up as a true service, which starts at boot...