Elasticsearch 的安装

零、前言

这文章算是官方文档的翻译。

先敬上官方文档:

  1. installing-elastic-stack》 elastic 技术栈安装
  2. install-elasticsearch》 Elasticsearch(5.0) 安装
  3. Install Elasticsearch on Windows》 Windows 下 Elasticsearch(5.0) 安装

一、安装

第二个文档中,有很多方式,虽然支持 rpm 方式安装,但我还是比较喜欢“不安装,解压即用”:《Install Elasticsearch with .zip or .tar.gz》。

# wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.0.1.tar.gz
# sha1sum elasticsearch-5.0.1.tar.gz
# tar -xzf elasticsearch-5.0.1.tar.gz
# cd elasticsearch-5.0.1/

说明:

  • 第二行:Compare the SHA produced by sha1sum or shasum with the published SHA。即:检验文件的 SHA。
  • 第四行:This directory is known as $ES_HOME。即:该目录就是 $ES_HOME (ES 的 home 目录)

二、运行:Running Elasticsearch from the command line

# ./bin/elasticsearch

默认地,Elasticsearch 运行在前台并打印日志到标准输出(stdout),可以使用Ctrl-C停止其运行。

三、检查是否启动:Checking that Elasticsearch is running

发送一个 HTTP 请求道 localhost 的 9200 端口上:

# GET /

将会返回例如:

{
  "name" : "Cp8oag6",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : "AT69_T_DTp-1qgIJlatQqA",
  "version" : {
    "number" : "5.0.1",
    "build_hash" : "f27399d",
    "build_date" : "2016-03-30T09:51:41.449Z",
    "build_snapshot" : false,
    "lucene_version" : "6.2.1"
  },
  "tagline" : "You Know, for Search"
}

可以使用命令行选项 -q–quiet 禁用打印到stdout的日志。

四、运行为守护进程:Running as a daemon

To run Elasticsearch as a daemon, specify -d on the command line, and record the process ID in a file using the -p option:

# ./bin/elasticsearch -d -p pid

Log messages can be found in the $ES_HOME/logs/ directory.

To shut down Elasticsearch, kill the process ID recorded in the pid file:

# kill `cat pid`

五、使用命令行配置:Configuring Elasticsearch on the command line

Elasticsearch 默认从 $ES_HOME/config/elasticsearch.yml 中加载配置,配置文件详解:《Configuring Elasticsearch
任何可在 配置文件中指定的设置,也都可以在命令行中指定。使用 -E语法如下:

# ./bin/elasticsearch -d -Ecluster.name=my_cluster -Enode.name=node_1

六、.zip 和 .tar.gz 文件的目录:Directory layout of .zip and .tar.gz

不翻了,还是直接看英文文档比较直接。

七、参考

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章