pgpoolAdmin - superuser: unknow (connetion error) - pgpool

After login i got following message.
create -> /var/www/.pcppass
#insert:hostname:port:username:password
*:*:admin:postgres
*:*:postgres:postgres
*:*:administrator:postges
host$ sudo chown www-data .pcppass
... and it don't works :-/

After long time searching it seems the issue is related to pg_hba.conf and pool_hba.conf incompatibility when using wrong combinations of trusted and md5 host entries. See here and the FAQ. Those links shows how to correctly pair both conf files with this matrix :
You have to set default entries according to this matrix in order to get the so called "superuser" in pgpoolAdmin to be enabled and also to be able to allow connection throught pgpool.
I also found this answer here that helped me finally achieving to enable correct connection to backend servers: I had to mark the pgpool server as a trusted server on local network on pg_hba.conf on my postgresql servers.

Related

gcloud beta sql connect "server closed the connection unexpectedly"

When trying to get a psql shell (not using iam user) I am receiving:
> gcloud alpha sql connect pg-instance --database mydb --user myuser --project my-project
Starting Cloud SQL Proxy: [/Users/me/google-cloud-sdk/bin/cloud_sql_proxy -instances my-project:us-central1:pg-instance=tcp:9470 -credential_file /Users/me/.config/gcloud/legacy_credentials/me#me.com/adc.json]]
2022/03/15 14:47:59 Rlimits for file descriptors set to {Current = 8500, Max = 9223372036854775807}
2022/03/15 14:47:59 using credential file for authentication; path="/Users/me/.config/gcloud/legacy_credentials/me#me.com/adc.json"
2022/03/15 14:48:00 Listening on 127.0.0.1:9470 for my-project:us-central1:pg-instance
2022/03/15 14:48:00 Ready for new connections
Connecting to database with SQL user [myuser].Password:
psql: error: connection to server at "127.0.0.1", port 9470 failed: server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
I had the same error message when connecting to Postgres(Cloud Sql) using a service account.
In my setup I did run cloud_sql_proxy inside docker container.
In order to make it work I had to add extra configuration defined in step #9 https://cloud.google.com/sql/docs/sqlserver/connect-docker#connect-client
docker run -d \
-v <PATH_TO_KEY_FILE>:/config \
-p 127.0.0.1:5432:5432\
gcr.io/cloudsql-docker/gce-proxy:1.33.1 /cloud_sql_proxy \
-instances=<INSTANCE_CONNECTION_NAME>=tcp:0.0.0.0:5432 -credential_file=/config
The missing bits were: host ip on port mapping and 0.0.0.0: in cloud_sql_proxy command
There are a few things I would like to point out. The best starting point for me would be the About connection options page; both the Overview and the Before you begin sections are very helpful to get the full idea of the process and how to properly configure the user. But the most important part is the Connection Options, for the message connection to server at "127.0.0.1" I’m guessing it is a private IP, but please make sure this section is covered before starting to debug.
In your case, the logs are saying there was an error in the connection to the server…
I used the Troubleshoot guide that includes the Diagnose issues link to get to the Debug connection issues page that has a lot of useful information on how to debug any connectivity issue.
Generally, connection issues fall into one of the following three areas:
Connecting - are you able to reach your instance over the network?
Authorizing - are you authorized to connect to the instance?
Authenticating - does the database accept your database credentials?
Each of those can be further broken down into different paths for investigation.
Once determining the connection method, there are different questions that will help to guide you through the possible troubleshooting paths.
If using these guides doesn’t get you a solution, please make sure to update your answer with the results, steps, and information followed to provide further help. This would be a good example, as it has the same log error, and this other question shows that there are a few different troubleshooting paths for this specific log message, plus they have useful information for you.

POSTGRESQL: Cannot log in postgresql in debian 9

I am trying to log in my postgresql.After researching I have solved a slew of many issues from a weird python dependency issue to creating sudoers with names and passwords as db to removing and reinstalling postgresql, still i cannot log in as the default user "postgres".
A simple error but i cannot find a straight forward answer.
Is the server running locally and accepting
connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
NOTE:
My first installation,postgresql 11, I changed pg_hba.conf from peer to md5 but refused to login.
I removed postgresql 11 using many commands to purge it out of my system but am shocked anytime i do a locate postgress or locate psql i find a list of postgresql files. The most weird is running *apt-get remove --auto-remove postgresql* and sudo apt --purge remove postgresql -y then running service postgresql start only for it to start!Cannot wrap my head around this after trying several times, i thought it would be removed completely?!.
Though I can locate pg_hba.conf, the actual file is totally nonexitent when I ls the containing directory!!! Are there many /etc/ folders, seems am looking at the wrong /etc/ ?
I also faced this problem - You try this method, it's work for me.
If You using Linux then do according your server path .
Window Path ->
Go To -> C:\Program Files\PostgreSQL\11\data then Open pg_hba.conf
Find and replace md5 or sha256 to trust
local replication all trust (Change md5 or sha256 to trust)
host replication all trust (Change md5 or sha256 to trust)
Maybe this method helpful for you.

Postgresql failed to start. Reboot is resetting the permission given to /var/run/postgresql/

FATAL: could not create lock file "/var/run/postgresql/.s.PGSQL.1111.lock": Permission denied
psql: could not connect to server: Connection refused
Is the server running on host "S01B01" (10.10.222.193) and accepting
TCP/IP connections on port 1111?
Could you please help me in getting a permanent fix for this.
postgresql.conf:
data_directory = '/apps/ins/router/pgdata'
hba_file = '/apps/ins/router/pgdata/pg_hba.conf'
pg_hba.conf:
host all ins 10.10.10.10 255.255.255.255 trust
host all ins 127.0.0.1 255.255.255.255 trust
Both socket directories for PostgreSQL (/run/postgresql and /var/run/postgresql) are temporary directories created at boot time. (The /var/run/postgresql is in fact usually a symbolic link to /run/postgresql).
With the advent of systemd, a new mechanism called systemd-tmpfiles has been introduced to manage temporary files and directories.
Systemd-tmpfiles creates temporary directories during boot and sets their owner, group and permissions. It may read configuration files in three different locations. Files in /etc/tmpfiles.d override files with the same name in /usr/lib/tmpfiles.d and /run/tmpfiles.d.
Check those configuration directories for PostgreSQL configuration, usually postgresql.conf. (You will most likely find it at /usr/lib/tmpfiles.d/postgresql.conf.) The file will contain something like the following line:
d /run/postgresql 0755 postgres postgres -
You can change permissions, owner and group by editing that line. The recommended way to make such changes, however, is not to directly edit files under /usr/lib/tmpfiles.d/, but to copy configuration files over to /etc/tmpfiles.d/, and make the necessary changes in that copy instead.
Another way to fix the issue is to relocate the PostgreSQL lock file location. We can do so by using below query
ALTER SYSTEM SET unix_socket_directories='<any-existing-path-with-valid-permissions>, /tmp';

Error connection pgadmin 4

I add a server and there are Error like this
I use pgadmin4
How I can Fix this?
Firstly, check if the server is listening.
Use the following command on your server:
netstat -nlt|grep :5432
If it's ok, SSH (or whatever method you use to access the server) to your server and view the file:
/etc/postgresql/9.1/main/postgresql.conf
Find the line start with:
listen_addresses=
If the value after "=" is 'localhost', it means that you cannot connect from outside. To be able to do so, change it to:
listen_addresses='*'
Now you will be able to connect from anywhere, outside from the server itself. And, don't forget to restart you DBMS and check if it works.
Ah. One more thing, you may also need to give your user access rights to your database as well.
Open the file:
/etc/postgresql/9.1/main/pg_hba.conf
And add:
host all all * md5
You also need to restart you DBMS to fire up changes.
P/s: You should enable SSL.

MySQL workbench SSH connection error [Bad authentication type(allowed_types=['publickey'])]

I have issue regarding SSH connection with my server. When i try to connect it results into error:"Bad authentication type(allowed_types=['publickey'])"
Thanks
You need to ensure that your private key is in openssh format. With puttygen you can export as Openssh. This worked for me.
Check your username and public key this can cause problem.
Attach the private key file with extension .ppk
Also verify your connection with putty.
Also check for the restriction on server.
FYI, my company uses a Yubikey and so the SSH part can be a bit mysterious. However, walking through a shell login with the yubikey yinit command, to ssh to IP (no password needed here), and finally to connecting mysql (still shell), I attempted to MySQL Workbench a few times with my different passwords to no avail.
Finally, I noticed the "SSH Key File" field and looked up where my .ssh file was -- /Users/myProfile/.ssh/
Set the "id_rsa.pub" file as it and voila!
Everything worked.