Cannot setup single node elasticsearch in docker

docker-compose config:

es_1:
  image: "elasticsearch:7.0.0"
  container_name: "es_1"
  hostname: "es_1"
  volumes:
    - es_vol_1_data:/usr/share/elasticsearch/data
    - es_vol_1_logs:/usr/share/elasticsearch/logs
    - /private/tmp/elasticsearch.yaml:/usr/share/elasticsearch/config/elasticsearch.yml
  networks:
    - "net"
  ports:
    - "9201:9200"
  expose:
    - "9300"
  restart: "always"
  logging:
    <<: *ES_LOGGING_DEFAULTS
  environment:
    - node.name=es_1
    - http.port=9200
    - discovery.type=single-node

crash:

{"type": "server", "timestamp": "2019-06-18T06:56:06,758+0000", "level": "WARN", "component": "o.e.b.ElasticsearchUncaughtExceptionHandler", "cluster.name": "es_cluster", "node.name": "es_1", "message": "uncaught exception in thread [main]" ,
"stacktrace": ["org.elasticsearch.bootstrap.StartupException: java.lang.IllegalStateException: cannot start with [discovery.type] set to [single-node] when local node {es_1}{eIL2EgmlQiGcgQpB0sbOqA}{DwoHWj75Q2eSIpsybKCtSg}{172.18.0.17}{172.18.0.17:9300}{ml.machine_memory=6246748160, xpack.installed=true, ml.max_open_jobs=20} does not have quorum in voting configuration VotingConfiguration{V_jSX7VQQ3aK5wbNtfIP3w,eIL2EgmlQiGcgQpB0sbOqA,ZbUHYuziRR63J3R9sg3Plg}",
"at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:163) ~[elasticsearch-7.0.0.jar:7.0.0]",
"at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:150) ~[elasticsearch-7.0.0.jar:7.0.0]",
"at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:86) ~[elasticsearch-7.0.0.jar:7.0.0]",
"at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:124) ~[elasticsearch-cli-7.0.0.jar:7.0.0]",
"at org.elasticsearch.cli.Command.main(Command.java:90) ~[elasticsearch-cli-7.0.0.jar:7.0.0]",
"at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:115) ~[elasticsearch-7.0.0.jar:7.0.0]",
"at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:92) ~[elasticsearch-7.0.0.jar:7.0.0]",
"Caused by: java.lang.IllegalStateException: cannot start with [discovery.type] set to [single-node] when local node {es_1}{eIL2EgmlQiGcgQpB0sbOqA}{DwoHWj75Q2eSIpsybKCtSg}{172.18.0.17}{172.18.0.17:9300}{ml.machine_memory=6246748160, xpack.installed=true, ml.max_open_jobs=20} does not have quorum in voting configuration VotingConfiguration{V_jSX7VQQ3aK5wbNtfIP3w,eIL2EgmlQiGcgQpB0sbOqA,ZbUHYuziRR63J3R9sg3Plg}",
"at org.elasticsearch.cluster.coordination.Coordinator.doStart(Coordinator.java:686) ~[elasticsearch-7.0.0.jar:7.0.0]",
"at org.elasticsearch.common.component.AbstractLifecycleComponent.start(AbstractLifecycleComponent.java:61) ~[elasticsearch-7.0.0.jar:7.0.0]",
"at org.elasticsearch.node.Node.start(Node.java:681) ~[elasticsearch-7.0.0.jar:7.0.0]",
"at org.elasticsearch.bootstrap.Bootstrap.start(Bootstrap.java:263) ~[elasticsearch-7.0.0.jar:7.0.0]",
"at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:334) ~[elasticsearch-7.0.0.jar:7.0.0]",
"at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:159) ~[elasticsearch-7.0.0.jar:7.0.0]",
"... 6 more"] }

I really have no idea what does "does not have quorum in voting configuration" mean, any idea?

Could you first remove the existing volume with docker-compose down -v If you don't have critical data.

And use 7.1.1 instead of 7.0.0.

Thank you for the reply. Got it, let me have a try.

Hi @dadoonet,

Still crashing after upgrade to 7.1.1:

