问题
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