我是mongo-db的新手,我尝试按照mongo-db网站中的程序配置分片。但是我遇到了一些错误......我将描述我的步骤然后配置分片......我在windows-os中试过了分片......
第1步:
*)在第一台机器中我创建了两个文件夹,即在以下路径c:/ data / db / a; c:/ data / db / config
*)现在我打开了命令提示符,并使用以下命令配置shard-server .......
C:/Program Files/mongodb-win32-i386-1.6.2/bin/mongod --shardsvr --dbpath c:/data/db/a --port 10000
第2步:
*)在第二台机器中我创建了两个文件夹,即在以下路径c:/ data / db / b; c:/ data / db / config
*)我再次打开命令提示符,并使用以下命令配置shard-server .......
*)现在我打开了命令提示符,并使用以下命令配置shard-server .......
C:/Program Files/mongodb-win32-i386-1.6.2/bin/mongod --shardsvr --dbpath c:/data/db/a --port 10001
第3步:
*)在第一台机器上,我打开了命令提示符,并使用以下命令配置config-server ....
C:/Program Files/mongodb-win32-i386-1.6.2/bin/mongod --configsvr --dbpath c:/data/db/config --port 20000
第4步:
*)在第二台机器中,我打开了命令提示符,并使用以下命令配置config-server ....
C:/Program Files/mongodb-win32-i386-1.6.2/bin/ mongod --configsvr --dbpath c:/data/db/config --port 20001
第5步:
*)我第一台机器我打开了命令提示符,我使用以下命令为第一台机器配置mongos-server ........
C:/Program Files/mongodb-win32-i386-1.6.2/bin/ mongos --configdb first-machine-ip:20000
*)我再次打开另一个命令提示符,我使用以下命令为第二台机器配置mongos-server ........
C:/Program Files/mongodb-win32-i386-1.6.2/bin/ mongos --configdb Second-machine-ip:20001
第6步:
*)现在我按如下方式运行mongo进程..
C:/Program Files/mongodb-win32-i386-1.6.2/bin/ mongo.exe first-machine-ip:27017/admin
第7步:
*)添加&启用分片我按照下面的步骤.......
> use admin
switched to db admin
> db.runCommand( { addshard : "10.0.0.137:10000" } )
{ "shardAdded" : "shard0000", "ok" : 1 }
> db.runCommand( { addshard : "10.0.0.180:10001" } )
{ "shardAdded" : "shard0001", "ok" : 1 }
> db.runCommand( { enablesharding : "test" } )
{ "ok" : 1 }
> db.runCommand( { shardcollection : "test.block_seek_pos", key : {file_GUID : 1} } )
{ "collectionsharded" : "test.people", "ok" : 1 }
第8步:
*)现在我配置了一个普通备份。
*)备份完成后,我检查了所有命令提示符......
*)我在mongos进程终端中得到如下错误......
>>mongos db version v1.6.2, pdfile version 4.5 starting (--help for usage)
>>git version: aef371ecf5d2a824f16ccdc3b745f3702165602f
>>sys info: windows (5, 1, 2600, 2, 'Service Pack 3') BOOST_LIB_VERSION=1_35
>>waiting for connections on port 27017
>>[websvr] web admin interface listening on port 28017
>>couldn't find database [sgserver] in config db
>>can't find a shard to put new db on
>>DBException in process: can't find a shard to put new db on
>>couldn't find database [sgserver] in config db
>>can't find a shard to put new db on
>>DBException in process: can't find a shard to put new db on
>>couldn't find database [sgserver] in config db
>>can't find a shard to put new db on
>>DBException in process: can't find a shard to put new db on
>>going to add shard: { _id: "shard0000", host: "first-machine-ip:10000" }
>>going to add shard: { _id: "shard0001", host: "second-machine-ip:10001" }
>>couldn't find database [test] in config db
>>put [test] on: shard0000:first-machine-ip:10000
>>enabling sharding on: test
>>CMD: shardcollection: { shardcollection: "test.people", key: { file_GUID: 1.0 } }
>>enable sharding on: test.people with shard key: { file_GUID: 1.0 }
>>no chunks for:test.people so creating first: ns:test.people at: shard0000:first-machine->>ip:10000 lastmod: 1|0 min: { file_GUID: MinKey } max: { file_GUID: MaxKey }
>>couldn't find database [sgserver] in config db
>>put [sgserver] on: shard0001:second-machine-ip:10001
>>creating WriteBackListener for: first-machine-ip:10000
>>creating WriteBackListener for: second-machine-ip:10001
任何人都可以帮我解决这个问题.......我在等待你的回复........
预先谢谢, Sampath Kumar ......
答案 0 :(得分:2)
我认为你误解了mongos(路由器)是如何工作的:
*)我第一台机器我打开了命令提示符,我使用以下命令为第一台机器配置mongos-server ........ C:/ Program Files / mongodb-win32-i386-1.6.2 / bin / mongos --configdb first-machine-ip:20000
这不会“配置”任何东西。分片命令需要从mongos
运行。
以下行没有意义,因为您尚未在该端口上启动进程:
C:/ Program Files / mongodb-win32-i386-1.6.2 / bin / mongo.exe first-machine-ip:27017 / admin