elasticsearch 叢集配置
1. 叢集節點ip設定:elasticsearch.yml
discovery.zen.ping.unicast.hosts: ["192.168.1.133", "192.168.1.134"] discovery.zen.minimum_master_nodes: 2 # 為了避免腦裂,叢集節點數最少為 半數+1
處理啟動報錯一:
[2017-01-12T15:55:55,433][INFO ][o.e.b.BootstrapCheck ] [SfD5sIh] bound or publishing to a non-loopback or non-link-local address, enforcing bootstrap checks ERROR: bootstrap checks failed max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
- 臨時提高了vm.max_map_count的大小,此操作需要root許可權:
sudo sysctl -w vm.max_map_count=262144
sysctl -a|grep vm.max_map_count
- 永久修改vm.max_map_count:
解決:切換到root使用者修改配置sysctl.conf
vi /etc/sysctl.conf
新增下面配置:
vm.max_map_count=655360
並執行命令:
sysctl -p
然後,重新啟動elasticsearch,即可啟動成功。
處理啟動報錯二:
max file descriptors [4096] for elasticsearch process likely too low, increase to at least [65536]
修改/etc/security/limits.conf檔案,新增或修改如下行:
* hard nofile 65536
* soft nofile 65536
處理啟動報錯三:
max number of threads [1024] for user [lish] likely too low, increase to at least [2048]
解決:切換到root使用者,進入limits.d目錄下修改配置檔案。
vi /etc/security/limits.d/90-nproc.conf
修改如下內容:
* soft nproc 1024
#修改為
* soft nproc 2048
補:啟動異常:ERROR: bootstrap checks failed system call filters failed to install; check the logs and fix your configuration or disable system call filters at your own risk
問題原因:因為Centos6不支援SecComp,而ES5.2.1預設bootstrap.system_call_filter為true進行檢測,所以導致檢測失敗,失敗後直接導致ES不能啟動。詳見 :https://github.com/elastic/elasticsearch/issues/22899
解決方法:在elasticsearch.yml中配置bootstrap.system_call_filter為false,注意要在Memory下面: bootstrap.memory_lock: false
bootstrap.system_call_filter: false
近日,單臺機器,8個節點的es叢集,8個節點都正常started了,但是就是無法形成叢集,後來看日誌,日誌中出現一堆的MasterNotDiscoveredException這種異常,完整日誌如下:
[2016-04-27 15:08:22,445][DEBUG][action.admin.cluster.health] [es.10.16.66.152.0] no known master node, scheduling a retry [2016-04-27 15:08:52,457][INFO ][rest.suppressed ] /_cat/health Params: {h=node.total} MasterNotDiscoveredException[waited for [30s]] at org.elasticsearch.action.support.master.TransportMasterNodeAction$4.onTimeout(TransportMasterNodeAction.java:160) at org.elasticsearch.cluster.ClusterStateObserver$ObserverClusterStateListener.onTimeout(ClusterStateObserver.java:239) at org.elasticsearch.cluster.service.InternalClusterService$NotifyTimeout.run(InternalClusterService.java:630) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745)
查看了每一個節點的elasticsearch.yml這個檔案之後,發現其中只有一個節點的node.master這個配置為true,而其中discovery.zen.minimum_master_nodes這個配置的值卻是5,而有資格成為主節點的只有一個,所以永遠也形成不了叢集啊。
結果就是要麼把其他節點的node.master都設定為true,要麼discovery.zen.minimum_master_nodes將這個配置改為1。