简体   繁体   English

我可以使用副本集名称通过mongo-connector连接

[英]Can i use replica set name to connect via mongo-connector

I would like to know, is there a way we can replicate from one mongo replica set to another via mongo-connector? 我想知道,有没有一种方法可以通过mongo-connector从一个mongo副本集复制到另一个? As per mongo documentation we can connect two mongo instances via mongo-connector by using a command as in the example below, but I would like to pass replica set name or use a configuration file instead of passing server:port name in command line. 根据mongo文档,我们可以使用以下示例中的命令通过mongo-connector连接两个mongo实例,但是我想传递副本集名称或使用配置文件,而不是在命令行中传递server:port名称。

Mongo Connector can replicate from one MongoDB replica set or sharded cluster to another using the Mongo DocManager. Mongo Connector可以使用Mongo DocManager从一个MongoDB副本集或分片群集复制到另一群集。 The most basic usage is like the following: 最基本的用法如下:

mongo-connector -m localhost:27017 -t localhost:37017 -d mongo_doc_manager mongo-connector -m本地主机:27017 -t本地主机:37017 -d mongo_doc_manager

I also tried config.json option by creating below config.json file but it has failed. 我还通过在下面的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
        }
    ]
}

yes its possible to connect to a replica set or a shard server using mongo connector. 是的,可以使用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>
}

you can also also pass a connection string to the mongo-connector such as 您还可以将连接字符串传递给mongo-connector,例如

{
mongo connector -m mongodb://db1.example.net,db2.example.net:2500/?replicaSet=test&connectTimeoutMS=300000

}

to specify specifc config files you can use 指定您可以使用的特定配置文件

{ mongo-connector -c config.json } 

where config.json is your config file. 其中config.json是您的配置文件。

I'm able to resolve my issue by entering backslash '\\' for my windows directory path.Here is my updated config file for reference. 我可以通过在Windows目录路径中输入反斜杠'\\'来解决问题。以下是我更新的配置文件供参考。 Thanks to ShaneHarvey Not able to use Configuration file for connecting to mongo-connector 感谢ShaneHarvey 无法使用配置文件连接到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
        }
    ]
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM