开发者社区> 问答> 正文

mongo-cxx-driver-legacy版本的客户端不支持连接分片集群?

根据api中提供的ConnectionString类的方式连接mongodb分片集群,报以下错误:

"Cannot list multiple servers in URL without 'replicaSet' option"

mongodb分片集群明显指定不了复制集名称啊,很困惑是否legacy的版本已经不支持分片了,求大师指导有无其他方案?

  • Examples:
    *

    • A replica set with three members (one running on default port 27017):
    • string uri = mongodb://localhost,localhost:27018,localhost:27019
      *
    • Authenticated connection to db 'bedrock' with user 'barney' and pwd 'rubble':
    • string url = mongodb://barney:rubble@localhost/bedrock
      *
    • Use parse() to parse the url, then validate and connect:
    • string errmsg;
    • ConnectionString cs = ConnectionString::parse( url, errmsg );
    • if ( ! cs.isValid() ) throw "bad connection string: " + errmsg;
    • DBClientBase * conn = cs.connect( errmsg );

展开
收起
light@aly 2018-01-17 21:33:20 4219 0
0 条回答
写回答
取消 提交回答
问答排行榜
最热
最新

相关电子书

更多
Data as a Service - 数据即服务 -- MongoDB⾼级应⽤模式 立即下载
32 Tips to Boost MongoDB Perfo 立即下载
MongoShake -- Multi Active-Active and Cross-Region Disaster Recoverable MongoDB Service 立即下载