Node doesn't join cluster

Is there a guide on how to add new nodes to a cluster?
Cause this ain't it.

The issue is both nodes are running, displaying no errors, but shards are not getting assigned.

Nodes in the cluster (cluster.name: local) have identical configurations except for node.master: true and node.data: true on the master node called node.name: bcp.local0.

Replica Node config:

http.port: 9202
network.host: ["0.0.0.0"]
node.name: bcp.local2
cluster.name: local
cluster.initial_master_nodes: ["bcp.local0"]

Cluster health:

{
    "cluster_name": "local",
    "status": "yellow",
    "timed_out": false,
    "number_of_nodes": 1,
    "number_of_data_nodes": 1,
    "active_primary_shards": 7,
    "active_shards": 7,
    "relocating_shards": 0,
    "initializing_shards": 0,
    "unassigned_shards": 1,
    "delayed_unassigned_shards": 0,
    "active_shards_percent_as_number": 87.5,
...
,
        "mydata": {
            "status": "yellow",
            "number_of_shards": 1,
            "number_of_replicas": 1,
            "active_primary_shards": 1,
            "active_shards": 1,
            "relocating_shards": 0,
            "initializing_shards": 0,
            "unassigned_shards": 1,
            "shards": {
                "0": {
                    "status": "yellow",
                    "primary_active": true,
                    "active_shards": 1,
                    "relocating_shards": 0,
                    "initializing_shards": 0,
                    "unassigned_shards": 1
                }
            }
        }
    }
}

What's a boy to do?

Index mydata Settings:

                "number_of_shards": "1",
                "number_of_replicas": "1",

I was expecting 1 shard with 1 replica to mean my primary/master node has the primary shard and the second node has the replica. Is this not the case?

I got things to green by setting number_of_replicas to 0 on each node but that sounds dodgy.

GET /_nodes on the "master" reveals only one node:

{
    "_nodes": {
        "total": 1,
        "successful": 1,
        "failed": 0
    },
...
            "settings": {
                "cluster": {
                    "initial_master_nodes": [
                        "bcp.local0"
                    ],
                    "name": "local",
                    "election": {
                        "strategy": "supports_voting_only"
                    }

Trying to reroute the replicate to node2:

POST /_cluster/reroute
{
    "commands" : [
        {
          "allocate_replica" : {
                "index" : "mydata", "shard" : 1,
                "node" : "bcp.local2"
          }
        }
    ]
}

Result

{
    "error": {
        "root_cause": [
            {
                "type": "illegal_argument_exception",
                "reason": "failed to resolve [bcp.local2], no matching nodes"
            }
        ],
        "type": "illegal_argument_exception",
        "reason": "failed to resolve [bcp.local2], no matching nodes"
    },
    "status": 400
}

OK, it seems to be working now.

My BIG MISTAKE was copying my elasticsearch\ folder to create the 2nd node or - to be precise - not deleting the contents of the data\ folder before starting the node.

So the solution was to empty the data directory on the new node and start it up again.

1 Like