pg_upgrade on AWS EC2 linux - pg_hba.conf settings - linux

I am running an Amazon EC2 CentOS 6.6 server instance with pre-installed PostgreSQL 8.4.20 server which I want to upgrade to 9.4.1 using pg_upgrade via SSH.
What I've done so far: Downloaded and installed PostgreSQL 9.4.1 with yum, configured it. Configured the postgres user to have the same password on the UNIX server and for both database instances. Both database instances are functioning correctly - old one on port 5432, new on 5433.
What I am trying to do:
su - postgres
/usr/pgsql-9.4/bin/pg_upgrade
-b /usr/bin/
-B /usr/pgsql-9.4/bin/
-d /var/lib/pgsql/data/
-D /var/lib/pgsql/9.4/data/
Here is my issue with pg_hba.conf. Using
TYPE DATABASE USER METHOD
local all all trust
or
TYPE DATABASE USER METHOD
local all all peer
I can't start the old server, getting:
Performing Consistency Checks
-----------------------------
Checking cluster versions ok
connection to database failed: fe_sendauth: no password supplied
Failure, exiting
Using the default setting
TYPE DATABASE USER METHOD
local all all ident
is the only method that allows me to start the server, but then I get the following error:
Performing Consistency Checks
-----------------------------
Checking cluster versions ok
*failure*
Consult the last few lines of "pg_upgrade_server.log" for
the probable cause of the failure.
connection to database failed: 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.50432"?
could not connect to old postmaster started with the command:
"/usr/bin/pg_ctl" -w -l "pg_upgrade_server.log" -D "/var/lib/pgsql/data/" -o "-p 50432 -c autovacuum=off -c autovacuum_freeze_max_age=2000000000 -c listen_addresses='' -c unix_socket_permissions=0700" start
Failure, exiting
I have been reading more than 10 hours straight everything related, before I posted this, but can't seem to find the solution. Will be very grateful if you can give me any hints.

Related

Can't connect to database from snapshot. Ubuntu 18.04 postgres 9.5

I'm trying to connect to database restored from disk snapshot. I have new VM with ubuntu 18.04. I installed postgres, postgres-client and postgres-contrib from *.deb files. Then I mounted managed disk into machine with database and tried to connect - no success.
Postgres server running good, cluster ok, status ok, pg_isready ok. Until I change the data_directory in postgresql.conf from default to mounted - /snapshot_data_path/. After that my cluster is down and I cannot use psql in postgres (error ~ .s.PGSQL missing. File dissapearing from default directory).
chown -R to /snapshot_data_path - done, looks ok.
I think my database is running manualy when I use :
/usr/lib/postgresql/9.5/bin/postgres -d 3 -D /database/postgresql/9.5/main -c config_file=/etc/postgresql/9.5/main/postgresql.conf with that new path. EDIT: Error, I can connect but no data inside.
I try search over the internet for similar problems - no luck.
Is it possible to take database from 1 VM and connect it with another fresh VM? Or I must use pg_dump to achieve that?
Here the official documentation on this topic: https://www.postgresql.org/docs/9.0/backup-file.html
The database server must be shut down in order to get a usable backup.
Did you shutdown the server while the data snapshot was taken?

Remote access to an Azure Postgres database

How can I connect to an Azure PostgreSQL database, from a remote machine?
Update 2. I can connect to the database from WSL/Ubuntu using sudo psql, but I can't using plain psql. So it's a permissions issue somewhere...
Update. I've discovered I can connect from the remote machine using PgAdmin4, but I can't connect using psql. So I want to know: how should I connect using psql?
Original question. I can connect to it using psql from a VM inside Azure, so I know the database is up and accepting connections.
But when I try to connect from my home machine, using exactly the same psql command, it fails:
psql --user=UUU --host=HHH DB
psql: server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
More information...
On the Azure database's "Connection Security" blade, I have
added a firewall rule with start IP=0.0.0.0 and end IP=255.255.255.255
set "enforce SSL connection" to disabled
turned on "allow access to Azure services".
My home machine is running Windows+WSL, and I'm trying to connect from WSL / Ubuntu 18.04
using psql version 10.11. I run into the same problem whether I try to connect from home or from work, and I'm not blocking any outgoing ports (that I know of).
The database is running PostgreSQL 10.
When I connect (successfully) from an Azure VM, using psql 10.10, it looks like this:
psql --user=UUU --host=HHH DB
Password for user UUU:
psql (10.10 (Ubuntu 10.10-0ubuntu0.18.04.1))
SSL connection (protocol: TLSv1.2, cipher: ECDHE-RSA-AES256-GCM-SHA384, bits: 256, compression: off)
Maybe your root user uses a different psql binary than your user. ( You can find out using
which psql and sudo which psql )
I Ran into the same connection issue. In my case, the base issue was a postgres major version mismatch.
I was connecting to an Azure Postgresql on version 11 with my local psql on version 12. Downgrading my local machine's Postgres version to 11.6 solved this for me.
Maybe your root user is using psql 10 and your default user is using psql 11 or 12. ( You can check this using psql -V and sudo psql -V )
I had the same issue. The error message sucks and is of 0 help.
You're probably using a different version of psql than your Azure DB. It needs to match whatever is installed in Azure.
So if you provisioned a version 10 DB in Azure, either you install version 10 for the pqsl tool or do a full Postgre version 10 install instead. The point is the major versions need to match between psql and the target database.

