ES配置文件參考與參數詳解


cluster.name: data-cluster  
node.name: "data-es-05"  
#node.data: false  
   
# Indexing & Cache config  
index.number_of_shards: 5  
index.number_of_replicas: 1  
index.cache.field.type: soft  
index.cache.field.expire: 10m  
index.cache.query.enable: true  
indices.cache.query.size: 2%  
indices.fielddata.cache.size: 35%  
indices.fielddata.cache.expire: 10m  
index.search.slowlog.level: INFO  
#indices.recovery.max_size_per_sec: 1gb  
index.merge.scheduler.max_thread_count: 2    # Only for spinning media.   
   
# Refresh config  
index.refresh_interval: 300s  
   
# Translog config  
index.translog.flush_threshold_ops:  100000  
   
# Paths config  
path.data: /data/esData  
path.plugins: /usr/share/elasticsearch/plugins  
   
# Network And HTTP  
network.bind_host: 10.0.126.203  
network.publish_host: 10.0.126.203  
transport.tcp.port: 9300  
transport.tcp.compress: true  
http.port: 9200  
   
# Discovery  
discovery.zen.minimum_master_nodes: 1  
discovery.zen.ping.timeout: 10s  
discovery.zen.ping.multicast.enabled: false  
discovery.zen.ping.unicast.hosts: ["10.0.32.3:9300", "10.0.4.37:9300", "10.0.40.159:9300", "10.0.107.116:9300" , "10.0.126.203:9300"] 

    配置文件位於%ES_HOME%/config/elasticsearch.yml文件中,用Editplus打開它,你便可以進行配置。
        所有的配置都可以使用環境變量,例如:
   node.rack: ${RACK_ENV_VAR}   表示環境變量中有一個RACK_ENV_VAR變量。
        下面列舉一下elasticsearch的可配置項:
        1. 集群名稱,默認為elasticsearch:
    cluster.name: elasticsearch
        2. 節點名稱,es啟動時會自動創建節點名稱,但你也可進行配置:
    node.name: "Franz Kafka"
        3. 是否作為主節點,每個節點都可以被配置成為主節點,默認值為true:
    node.master: true
        4. 是否存儲數據,即存儲索引片段,默認值為true:
    node.data: true
         master和data同時配置會產生一些奇異的效果:
        1) 當master為false,而data為true時,會對該節點產生嚴重負荷;
        2) 當master為true,而data為false時,該節點作為一個協調者;
        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]"]

       35.設置是否可以通過正則或者_all刪除或者關閉索引

    action.destructive_requires_name 默認false 允許 可設置true不允許 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM