天天看點

elasticsearch-.yml(中文配置詳解)

此elasticsearch-.yml配置檔案,是在$ES_HOME/config/下

elasticsearch-.yml(中文配置詳解)
elasticsearch-.yml(中文配置詳解)

elasticsearch-.yml(中文配置詳解)

# ======================== Elasticsearch Configuration =========================

#

# NOTE: Elasticsearch comes with reasonable defaults for most settings.

# Before you set out to tweak and tune the configuration, make sure you

# understand what are you trying to accomplish and the consequences.

# The primary way of configuring a node is via this file. This template lists

# the most important settings you may want to configure for a production cluster.

# Please see the documentation for further information on configuration options:

# <http://www.elastic.co/guide/en/elasticsearch/reference/current/setup-configuration.html>

# ---------------------------------- Cluster -----------------------------------

# Use a descriptive name for your cluster:

# 叢集名稱,預設是elasticsearch

# cluster.name: my-application

# ------------------------------------ Node ------------------------------------

# Use a descriptive name for the node:

# 節點名稱,預設從elasticsearch-2.4.3/lib/elasticsearch-2.4.3.jar!config/names.txt中随機選擇一個名稱

# node.name: node-1

# Add custom attributes to the node:

# node.rack: r1

# ----------------------------------- Paths ------------------------------------

# Path to directory where to store the data (separate multiple locations by comma):

# 可以指定es的資料存儲目錄,預設存儲在es_home/data目錄下

# path.data: /path/to/data

# Path to log files:

# 可以指定es的日志存儲目錄,預設存儲在es_home/logs目錄下

# path.logs: /path/to/logs

# ----------------------------------- Memory -----------------------------------

# Lock the memory on startup:

# 鎖定實體記憶體位址,防止elasticsearch記憶體被交換出去,也就是避免es使用swap交換分區

# bootstrap.memory_lock: true

# 確定ES_HEAP_SIZE參數設定為系統可用記憶體的一半左右

# Make sure that the `ES_HEAP_SIZE` environment variable is set to about half the memory

# available on the system and that the owner of the process is allowed to use this limit.

# 當系統進行記憶體交換的時候,es的性能很差

# Elasticsearch performs poorly when the system is swapping the memory.

# ---------------------------------- Network -----------------------------------

# 為es設定ip綁定,預設是127.0.0.1,也就是預設隻能通過127.0.0.1 或者localhost才能通路

# es1.x版本預設綁定的是0.0.0.0 是以不需要配置,但是es2.x版本預設綁定的是127.0.0.1,需要配置

# Set the bind address to a specific IP (IPv4 or IPv6):

# network.host: 192.168.0.1

# 為es設定自定義端口,預設是9200

# 注意:在同一個伺服器中啟動多個es節點的話,預設監聽的端口号會自動加1:例如:9200,9201,9202...

# Set a custom port for HTTP:

# http.port: 9200

# For more information, see the documentation at:

# <http://www.elastic.co/guide/en/elasticsearch/reference/current/modules-network.html>

# --------------------------------- Discovery ----------------------------------

# 當啟動新節點時,通過這個ip清單進行節點發現,組建叢集

# 預設節點清單:

# 127.0.0.1,表示ipv4的回環位址。

# [::1],表示ipv6的回環位址

# 在es1.x中預設使用的是多點傳播(multicast)協定,預設會自動發現同一網段的es節點組建叢集,

# 在es2.x中預設使用的是單點傳播(unicast)協定,想要組建叢集的話就需要在這指定要發現的節點資訊了。

# 注意:如果是發現其他伺服器中的es服務,可以不指定端口[預設9300],如果是發現同一個伺服器中的es服務,就需要指定端口了。

# Pass an initial list of hosts to perform discovery when new node is started:

# The default list of hosts is ["127.0.0.1", "[::1]"]

# discovery.zen.ping.unicast.hosts: ["host1", "host2"]

# 通過配置這個參數來防止叢集腦裂現象 (叢集總節點數量/2)+1

# Prevent the "split brain" by configuring the majority of nodes (total number of nodes / 2 + 1):

# discovery.zen.minimum_master_nodes: 3

# <http://www.elastic.co/guide/en/elasticsearch/reference/current/modules-discovery.html>

# ---------------------------------- Gateway -----------------------------------

# Block initial recovery after a full cluster restart until N nodes are started:

# 一個叢集中的N個節點啟動後,才允許進行資料恢複處理,預設是1

# gateway.recover_after_nodes: 3

# <http://www.elastic.co/guide/en/elasticsearch/reference/current/modules-gateway.html>

# ---------------------------------- Various -----------------------------------

# 在一台伺服器上禁止啟動多個es服務

# Disable starting multiple nodes on a single system:

# node.max_local_storage_nodes: 1

# 設定是否可以通過正則或者_all删除或者關閉索引庫,預設true表示必須需要顯式指定索引庫名稱

# 生産環境建議設定為true,删除索引庫的時候必須顯式指定,否則可能會誤删索引庫中的索引庫。

# Require explicit names when deleting indices:

# action.destructive_requires_name: true

 叢集名稱,預設是elasticsearch

  輸入,http://192.168.80.200:9200/

