Elasticsearch集群搭建配置

Elasticsearch集群搭建配置

官网:生产环境必配

path.data :存储主要文件的位置
path.logs  :log文件的位置
cluster.name :集群名字
node.name :当前节点的名字
bootstrap.memory_lock :  设置为true
network.host : 默认是回环地址(127.0.0.1),实际生产环境是多台主机,为了能正常接入到集群,要设置成公网ip
discovery.zen.ping.unicast.hosts : 集群节点配置
discovery.zen.minimum_master_nodes : 选出主节点最少需要多少票,计算公式为:(master_eligible_nodes / 2) + 1

JVM heap dump path:这是堆异常设置,默认会dump到/var/lib/elasticsearch文件下,可以自己在jvm.options 配置文件中配置XX:HeapDumpPath=/x/x/x 这个属性

这里集群搭建我只用了两台服务器,两台学生机,一个阿里云,一个华为云,阿里服务器作为master,华为服务器作为slave,集群配置最主要的就是配置elasticsearch.yml文件,下面的配置没有设置bootstrap.memory_lock,如果要改成true,自行百度

master的elasticsearch.yml配置

http.cors.enabled: true
http.cors.allow-origin: "*"
http.port: 9200
# cluster set
node.name: master
cluster.name: test
network.host: 0.0.0.0
network.publish_host: 47.1xx.2xx.2x
bootstrap.system_call_filter: false
node.master: true
node.data: true
path.data: /data/elasticsearch/data
path.logs: /data/elasticsearch/logs
transport.tcp.port: 9300
transport.tcp.compress: true
bootstrap.memory_lock: false
discovery.zen.ping.unicast.hosts: ["114.1xx.2xx.1xx:9300","47.1xx.2xx.2x:9300"]
discovery.zen.ping_timeout: 3s
discovery.zen.minimum_master_nodes: 2

slave的elasticsearch.yml配置

http.cors.enabled: true
http.cors.allow-origin: "*"
http.port: 9200
node.name: slave
cluster.name: test
node.master: true
node.data: true
path.data: /data/elasticsearch/data
path.logs: /data/elasticsearch/logs
bootstrap.memory_lock: false
bootstrap.system_call_filter: false
network.host: 0.0.0.0
network.publish_host: 114.1xx.2xx.1xx
transport.tcp.port: 9300
transport.tcp.compress: true
discovery.zen.ping.unicast.hosts: ["47.1xx.2xx.2x:9300","114.1xx.2xx.1xx:9300"]
discovery.zen.ping_timeout: 3s
discovery.zen.minimum_master_nodes: 2

  1. 启动的时候提示: OpenJDK 64-Bit Server VM warning: If the number of processors is expected to increase from one, then you should configure the number of parallel GC threads appropriately using -XX:ParallelGCThreads=N

    解决:这是由于elasticsearch使用的CMS垃圾收集器,并发清除的时候需要指定垃圾收集线程的数量,可以在jvm.option文件中添加一行-XX:ParallelGCThreads=2

  2. 启动报错: Exception BindTransportException[Failed to bind to [9300-9400]]

    解决:network.host设置不对,不能设置成公网ip地址,更改为0.0.0.0

  3. 启动成功,但是无法连接到master或者slave:failed to connect master

    解决:在network.host配置下面加一行配置 network.publish_host: 公网ip地址

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。