Elasticsearch分佈式搜索集羣配置

  配置文件位於%ES_HOME%/config/elasticsearch.yml文件中,用Editplus打開它,你即可以進行配置。html

    全部的配置均可以使用環境變量,例如:node.rack: ${RACK_ENV_VAR}  表示環境變量中有一個RACK_ENV_VAR變量。node

        下面列舉一下elasticsearch的可配置項:git

        1. 集羣名稱,默認爲elasticsearch:cluster.name: elasticsearchgithub

        2. 節點名稱,es啓動時會自動建立節點名稱,但你也可進行配置:node.name: "Franz Kafka"bootstrap

        3. 是否做爲主節點,每一個節點均可以被配置成爲主節點,默認值爲true:node.master: true網絡

        4. 是否存儲數據,即存儲索引片斷,默認值爲true:node.data: true併發

        master和data同時配置會產生一些奇異的效果:app

        1) 當master爲false,而data爲true時,會對該節點產生嚴重負荷;負載均衡

        2) 當master爲true,而data爲false時,該節點做爲一個協調者;elasticsearch

        3) 當master爲false,data也爲false時,該節點就變成了一個負載均衡器。

        你能夠經過鏈接http://localhost:9200/_cluster/health或者http://localhost:9200/_cluster/nodes

        或者使用插件http://github.com/lukas-vlcek/bigdesk或http://mobz.github.com/elasticsearch-head來查看集羣狀態。

        5. 每一個節點均可以定義一些與之關聯的通用屬性,用於後期集羣進行碎片分配時的過濾:node.rack: rack314

        6. 默認狀況下,多個節點能夠在同一個安裝路徑啓動,若是你想讓你的es只啓動一個節點,能夠進行以下設置:node.max_local_storage_nodes: 1

        7. 設置一個索引的碎片數量,默認值爲5:index.number_of_shards: 5

        8. 設置一個索引可被複制的數量,默認值爲1:index.number_of_replicas: 1

        當你想要禁用公佈式時,你能夠進行以下設置:

        index.number_of_shards: 1

        index.number_of_replicas: 0

        這兩個屬性的設置直接影響集羣中索引和搜索操做的執行。假設你有足夠的機器來持有碎片和複製品,那麼能夠按以下規則設置這兩個值:

        1) 擁有更多的碎片能夠提高索引執行能力,並容許經過機器分發一個大型的索引;

        2) 擁有更多的複製器可以提高搜索執行能力以及集羣能力。

        對於一個索引來講,number_of_shards只能設置一次,而number_of_replicas可使用索引更新設置API在任什麼時候候被增長或者減小。

        ElasticSearch關注加載均衡、遷移、從節點彙集結果等等。能夠嘗試多種設計來完成這些功能。

        能夠鏈接http://localhost:9200/A/_status來檢測索引的狀態。

        9. 配置文件所在的位置,即elasticsearch.yml和logging.yml所在的位置:path.conf: /path/to/conf

        10. 分配給當前節點的索引數據所在的位置:path.data: /path/to/data

        能夠可選擇的包含一個以上的位置,使得數據在文件級別跨越位置,這樣在建立時就有更多的自由路徑,如:path.data: /path/to/data1,/path/to/data2

        11. 臨時文件位置:path.work: /path/to/work

        12. 日誌文件所在位置:path.logs: /path/to/logs

        13. 插件安裝位置:path.plugins: /path/to/plugins

        14. 插件託管位置,若列表中的某一個插件未安裝,則節點沒法啓動:plugin.mandatory: mapper-attachments,lang-groovy

        15. JVM開始交換時,ElasticSearch表現並很差:你須要保障JVM不進行交換,能夠將bootstrap.mlockall設置爲true禁止交換:bootstrap.mlockall: true

        請確保ES_MIN_MEM和ES_MAX_MEM的值是同樣的,而且可以爲ElasticSearch分配足夠的內在,併爲系統操做保留足夠的內存。

        16. 默認狀況下,ElasticSearch使用0.0.0.0地址,併爲http傳輸開啓9200-9300端口,爲節點到節點的通訊開啓9300-9400端口,也能夠自行設置IP地址:network.bind_host: 192.168.0.1

        17. publish_host設置其餘節點鏈接此節點的地址,若是不設置的話,則自動獲取,publish_host的地址必須爲真實地址:network.publish_host: 192.168.0.1

        18. bind_host和publish_host能夠一塊兒設置:network.host: 192.168.0.1

        19. 能夠定製該節點與其餘節點交互的端口:transport.tcp.port: 9300

        20. 節點間交互時,能夠設置是否壓縮,轉爲爲不壓縮:transport.tcp.compress: true

        21. 能夠爲Http傳輸監聽定製端口:http.port: 9200

        22. 設置內容的最大長度:http.max_content_length: 100mb

        23. 禁止HTTP:http.enabled: false

        24. 網關容許在全部集羣重啓後持有集羣狀態,集羣狀態的變動都會被保存下來,當第一次啓用集羣時,能夠從網關中讀取到狀態,默認網關類型(也是推薦的)是local:gateway.type: local

        25. 容許在N個節點啓動後恢復過程:gateway.recover_after_nodes: 1

        26. 設置初始化恢復過程的超時時間:gateway.recover_after_time: 5m

        27. 設置該集羣中可存在的節點上限:gateway.expected_nodes: 2

        28. 設置一個節點的併發數量,有兩種狀況,一種是在初始復甦過程當中:cluster.routing.allocation.node_initial_primaries_recoveries: 4

        另外一種是在添加、刪除節點及調整時:cluster.routing.allocation.node_concurrent_recoveries: 2

        29. 設置復甦時的吞吐量,默認狀況下是無限的:indices.recovery.max_size_per_sec: 0

        30. 設置從對等節點恢復片斷時打開的流的數量上限:indices.recovery.concurrent_streams: 5

        31. 設置一個集羣中主節點的數量,當多於三個節點時,該值可在2-4之間:discovery.zen.minimum_master_nodes: 1

        32. 設置ping其餘節點時的超時時間,網絡比較慢時可將該值設大:discovery.zen.ping.timeout: 3s

        http://elasticsearch.org/guide/reference/modules/discovery/zen.html上有更多關於discovery的設置。

        33. 禁止當前節點發現多個集羣節點,默認值爲true:discovery.zen.ping.multicast.enabled: false

        34. 設置新節點被啓動時可以發現的主節點列表:discovery.zen.ping.unicast.hosts: ["host1", "host2:port", "host3[portX-portY]"]

 

