Elastic Search 7.x 集群配置

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。


请使用浏览器的分享功能分享到微信等