Prisma + MongoDB -> Replica set - mongodb

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 :)

Related

Restart MongoDB Replica Set

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 ?

Mongo DB BI Connector with Tableau not working with sharded instance

I've been trying to follow these instructions https://onlinehelp.tableau.com/current/pro/desktop/en-us/examples_mongodb.html#make_cx
to get the tableau desktop to connect to my mongo db server. looking at the data source example in the link above they only have 1 server listed where I have a replica set, which I think might be an issue.
i was wondering if anyone has an example connecting tableau to mongo where mongo is on a replica set?
It should work. When you setup the Mongo BI Connector, you can specify a standard Mongo URI connection string with multiple replicas. However, when connecting from Tableau, you specify the hostname of the server where the Mongo BI Connector service is running. It will use the uri connection string you defined.
See: https://docs.mongodb.com/bi-connector/master/reference/mongosqld/#cmdoption-mongosqld-mongo-uri

mongo config server with mongo cluster

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.

Connect directly to the "local" database of primary MongoDB node in replica set

I need access to the OpLog of the primary of my replica set in MongoDB. I am developing an OpLog driven ETL job as it is far more efficient than simply querying and transferring data from the entire table.
I can access the OpLog easily with the following steps in the terminal:
mongo mymongoserver.com:10733/my-db -u oplogUser -pxxxxxxxx
Then I run:
use local
and then I can query the OpLog using:
db.oplog.rs.find()
My question is: Are there any settings I can pass to the mongo connect command to get me straight into the local database for the primary node?
I am using Talend Open Studio for my ETL needs. Am I approaching this the wrong way?
I have come across this from the guys at Stripe, which means that this is definitely possible! https://www.mongodb.com/presentations/building-real-time-systems-mongodb-using-oplog-stripe

Sharding & Replication in mongodb

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