此elasticsearch-.yml配置文件,是在$ES_HOME/config/下
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
#
# For more information, see the documentation at:
# <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
#
# For more information, see the documentation at:
# <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/
默認存儲在es_home/data目錄下
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
total 4
drwxrwxr-x. 3 hadoop hadoop 4096 Feb 20 23:00 nodes
[hadoop@djt002 elasticsearch]$ cd nodes/
[hadoop@djt002 nodes]$ ll
total 4
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
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]$ cd indices/
[hadoop@djt002 indices]$ ll
total 4
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
drwxrwxr-x. 2 hadoop hadoop 4096 Feb 21 22:51 _state
[hadoop@djt002 zhouls]$ cd 0
[hadoop@djt002 0]$ ll
total 12
drwxrwxr-x. 2 hadoop hadoop 4096 Feb 21 22:57 index
drwxrwxr-x. 2 hadoop hadoop 4096 Feb 21 22:51 _state
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很多地方做了默認配置。
更詳細,請移步