{"type": "server", "timestamp": "2019-06-18T07:35:38,645+0000", "level": "WARN", "component": "o.e.b.ElasticsearchUncaughtExceptionHandler", "cluster.name": "es_cluster", "node.name": "es_1", "message": "uncaught exception in thread [main]" ,
"stacktrace": ["org.elasticsearch.bootstrap.StartupException: java.lang.IllegalStateException: cannot start with [discovery.type] set to [single-node] when local node {es_1}{eIL2EgmlQiGcgQpB0sbOqA}{hIX50HfvRr-gkPZkI_us1g}{172.18.0.18}{172.18.0.18:9300}{ml.machine_memory=6246748160, xpack.installed=true, ml.max_open_jobs=20} does not have quorum in voting configuration VotingConfiguration{V_jSX7VQQ3aK5wbNtfIP3w,eIL2EgmlQiGcgQpB0sbOqA,ZbUHYuziRR63J3R9sg3Plg}",
"at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:163) ~[elasticsearch-7.1.1.jar:7.1.1]",
"at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:150) ~[elasticsearch-7.1.1.jar:7.1.1]",
"at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:86) ~[elasticsearch-7.1.1.jar:7.1.1]",
"at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:124) ~[elasticsearch-cli-7.1.1.jar:7.1.1]",
"at org.elasticsearch.cli.Command.main(Command.java:90) ~[elasticsearch-cli-7.1.1.jar:7.1.1]",
"at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:115) ~[elasticsearch-7.1.1.jar:7.1.1]",
"at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:92) ~[elasticsearch-7.1.1.jar:7.1.1]",
"Caused by: java.lang.IllegalStateException: cannot start with [discovery.type] set to [single-node] when local node {es_1}{eIL2EgmlQiGcgQpB0sbOqA}{hIX50HfvRr-gkPZkI_us1g}{172.18.0.18}{172.18.0.18:9300}{ml.machine_memory=6246748160, xpack.installed=true, ml.max_open_jobs=20} does not have quorum in voting configuration VotingConfiguration{V_jSX7VQQ3aK5wbNtfIP3w,eIL2EgmlQiGcgQpB0sbOqA,ZbUHYuziRR63J3R9sg3Plg}",
"at org.elasticsearch.cluster.coordination.Coordinator.doStart(Coordinator.java:689) ~[elasticsearch-7.1.1.jar:7.1.1]",
"at org.elasticsearch.common.component.AbstractLifecycleComponent.start(AbstractLifecycleComponent.java:61) ~[elasticsearch-7.1.1.jar:7.1.1]",
"at org.elasticsearch.node.Node.start(Node.java:683) ~[elasticsearch-7.1.1.jar:7.1.1]",
"at org.elasticsearch.bootstrap.Bootstrap.start(Bootstrap.java:263) ~[elasticsearch-7.1.1.jar:7.1.1]",
"at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:334) ~[elasticsearch-7.1.1.jar:7.1.1]",
"at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:159) ~[elasticsearch-7.1.1.jar:7.1.1]",
"... 6 more"] }

I checked the source code: https://github.com/elastic/elasticsearch/blob/master/server/src/main/java/org/elasticsearch/cluster/coordination/Coordinator.java#L653

final ClusterState lastAcceptedState = coordinationState.get().getLastAcceptedState();
if (lastAcceptedState.metaData().clusterUUIDCommitted()) {
    logger.info("cluster UUID [{}]", lastAcceptedState.metaData().clusterUUID());
}
final VotingConfiguration votingConfiguration = lastAcceptedState.getLastCommittedConfiguration();
if (singleNodeDiscovery &&
    votingConfiguration.isEmpty() == false &&
    votingConfiguration.hasQuorum(Collections.singleton(getLocalNode().getId())) == false) {
    throw new IllegalStateException("cannot start with [" + DiscoveryModule.DISCOVERY_TYPE_SETTING.getKey() + "] set to [" +
        DiscoveryModule.SINGLE_NODE_DISCOVERY_TYPE + "] when local node " + getLocalNode() +
        " does not have quorum in voting configuration " + votingConfiguration);
}

Seems "votingConfiguration" has to be empty. Though I don't know what's this.

Here is the one I'm using:

---
version: '3'
services:

  elasticsearch:
    image: docker.elastic.co/elasticsearch/elasticsearch:7.1.1
    environment:
      - bootstrap.memory_lock=true
      - discovery.type=single-node
    ulimits:
      memlock:
        soft: -1
        hard: -1
    ports:
      - 9200:9200

HTH

Hi @dadoonet,

Thank you very much, it's ok now. As following your suggestion, using the min configuration.

es_1:
  image: "elasticsearch:7.1.1"
  container_name: "es_1"
  hostname: "es_1"
  networks:
    - "net"
  ports:
    - "9200:9200"
  restart: "always"
  logging:
    <<: *ES_LOGGING_DEFAULTS
  environment:
    - bootstrap.memory_lock=true
    - discovery.type=single-node
    - *ES_JAVA_OPTS
  ulimits:
    memlock:
      soft: -1
      hard: -1

What I removed:

 cluster.name: es_cluster
 node.name=es_1
 http.port=9200
 network.host: 0.0.0.0
 path.data: /usr/share/elasticsearch/data
 path.logs: /usr/share/elasticsearch/logs

Maybe you guys could find some hint to enhance the docs. Thanks again.

I used to set cluster.name: es_cluster as well but I removed it from my example as it was not adding value IMO.

I'd not touch network.host. path.data and path.logs are not needed IMO.

Maybe you guys could find some hint to enhance the docs. Thanks again.

Which part should we change from Install Elasticsearch with Docker | Elasticsearch Guide [8.11] | Elastic ? PR are welcomed.

I just think the error log is a bit too, how to say, "code oriented".

As you can see, I'm not familiar with the implementation of the elasticsearch, just a user. And the error shown in the log file is: "cannot start with [discovery.type] set to [single-node] when local node {es_1}... does not have quorum in voting configuration VotingConfiguration...".

And it really cannot help me to find what's wrong in the config. As a user, what I want is to know what configuration is invalid, and fix it asap to get the cluster up.

Maybe it's not helpful to you guys. Just some feeling. :grinning:

Why did you change the config in the first place? I mean that the settings you touched are not mentioned in Install Elasticsearch with Docker | Elasticsearch Guide [8.11] | Elastic if I'm not mistaken.

I just making some docker experiment, and put all the variables may possible to be modified later into docker env. So...

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.