pkdone / gke-mongodb-shards-demo

MongoDB Sharded Cluster Deployment Demo for Kubernetes on GKE
MIT License
48 stars 33 forks source link

replica set initiate getting failed with self domain + Mongos Add Shard CONNECT_ERROR #5

Closed sunnykrGupta closed 6 years ago

sunnykrGupta commented 6 years ago

I am getting error while initiating a replicaset. Here, i am trying to setup standalone (only one member) replicaset. rs.initiate({_id: "Shard1RepSet", version: 1, members: [ {_id: 0, host: "mongodb-shard1-0.mongodb-shard1-service:27017"} ]}) { "ok" : 0, "errmsg" : "couldn't initiate : can't find self in the replset config" }

Instead of this if i do rs.initiate() it assign perfectly and make it PRIMARY.

Then after this init, proceeding to adding shard from mongos, it throws following sh.addShard("Shard1RepSet/mongodb-shard1-0.mongodb-shard1-headless-service:27017") { "ok" : 0, "errmsg" : "couldn't connect to new shard socket exception [CONNECT_ERROR] for Shard1RepSet/mongodb-shard1-0.mongodb-shard1-headless-service:27017" }

I thought of network issue, then from same mongos container i did tried to connect to replicaset member its connecting perfectly. Can you help me with this? what could be possible reason? I am running mongo:2.6 root@mongos-567bcbb45d-lx47x:/# mongo --host mongodb-shard1-0.mongodb-shard1-headless-service --port 27017

sunnykrGupta commented 6 years ago

It could be typos while configuring DNS of stateful pods. Followed : https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/#stable-network-id to understand more into static hostname.

pkdone commented 6 years ago

Unfortunately only MongoDB version 3.2 and greater are supported, due to the scripts assuming the use of of the more modern way to manage the config servers as a "proper" replica sets. A.k.a. "Config Servers Replica Set" (CSRS)

sunnykrGupta commented 6 years ago

That's part I ignored and used whole script to setup sharding in mongo 2.6. Initially i was unsure about replica set in config server. That's for pointing docs.