I have a mongo cluster of 1 Main mongo, with 3 shards en 3 config servers.
Each shard have a primary mongo database, a secundairy mongo database and an arbiter mongo database.
So in total I have 13 servers with mongo on it.
Al the mongo database are running on version 2.6
What I want is to upgrade all the databases to mongo 3.2.
Because this is a production database I want to do this in steps.
Question 1:
Is this possible, without downtime?
Question 2: So can I, for example, upgrade the config servers with from 2.6 to 3.2, without stopping the database cluster.
Question 3: Can a mongo 3.2 secundairy server running along a mongo 2.6 primairy server?
Question 4: Can a shard running on mongo 2.6 runing along with a shard running on mongo 3.2 shard?
Regards,
Q1: Yes. It's called Rolling Maintenance. I recommend to read this guide Your Ultimate Guide to rolling upgrades and to practice the steps in a safe environment before doing it on production.
Basic procedure for all nodes:
shutdown down node
replace binaries
(optional) restart node without --replSet and on different port
(optional) do maintenance work in server
restart node with --replSet and on original port
Q2-5: are preconditions for 1, so, all: yes.
Related
Error Invalid "prisma.user.create()". Prisma needs to perform transactions, which requires your MongoDB server to be run as a replica set.
I used Nx (nx.dev) with MongoDB/Express with Prisma.
Apparently, after long hours of facing continuous issues in connecting Prisma and MongoDB(local), we have 3 ways of fixing this.
You have to use either Docker or MongoDB Atlas.
Docker - Docker
MongoDB Atlas - MongoDB Replica
Ps. Your MongoDB URL env should be looking like this -> mongodb://localhost:27017/<your-db-name>?retryWrites=true&w=majority.
I decided to finally choose the option 3.
Jumping from MongoDB to PostgreSQL which don't have any replica issues, but no noSQL :)
I tried to search but most of the solutions are very old, and I feel there will be a better solution available which I am unable to find.
Problem
I created the replica set, and it's working. I tried to connect my docker backed application, and it was connecting to it.
Later I changed the dbpath from dbpath=/var/lib/mongodb to the new path dbpath=/data/mongodb. I didn't restart the replica set after this change.
I ran my backend application and it couldn't connect to the replica set. I think its because I didn't restart the MogoDB ReplicaSet. I am using Mongo version 4.4.5
I want to restart the MongoDB Replica Set to check if this can solve the issue.
My connection string :
mongodb://username:pwd#prod-privateIP-1:27017,prod-privateIP-2:27017,prod-privateIP-3:27017/prodDB?replicaSet=replica1&authSource=admin
What is the best practice/recommended approach to restart the MongoDB Replica Set ?
In Oracle developers can run sqls in nologging mode. Is it possible on Mongo DB or Mongo DB writes all operations into the oplog(operations log)?
A standalone server (not part of replica set or sharded cluster) does not employ the oplog.
First of all, I'm a beginner in mongoDB so please be patient with me. I'm using windows and I created a simple database that contains 4 collections. When I'm dealing with mongoDB, I first run: mongod.exe --dbpath "Path To Data Folder" in a terminal and then I connect to the mongod using mongo.exe. What I'm supposed to do is to distribute the database along with its collections into shards and replica sets for supporting distributed queries.
I tried to use commands like sh.enableSharding("DATABASE NAME") but it didn't work. I then figured out that I need to run mongos instead of mongod, so I followed this: Sharding in MongoDB but unfortunately I didn't succeeded. I also did some research but it seems there is a lack of to-the-point guides on sharding and replication. So if you point me to the right direction, I would really appreciate it.
You can't enable sharding on a single database instance. You need to have at least 3 config server instances, two database (mongod) instances and a router instance (mongos). All of them should be running in the same time (i.e don't close the terminals in which you started all your instances).
A good starting point for you is to read the sharding tutorial in Deploy a Sharded Cluster - MongoDB.org
I am supposed to setup mongodb on 4 servers (a school project to benchmark mongodb, vs others). So I am thinking of using only sharding without replication. So I attempted to setup the 1st 3 server to run mongod --configsvr, and the 4th just a normal mongod instance. Then for all servers, I run mongos. Then I am at the part where I run sh.addShard("...") and I get
{
"ok" : 0,
"errmsg" : "the specified mongod is a --configsvr and should thus not be a shard server"
}
Seems like I cant have a config server running as a shard too? How then should I set things up?
No, the config server is not a shard. The config server is a special mongod instance that stores the sharded cluster metadata, essentially how the data is distributed across the sharded cluster.
You really only need 1 mongos instance for a simple setup like this. When you start mongos, you will provide it with the hostname(s) of your config server(s).
The Sharded Cluster Deployment Tutorial explains all of the steps that you need to follow.