Elasticsearch 配置文件詳解

此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

#spring集成Elasticsearch需增加配置

transport.tcp.port: 9300
transport.tcp.compress: true
http.cors.enabled: true 
http.cors.allow-origin: "*"
node.master: true
node.data: true

總結

  1、es已經爲大多數參數設置合理的默認值

  2、這個配置文件中列出來了針對生產環境下的一些重要配置

  3、注意:這個文件是yaml格式的文件

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

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

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

        network.host: 192.168.80.200

  4、es的1.*版本比2.*版本,這個配置文件多了很多屬性,爲什麼2.*版本沒了呢,因爲,es很多地方做了默認配置。

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