Reputation: 21
Im trying to addshard via router to 2 replication set on windows. I already searched a lot of similar questions and tried the same steps. But unfornately ... Below is my steps: for config node, config file:
dbpath=D:/MongoDBConfigNode/config
logpath=D:/MongoDBConfigNode/logs/config1.log
logappend=true
bind_ip=0.0.0.0
port = 17011
configsvr=true
replSet=configsvr
starting using mongod -f D:\MongoDBConfigNode\config-17011.conf
and connect to it using mongo -host 127.0.0.1 --port 17011
and initialize:
config = { _id : "configsvr", members :[{_id : 0, host : "127.0.0.1:17011" }]}
{
"_id" : "configsvr",
"members" : [
{
"_id" : 0,
"host" : "127.0.0.1:17011"
}
]
}
> rs.initiate(config)
{
"ok" : 1,
"$gleStats" : {
"lastOpTime" : Timestamp(1622598318, 1),
"electionId" : ObjectId("000000000000000000000000")
},
"lastCommittedOpTime" : Timestamp(0, 0)
}
I have two replication set, sharding1 and sharding2, each has 3 servers in it.
port 37018 config file, 37017 and 37019 are similar
dbpath=D:\MongoDBSharding1Slave1\data
bind_ip=0.0.0.0
port=37018
logpath=D:\MongoDBSharding1Slave1\logs\sharding1Slave1.log
replSet=Sharding1
shardsvr=true
I started mongodb on port 37017, 37018, 37019 like following:
mongod -f D:\MongoDBSharding1Master\config\mongo_37017.conf
mongod -f D:\MongoDBSharding1Slave1\config\mongo_37018.conf
mongod -f D:\MongoDBSharding1Slave2\config\mongo_37019.conf
using following to connect mongo --port 37017
, and intialize like following:
config = { _id : "Sharding1", members : [{_id : 0, host : "127.0.0.1:37017"},{_id : 1, host : "127.0.0.1:37018"},{_id : 2, host : "127.0.0.1:37019", "arbiterOnly":true }]}
{
"_id" : "Sharding1",
"members" : [
{
"_id" : 0,
"host" : "127.0.0.1:37017"
},
{
"_id" : 1,
"host" : "127.0.0.1:37018"
},
{
"_id" : 2,
"host" : "127.0.0.1:37019",
"arbiterOnly" : true
}
]
}
> rs.initiate(config);
I did the same for Sharding2. Then i started the router node: router node config:
port=27017
bind_ip=0.0.0.0
logpath=D:/MongoDBRoute/logs/route.log
configdb=configsvr/localhost:17011
started the node like this:
mongos -f D:\MongoDBRoute\config\route-27017.conf
connect to it like this:
mongo --host localhost --port 27017,
and i got the erros :
> sh.status()
printShardingStatus: this db does not have sharding enabled. be sure you are connecting to a mongos from the shell and not to a mongod.
> sh.addShard("Sharding1/127.0.0.1:37017, 127.0.0.1:37018, 127.0.0.1:37019");
{
"ok" : 0,
"errmsg" : "no such command: 'addShard'",
"code" : 59,
"codeName" : "CommandNotFound"
}
Appreciate your help!
Upvotes: 0
Views: 286
Reputation: 59436
Have a look at your service manager services.msc
, there you should be able to stop it.
or use
sc stop <SERVICE_NAME>
sc delete <SERVICE_NAME>
If the service does not stop, try
sc queryex <SERVICE_NAME>
taskkill /pid <SERVICE_PID> /f
If the service is started with config files (like the ones you defined) you can remove it also like this:
mongod.exe -f D:\MongoDBConfig\config-27017.conf --remove
Upvotes: 1