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

不翻了,還是直接看英文文檔比較直接。

七、參考

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