mongodb-replica-set

Mongo DB - difference between standalone & 1-node replica set

≡放荡痞女 提交于 2020-12-24 15:51:29
问题 I needed to use Mongo DB transactions, and recently I understood that transactions don't work for Mongo standalone mode, but only for replica sets (Mongo DB with C# - document added regardless of transaction). Also, I read that standalone mode is not recommended for production. So I found out that simply defining a replica set name in the mongod.cfg is enough to run Mongo DB as a replica set instead of standalone. After changing that, Mongo transactions started working. However, it feels a

Mongo DB - difference between standalone & 1-node replica set

对着背影说爱祢 提交于 2020-12-24 15:50:19
问题 I needed to use Mongo DB transactions, and recently I understood that transactions don't work for Mongo standalone mode, but only for replica sets (Mongo DB with C# - document added regardless of transaction). Also, I read that standalone mode is not recommended for production. So I found out that simply defining a replica set name in the mongod.cfg is enough to run Mongo DB as a replica set instead of standalone. After changing that, Mongo transactions started working. However, it feels a

Mongo DB - difference between standalone & 1-node replica set

梦想的初衷 提交于 2020-12-24 15:50:09
问题 I needed to use Mongo DB transactions, and recently I understood that transactions don't work for Mongo standalone mode, but only for replica sets (Mongo DB with C# - document added regardless of transaction). Also, I read that standalone mode is not recommended for production. So I found out that simply defining a replica set name in the mongod.cfg is enough to run Mongo DB as a replica set instead of standalone. After changing that, Mongo transactions started working. However, it feels a

reading data from specific nodes in mongo replica set

你。 提交于 2020-01-02 15:03:46
问题 I have a replica set of three members. Is it possible that I just want to read from one of the two secondary nodes? I use following code where the ip is one of the secondary, but I still saw the traffic was deployed to other nodes. Mongo mongo = new MongoClient("171.21.43.34"); 回答1: The best way is to use tags as stated in mongodb manual. https://docs.mongodb.com/manual/tutorial/configure-replica-set-tag-sets/ conf = rs.conf() conf.members[0].tags = { "offline": "false"} conf.members[1].tags

Read from secondary replica set in mongodb through javascript

心已入冬 提交于 2019-12-12 20:44:22
问题 I have 2 mongo instance running in 2 different servers (one primary and other secondary); I am able to retrieve a document from the primary server using this connection code: var db = mongojs('user:pswd@localhost:27017/mydb?authSource=admin'); But when I try to retrieve a document from the secondary server, I am getting the following error: { [MongoError: not master and slaveOk=false] name: 'MongoError', message: 'not master and slaveOk=false', ok: 0, errmsg: 'not master and slaveOk=false',

MongoDB replication timeout

北城余情 提交于 2019-12-12 04:01:42
问题 I use MongoDB 3.4.3 and have three machines in one replica set. Let its names as server1 , server2 and server3 . server2 is in a constant rollback state, so we turned it off. server3 is in recovering state and tries to get oplog from server1 but its attempts result in ExceededTimeLimit exception. So this is an extract from the server3 log: 2017-06-26T14:42:14.442+0300 I REPL [replication-0] could not find member to sync from 2017-06-26T14:42:24.443+0300 I REPL [rsBackgroundSync] sync source

Unable to connect to MongoDB Replica Set using public IP addresses

喜欢而已 提交于 2019-12-02 22:20:34
问题 I have configured a three-node replica set in MongoDB; replication is in sync. I am able to connect to each server individually, and using each server's private IP address I can to connect to the replica set like this: mongo --host rs0/10.X.X.X:27017,10.X.X.X:27017,10.X.X.X:27017 -u root -p abc123 --authenticationDatabase admin But when I try to connect to the replica set using the servers' public IP addresses, like this: mongo --host rs0/52.X.X.X:27017,52.X.X.X:27017,52.X.X.X:27017 -u root

Unable to run mongo container with replica set using docker-compose

浪子不回头ぞ 提交于 2019-12-02 11:30:20
问题 Here's my docker-compose file: version: '3' services: mongo: hostname: mongo container_name: search_mongo image: mongo:latest volumes: - ./docker/local/persist/mongo:/data/db - ./docker/mongo:/opt/mongo ports: - "8884:27017" - "8885:27018" entrypoint: /opt/mongo/entrypoint_mongo.sh agent: build: . image: myapp_search:compose depends_on: - mongo Here's my entrypoint_mongo.sh #!/bin/bash mongod --port 27018 --replSet rs0 --fork --syslog --smallfiles mongo --port 27018 --eval "rs.initiate({_id :

Unable to connect to MongoDB Replica Set using public IP addresses

别说谁变了你拦得住时间么 提交于 2019-12-02 08:07:46
I have configured a three-node replica set in MongoDB; replication is in sync. I am able to connect to each server individually, and using each server's private IP address I can to connect to the replica set like this: mongo --host rs0/10.X.X.X:27017,10.X.X.X:27017,10.X.X.X:27017 -u root -p abc123 --authenticationDatabase admin But when I try to connect to the replica set using the servers' public IP addresses, like this: mongo --host rs0/52.X.X.X:27017,52.X.X.X:27017,52.X.X.X:27017 -u root -p abc123 --authenticationDatabase admin I get an error: " No primary detected for set rs0 ". When you