Error when install postgresql in linux mint sarah

I want to install postgresql in my computer Linux mint sarah, and I finish procedure installation but when I type psql in my cmd postgres error, like this :
Error when install PostgreSQL
psql: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
how I fixed that ??
thanks
The error states that the psql utility can't find the socket to connect to your database server.
Either you don't have the database service running in the background, or the socket is located elsewhere, or perhaps the pg_hba.conf needs to be fixed.
Step 1: Verify that the database is running
The command may vary depending on your operating system. But on most *ix systems the following would work, it will search for postgres among all running processes
ps -ef | grep postgres
On my system, mac osx, this spits out
501 408 1 0 2Jul15 ?? 0:21.63 /usr/local/opt/postgresql/bin/postgres -D /usr/local/var/postgres -r /usr/local/var/postgres/server.log
The last column shows the command used to start the server, and the options.
You can look at all the options available to start the postgres server using the following.
man postgres
From there, you'd see that the options -D and -r are respectively the datadir & the logfilename.
Step 2: If the postgres service is running
Use find to search for the location of the socket, which should be somewhere in the /tmp
sudo find /tmp/ -name .s.PGSQL.5432
If postgres is running and accepting socket connections, the above should tell you the location of the socket. On my machine, it turned out to be:
/tmp/.s.PGSQL.5432
Then, try connecting via psql using this file's location explicitly, eg.
psql -h /tmp/ dbname
Step 3: If the service is running but you don't see a socket
If you can't find the socket, but see that the service is running, Verify that the pg_hba.conf file allows local sockets.
Browse to the datadir and you should find the pg_hba.conf file.
By default, near the bottom of the file you should see the following lines:
# "local" is for Unix domain socket connections only
local all all trust
If you don't see it, you can modify the file, and restart the postgres service.

Bacula bconsole doesn't connect to localhost Centos7

I've recently installed Bacula on Centos7 Cloud HaaS from digital ocean. However, all the tests and steps were done correctly, the problem is when I try to connect to bacula's console using the command:
sudo bconsole
I get Connecting to Director localhost:9101 and nothing happens.
If i try listening:
netstat -ltnp
No outputs are present from the port 9101
After trying debugging using:
bacula-dir -d 100 -c /etc/bacula/bacula-dir.conf
I get the following output:
bacula-dir: dird.c:223-0 Debug level = 100
[root#panel ~]# 14-أكت 11:37 bacula-dir: ERROR TERMINATION at bsys.c:484
bacula-dir is already running. pid=2458
Check file /var/run/bacula-dir.9101.pid
Any clue what to do in order to get the bconole to work?
Resolved.
Database user was not connected to the configuration files.
To fix this login to mysql as root:
mysql -u root -p
Enter your root password, then create a DB user and password for Bacula.
(Assuming you already entered your db password inside "bacula-sd.conf"
Now lets set Bacula to use the Mysql library:
su -c 'alternatives --config libbaccats.so'
This should show you the following:
There are 3 programs which provide ‘libbaccats.so’.
Selection Command
————————————————————————
1 /usr/lib64/libbaccats-mysql.so
2 /usr/lib64/libbaccats-sqlite3.so
*+ 3 /usr/lib64/libbaccats-postgresql.so
Hit 1 and press enter to select MySql.

Trying to use mongodump with remote server heroku using mongolab

In my computer i'm running this command to make a backup of the information of some mongodb database.
mongodump -h <hostName>:<port> -d <databes> -u <user> -p <pass> -o direction/where/to/make Backup
But gave to me this error:
Failed: error connecting to db server: no reachable servers
I try to connect robomongo with the same user, pass, host and databes and it's work fines.
Version of mongo 3.0.1
Thanks.
This is basically what I figure from this link
The new mongo tool set doesn't work too well with Unix Domain Socket . The issue is still open.
If you're connecting via hostname try using the IP as the link suggests.
Hope this helps.

Resources