Oracle DB active/passive setup with Node.js - node.js

I want to understand how the Oracle db active passive connection works with Node js. Currently my project is using loopback Oracle connector node module. What configuration I have to do in db or app or env level to complete the setup.

Asuming you connect through a connection pool you don’t need to do anything since the connection pool should take care of failed connections, as long as one succeeds.
This ofcourse assumes a correct sqlnet configuration in the connection pool, that by itself should be prefixed by a vip.

Related

Connecting to documentDB using mongodb 4.x node driver with port forwarding not working

I have locally setup a port forwarding to the documentDB that is working successfully on the mongodb driver versions 3.x. When I update the mongodb package to 4.x I am getting an error of a timeout with the reason ReplicaSetNoPrimary.
The code is very simple:
const MongoClient = require('mongodb').MongoClient;
const client = new MongoClient('mongodb://xxxx:xxxx#localhost:27017');
client.connect(function(err) {
if (err) {
console.log(err);
return;
}
const db = client.db('testdb');
console.log("Connected successfully to server");
client.close();
});
Has anyone been able to connect to the documentDB locally using port forwarding with the 4.x driver? Am I missing some sort of config options? (Keep in mind I have disabled all tls and everything to make it simpler to connect and as previously stated, successfully connect when using the mongodb 3.x packages)
When connecting to a replica set, the driver:
uses the host in the connection string as a seed to make an initial connection.
runs the isMaster or hello command on that initial connection to get the full list of host:port replica set members and their current status
drops the initial connections
connects to each of the members discovered in step #2
during operations, automatically monitors all of the members, sending operation to the primary even if a different node becomes primary
In your scenario, even though you are connecting to localhost, the initial connection returns the host:port pairs that are included in the replica set configuration.
The reason that this just became a problem is the MongoDB driver specifications changed to use unified topology by default.
Unified topology permits the driver to automatically detect if it is connecting to a standalone instance, replica set, or sharded cluster, which simplifies the connection process and reduces the administrative overhead required when changing how the database is deployed.
Since your connection is failing, I assume the hostname:port pairs listed in the replica set config are either not resolvable or not reachable from the test host.
To resolve this situation either:
make it so this machine can resolve the hostnames via DNS or hosts file, and permit the connections to those ports through any firewalls
use the directConnection=true connection option to disable topology discovery

SailsJS: not able to connect to postgresql database

We have SailsJS app with postgresql adapter. Requests made to server chokes at database query via models. i.e Users.find(). Database server is up and running, connection string is correct and one can connect to database using same connection string.
datastore has default adaptor set to sails-postgresql. If database adaptor is changed to mysql or default sails-disk, it works. But sails-postgresql is not

MongoDb in Fastcomet shared hosting server

I haven't created an account in fastcomet yet, but I would like to ask the following questions. The site mentions that it supports node.js applications. So that means I can upload an express application right? How about MongoDB and mongoose? I can access MongoDB by typing in the terminal
$ mongod --dbpath=data -bind_ip 127.0.0.1
And the MongoDB URL in my case is
mongodb://localhost:27017/ilovearisti
How different would it be in fastcommet? I guess I'll have to contact them for the port numbers right?
Thanks,
Theo.
FastComet Team here! Indeed, our hosting plans are fully compatible with Node.js apps and you can have your project hosted on an appropriate package.
If you plan using the MongoDB database type in particular, our experience shows it requires a server solution with more resources and a higher level of private access. This way you would be able to accommodate the operation on an environment suitable for coding with Mongoose on top of the MongoDB driver for Node.js.
As for addressing your URL query, the default IP when starting a mongo instance is set to 127.0.0.1, so it is configured as localhost and port 27017. With this in mind, you only need to make changes on the IP configuration via the mongod daemon if you are using a remote database setup with a different IP address.
Having said all of the above, we can confirm that if you have created a database called iloveiristi, the MongoDB URL will be as follows:
mongodb://localhost:27017/iloveiristi
We hope this information proves useful and we wish you good luck with your project.
Best regards!

Gracefully disconnecting to from mongodb atlas upon restarting via nodemon

The current application is in development phase and nodejs server is restarted everything any file changes. This lets mongoose reconnect to the MongoDB server.
I am the only one user to connect to remove MongoDB atlas by I don't know how its showing 5 connections are already opened. I don't know-how.
Is there any way to disconnect from MongoDB server before restarting of the application
I am the only one user to connect to remove MongoDB atlas by I don't know how its showing 5 connections are already opened.
There are internal connections used by MongoDB for various purposes like replica set node communications.
Is there any way to disconnect from MongoDB server before restarting of the application
There surely must be but if you are concerned for Atlas having extra connections open, at this scale (5 connections) it is really not worthwhile worrying about it.

Procedure for creating a database locally using mongodb

I've connected to mLab using MongoClient.connect, but now I want to create a local database rather than use mLab. I've tried changing the URL to "mongodb://localhost:27017/mydb" to create a database locally as suggested, but I'm getting a failed to connect to server error. Is there anything I should install? Or am I just missing something?
First, install your mongoDB server:
https://docs.mongodb.com/manual/installation/
After that, you should be able to start your local mongodb server:
sudo service mongod start //in case of linux
Here the docs to start the mongodb server
Then, you will type mongo and the client command line will start.
And when typing use yourDatabase, mongo will create the database if
it does not exist.
Then, your server will be up, and the database created. Anyway, check the docs if you need the guides for windows or other systems.
First you need to understand how server works and mlab works. mLab is a company who provide database as a services. Means you no need to handle server hurdles, they take care server , backups , infrastructure etc. They provide mongodb server , You just need to create database on mongodb server's and use them.
Now comes to main points.
If you want use mongodb on your local system then you first need to install mongodb on your local system and then connect it.

Resources