我最近切换到RockMongo浏览器,但我很难使用replicaSet.
根据官方文档,我将服务器声明为:
$MONGO["servers"][$i]["mongo_name"] = "localhost";//mongo server name
$MONGO["servers"][$i]["mongo_host"] = "127.0.0.1";//mongo host
$MONGO["servers"][$i]["mongo_port"] = "27017";//mongo port
$MONGO["servers"][$i]["mongo_timeout"] = 0;//mongo connection timeout
Run Code Online (Sandbox Code Playgroud)
RockMongo抱怨如下:
Execute failed:not master
function (){ return db.getCollectionNames(); }
Run Code Online (Sandbox Code Playgroud)
我还尝试了另一种变体导致了同样的错误:
$MONGO["servers"][$i]["mongo_host"] = "mongodb://192.168.0.2,192.168.0.3";// multiple hosts
Run Code Online (Sandbox Code Playgroud)
RockMongo可以使用replicaSet吗?
但是如果你深入研究源代码,你会发现rockmongo确实可以使用未记录的"mongo_options"键连接到replicaSet:
$MONGO["servers"][$i]["mongo_options"] = array('replicaSet' => 'REPLICA_NAME');//mongo server name
$MONGO["servers"][$i]["mongo_host"] = "mongodb://192.168.0.2,192.168.0.3";//mongo host
$MONGO["servers"][$i]["mongo_port"] = false;//mongo port
Run Code Online (Sandbox Code Playgroud)
希望这可以帮助 !
| 归档时间: |
|
| 查看次数: |
3144 次 |
| 最近记录: |