Hosting a database on a VM [closed] - mongodb

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I need some help understanding how to connect my local machine to a separately hosted database on a different machine.
Context:
I have ssh'd into my host machine (hereafter referred to as VM) and installed MongoDB. The VM runs CentOS and I have no restrictions beyond that.
Goal
My goal is to interact with the VM remotely via my local client on my local machine (Mac), perhaps through some sort of API (direct connection works as well). I'm willing to create that API, but I need to actually establish some sort of contact before that can happen. How can I actually deliver requests from my local machine to the VM, and therefore to my database?
Edit #1:
I should add that this is not exclusive to MongoDB and its host machine. I have several other NoSQL databases (each on their own individual machine). I'm hoping that if I can find a way to make one work, the rest will follow the same pattern.

Answer:
I found out that the firewalls were preventing me from connecting to MongoDB on my remote server. So here is how I finally connected and verified:
Remote Server
Stop the firewall:
systemctl stop firewalld
Start up Mongo:
mongod
Local Client
Form connection using Mongo
mongo REMOTE_IP
or
mongo REMOTE_DOMAIN_NAME

Related

How to load an existing database dump into AWS RDS PostgreSQL Instance [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed last year.
Improve this question
I have a database dump which I want to load into my RDS PostgreSQL instance. However I'm unable to do so, please suggest ways to do that.
RDS is just a database service, which will give you working PostgreSQL database. Connect to it like you normally connect to your DB Instance and use client tool like "pgAdmin" which will give you many options to load the dump into DB.
Update:
You can't SSH into RDS server like you would do with EC2 instances. If you want to access your RDS via Bastion host and asking about how to SSH Tunnel into your RDS then your Bastion host should be accepting public SSH traffic. Have to update Security Groups to achieve that and should be in a subnet which has public access.
If you want to connect via CLI then follow this link: https://aws.amazon.com/premiumsupport/knowledge-center/rds-connect-using-bastion-host-linux/
If you want to connect using UI tool like PGAdmin then this might help: https://stackoverflow.com/a/62335972/970422

Check if database is running on production environment [duplicate]

This question already has answers here:
Query to check postgresql database status
(2 answers)
Closed 4 years ago.
I have a Postgres database in the production environment for which I don't have access to. All I want to do is to check if the database is up and running, Is there any command or program or anything to check this? Just need to verify if it's up as easy as possible. I know the password, the database, the host/servername and the database accountname
How do I use all of these parameters to check if the database is up and running. The guys that configured the production environment have made so that no one outside the production environment can touch it. The production environment is Linux and iam using windows in my virtual desktop
You can check for a connection on the default port, which the Postgres service is running.
Some Administrators use default ports for database services:
Try checking 5432 or 5433 as the default ports.
If you have Win and you're looking also for solution, then you may check some dedicated monitoring software like NetCrunch.

Installing Bugzilla with a sql database on a different drive - how to connect database? [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
I'm attempting to install Bugzilla on a server with a MySQL database on it already. The database is on E: (for space) and Bugzilla is on C:. Currently Bugzilla does not have a database associated with it, and the perl checksetup script looks for a drive local database.
How can I attempt to get bugzilla to target the database on my other drive? Is there a line I can change in the initial scripts to do this?
You tell Bugzilla how to connect to the database server in the localconfig file.
$db_driver = mysql
# The DNS name of the host that the database server runs on.
$db_host = localhost
I believe with MySQL you can also directly connect via a local socket. Be sure to follow the Bugzilla installation instructions for setting up a database, a database user and password for the connection to use. The tables will be set up automatically by Bugzilla's setup scripts.

Is it possible to establish an SSH tunnel between two Windows computers? (without a third-party web server) [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
The purpose of the question is to create a remote connection between two PostgreSQL databases. I currently use Navicat. I've read a lot of tutorials about using PuTTY and Cygwin to create the SSH server, but it only works on the local test, when I try with the public IP address in the other computer it doesn't.
In order to prevent this to become a private / particular problem I'll stick with how to get an SSH tunnel without a web server between two Windows computers. This is really a general problem for Windows users. I've tried in six different computers at my company and two at home and all the time is the same answer. From the research I've done in forums and here on Stack Overflow this is a common problem. I've attached two pictures to show that an SSH server runs smooth locally, but when you use the IP address assigned by your ISP, it fails.
I'm starting to think that doing this in a Windows enviroment is a bad idea.. ps. 1- When you install bitvise it automatically 'opens' port 22, so I think it's not a port problem. 2- My company's Internet provider and home's are different so I think this isn't an ISP problem either. I don't know what more it can be...
http://matheus25.site90.net/itworks.jpg
http://matheus25.site90.net/itdoesntwork.jpg
Yes, it's possible, but exactly what you need to do will depend on exactly what setup you have. A web server should not be necessary or relevant. I'm not clear exactly what connection you want, but in general you need 3 things:
An SSH client, on every machine that needs to login to a remote database
An SSH server, on every machine that needs to accept remote logins
The ability to connect from one to the other through whatever firewalls etc sit in between
Item 1 is trivial: you can install PuTTY, use its graphical application for testing, and the command-line plink for automated connections. It's possible that Navicat can also act as the SSH client itself, logging in over SSH and configuring the tunnel automatically, but I have no experience of that tool. PuTTY will certainly be useful for initial testing though.
Item 2 might be a little trickier: you'll need to install the SSH server and configure appropriate logins.
Item 3 may or may not be an issue: there may be a firewall next to both client and server which could restrict the traffic (generally on port 22) that constitutes the SSH connection, or it may already be open and ready to use. One way to test this is by running telnet address.of.remote.machine 22 from another location. If the connection fails, then something is blocking connections on that port; in that case, you will probably need to talk to the host of the server to ask them if you can have that port opened up.
Once you have that all working so that you can login manually with PuTTY, you need to configure your SSH tunnels, on the client end. These basically work by making a local network port on the client (say, port 5433) connect, via the SSH connection, to a different port on the server (for a standard Postgres install, port 5432).
So when you tell Navicat to connect to "localhost:5433", the connection is "tunnelled" and actually gives you data from port 5432 on some other server somewhere else. You will not tell Navicat that it is connecting to the public address of the remote machine, since that will just go over the public Internet, not the SSH tunnel.
If you are trying to re-invent database replication consider one of the production-ready solutions.
If you just want to copy selected data between databases, you can use the additional module dblink to copy data directly from DB to DB, optionally encrypted with SSL. The servers can be anywhere in the net.
A basic example to fetch data from another db (anywhere in the net) could look like this:
CREATE TABLE tbl (tbl_id integer, col1 text, col2 text);
SELECT dblink_connect('myserver');
-- FDW postgresql, USER MAPPING FOR postgres; PW from .pgpass
INSERT INTO tbl (tbl_id, col1, col2) -- same table exists on foreign server
SELECT *
FROM dblink('SELECT tbl_id, col1, col2 FROM tbl') AS b(
tbl_id integer
,col1 text
,col2 text);
SELECT dblink_disconnect();
You could easily encapsulate this in a function:
CREATE OR REPLACE FUNCTION foo()
RETURNS text AS
$func$
-- code from above goes here
$func$ LANGUAGE sql;
Call:
SELECT foo();
I am using a FOREIGN SERVER here. Basic example statements to create:
FDW (only if you don't already have it):
CREATE FOREIGN DATA WRAPPER postgresql VALIDATOR postgresql_fdw_validator;
Foreign server:
CREATE SERVER myserver
FOREIGN DATA WRAPPER postgresql
OPTIONS (hostaddr '1.2.3.4', port '5432', dbname 'mydb', sslmode 'require');
By adding sslmode 'require' to your connection string you enforce SSL encrypted connections only. Read more in the manual here.
User mapping:
CREATE USER MAPPING FOR postgres
SERVER myserver OPTIONS (user 'postgres');
And to simplify things and make it safe I am using the .pgpass file to provide a password. You probably need to read some documentation before you use any of this.

Postgresql error : Error : ACL arrays must be one dimensional when connecting through pgAdminIII 1.16 [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I am trying to connect to my remote postgresql database using pgAdminIII. I am able to connect to the database server via command line using psql client. But when I try to connect using pgAdminIII 1.16, I get the following error :
ERROR: ACL arrays must be one dimensional.
I have checked hba_conf entries. The same entries worked for another database server.
pg_hba is not relevant. ACL arrays are used to store privileges for database objects (database, schema, table, sequence, view, function, and so on).
So the problem is that either:
You have some weird data in one of ACLs
pgAdmin has a bug
Solution would be to:
Enable logging of all queries in remote database (for example: log_statement = all, or log_min_duration_statement = 0)
start pgadmin3, and let it connect, and error out
check in Pg logs what was the last query pgadmin issued, as it is likely the problem was with data from last query
analyze the data using psql connection, and either fix data in db, or report bug in pgadmin