Elastic Search 7.x 叢集配置

superjack2發表於2020-05-16

1、解壓Elasticsearch 7.x.tar包(/opt/elasticsearch-7.2.1/下的data目錄,當啟動es會自動生成data)

2、配置elasticsearch.yml。

3、/opt/elasticsearch-7.2.1/bin下啟動。(啟動命令./elasticsearch , 若是後臺啟動./elasticsearch -d)

配置elasticsearch.yml

a節點(192.168.137.200)


#叢集名稱

cluster.name : elasticsearch
#節點名稱
node.name : node-a
#是不是有資格競選主節點
node.master : true
#是否儲存資料
node.data : true
#最大叢集節點數
node.max_local_storage_nodes : 3
#閘道器地址
network.host : 192.168.137.200
#埠
http.port : 9200
#內部節點之間溝通埠
transport.tcp.port : 9300
#es7.x 之後新增的配置,寫入候選主節點的裝置地址,在開啟服務後可以被選為主節點
discovery.seed_hosts : [ "192.168.137.200:9300" , "192.168.137.201:9300" , "192.168.137.202:9300" ]
#es7.x 之後新增的配置,初始化一個新的叢集時需要此配置來選舉master
cluster.initial_master_nodes : [ "192.168.137.200" , "192.168.137.201" , "192.168.137.202" ]
# ping超時時長,預設3S,適當修改,防止腦裂
discovery.zen.ping_timeout: 120s
client.transport.ping_timeout: 60s

#資料儲存路徑(這裡不配,預設就好)
##path.data: /home/es/software/es/data
#日誌儲存路徑
#path.logs: /home/es/software/es/logs
bootstrap.system_call_filter: false
http.cors.enabled: true
http.cors.allow-origin: "*"
http.cors.allow-methods: OPTIONS, HEAD, GET, POST, PUT, DELETE
http.cors.allow-headers: "X-Requested-With, Content-Type, Content-Length, X-User"

b節點(192.168.137.201)

#叢集名稱
cluster.name: elasticsearch
#節點名稱
node.name: node-b
#是不是有資格競選主節點
node.master: true
#是否儲存資料
node.data: true
#最大叢集節點數
node.max_local_storage_nodes: 3
#閘道器地址
network.host: 192.168.137.201
#埠
http.port: 9200
#內部節點之間溝通埠
transport.tcp.port: 9300
#es7.x 之後新增的配置,寫入候選主節點的裝置地址,在開啟服務後可以被選為主節點
discovery.seed_hosts: ["192.168.137.200:9300","192.168.137.201:9300","192.168.137.202:9300"]
#es7.x 之後新增的配置,初始化一個新的叢集時需要此配置來選舉master
cluster.initial_master_nodes: ["192.168.137.200", "192.168.137.201","192.168.137.202"]
# ping超時時長,預設3S,適當修改,防止腦裂
discovery.zen.ping_timeout: 120s
client.transport.ping_timeout: 60s
#資料儲存路徑(這裡不配,預設就好)
##path.data: /home/es/software/es/data
#日誌儲存路徑
#path.logs: /home/es/software/es/logs
bootstrap.system_call_filter: false
http.cors.enabled: true
http.cors.allow-origin: "*"
http.cors.allow-methods: OPTIONS, HEAD, GET, POST, PUT, DELETE
http.cors.allow-headers: "X-Requested-With, Content-Type, Content-Length, X-User"

c節點(192.168.137.202)

#叢集名稱
cluster.name: elasticsearch
#節點名稱
node.name: node-c
#是不是有資格競選主節點
node.master: true
#是否儲存資料
node.data: true
#最大叢集節點數
node.max_local_storage_nodes: 3
#閘道器地址
network.host: 192.168.137.202
#埠
http.port: 9200
#內部節點之間溝通埠
transport.tcp.port: 9300
#es7.x 之後新增的配置,寫入候選主節點的裝置地址,在開啟服務後可以被選為主節點
discovery.seed_hosts: ["192.168.137.200:9300","192.168.137.201:9300","192.168.137.202:9300"]
#es7.x 之後新增的配置,初始化一個新的叢集時需要此配置來選舉master
cluster.initial_master_nodes: ["192.168.137.200", "192.168.137.201","192.168.137.202"]
# ping超時時長,預設3S,適當修改,防止腦裂
discovery.zen.ping_timeout: 120s
client.transport.ping_timeout: 60s
#資料儲存路徑(這裡不配,預設就好)
##path.data: /home/es/software/es/data
#日誌儲存路徑
#path.logs: /home/es/software/es/logs
bootstrap.system_call_filter: false
http.cors.enabled: true
http.cors.allow-origin: "*"
http.cors.allow-methods: OPTIONS, HEAD, GET, POST, PUT, DELETE
http.cors.allow-headers: "X-Requested-With, Content-Type, Content-Length, X-User"

Elasticsearch啟動失敗,檢查沒有透過,報錯

   ERROR: [2] bootstrap checks failed [ 1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]

[2]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]

[1]: max file descriptors [65535] for elasticsearch process is too low, increase to at least [65536]

編輯 /etc/security/limits.conf,追加以下內容;

  • soft nofile 65536

  • hard nofile 65536

[2]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]

編輯 /etc/sysctl.conf,追加以下內容: vm.max_map_count=655360 儲存後,執行: sysctl -p

錯誤提示:ERROR: [1] bootstrap checks failed [ 1]: max number of threads [1024] for user [elasticsearch] is too low, increase to at least [2048] vi /etc/security/limits.d/90-nproc.conf,把1024改為4096

  • * soft nproc 4096

以上三個檔案修改後需要重新登入使用者,才會生效;最後重啟ES。


來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/31537832/viewspace-2692556/,如需轉載,請註明出處,否則將追究法律責任。

相關文章