I installed two postgresql(s), 9.5 should use port 5433, 9.3.4 should use port 5432:
me#camb:/usr/lib/postgresql/9.5/bin$ ls -al psql
-rwxr-xr-x 1 root root 564464 Jan 7 14:54 psql
me#camb:/opt/pkgs/postgresql-9.3.4/bin$ ls -al psql
-rwxr-xr-x 1 root root 405960 Aug 5 18:52 psql
me#camb:/opt/pkgs/postgresql-9.3.4/bin$ cat /etc/group
postgres:x:200:
me#camb:/opt/pkgs/postgresql-9.3.4/bin$ groups postgres
postgres : postgres ssl-cert
I wrote a script to install postgresql-9.5 and migrate from 9.3.4 to 9.5
Problem 0: postgresql-9.5 can not start sucessfully and why status is online
Output during install:
* Starting PostgreSQL 9.5 database server
* The PostgreSQL server failed to start. Please check the log output:
2016-01-19 19:41:49 UTC [16523-1] LOG: database system was shut down at 2016-01-19 19:41:48 UTC
2016-01-19 19:41:49 UTC [16523-2] LOG: MultiXact member wraparound protections are now enabled
2016-01-19 19:41:49 UTC [16522-1] LOG: database system is ready to accept connections
2016-01-19 19:41:49 UTC [16527-1] LOG: autovacuum launcher started
2016-01-19 19:41:49 UTC [16529-1] [unknown]#[unknown] LOG: incomplete startup packet
...fail!
invoke-rc.d: initscript postgresql, action "start" failed.
dpkg: error processing postgresql-9.5 (--configure):
subprocess installed post-installation script returned error exit status 1
dpkg: dependency problems prevent configuration of postgresql:
postgresql depends on postgresql-9.5; however:
Package postgresql-9.5 is not configured yet.
dpkg: error processing postgresql (--configure):
dependency problems - leaving unconfigured
Processing triggers for libc-bin ...
No apport report written because the error message indicates its a followup error from a previous failure.
ldconfig deferred processing now taking place
Errors were encountered while processing:
postgresql-9.5
postgresql
E: Sub-process /usr/bin/dpkg returned an error code (1)
Error while installing Postgresql-9.5:1
Then I did some tests:
me#camb:/usr/lib/postgresql/9.5/bin$ sudo service postgresql start
* Starting PostgreSQL 9.5 database server [ OK ]
me#camb:/usr/lib/postgresql/9.5/bin$ sudo service postgresql status
9.5/main (port 5433): online
What do the above errors?
By the way, another error is:
ERROR: role "postgres" already exists
Problem 1: Why I cannot use /usr/lib/postgresql/9.5/bin/psql to loginto the database, but I can do this by /opt/pkgs/postgresql-9.3.4/bin/psql
me#camb:/usr/lib/postgresql/9.5/bin$ sudo -u postgres /opt/pkgs/postgresql-9.3.4/bin/psql -p 5433 reporting_central postgres
psql (9.3.4, server 9.5.0)
WARNING: psql major version 9.3, server major version 9.5.
Some psql features might not work.
Type "help" for help.
reporting_central=# \q
me#camb:/usr/lib/postgresql/9.5/bin$ sudo -u postgres /opt/pkgs/postgresql-9.3.4/bin/psql -p 5432 reporting_central postgres
psql (9.3.4)
Type "help" for help.
reporting_central=# \q
me#camb:/usr/lib/postgresql/9.5/bin$ sudo -u postgres /usr/lib/postgresql/9.5/bin/psql -p 5433 reporting_central postgres
/usr/lib/postgresql/9.5/bin/psql: symbol lookup error: /usr/lib/postgresql/9.5/bin/psql: undefined symbol: PQsslInUse
me#camb:/usr/lib/postgresql/9.5/bin$ sudo -u postgres /usr/lib/postgresql/9.5/bin/psql -p 5432 reporting_central postgres
/usr/lib/postgresql/9.5/bin/psql: symbol lookup error: /usr/lib/postgresql/9.5/bin/psql: undefined symbol: PQsslInUse
The error is "undefined symbol: PQsslInUse". what does this mean? Why I cannot use /usr/lib/postgresql/9.5/bin/psql to loginto the database, but I can do this by /opt/pkgs/postgresql-9.3.4/bin/psql?
Thanks
By the way, I run the following to do migration:
sudo -u postgres /opt/pkgs/postgresql-9.3.4/bin/pg_dumpall -p 5432 | sudo -u postgres /opt/pkgs/postgresql-9.3.4/bin/psql -p 5433
Thanks
You have to use the same libpq library as the one used in psql 9.5.
You should do the following:
export LD_LIBRARY_PATH=/usr/lib/postgresql/9.5/lib:$LD_LIBRARY_PATH
sudo /sbin/ldconfig /usr/lib/postgresql/9.5/lib
You mess up with different versions of postgresql.
To start/use 9.5, you must use the appropriate binaries: initdb, pg_ctl and psql (for example):
mkdir /usr/lib/postgresql/9.5/data
/usr/lib/postgresql/9.5/bin/initdb -D ../data/
/usr/lib/postgresql/9.5/bin/pg_ctl -D ../data/ -l logfile start
/usr/lib/postgresql/9.5/bin/psql -p 5432 -d template1
More info: https://www.postgresql.org/docs/devel/static/install-post.html
and PQsslInUse issue: http://postgresql.nabble.com/psql-error-on-postgresql-9-0-psql-symbol-lookup-error-psql-undefined-symbol-PQconnectdbParams-td5104930.html
The error is "undefined symbol: PQsslInUse"
I just ran into this problem myself. I discovered that the reason was because I compiled Postgres 9.5 from scratch into a particular directory and then decided that I wanted it elsewhere and moved the install to a new directory. Down the line when I went to restore my database with psql, I got the above error. I corrected the problem by deleting my installation directory, changing the PREFIX to the correct location, recompiling and reinstalling Postgres. psql worked fine after this.
I had the same problem
psql: symbol lookup error: psql: undefined symbol: PQsetErrorContextVisibility
And the solution is :
export LD_LIBRARY_PATH=$PGXZ_HOME/lib:${LD_LIBRARY_PATH}
I had a similar issue and finally found a solution:
My user did not have permission for the postgres installation.
What worked for me was to switch to the postgres user:
sudo su - postgres
psql
and then it worked no issues.
Related
I use pip3 install pgadmin4==4.30 to install pgadmin in my ubuntu. And I want to backup my remote server data by Tools-Backup in pgadmin, which is equal to the following command.
/usr/bin/pg_dump --file "~/demo.backup" --host "127.0.0.1" --port "42885" --username "postgres"....
However there is an error says:pg_dump: sever version:11.7; pg_dump version: 10.3(Ubuntu-10.3-1). One thing that puzzles me is I don't have version 11.7 installed at all. Here is the output of ls -la /usr/bin/pg_dump
0 lrwxrwxrwx 1 root root 34 Mar 2 18:05 /usr/bin/pg_dump -> /usr/lib/postgresql/10/bin/pg_dump
And there is only one version(10) in /usr/lib/postgresql folder. Anyone can tell me how I can fix this? I have tried every solution of this and neither of them worked out.
I've just sit down to my work, forgetting that I've upgraded brew in the 2020 – so of course I have a postgresql problem.
The last version I had was 12.x. Now I have 13.1 installed:
$ brew info postgres
Warning: Treating postgres as a formula. For the cask, use homebrew/cask/postgres
postgresql: stable 13.1 (bottled), HEAD
Object-relational database system
https://www.postgresql.org/
/usr/local/Cellar/postgresql/13.1 (3,217 files, 42.6MB) *
Poured from bottle on 2020-12-26 at 14:36:54
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/postgresql.rb
License: PostgreSQL
==> Dependencies
Build: pkg-config ✔
Required: icu4c ✔, krb5 ✔, openssl#1.1 ✔, readline ✔
==> Options
--HEAD
Install HEAD version
==> Caveats
To migrate existing data from a previous major version of PostgreSQL run:
brew postgresql-upgrade-database
This formula has created a default database cluster with:
initdb --locale=C -E UTF-8 /usr/local/var/postgres
For more details, read:
https://www.postgresql.org/docs/13/app-initdb.html
To have launchd start postgresql now and restart at login:
brew services start postgresql
Or, if you don't want/need a background service you can just run:
pg_ctl -D /usr/local/var/postgres start
==> Analytics
install: 181,394 (30 days), 574,628 (90 days), 1,984,700 (365 days)
install-on-request: 176,623 (30 days), 554,629 (90 days), 1,910,250 (365 days)
build-error: 0 (30 days)
Following the output, I'm trying to run brew postgresql-upgrade-database, but it does not work – here is the output:
$ brew postgresql-upgrade-database --debug --verbose
/usr/local/Homebrew/Library/Homebrew/brew.rb (Formulary::FormulaLoader): loading /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/postgresql.rb
==> Upgrading postgresql data from 12 to 13...
/usr/local/Cellar/postgresql#12/12.5/bin/pg_ctl -w -D /usr/local/var/postgres start
waiting for server to start....2021-01-04 17:37:33.282 CET [8190] FATAL: database files are incompatible with server
2021-01-04 17:37:33.282 CET [8190] DETAIL: The database cluster was initialized with PG_CONTROL_VERSION 1300, but the server was compiled with PG_CONTROL_VERSION 1201.
2021-01-04 17:37:33.282 CET [8190] HINT: It looks like you need to initdb.
2021-01-04 17:37:33.282 CET [8190] LOG: database system is shut down
stopped waiting
pg_ctl: could not start server
Examine the log output.
==> Moving postgresql data from /usr/local/var/postgres to /usr/local/var/postgres.old...
==> Creating database...
/usr/local/opt/postgresql/bin/initdb /usr/local/var/postgres
The files belonging to this database system will be owned by user "nyc".
This user must also own the server process.
The database cluster will be initialized with locale "en_US.UTF-8".
The default database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".
Data page checksums are disabled.
fixing permissions on existing directory /usr/local/var/postgres ... ok
creating subdirectories ... ok
selecting dynamic shared memory implementation ... posix
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
selecting default time zone ... Europe/Warsaw
creating configuration files ... ok
running bootstrap script ... ok
performing post-bootstrap initialization ... ok
syncing data to disk ... ok
initdb: warning: enabling "trust" authentication for local connections
You can change this by editing pg_hba.conf or using the option -A, or
--auth-local and --auth-host, the next time you run initdb.
Success. You can now start the database server using:
/usr/local/opt/postgresql/bin/pg_ctl -D /usr/local/var/postgres -l logfile start
==> Migrating and upgrading data...
/usr/local/opt/postgresql/bin/pg_upgrade -r -b /usr/local/Cellar/postgresql#12/12.5/bin -B /usr/local/opt/postgresql/bin -d /usr/local/var/postgres.old -D /usr/local/var/postgres -j 4
Performing Consistency Checks
-----------------------------
Checking cluster versions ok
The source cluster was not shut down cleanly.
Failure, exiting
Error: Upgrading postgresql data from 12 to 13 failed!
==> Removing empty postgresql initdb database...
==> Moving postgresql data back from /usr/local/var/postgres.old to /usr/local/var/postgres...
Error: Failure while executing; `/usr/local/opt/postgresql/bin/pg_upgrade -r -b /usr/local/Cellar/postgresql#12/12.5/bin -B /usr/local/opt/postgresql/bin -d /usr/local/var/postgres.old -D /usr/local/var/postgres -j 4` exited with 1.
/usr/local/Homebrew/Library/Homebrew/utils.rb:303:in `safe_system'
/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/cmd/postgresql-upgrade-database.rb:126:in `block in postgresql_upgrade_database'
/usr/local/Homebrew/Library/Homebrew/extend/pathname.rb:318:in `block in cd'
/usr/local/Homebrew/Library/Homebrew/extend/pathname.rb:318:in `chdir'
/usr/local/Homebrew/Library/Homebrew/extend/pathname.rb:318:in `cd'
/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/cmd/postgresql-upgrade-database.rb:125:in `postgresql_upgrade_database'
/usr/local/Homebrew/Library/Homebrew/brew.rb:124:in `<main>'
How can I fix this?
As a PostgreSQL newbie user, I am getting this error below, when running sudo service postgresql start.
* Starting PostgreSQL 12 database server * Error: /usr/lib/postgresql/12/bin/pg_ctl /usr/lib/postgresql/12/bin/pg_ctl start -D /var/lib/postgresql/12/main -l /var/log/postgresql/postgresql-12-main.log -s -o -c config_file="/etc/postgresql/12/main/postgresql.conf" exited with status 1:
2020-10-01 15:58:42.129 EDT [6750] LOG: starting PostgreSQL 12.4 (Ubuntu 12.4-0ubuntu0.20.04.1) on x86_64-pc-linux-gnu, compiled by gcc (Ubuntu 9.3.0-10ubuntu2) 9.3.0, 64-bit
2020-10-01 15:58:42.131 EDT [6750] LOG: could not bind IPv4 address "127.0.0.1": Permission denied
2020-10-01 15:58:42.131 EDT [6750] HINT: Is another postmaster already running on port 5432? If not, wait a few seconds and retry.
2020-10-01 15:58:42.131 EDT [6750] WARNING: could not create listen socket for "localhost"
2020-10-01 15:58:42.131 EDT [6750] FATAL: could not create any TCP/IP sockets
2020-10-01 15:58:42.132 EDT [6750] LOG: database system is shut down
pg_ctl: could not start server
Examine the log output.
The issue was because I installed postgresql without specifying the version so uninstalling and reinstalling with the version specified fixed the issue
To uninstall
sudo apt-get remove --purge postgresql-12
and then to reinstall
sudo apt-get install postgresql-12
I have installed postgresql and done all the setup and created db and tables yesterday but today morning I got sudden this error
I have also uninstalled and installed postgresql but still same error. And also I have observed that when installed freshly it is working fine but once I shutdown or restart my system I'm getting the below error.
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"?
I have tried all the solutions given in all the mediums but I'm not able to resolve the issue so I'm posting this question again with my outputs.
The status of postgresql
**sudo /etc/init.d/postgresql status**
postgresql.service - PostgreSQL RDBMS
Loaded: loaded (/lib/systemd/system/postgresql.service; enabled; vendor preset: enabled)
Active: active (exited) since Wed 2019-10-30 11:40:39 IST; 5min ago
Process: 7666 ExecStart=/bin/true (code=exited, status=0/SUCCESS)
Main PID: 7666 (code=exited, status=0/SUCCESS)
Tasks: 0
Memory: 0B
CPU: 0
CGroup: /system.slice/postgresql.service
When I run the pg_lsclusters
**pg_lsclusters**
Ver Cluster Port Status Owner Data directory Log file
11 main 5432 down postgres /var/lib/postgresql/11/main /var/log/postgresql/postgresql-11-main.log
**dpkg -l | grep postgres**
ii pgdg-keyring 2018.2 all keyring for apt.postgresql.org
ii postgresql 11+207.pgdg16.04+1 all object-relational SQL database (supported version)
ii postgresql-11 11.5-3.pgdg16.04+1 amd64 object-relational SQL database, version 11 server
ii postgresql-client-11 11.5-3.pgdg16.04+1 amd64 front-end programs for PostgreSQL 11
ii postgresql-client-common 207.pgdg16.04+1 all manager for multiple PostgreSQL client versions
ii postgresql-common 207.pgdg16.04+1 all PostgreSQL database-cluster manager
ii postgresql-contrib 11+207.pgdg16.04+1 all additional facilities for PostgreSQL (supported version)
I even tried to restart the postgres still same issue.
**sudo /etc/init.d/postgresql status**
I had exactly this error message, and this is how I resolved it.
In the log file at /var/log/postgresql/postgresql-13-main.log, these lines were present:
2021-09-15 08:26:04.936 UTC [46258] LOG: invalid value for parameter "lc_messages": "en_US.UTF-8"
2021-09-15 08:26:04.936 UTC [46258] LOG: invalid value for parameter "lc_monetary": "en_US.UTF-8"
2021-09-15 08:26:04.937 UTC [46258] LOG: invalid value for parameter "lc_numeric": "en_US.UTF-8"
2021-09-15 08:26:04.937 UTC [46258] LOG: invalid value for parameter "lc_time": "en_US.UTF-8"
2021-09-15 08:26:04.937 UTC [46258] FATAL: configuration file "/etc/postgresql/13/main/postgresql.conf" contains errors
pg_ctl: could not start server
Examine the log output.
This is caused by missing locales, with these possible fixes:
localedef allegedly fixes this according but I had no luck with this.
localedef -i en_US -f UTF-8 en_US.UTF-8
change postgresql.conf and use a locale that does exist (en_GB in my case)
lc_messages = 'en_GB.UTF-8' # locale for system error message strings
lc_monetary = 'en_GB.UTF-8' # locale for monetary formatting
lc_numeric = 'en_GB.UTF-8' # locale for number formatting
lc_time = 'en_GB.UTF-8' # locale for time formatting
post settings
port = 5432 # (change requires restart)
Port was wrong on my PostgreSQL 13 default config (was 5433) and required a change back to the default 5432. I presume this was a result of upgrading from v11 so it gave it a new port number.
After these changes, PostgreSQL needs to restart and it should now function correctly without errors in the log, and the psql command working as expected.
Try this:
sudo -u postgres -i
And then:
initdb --locale $LANG -E UTF8 -D '/var/lib/postgres/data/'
exit
This has worked for me so far
I'm using Open Source Chef 11.0.10 on Ubuntu 12.04. This is a shared server where PostgreSQL and Apache are already running, so I'm trying to customize the Chef port numbers.
I've created the file /etc/chef-server/chef-server.rb, which contains the lines:
nginx['ssl_port'] = 8443
postgresql['port'] = 5433
When I execute the command:
sudo chef-server-ctl reconfigure
it fails on the line:
execute[/opt/chef-server/embedded/bin/createdb -T template0 -E UTF-8 opscode_chef] action run
and the error message says:
---- Begin output of /opt/chef-server/embedded/bin/createdb -T template0 -E UTF-8 opscode_chef ----
STDOUT:
STDERR: createdb: could not connect to database template1: 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"?
---- End output of /opt/chef-server/embedded/bin/createdb -T template0 -E UTF-8 opscode_chef ----
Now, the Chef instance of PostgreSQL does appear to be running, in addition to the original instance:
$ ps -ef | grep postgresql | grep -v grep
postgres 1000 1 0 09:14 ? 00:00:00 /usr/lib/postgresql/9.1/bin/postgres -D /var/lib/postgresql/9.1/main -c config_file=/etc/postgresql/9.1/main/postgresql.conf
root 4830 4421 0 09:46 ? 00:00:00 runsv postgresql
root 4831 4830 0 09:46 ? 00:00:00 svlogd -tt /var/log/chef-server/postgresql
998 5579 4830 0 09:49 ? 00:00:00 /opt/chef-server/embedded/bin/postgres -D /var/opt/chef-server/postgresql/data
What did I miss?
More details:
I had used the omnibus package to do the initial chef-server install:
https://opscode-omnibus-packages.s3.amazonaws.com/ubuntu/12.04/x86_64/chef-server_11.0.10-1.ubuntu.12.04_amd64.deb
It failed before completion at the same step with the same error because it's trying to use the default PostgreSQL port, which is already in use.
And the Chef PostgreSQL instance is running:
$ sudo /opt/chef-server/embedded/bin/sv status postgresql
run: postgresql: (pid 5579) 86034s; run: log: (pid 4831) 86158s
I gave up trying to get Chef's PostgreSQL instance configured to use a different port.
Instead, I modified our existing PostgreSQL installation's port number to be 5433 and let Chef's instance use 5432. Now the "chef-server-ctl reconfigure" command completes successfully.
check postgresql log file
tail -f /var/log/chef-server/postgresql/current
2015-02-28_13:29:01.48646 FATAL: could not create lock file "/tmp/.s.PGSQL.5432.lock": Permission denied
2015-02-28_13:29:02.57961 FATAL: could not create lock file "/tmp/.s.PGSQL.5432.lock": Permission denied
2015-02-28_13:29:02.57961 FATAL: could not create lock file "/tmp/.s.PGSQL.5432.lock": Permission denied
My problem is solve running following command
chmod 777 /tmp