Replication on MongoDB using Visual Studio

喜夏-厌秋 提交于 2019-12-24 07:01:08

问题


I am trying to replicate my data (a rar file) using mongodb and following this simple tutorial on mongodb website mongodb_connections but its not working properly and giving run-time error of

Unhandled exception at 0x577be130 in getting_started.exe: 0xC0000005: Access violation reading location 0x00000000.

I am using these commands

gridfs gfs[1];
gridfile gfile[1];
mongo conn[1];

mongo_replica_set_init(conn,"rs-dc-1");
mongo_replica_set_add_seed(conn,TEST_SERVER,TEST_PORT);
mongo_replica_set_add_seed(conn,TEST_SERVER,TEST_PORT+1);
mongo_replica_set_client(conn);
gridfs_init( conn, "test", "fs", gfs );

Can anyone guide me how i can setup the replication using visual studio and also as we know that all the data from mongodb will saves to

C:\data\db

so where will the new port data will save?

EDITED:

I tried to just connect to the replicated server with these simple commands

mongo conn[1];
mongo_replica_set_init(conn,"rs-dc-1");
mongo_replica_set_add_seed(conn,TEST_SERVER,TEST_PORT);
mongo_replica_set_add_seed(conn,TEST_SERVER,TEST_PORT+1);
res=mongo_replica_set_client(conn);

but it is still not connected and when i checked res is -1 means MONGO_ERROR is coming.

Do anyone has any idea about how to solve this?

EDITED-2:

This is the error i am getting

 MONGO_CONN_NO_PRIMARY,   /**< Can't find primary in replica set. Connection closed. */

来源:https://stackoverflow.com/questions/19629753/replication-on-mongodb-using-visual-studio

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!