Mongo DB: Unable to create a sharding cluster in Ubuntu

断了今生、忘了曾经 提交于 2019-12-11 02:59:12

问题


I have installed MongoDB using http://docs.mongodb.org/manual/tutorial/install-mongodb-on-ubuntu/ in my Ubuntu machine and the mongo instance is working fine.

I am able to do CRUD operations in the instance. I also installed the MonjaDB eclipse plugin and am able to see all databases/collections/documents in it.

Now, I want to create a sharded cluster in my machine. I am trying to create this way:

cluster = new ShardingTest({"shards" : 3, "chunksize" : 1})

It is giving the following error: Resetting db path '/data/db/test0' Wed Feb 12 15:46:43 Error: boost::filesystem::create_directory: Permission denied: "/data/db/test0" (anon):1

Also, I tried to create shards for existing collection. For this, first I tried to enable sharding in my database ("test")

sh.enableSharding("test") Wed Feb 12 15:48:14 uncaught exception: not connected to a mongos

Can someone please let me know, what might went wrong.

Thanks in advance,

Raghu


回答1:


I can suggest that you follow the documentation from the MongoDB site to deploy your sharded cluster for the first time:

http://docs.mongodb.org/manual/tutorial/deploy-shard-cluster/

If you then wish to work through another product to aid in this then you can be more aware of what actually needs to be done and what is not happening.




回答2:


Try starting mongo shell with root user:

$ sudo mongo --nodb

and then in mongo shell:

> cluster = new ShardingTest({"shards" : 3, "chunksize" : 1})

If your problem persists check permissions and ownership for the directory "/data/db/". See mongodb Mongod complains that there is no /data/db folder answer.



来源:https://stackoverflow.com/questions/21724991/mongo-db-unable-to-create-a-sharding-cluster-in-ubuntu

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!