elasticsearch-.yml(中文配置詳解)

 預設存儲在es_home/data目錄下

elasticsearch-.yml(中文配置詳解)

total 60

drwxrwxr-x. 2 hadoop hadoop 4096 Feb 20 22:54 bin

drwxrwxr-x. 3 hadoop hadoop 4096 Feb 21 01:28 config

drwxrwxr-x. 3 hadoop hadoop 4096 Feb 20 22:59 data

drwxrwxr-x. 2 hadoop hadoop 4096 Feb 20 22:54 lib

-rw-rw-r--. 1 hadoop hadoop 11358 Aug 24 00:46 LICENSE.txt

drwxrwxr-x. 2 hadoop hadoop 4096 Feb 21 00:33 logs

drwxrwxr-x. 5 hadoop hadoop 4096 Dec 8 00:41 modules

-rw-rw-r--. 1 hadoop hadoop 150 Aug 24 00:46 NOTICE.txt

drwxrwxr-x. 4 hadoop hadoop 4096 Feb 21 23:13 plugins

-rw-rw-r--. 1 hadoop hadoop 8700 Aug 24 00:46 README.textile

-rw-rw-r--. 1 hadoop hadoop 288 Feb 21 07:07 request

[hadoop@djt002 elasticsearch-2.4.3]$ cd data/

[hadoop@djt002 data]$ pwd

/usr/local/elasticsearch/elasticsearch-2.4.3/data

[hadoop@djt002 data]$ ll

total 4

drwxrwxr-x. 3 hadoop hadoop 4096 Feb 20 23:00 elasticsearch

[hadoop@djt002 data]$ cd elasticsearch/

[hadoop@djt002 elasticsearch]$ ll

drwxrwxr-x. 3 hadoop hadoop 4096 Feb 20 23:00 nodes

[hadoop@djt002 elasticsearch]$ cd nodes/

[hadoop@djt002 nodes]$ ll

drwxrwxr-x. 4 hadoop hadoop 4096 Feb 21 22:51 0

[hadoop@djt002 nodes]$ cd 0

[hadoop@djt002 0]$ ll

total 8

drwxrwxr-x. 3 hadoop hadoop 4096 Feb 21 01:33 indices

-rw-rw-r--. 1 hadoop hadoop 0 Feb 20 23:00 node.lock

drwxrwxr-x. 2 hadoop hadoop 4096 Feb 21 22:51 _state

[hadoop@djt002 0]$

索引片段,裡面存放着具體的資料

  如,segments_6,是在/usr/local/elasticsearch/elasticsearch-2.4.3/data/elasticsearch/nodes/0/indices/zhouls/0/index

elasticsearch-.yml(中文配置詳解)

[hadoop@djt002 0]$ cd indices/

[hadoop@djt002 indices]$ ll

drwxrwxr-x. 8 hadoop hadoop 4096 Feb 21 00:33 zhouls

[hadoop@djt002 indices]$ cd zhouls/

[hadoop@djt002 zhouls]$ ll

total 24

drwxrwxr-x. 5 hadoop hadoop 4096 Feb 21 00:33 0

drwxrwxr-x. 5 hadoop hadoop 4096 Feb 21 00:33 1

drwxrwxr-x. 5 hadoop hadoop 4096 Feb 21 00:33 2

drwxrwxr-x. 5 hadoop hadoop 4096 Feb 21 00:33 3

drwxrwxr-x. 5 hadoop hadoop 4096 Feb 21 00:33 4

[hadoop@djt002 zhouls]$ cd 0

total 12

drwxrwxr-x. 2 hadoop hadoop 4096 Feb 21 22:57 index

drwxrwxr-x. 2 hadoop hadoop 4096 Feb 21 22:51 translog

[hadoop@djt002 0]$ cd index/

[hadoop@djt002 index]$ pwd

/usr/local/elasticsearch/elasticsearch-2.4.3/data/elasticsearch/nodes/0/indices/zhouls/0/index

[hadoop@djt002 index]$ ll

total 16

-rw-rw-r--. 1 hadoop hadoop 363 Feb 21 03:35 _0.cfe

-rw-rw-r--. 1 hadoop hadoop 2488 Feb 21 03:35 _0.cfs

-rw-rw-r--. 1 hadoop hadoop 371 Feb 21 03:35 _0.si

-rw-rw-r--. 1 hadoop hadoop 224 Feb 21 22:57 segments_6

-rw-rw-r--. 1 hadoop hadoop 0 Feb 21 00:33 write.lock

[hadoop@djt002 index]$

總結

  1、es已經為大多數參數設定合理的預設值

  2、這個配置檔案中列出來了針對生産環境下的一些重要配置

  3、注意:這個檔案是yaml格式的檔案

    (1):屬性頂格寫,不能有空格

    (2):縮進一定不能使用tab制表符

    (3):屬性和值之間的:後面需要有空格

        network.host: 192.168.80.200

  4、es的1.*版本比2.*版本,這個配置檔案多了很多屬性,為什麼2.*版本沒了呢,因為,es很多地方做了預設配置。

本文轉自大資料躺過的坑部落格園部落格,原文連結:http://www.cnblogs.com/zlslch/p/6419948.html,如需轉載請自行聯系原作者

繼續閱讀