我想用新配置重新启动elasticsearch节点.优雅地关闭节点的最佳方法是什么?
杀死进程是关闭服务器的最佳方法,还是有一些神奇的URL我可以用来关闭节点?
dad*_*net 121
更新的答案.
_shutdown 已在elasticsearch 2.x中删除API.
一些选择:
在你的终端(基本上是开发模式),只需输入"Ctrl-C"
如果你以守护进程启动它(-d)找到PID并SIGTERM终止进程:将干净地关闭Elasticsearch(kill -15 PID)
如果作为服务运行,请执行以下操作service elasticsearch stop:
以前的答案.它现在已从1.6弃用.
是啊.请参阅admin cluster nodes shutdown documentation
基本上:
# Shutdown local node
$ curl -XPOST 'http://localhost:9200/_cluster/nodes/_local/_shutdown'
# Shutdown all nodes in the cluster
$ curl -XPOST 'http://localhost:9200/_shutdown'
Run Code Online (Sandbox Code Playgroud)
Ija*_*han 17
如果您只想应用新配置,则无需关闭它.
$ sudo service elasticsearch restart
但是如果你想要关闭它:
$ sudo service elasticsearch stop
要么
$ sudo systemctl stop elasticsearch.service
$ sudo systemctl restart elasticsearch.service
泊坞窗:
docker restart <elasticsearch-container-name or id>
Sur*_*shS 10
停止服务并杀死守护进程确实是关闭节点的正确方法。但是,如果您想关闭节点进行维护,不建议直接这样做。事实上,如果您没有副本,您将丢失数据。
当你直接关闭一个节点时,Elasticsearch 会等待 1m(默认时间)让它重新上线。如果没有,那么它将开始将分片从该节点分配给其他节点,从而浪费大量 IO。
一种典型的方法是通过发出以下命令暂时禁用分片分配:
PUT _cluster/settings
{
"persistent": {
"cluster.routing.allocation.enable": "none"
}
}
Run Code Online (Sandbox Code Playgroud)
现在,当您关闭一个节点时,ES 不会尝试从该节点向其他节点分配分片,您可以执行维护活动,然后一旦节点启动,您可以再次启用分片分配:
PUT _cluster/settings
{
"persistent": {
"cluster.routing.allocation.enable": "all"
}
}
Run Code Online (Sandbox Code Playgroud)
来源:https : //www.elastic.co/guide/en/elasticsearch/reference/5.5/restart-upgrade.html
如果您没有所有索引的副本,那么执行此类活动将导致某些索引停机。在这种情况下,一种更简洁的方法是在关闭节点之前将所有分片迁移到其他节点:
PUT _cluster/settings
{
"transient" : {
"cluster.routing.allocation.exclude._ip" : "10.0.0.1"
}
}
Run Code Online (Sandbox Code Playgroud)
这会将所有分片从10.0.0.1其他节点移动到其他节点(需要时间,具体取决于数据)。一切都完成后,您可以终止节点,执行维护并使其重新联机。这是一个较慢的操作,如果您有副本则不需要。
(用通配符代替 _ip、_id、_name 就可以了。)
更多信息:https : //www.elastic.co/guide/en/elasticsearch/reference/5.5/allocation-filtering.html
其他答案已经解释了如何终止进程。
对于使用Homebrew (Brew) 安装和管理服务的Mac 用户:
列出您的 Brew 服务:
brew services
Run Code Online (Sandbox Code Playgroud)
用服务做一些事情:
brew services start elasticsearch-full
brew services restart elasticsearch-full
brew services stop elasticsearch-full
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
92302 次 |
| 最近记录: |