[英]How to auto start elasticsearch in Centos 6.5?
I have installed elasticsearh on a server based on Cent OS 6.5. 我已经在基于Cent OS 6.5的服务器上安装了elasticsearh。 To start it:
要启动它:
# cd /usr/share/elasticsearch/elasticsearch-1.5.2]
# ./bin/elasticsearch &
But when I close the terminal, the process is killed. 但是当我关闭终端时,该过程被终止。 How can I set it to automatically start as a service?
如何设置它作为服务自动启动?
Try using the "nohup" command with elastic search. 尝试在弹性搜索中使用“ nohup”命令。
$ nohup ./bin/elasticsearch
Now what the nohup
does? 现在,
nohup
做什么? In the following example, it starts the program abcd in the background in such a way that the subsequent logout does not stop it. 在下面的示例中,它将在后台启动程序abcd,以免后续注销不会停止它。
$ nohup abcd &
$ exit
Hope that helped. 希望能有所帮助。
As @DerStoffel said, you have to start elasticsearch as a service ( sudo service elasticsearch start
). 正如@DerStoffel所说,您必须将elasticsearch作为
sudo service elasticsearch start
( sudo service elasticsearch start
)。 This is highly recommended in production settings. 在生产设置中强烈建议这样做。 Also add the service to start in case of reboot (
sudo /sbin/chkconfig --add elasticsearch
) 还要添加服务以在重新启动的情况下启动(
sudo /sbin/chkconfig --add elasticsearch
)
It depends the distribution of linux you use: 这取决于您使用的linux的分布:
Debian/Ubuntu Debian / Ubuntu
sudo update-rc.d elasticsearch defaults 95 10
sudo /etc/init.d/elasticsearch start
https://www.elastic.co/guide/en/elasticsearch/reference/1.6/setup-service.html#_debian_ubuntu https://www.elastic.co/guide/zh-CN/elasticsearch/reference/1.6/setup-service.html#_debian_ubuntu
RPM based distributions like Centos 基于RPM的发行版,如Centos
sudo /sbin/chkconfig --add elasticsearch
sudo service elasticsearch start
https://www.elastic.co/guide/en/elasticsearch/reference/1.6/setup-service.html#_rpm_based_distributions https://www.elastic.co/guide/zh-CN/elasticsearch/reference/1.6/setup-service.html#_rpm_based_distributions
sudo /bin/systemctl daemon-reload
sudo /bin/systemctl enable elasticsearch.service
sudo /bin/systemctl start elasticsearch.service
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.