通过Ansible的Elasticsearch多节点集群

时间:2019-06-11 11:10:26

标签: elasticsearch ansible

ElasticSearch 7.1.1(从6.1.1升级)

我是ansible / ES世界的新手,并且通过ansible进行了以下集群设置:

- name: Determine nodes to join
set_fact:
  join_list: "{{ groups['elasticsearch'] | map('extract', hostvars, ['ansible_host']) | list }}"

- name: Launch Elasticsearch
docker_container:
  name: elasticsearch
  image: "{{ ELASTICSEARCH_DOCKER_IMAGE }}"
  restart_policy: always
  ulimits:
    memlock:-1:-1
  env: 
    ES_JAVA_OPTS: -Xms{{ ELASTICSEARCH_JAVA_HEAP_SIZE }}{{ ELASTICSEARCH_JAVA_HEAP_SIZE_UNIT }} -Xmx{{ ELASTICSEARCH_JAVA_HEAP_SIZE }}{{ ELASTICSEARCH_JAVA_HEAP_SIZE_UNIT }}
    cluster.name: "{{ cluster_name }}"
    cluster.max_shards_per_node: "{{ ELASTICSEARCH_MAX_SHARDS_PER_MACHINE }}"
    network.host: 0.0.0.0
    network.publish_host: "{{ ansible_default_ipv4.address }}"
    discovery.seed_hosts: "{{ join_list | join(',') }}" # ip1,ip2,ip3
    cluster.initial_master_nodes: "{{ join_list | join(',') }}" # ip1,ip2,ip3
    bootstrap.memory_lock: "true"
    xpack.security.enabled: "false"
    xpack.monitoring.enabled: "false"
  volumes:
    - /data/elasticsearch:/usr/share/elasticsearch/data
    - /etc/elasticsearch/conf/readonlyrest.yml:/usr/share/elasticsearch/config/readonlyrest.yml
  recreate: yes
  ports:
    - '9200:9200'
    - '9300:9300'
  log_driver: "json-file"
  log_options:
    max-size: "50m"

但是,在重新启动群集时遇到麻烦,我需要尝试5次重新启动,直到选举出主服务器为止。我得到了:

{"type": "server", "timestamp": "2019-06-11T09:50:31,841+0000", "level": "WARN", 
"component": "o.e.c.c.ClusterFormationFailureHelper", "cluster.name": "logs-cluster", 
"node.name": "909633d86b87",  "message": "master not discovered or elected yet, 
an election requires at least 2 nodes with ids from [1zCGKj0hRT6T8bGY9iq9pg, 
FX02Pbg-SJGwlTTJUuSYpA, e17LddjDToik0qvncMfmDA], have discovered 
[{59f4a78488db}{e17LddjDToik0qvncMfmDA}{592--tXmTK6d8lspA8xH_A}{ipMachine2}
{ipMachine2:9300}{ml.machine_memory=67333812224, ml.max_open_jobs=20, xpack.installed=true}, 
{0accfaedf881}{FX02Pbg-SJGwlTTJUuSYpA}{HHFu_ZWRS3u5d4n_Q2zRGw}{ipMchine3}{ipMchine3:9300}
{ml.machine_memory=67333812224, ml.max_open_jobs=20, xpack.installed=true}] 
which is a quorum; discovery will continue using [ipMchine2:9300, ipMchine3:9300] 
from hosts providers and [{909633d86b87}{1zCGKj0hRT6T8bGY9iq9pg}{wH0GrkImRFSX6FcNgv6UAQ}
{ipMachine1}{ipMachine1:9300}{ml.machine_memory=67333812224, xpack.installed=true, ml.max_open_jobs=20}] 
from last-known cluster state; node term 161, last-accepted version 74165 in term 157"  }

另一个日志(可能来自另一个重新启动会话):

{"type": "server", "timestamp": "2019-06-11T09:47:01,500+0000", "level": "INFO", "component": "o.e.c.c.JoinHelper", "cluster.name": "logs-cluster", "node.name": "logger01",  "message": "failed to join {logger02}{e17LddjDToik0qvncMfmDA}{D2CEEIHkQnKZbf9udR_H7A}{ipMachine2}{ipMachine2:9300}{ml.machine_memory=67333812224, ml.max_open_jobs=20, xpack.installed=true} with JoinRequest{sourceNode={logger01}{1zCGKj0hRT6T8bGY9iq9pg}{axID8iQ1TPuplM1Z_Eg35g}{ipMachine1}{ipMachine1:9300}{ml.machine_memory=67333812224, xpack.installed=true, ml.max_open_jobs=20}, optionalJoin=Optional[Join{term=153, lastAcceptedTerm=151, lastAcceptedVersion=74161, sourceNode={logger01}{1zCGKj0hRT6T8bGY9iq9pg}{axID8iQ1TPuplM1Z_Eg35g}{ipMachine1}{ipMachine1:9300}{ml.machine_memory=67333812224, xpack.installed=true, ml.max_open_jobs=20}, targetNode={logger02}{e17LddjDToik0qvncMfmDA}{D2CEEIHkQnKZbf9udR_H7A}{ipMachine2}{ipMachine2:9300}{ml.machine_memory=67333812224, ml.max_open_jobs=20, xpack.installed=true}}]}" , 

此设置看起来合法吗?

0 个答案:

没有答案