enabling multiple instances of mongodb on Ubuntu 20.04 - mongodb

I am working on a SaaS application where there will be a separate database for each tenant and one landlord/master database for the landlord. So
foo.example.com will connect the sales_foo database
bar.example.com will connect the sales_bar database and so on.
Now I have two environments, staging and testing both on the same server managed by a virtual host. So the problem is if I have 10 tenants then there will be 10 databases plus one landlord database. These all databases should be in one environment and one environment should not access other environment's databases. How can I achieve this?
Till now I have created separate .conf file for each environment and I can start mongod process with that conf as well. But how can I keep it enable all the time? Is it possible?
On a side note, I am using laravel for interacting with database.

Related

How to create a READ replica for postgreSql database on local machine?

I have a use case where I have keep sync two databases on my local windows machine.
For example DB_primary and DB_secondary both has one table employee.
How to create a read replica to keep both those DBs in sync?
Please note: I am not using any cloud. I have Postgresql v14 installed on my windows machine.

Firebird local vs remote connection

I have a cloud-service based on firebird databases. Every customer has his own database file. So many connection-definitions are loaded into my service at startup. This works all well.
Currently the load for the server is ok so the database files are on the same machine as the service itself. Later I could extend it by another server.
My question is:
Does it matter if I use a local firebird connection or should I prefer a remote connection (via TCP/IP). Although I am on the same machine.
Are there advantages / disadvantages or any limits? I got a lot of requests to this server.
I am using Firebird 2.5.7 (64Bit).

Postgresql server to server replication

Say I have two remote servers 10.0.0.1 and 10.0.0.2. In both the servers I have postgresql database installed with the same databases. Now what I need is, whatever changes or alterations that are done to the database on server 10.0.0.1 should automatically be replicated to the database on server 10.0.0.2.Is there any way to do this automation process? If So, Please suggest me the best and most efficient way of doing this. The version of postgresql I am using is 9.5.3.
That article by Digital Ocean seems to describe every step well enough — how to setup master slave replication on postgresql

Replicate only certain databases

I have one instance of database on local server, another on remote. So when internet is gone, application works on local database. After internet connection is reestablished I want to sync these two databases. I have two questions:
How to replicate only one database. (there are several databases on instance);
I have only succeeded to replicate instances on same machine (when one host is localhost and another is remote instance, it throws error), how to replicate database on different machines?
How to replicate only one database. (there are several databases on instance);
You can make the other database as Arbiter. It does not have a copy of data.
I have only succeeded to replicate instances on same machine (when one host is localhost and another is remote instance, it throws error), how to replicate database on different machines?
looks like a network setup problem to me. Test Connections Between all Members

Mirror one database to another in PostgreSQL

I know the way to set up a Master/Slave DB in Postgres is having 2 DB servers, but unfortunately i have only one server for now.
How can i mirror my production db into another "backup db" in "real_time"? I want to give access to another user to the mirrored db, so even if he does something there it will not affect production.
Nothing stops you setting up hot standby streaming replication, or another replication option like Londiste, between two PostgreSQL instances on the same computer.
The two copies of PostgreSQL must use different ports, but that's the only real restriction.
How to set up the second PostgreSQL instance depends on your operating system and how you installed PostgreSQL, which you have not mentioned.
You'll want to use streaming replication with hot standby if you want a read-only replica. If you want it to be read/write, then you can do a one-off copy of the database with pg_basebackup and not keep them in sync after that. Or you can use a tool like Londiste to replicate changes selectively.
You can run multiple instances of PostgreSQL on the same computer, by using different ports.