How to run pg_ctlcluster with CentOS? - postgresql

I'm using CentOS 7 with EPEL Repo and installed Postgresql 9.6 which is a need for a webshop application. Now some propel installation script wants to execute pg_ctlcluster. The Installation ends with an error:
Exception: sudo: pg_ctlcluster: command not found
I checked /usr/pgsql-9.6/bin, there is only pg_ctl, but no pg_ctlcluster. Some said pg_ctl and pg_ctlcluster are not exactly the same. It looks like pg_ctlcluster is a Ubuntu thing. It's used for Postgres Cluster (...).
Do you have any ideas what's the best way to replace pg_ctlcluster?
Just copy/symlink pg_ctlcluster -> pg_ctl sounds not like it should be. Maybe someone have a suiteable RPM.

pg_ctlcluster is not part of core PostgreSQL, but the PGDG Debian install packages come with an additional utility command of that name.
So that propel installation script is written for Debian or Ubuntu Linux.
You'd best ask the provider of the script for a script that supports the Redhat-based Linux distrubutions.

I didnt want to overwork the whole PHP installation script, so this fix worked for me:
- $process = $this->getProcess(sprintf('sudo pg_ctlcluster %s main restart --force', $postgresVersion));
+ $process = $this->getProcess(sprintf('sudo -i -u postgres /usr/pgsql-9.6/bin/pg_ctl %s restart', NULL));
+ $process = $this->getProcess(sprintf('exit', NULL));
Not for use in productional enviroments

Related

Unable to reinstall postgresql on mac

I'm trying to reset postgreSQL but looks like it is stuck on Mac M1 with a password and every time that I uninstall and reinstall postgreSQL it is remembering the previously set password.
So when I run brew uninstall postgresql and then brew install postgresql it is not fixing the problem.
I tried to delete the /tmp/.s.PGSQL but it looks like that makes it worse because now can't find this file even on the reinstall.
So what is the proper way to completely remove postgreSQL from a Mac M1 and then reinstall it from 0.
Disclaimer: Make sure you backup your db's in case you need them later because running these commands will delete all your local Postgres databases.
First you need to run:
$ brew uninstall postgres
$ rm -rf /usr/local/var/postgres
$ rm /usr/local/var/log/postgres.log
$ rm -f ~/.psqlrc ~/.psql_history
If you want to make sure there are no other Postgres-adjacent Homebrew formulae still installed you can eihter check via:
$ brew list --formula | grep -e postgres -e psql
or search your entire system for file name matches:
$ sudo find / -name "*postgres*" -o -name "*psql*"
Before reinstalling postgreSQL it might be a good time to reboot your machine. After the reboot run the following commands to get your fresh installation of postgreSQL:
Make sure your Homebrew is fully updated and give Homebrew a chance to diagnose any problems:
$ brew update
$ brew doctor
The diagnostic command $ brew doctor should exit cleanly with the simple message 'Your system is ready to brew.'
Now you can reinstall postgreSQL and see if it runs via:
$ brew install postgres
$ brew services start postgresql
Source: https://blog.testdouble.com/posts/2021-01-28-how-to-completely-uninstall-homebrew-postgres/

Could not load library /usr/local/lib/postgresql/plpgsql.so .. undefined symbol "MakeExpandedObjectReadOnly"

