我正在尝试设置分片和副本集。
我的假设程序是这样的:
- 启动一个副本集(让它只有一个,仅用于测试(
- 然后
mongo
启动副本 - 启动一个配置服务器(再次让它成为一个,仅用于测试(
- 启动一个分片服务器(再次让它只是一个(
- 添加分片并通过
mongo
启用sharding
我做了什么:
-
mongod --replSet rs0 --dbpath data/rs0-0 --unixSocketPrefix data/rs0-0
-
mongo
然后rs.initiate()
-
mongod --configsvr --dbpath data/rs0-0 --unixSocketPrefix data/rs0-0
-- 现在卡在步骤 3 上。
我发现的错误是 2017-05-22T20:00:13.857+0530 [initandlisten] exception in initAndListen: 10310 Unable to lock file: data/rs0-0/mongod.lock. Is a mongod instance already running?, terminating
我试过什么:
我尝试使用不同的目录进行 --unixSocketPrefix 选项,但每次它都命中data/rs0-0/mongod.lock
同一个文件。所以它没有奏效
这似乎很简单,但无法弄清楚锁定文件如何在各种 mongod(无论是配置服务器、副本集还是分片服务器(之间共享
我在蒙戈布2.6.12
您需要使用不同的数据库路径选项启动mongod
和config server
。您可以按照以下步骤操作:
mongod --replSet rs0 --dbpath data/rs0-0 --unixSocketPrefix data/rs0-0
或
mongod --replSet rs0 --dbpath data/rs0-0
mongo
然后rs.initiate()
mkdir -p /data/configdb
(递归授予所需权限(
mongod --configsvr --dbpath /data/configdb --port 27019