轉載:http://www.cnblogs.com/hunttown/p/5450602.html

 

 

# ======================== 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:#cluster.name: MyElasticearch## ------------------------------------ Node 節點信息------------------------------------## Use a descriptive name for the node:#節點名字node.name: node-1#設置爲主節點node.master: true#是否存儲數據node.data: true#多個節點能夠在同一個安裝路徑啓動,若是你想讓你的es只啓動一個節點#node.max_local_storage_nodes: 1#設置一個索引的碎片數量,默認值爲5#index.number_of_shards: 5#設置一個索引可被複制的數量,默認值爲1:#index.number_of_replicas: 1## Add custom attributes to the node:## node.rack: r1## ----------------------------------- Paths ------------------------------------# 配置文件所在的位置,即elasticsearch.yml和logging.yml所在的位置:path.conf: /path/to/conf## Path to directory where to store the data (separate multiple locations by comma):## path.data: /path/to/data## Path to log files:## path.logs: /path/to/logs## ----------------------------------- Memory -----------------------------------## Lock the memory on startup:## bootstrap.mlockall: true## 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.## Elasticsearch performs poorly when the system is swapping the memory.## ---------------------------------- Network -----------------------------------## Set the bind address to a specific IP (IPv4 or IPv6):#network.host: 192.168.1.102## Set a custom port for HTTP:#Http傳輸監聽定製端口http.port: 9200##定製該節點與其餘節點交互的端口:transport.tcp.port: 9300#節點間交互時,能夠設置是否壓縮,轉爲爲不壓縮:#transport.tcp.compress: true#設置內容的最大長度:#http.max_content_length: 100mb#禁止HTTP:#http.enabled: false#網關容許在全部集羣重啓後持有集羣狀態,集羣狀態的變動都會被保存下來,當第一次啓用集羣時,能夠從網關中讀取到狀態,默認網關類型(也是推薦的)是local:#gateway.type: local# For more information, see the documentation at:# <http://www.elastic.co/guide/en/elasticsearch/reference/current/modules-network.html>## --------------------------------- Discovery ----------------------------------## 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: ["192.168.1.102", "192.168.1.103:9200"]# discovery.zen.ping.unicast.hosts: ["host1", "host2"]## Prevent the "split brain" by configuring the majority of nodes (total number of nodes / 2 + 1):#禁止當前節點發現多個集羣節點,默認值爲true:discovery.zen.ping.multicast.enabled: false#設置一個集羣中主節點的數量,當多於三個節點時,該值可在2-4之間:# discovery.zen.minimum_master_nodes: 1## 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個節點啓動後恢復過程:gateway.recover_after_nodes: 3#設置初始化恢復過程的超時時間:gateway.recover_after_time: 5m#設置該集羣中可存在的節點上限:gateway.expected_nodes: 2設置ping其餘節點時的超時時間,網絡比較慢時可將該值設大 discovery.zen.ping.timeout: 3s# For more information, see the documentation at:# <http://www.elastic.co/guide/en/elasticsearch/reference/current/modules-gateway.html>## ---------------------------------- Various -----------------------------------## Disable starting multiple nodes on a single system:## node.max_local_storage_nodes: 1## Require explicit names when deleting indices:## action.destructive_requires_name: true

相關文章
相關標籤/搜索