mongo-cxx-driver-legacy-1.0.4
SCons--extrapath=/usr/local/boost158/--prefix=/usr/local/mongodb30--ssl=ssl--use-sasl-client=USE-SASL-CLIENT.
Boost_1_58_0.tar
./bootstrap.sh--prefix=/usr/local/boost158
./B2 Install
Mongo-cxx-pool-master (requires-std=c++11 can modify the source code with a low version compiled)
mongodb3.0 Connection String Mongodb://xxx:[email protected]:27017/admin
mongodb3.0 replica Set connection string Mongodb://xxx:[email protected]:27011,192.168.0.21:27012,192.168.0.21:27010/admin?authmechanism =scram-sha-1&authsource=admin&replicaset=rs0 (default with authmechanism= MONGODB-CR failure)
Need to authenticate first to get mastr and slave accurately
cout<< "One by One:" <<conn->slaveconn (). Getserveraddress () <<endl;
Bsonobj obj = Conn->slaveconn (). FindOne ("Test.testdb", Mongo_query ("_id" <<oid ("55b886c1b0852f7c713227b0") ), 0,queryoption_slaveok);
Cout<<obj.jsonstring () <<endl;
May get a different address
dbclientconnection& conn1 = Conn->slaveconn ();
cout<< "All:" <<conn1.getserveraddress () <<endl;
Bsonobj obj = Conn1.findone ("Test.testdb", Mongo_query ("_id" <<oid ("55b886c1b0852f7c713227b0")), 0,QueryOption _SLAVEOK);
Cout<<obj.jsonstring () <<endl;
MongoDB C + + interface