Elasticsearch 启动 关闭

Posted by

1. 检测Elasticsearch是否启动使用下面的命令

ps -ef | grep elastic
Easticsearch 启动信息

如看到上面结果代表 elasticsearch 已经启动。

在上图我们可以看到,elasticsearch 由 “es” 用户执行,进程id是 26331

2. 关闭Elasticsearch

由于Elasticsearch 比较耗内存。有时候我们需要关闭Elasticsearch 操作命令如下:

kill 26331

我们再来检测下Elasticsearch 是否开启

curl localhost:9200/
curl localhost:9200/
curl: (7) Failed to connect to localhost port 9200: Connection refused

代表我们关闭Elasticsearch 成功。

3. 启动Elasticsearch

由于Elasticsearch 不能由root用户来操作,因此需要建立普通用户来执行,找到elasticseach的安装目录,然后进到bin目录。比如我的普通用户是:es

cd /usr/local/tool/elasticsearch/elasticsearch-7.13.3/bin/
su es
./elasticsearch -d

检测是否启动成功

输入下面命令:

curl localhost:9200/

若出现下面结果,代表启动成功

curl localhost:9200/
{
  "name" : "ip-172-31-25-129.eu-central-1.compute.internal",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : "OU1HndvoQ2O_bUF0XXLIXg",
  "version" : {
    "number" : "7.13.3",
    "build_flavor" : "default",
    "build_type" : "tar",
    "build_hash" : "5d21bea28db1e89ecc1f66311ebdec9dc3aa7d64",
    "build_date" : "2021-07-02T12:06:10.804015202Z",
    "build_snapshot" : false,
    "lucene_version" : "8.8.2",
    "minimum_wire_compatibility_version" : "6.8.0",
    "minimum_index_compatibility_version" : "6.0.0-beta1"
  },
  "tagline" : "You Know, for Search"
}
elasticsearch