What I'm trying to do is to convert this installing script for webodm (https://gist.github.com/lkpanganiban/5226cc8dd59cb39cdc1946259c3fea6e) written in bash to be used in tcsh shell under a freenas jail.
I have now enter at part where I can't find a solution to and my hope is that someone can en light me what to do next.
The line that is triggering the problem is :
su - postgres -c "psql -d webodm_dev -c "\""CREATE EXTENSION postgis;"\"" "
The whole error line :
ERROR: could not load library "/usr/local/lib/postgresql/plpgsql.so": dlopen (/usr/local/lib/postgresql/plpgsql.so) failed: /usr/local/lib/postgresql/plpgsql.so: Undefined symbol "MakeExpandedObjectReadOnly"
pkg info give :
postgis24-2.4.5_1 Geographic objects support for PostgreSQL databases
postgresql95-client-9.5.15_2 PostgreSQL database (client)
postgresql95-contrib-9.5.15_2 The contrib utilities from the PostgreSQL distribution
postgresql95-server-9.5.15_2 PostgreSQL is the most advanced open-source database available anywhere
And yes the file exists:
root#webodm2:~ # ls -l /usr/local/lib/postgresql/plpgsql.so
-rwxr-xr-x 1 root wheel 195119 Feb 7 18:16 /usr/local/lib/postgresql/plpgsql.so
root#webodm2:~ #
So anyone have some idea ?
I faced this issue after the upgrade from postgres 11 to 12, here how to fix it for Linux and Mac (without brew)
$ sudo su postgres
$ /usr/lib/postgresql/12/bin/pg_upgrade \
--old-datadir=/var/lib/postgresql/11/main \
--new-datadir=/var/lib/postgresql/12/main \
--old-bindir=/usr/lib/postgresql/11/bin \
--new-bindir=/usr/lib/postgresql/12/bin \
--old-options '-c config_file=/etc/postgresql/11/main/postgresql.conf' \
--new-options '-c config_file=/etc/postgresql/12/main/postgresql.conf' \
you can add --check to do a dry test upgrade without changing anything in your postgres installation.
for Mac users with brew installation:
after the upgrade run the following command"
$ brew postgresql-upgrade-database
That error message means that you have a plpgsql.so from PostgreSQL 9.5 or earlier and try to use it with PostgreSQL 9.6 or later.
Either you are picking up the wrong library, or you copied files around.
Anyway, the problem has nothing to do with PostGIS.
It might be your database has an outdated version, try to run the checks before running brew postgresql-upgrade-database. OR try to restart your service brew services restart postgres.
psql --version # 11.4 <--- psql cli version
psql -c 'select version();' postgres # 10.2 <--- db version in storage
brew info postgres # check pg info <--- found solution
brew postgresql-upgrade-database # upgrade db version in storage and fixed the issue

How to install postgresql-client / psql on Nixos

I'm wondering how to install the psql command on NixOS. To be clear: I'm only interested in the client, not the server.
I've looked at the derivation but couldn't find any pointers.
Is there a way to create a derivation without building from source?
Thanks!
The psql command is in any of the postgresql* packages, so you can just add that to environment.systemPackages and rebuild:
environment.systemPackages = [ pkgs.postgresql ];
Instead of installing the package you can also use nix shell / run, and define a shell alias:
alias psql="nix shell nixpkgs#postgresql --command psql"

erroer while installing pl/java postgresql

I am trying to install pljava in my Linux system.
the below is my command and error
root#pega-5-instance:/etc/postgresql/9.1/share/pljava# su postgres -c "/usr/bin/psql -d pegadb -f /etc/postgre
sql/9.1/share/pljava/install.sql"<br>
CREATE SCHEMA<br>
GRANT<br>
psql:/etc/postgresql/9.1/share/pljava/install.sql:6: ERROR: could not access file "pljava": No such file or directory
I have installed java 64bit and pljava 64 bit.
please help me to solve the problem.

pgbench for postgresql 9.3 for centos where to find it?

How can I install pgbench for postgresql 9.3?
I have basically set up my postgresql9.3 on centos 64 bit, and it runs fine. No problem at all.
I then installed postgresql93-contrib on my centos machine. But i dont seem to have pgbench? I get command not found?
I execute the following under bash:
pgbench -i -U test test
any ideas?
It is in contrib. The exact spelling depends on which repo you use, something like postgresql93-contrib
It is possible that pgbench will not be in your default path. Then you can run it by executing: /usr/pgsql-10/bin/pgbench --help
in Centos6
install pgbench
yum install postgresql93-contrib
then pgbench will appear in /usr/pgsql-9.3/bin
add this path to system
vi /etc/profile
add /usr/pgsql-9.3/bin to Path
source /etc/profile
now can run pgbench now