我正在尝试通过路由器将碎片添加到windows上的2复制集。我已经搜索了很多类似的问题,并尝试了相同的步骤。但不幸的是..。以下是我的步骤:对于config节点,config文件:
dbpath=D:/MongoDBConfigNode/config
logpath=D:/MongoDBConfigNode/logs/config1.log
logappend=true
bind_ip=0.0.0.0
port = 17011
configsvr=true
replSet=configsvr开始使用mongod -f D:\MongoDBConfigNode\config-17011.conf,并使用mongo -host 127.0.0.1 --port 17011和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)
}我有两个复制集sharding1和sharding2,每个复制集有3个服务器。
端口37018配置文件、37017和37019相似
dbpath=D:\MongoDBSharding1Slave1\data
bind_ip=0.0.0.0
port=37018
logpath=D:\MongoDBSharding1Slave1\logs\sharding1Slave1.log
replSet=Sharding1
shardsvr=true我在端口37017,37018,37019上启动了mongodb,如下所示:
mongod -f D:\MongoDBSharding1Master\config\mongo_37017.conf
mongod -f D:\MongoDBSharding1Slave1\config\mongo_37018.conf
mongod -f D:\MongoDBSharding1Slave2\config\mongo_37019.conf使用以下命令连接mongo --port 37017,并进行如下初始化:
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);我也为Sharding2做了同样的事情。然后启动路由器节点: router node config:
port=27017
bind_ip=0.0.0.0
logpath=D:/MongoDBRoute/logs/route.log
configdb=configsvr/localhost:17011如下所示启动节点:
mongos -f D:\MongoDBRoute\config\route-27017.conf 像这样连接到它:
mongo --主机本地主机--端口27017,
我得到了错误:
> 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"
}感谢您的帮助!
发布于 2021-06-03 14:22:40
看看你的服务管理器services.msc,在那里你应该能够阻止它。
或使用
sc stop <SERVICE_NAME>
sc delete <SERVICE_NAME>如果服务未停止,请尝试
sc queryex <SERVICE_NAME>
taskkill /pid <SERVICE_PID> /f如果服务是使用配置文件(如您定义的配置文件)启动的,则还可以像这样删除它:
mongod.exe -f D:\MongoDBConfig\config-27017.conf --removehttps://stackoverflow.com/questions/67798868
复制相似问题