我想知道,有没有办法可以通过mongo-connector从一个mongo副本集复制到另一个mongo副本集?根据mongo文档,我们可以通过mongo-connector使用命令连接两个mongo实例,如下例所示,但我想传递副本集名称或使用配置文件而不是传递 server:port 命令行中的名称。
Mongo Connector可以使用Mongo DocManager从一个MongoDB副本集或分片集群复制到另一个集群。最基本的用法如下:
mongo-connector -m localhost:27017 -t localhost:37017 -d mongo_doc_manager
我也通过创建下面的config.json文件尝试了config.json选项,但它失败了。
{
"__comment__": "Configuration options starting with '__' are disabled",
"__comment__": "To enable them, remove the preceding '__'",
"mainAddress": "localhost:27017",
"oplogFile": "C:\Dev\mongodb\mongo-connector\oplog.timestamp",
"verbosity": 2,
"continueOnError": false,
"logging": {
"type": "file",
"filename": "C:\Dev\mongodb\mongo-connector\mongo-connector.log",
"__rotationWhen": "D",
"__rotationInterval": 1,
"__rotationBackups": 10,
"__type": "syslog"
},
"docManagers": [
{
"docManager": "mongo_doc_manager",
"targetURL": "localhost:37010",
"__autoCommitInterval": null
}
]
}
答案 0 :(得分:1)
是的,可以使用mongo连接器连接到副本集或分片服务器。
{
mongo-connector -m <mongodb server hostname>:<replica set port> \
-t <replication endpoint URL, e.g. http://localhost:8983/solr> \
-d <name of doc manager, e.g., solr_doc_manager>
}
您还可以将连接字符串传递给mongo-connector,例如
{
mongo connector -m mongodb://db1.example.net,db2.example.net:2500/?replicaSet=test&connectTimeoutMS=300000
}
指定可以使用的特定配置文件
{ mongo-connector -c config.json }
其中config.json是您的配置文件。
答案 1 :(得分:0)
我可以通过为我的Windows目录路径输入反斜杠'\'来解决我的问题。这是我更新的配置文件以供参考。感谢ShaneHarvey Not able to use Configuration file for connecting to mongo-connector
{
"__comment__": "Configuration options starting with '__' are disabled",
"__comment__": "To enable them, remove the preceding '__'",
"mainAddress": "localhost:27017",
"oplogFile": "C:\\Dev\\mongodb\\mongo-connector\\oplog.timestamp",
"noDump": false,
"batchSize": -1,
"verbosity": 2,
"continueOnError": false,
"logging": {
"type": "file",
"filename": "C:\\Dev\\mongodb\\mongo-connector\\mongo-connector.log",
"__format": "%(asctime)s [%(levelname)s] %(name)s:%(lineno)d - %(message)s",
"__rotationWhen": "D",
"__rotationInterval": 1,
"__rotationBackups": 10,
"__type": "syslog",
"__host": "localhost:27017"
},
"docManagers": [
{
"docManager": "mongo_doc_manager",
"targetURL": "localhost:37017",
"__autoCommitInterval": null
}
]
}