Access MONGODB database in windos server from docker executing in WSL2 - mongodb

I'm trying to implement a small API in docker and i need that API writes to a database which is hosted on the same server but running on windows server 2006
I can't change the OS in the server because that server also works as a gateway for Powerbi
Should i mount the volume to (I'm guessing C:/mongodb/data) or should i make the insert by the localhost
These are my limitations :
host: running windows server 2006 (cant change this)
app: a container running in windows subsystem for linux (it has to run on linux because i need async functions and i only have knoweldge in python|nodejs) but it has to persist the data in the mongo database running on host
mongo database : it has to be running in windows server because a Power Bi Gateway is running comsuming data
keeping with diagrams maybe this will help to explain this in a better way

As far as I understand your system is as in the picture. You want to write data to MongoDB. There should be a network bridge to connect between the host and the Linux environment. You can access MongoDB via bridge IP. If you want to run another MongoDB and mount disk where is in the host. It is not reliable because the data may conflict.

Related

Connect PostgreSQL to rabbitMQ

I'm trying to get RabbitMQ to monitor a postgresql database to create a message queue when database rows are updated. The eventual plan is to feed this message queue into an AWS EKS (Elastic Kubernetes Service) cluster as a job.
I've read many many approaches to this but they are still confusing as a newcomer to RabbitMQ and many seemed to be written more than 5 years ago so I'm not sure if they'll still work with current versions of postgres and rabbitmq.
I've followed this guide about installing the area51/notify-rabbit docker container which can connect the two via a node app, but when I ran the docker container it immediately stopped and didn't seem to do anything.
There is also this guide, which uses a go app to connect the two, but I'd rather not use Go ouside of a docker container.
Additionally, there is also this method, to install the pg_amqp extension from a repository which hasn't been updated in years, which allows for a direct connection from PostgreSQL to RabbitMQ. However, when I followed this and attempted to install pg_amqp on my Postgres db (postgresql 12), I was unable to connect using psql to the database, getting the classic error:
psql: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
My current set-up, is I have a rabbitMQ server installed in a docker container in an AWS EC2 instance which I can access via the internet. I ran the following to install and run it:
docker pull rabbitmq:3-management
docker run --rm -p 15672:15672 -p 5672:5672 rabbitmq:3-management
The postgresql database is running on a separate EC2 instance and both instances have the required ports open for accessing data from each server.
I have also looked into using Amazon SQS as well for this, but it didn't seem to have any info on linking Postgresql up to it. I haven't really seen any guides or Stack Overflow questions on this since 2017/18 so I'm wondering if this is still the best way to create a message broker for a kubernetes system? Any help/pointers on this much appreciated.
In the end, I decided the best thing to do was create some simple Python scripts to do the LISTEN/NOTIFY steps and route traffic from PostgreSQL to RabbitMQ based off the following code https://gist.github.com/kissgyorgy/beccba1291de962702ea9c237a900c79
I set it up inside Docker containers and set them to run in my Kubernetes cluster so they are within the automatic restarts if they fail.

Mongo dbshell command history

I am trying to find the location of .dbshell storing, but I can't manage to find.
May I know normally where does it storing?
Environment:
Docker mongo
The server is installing in GCP, I am using debian server and run with ssh to manage the server.

Connect a Mongodb Docker Container Running on Server to Robo 3t on my Computer

I'm trying to deploy my first web app and I decided that it would be a good training to be able to connect my empty Mongo DB (inside its own docker container) itself running in a Digital Ocean server to Robo3t on my computer.
I could find several guides explaining how to either do it for a DB running directly on the server or inside a container but not on a remote server.
To be honest I'm a bit lost right now because I'm still completely new to these things. So I don't even what's the strategy I need to use...
Your help will be greatly appreciated, many thanks in advance!
You have to bind ports when you build the image with -p 80:80 for example. Change 80 with your port. Next step is open port in the remote machine. So then you can connect Roboto 3T with your db.

How do I connect to the postgres from my home OS using a GUI client like postico?

I am running the Django Cookiecutter on Docker and tried to connect to the postgres database using Postico, a GUI client on my laptop.
The credentials I used was basically the same as .envs/.local/.postgres Yet I still cannot connect.
I wonder what's the issue that's blocking me from doing so?
The issue is that I wasn't aware that Docker allows you to state which ports get mapped to the host OS.
See https://docs.docker.com/compose/compose-file/#network_mode for details.
Specifically, I needed to go to local.yml under postgres definition and add:
ports:
- "5432:5432"
Then restart the docker.
In case you want to map different port number note that the syntax is
the HOST:CONTAINER format

Restart PostgreSQL Remotely

Can I remotely restart a PostgreSQL server throught PGAdmin ? The user I currently is the administrative privileges.
Regards,
Dino
I don't think there is such possibility. At best you can reload connected PostgreSQL server using pg_reload_conf() function:
pg_reload_conf sends a SIGHUP signal
to the server, causing configuration
files to be reloaded by all server
processes.
Command:
SELECT pg_reload_conf();
You can also install adminpack contrib module and reload server using Tools menu.
EDIT:
According to pgAdmin documentation:
If pgAdmin is running on a Windows
machine, it can control the postmaster
service if you have enough access
rights. Enter the name of the service.
In case of a remote server, it must be
prepended by the machine name (e.g.
PSE1\pgsql-8.0). pgAdmin will
automatically discover services
running on your local machine.
If pgAdmin is running on a Unix
machine, it can control processes
running on the local machine if you
have enough access rights. Enter a
full path and needed options to access
the pg_ctl program. When executing
service control functions, pgAdmin
will append status/start/stop keywords
to this. Example: sudo
/usr/local/pgsql/bin/pg_ctl -D
/data/pgsql
You can try use Start Service/Stop Service options (in Tools menu) to restart remote server.