最新版es搭集群的方法簡(jiǎn)直簡(jiǎn)單到爆
Linux and macOS:
cd elasticsearch-7.6.0/bin
./elasticsearch
./elasticsearch -Epath.data=data2 -Epath.logs=log2
./elasticsearch -Epath.data=data3 -Epath.logs=log3
ES啟動(dòng)時(shí)默認(rèn)讀取改配置文件:config/elasticsearch.yml,同時(shí)也可以使用-E覆蓋
./bin/elasticsearch -d -Ecluster.name=my_cluster -Enode.name=node_1
Windows:
cd elasticsearch-7.6.0/bin
.\elasticsearch.bat
.\elasticsearch.bat -E path.data=data2 -E path.logs=log2
.\elasticsearch.bat -E path.data=data3 -E path.logs=log3
作為守護(hù)進(jìn)程(后臺(tái))啟動(dòng)
-d指定為守護(hù)進(jìn)程,-p pid 將進(jìn)程號(hào)寫入 logs目錄下pid文件中
./bin/elasticsearch -d -p pid
關(guān)閉
pkill -F pid
埋坑時(shí)間(Linux):
0. 開啟遠(yuǎn)程訪問
vi conf/elasticsearch.yml
network.host: 0.0.0.0
0. 開啟跨域
vi conf/elasticsearch.yml
http.cors.enabled: true
http.cors.allow-origin: "*"
0. jvm調(diào)優(yōu)
Java HotSpot(TM) 64-Bit Server VM warning: INFO: os::commit_memory(0x0000000085330000, 2060255232, 0) failed; error='Cannot allocate memory' (errno=12)
這個(gè)步驟應(yīng)該是jvm調(diào)優(yōu)時(shí)就做的,設(shè)置為內(nèi)存的一半
vi config/jvm.options
-Xms512m
-Xmx512m
1.
java.lang.UnsupportedOperationException: seccomp unavailable: CONFIG_SECCOMP not compiled into kernel, CONFIG_SECCOMP and CONFIG_SECCOMP_FILTER are needed
省略
java.nio.file.NoSuchFileException: /proc/sys/vm/max_map_count
錯(cuò)誤描述:
ElasticSearch集群?jiǎn)?dòng)錯(cuò)誤,錯(cuò)誤的原因是:因?yàn)镃entos6不支持SecComp,而ES默認(rèn)bootstrap.system_call_filter為true進(jìn)行檢測(cè),所以導(dǎo)致檢測(cè)失敗,失敗后直接導(dǎo)致ES不能啟動(dòng)解決:修改elasticsearch.yml
問題解決:
在所有節(jié)點(diǎn)的elasticsearch.yml配置文件中加入:
bootstrap.memory_lock: false
bootstrap.system_call_filter: false
max_map_count
這個(gè)文件沒找到是因?yàn)槲以趙in10子系統(tǒng)的linux上,估計(jì)是權(quán)限不夠。
2. es不允許使用root賬號(hào)啟動(dòng)
org.elasticsearch.bootstrap.StartupException: java.lang.RuntimeException: can not run elasticsearch as root
3. bootstrap checks failed
ERROR: [4] bootstrap checks failed
[1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65535]
[2]: max number of threads [3795] for user [elasticsearch] is too low, increase to at least [4096]
[3]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
[4]: the default discovery settings are unsuitable for production use; at least one of [discovery.seed_hosts, discovery.seed_providers, cluster.initial_master_nodes] must be configured
問題解決:
[1][2]解決
使用root用戶:在/etc/security/limits.conf文件中添加如下配置
# 設(shè)置
* soft nofile 65535
* hard nofile 65535
* soft nproc 4096
* hard nproc 4096
[3]解決:
修改/etc/sysctl.conf文件,增加配置
vm.max_map_count=262144
執(zhí)行命令sysctl -p生效
sysctl -p
[4]解決:
編輯conf/elasticsearch.yml,按如下修改:
#cluster.initial_master_nodes: ["node-1", "node-2"]
cluster.initial_master_nodes: ["node-1"]
4. 訪問503
{XHR Error: "error", message: "Service Unavailable"}
這個(gè)錯(cuò)誤可能原因很多,我的問題是可復(fù)現(xiàn)的,有些甚至無法復(fù)現(xiàn),比如內(nèi)存之類的。
錯(cuò)誤原因,由問題3. bootstrap checks failed中的第4個(gè)小問題導(dǎo)致的。那里的node.name是減號(hào),我自己定義的是下劃線。。。
參考資料
ElasticSearch啟動(dòng)報(bào)錯(cuò),bootstrap checks failed
# 記錄下安裝ES過程中遇到的錯(cuò)誤及解決