Install Pgpool on a server different from the DB server - postgresql

I have 3 server (PgPool-II installed) and 2 Db (PostgreSQL installed) server.
I followed https://www.pgpool.net/docs/43/en/html/example-cluster.html
But can't execute psql template1 -c "CREATE EXTENSION pgpool_recovery"
What can i do?
Is it possible to install Postgresql and Pgpool on different servers in the first place?

You need to install Pgpool-II extension on the Postgresql machine to execute following command.
psql template1 -c "CREATE EXTENSION pgpool_recovery"
see details here:
https://www.pgpool.net/docs/43/en/html/install-pgpool-recovery.html
And yes, its possible to have Pgpool-II and Postgresql on two different machines.

Related

Should I remove psql after postgres uninstalling from Mac M1?

I am trying to remove postgresql completely from my Mac M1 and then install postgres 13.
There were postgres 14, postgres 11 and postgres 13 installed (simultaneously) on my computer. Due to versions conflict I decided to remove all my postgreses and install version 13 de novo.
To uninstall postgres completely, I followed these recommendations: https://blog.testdouble.com/posts/2021-01-28-how-to-completely-uninstall-homebrew-postgres/
Now I have:
% postgres --version
zsh: command not found: postgres
% which postgresql
postgresql not found
% psql testdb
psql: error: connection to server on socket "/tmp/.s.PGSQL.5432" failed: No such file or directory == NO DATABASES
%brew list also shows no postgres installed
but when I do
% psql --version
I see:
psql (PostgreSQL) 14.1
and
% which psql
/opt/homebrew/opt/libpq/bin/psql
So, I have front-end PostgreSQL 14 until now.
Is it normal that psql was not uninstalled with postgres server?
Of course some postgres files also remain in cache, as well as some Docker postgres images.
Should I remove postgresql14.1 client manually? Here I read that in such case after re-installation I can expect Error.
Or, in general: am I missing something that will prevent my computer from correct installing and running Postgres 13 locally and outside of Docker?
Thank you so much in advance for clarification.
Yes, Postgres client (psql) and PostgreSQL server are two separate software. Quite often you need psql in your workstation even if server is running somewhere else.
But if you don't need to connect any PostgreSQL server anymore from your workstation, you can remove psql. No harm done. And it is always easy to re-install if needed.

pgAdmin4 + WSL2: can't see dbs created with other client

I have followed the steps from here. I successfuly installed both postgres#12.8 in WSL2 and PGAdmin4 on Windows.
Once I start service in WSL and create a server connection in pgAdmin I am not able to see any databases create from the pgAdmin GUI or neither from psql client.
I tried to:
set env variable PGHOST to localhost
editing postgresql.conf to listen_addresses = 'localhost'
connecting pgAdmin server by localhost name and by IP 127.0.0.1
nothing works..
I just ran into the same issue.
If you try to access your DB installed with pgAdmin from WSL 2, make sure you didnt install postgreSQL from Windows, as sudo service postgresql start from WSL will also start the only postgresql service you need.
Basically, it means you need to install postgresql ( sudo apt-get install postgresql) and start it FROM WSL, and then just open pgAdmin from Windows. Do NOT install postgresql directly on Windows as then your pgAdmin might create your DBs into the postgresql service started in Windows and not from the one started from WSL.
Make also sure that pgAdmin is installed for the same user that your WSL 2 uses, if you use it from VSCode for example. Otherwise, for the same reason, your WSL may not be able to find the corresponding DB.
Note that you can list the DB existing on a specific port by running psql -p 5432 -l from WSL ( change 5432 by the port you want to use ).

PostgreSQL: How to unify versions?

On my Kubuntu machine, locally I was running PostgreSQL in a user-defined directory. Actually, an upgrade from Kubuntu 18.04 to 20.04 provided PostgreSQL12. Actually, I have:
$ psql --version
psql (PostgreSQL) 12.6 (Ubuntu 12.6-0ubuntu0.20.04.1)
$sudo -u postgres psql
[sudo] Passwort:
psql (12.6 (Ubuntu 12.6-0ubuntu0.20.04.1), server 10.16 (Ubuntu 10.16-0ubuntu0.18.04.1))
What do I have to do, to unify this (to version 12) without losing data in the user-defined directory? There are two version 10 packages (PostgreSQL-10 and PostgreSQL-client-10) and the same ones version 12: Is it OK and sufficient to remove the two from 10?
Thank you!
PostgreSQL is free to change how it stores data between versions. So just moving/copying the data directory is highly unlikely to be sufficient.
The simplest solution is to basically dump the data and then load it into the new server. If you start your new server running on a different port and different data directory, you can do this as one-liner.
pg_dumpall -p 5432 | psql -d postgres -p 5433
https://www.postgresql.org/docs/12/upgrading.html#UPGRADING-VIA-PGDUMPALL
If you have a lot of data, and you need to keep your database available during the upgrade then you may wish to look into logical replication.

Multiple installations of Postgres on Ubuntu

This is the first time I am setting up multiple Postgres postgres servers on Ubuntu 12.04LTS. (I know multiple versions is a bad idea, but need to sanity check new installation before I migrate and kill the old instance)
Original Postgres V9.1 is installed using bundled apt-get install. (Port : 5432)
New Postgres V10 is installed via EnterpriseDB package. (Port : 5433)
I am able to use standard utilities for the V9.1 like psql, pg_dump, etc. However, I am not able to access psql of V10. Instead I am getting this error message (note the incorrect port):
/opt/PostgreSQL/10/bin$ ./psqlpsql.bin: 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"?
I would like to be able to manage both ideally by using psql.
I usually use Python to connect to databases and I am able to create an SQLAlchemy connection to new instance at port 5433. I can query pg_catalog and information_schema as well.
Thanks in advance!
The default port of postgres is 5432.
So If you want to access psql of V10, use the below commands:
export PATH=/opt/PostgreSQL/10/bin:$PATH
psql -p 5433

PostgreSQL client -- How To Start It?

I just installed PostgreSQL-8.4 on Ubuntu. How do I start it / its GUI, connect to a database etc? I know SQL, but can't find PostgreSQL's icon in my Ubuntu 10.04 desktop (hence, am not sure how to start it).
Postgresql has no built in gui.
to check if it is running run the following from a terminal
ps aux | grep postgres
You can use psql to access from the command line.
to install psql
aptitude install postgresql-client
then to run
psql -h dbhost -U username dbname
If you want a gui intall package pgadmin
aptitude install pgadmin3
I start postgres prompt by using the following command:
sudo -u postgres psql
I use Ubuntu 14.04
If you're a Mac user, try running this
postgres -D /usr/local/var/postgres
then do
psql
you may start by firing up a graphical client. In a terminal type : pgadmin3
You will be presented with the pgAdmin III interface. Click on the "Add a connection to a server" button (top left). In the new dialog, enter the address 127.0.0.1, a description of the server, the default database ("mydb" in the example above), your username ("postgres") and your password.
With this GUI you may start creating and managing databases, query the database, execute SQl etc.
check out - https://help.ubuntu.com/community/PostgreSQL