I've installed, correctly Postgres13 with BDR. First node is configured correctly
create_node
-------------
661510928
(1 row)
create_node_group
-------------------
3209631483
(1 row)
wait_for_join_completion
--------------------------
ACTIVE
(1 row)
The problem is on second node, if I try to join the node 1, with command:
bdr_init_physical -D /home/postgres/data -n bdr_node_rm1_02 --local-dsn="port=5432 dbname=lmw host=192.168.0.101 user=postgres password=PWD" -d "port=5432 dbname=lmw host=192.168.0.102 user=postgres password=PWD"
Starting bdr_init_physical ...
Getting remote server identification ...
Creating replication slot on remote node ...
Creating base backup of the remote node ...
38798/38798 kB (100%), 1/1 tablespace
Creating temporary synchronization replication slot on remote node ...
Bringing local node to the target lsn ...
I see on log, that this command is in idle:
Feb 15 10:16:43 localhost postgres[8080]: [11-1] 2023-02-15 10:16:43.685 CET [8080] LOG: logical decoding found consistent point at 0/405EA10
Feb 15 10:16:43 localhost postgres[8080]: [11-2] 2023-02-15 10:16:43.685 CET [8080] DETAIL: There are no running transactions.
Feb 15 10:16:43 localhost postgres[8080]: [11-3] 2023-02-15 10:16:43.685 CET [8080] STATEMENT: SELECT pg_catalog.pg_create_logical_replication_slot('bdr_lmw_lmw_bdr_node_rm1_02', 'pglogical_output') -- bdr_init_physical
Feb 15 10:16:43 localhost postgres[8081]: [11-1] 2023-02-15 10:16:43.734 CET [8081] LOG: using default exclude directory 0xa0a220 0xa0a220
Feb 15 10:16:43 localhost postgres[8081]: [11-2] 2023-02-15 10:16:43.734 CET [8081] STATEMENT: BASE_BACKUP LABEL 'pg_basebackup base backup' PROGRESS FAST NOWAIT MANIFEST 'yes'
Feb 15 10:16:45 localhost postgres[8078]: [11-1] 2023-02-15 10:16:45.851 CET [8078] LOG: logical decoding found consistent point at 0/6000028
Feb 15 10:16:45 localhost postgres[8078]: [11-2] 2023-02-15 10:16:45.851 CET [8078] DETAIL: There are no running transactions.
Feb 15 10:16:45 localhost postgres[8078]: [11-3] 2023-02-15 10:16:45.851 CET [8078] STATEMENT: CREATE_REPLICATION_SLOT "bdr_lmw_lmw_bdr_node_rm1_02_tmp" TEMPORARY LOGICAL pglogical_output
Feb 15 10:16:45 localhost postgres[8078]: [12-1] 2023-02-15 10:16:45.851 CET [8078] LOG: exported logical decoding snapshot: "00000008-0000002C-1" with 0 transaction IDs
Feb 15 10:16:45 localhost postgres[8078]: [12-2] 2023-02-15 10:16:45.851 CET [8078] STATEMENT: CREATE_REPLICATION_SLOT "bdr_lmw_lmw_bdr_node_rm1_02_tmp" TEMPORARY LOGICAL pglogical_output
Do you know why this command is in idle?
Related
Postgres is restarting continuously on using shared_preload_libraries extension.
https://postgresqlco.nf/doc/en/param/shared_preload_libraries/
I am running postgres-15.1 using a python-based daemon in CentOS7-32bit arch. It is working fine if we do not use "shared_preload_libraries" extension. But after enabling this extension using "ALTER SYSTEM SET shared_preload_libraries" command, the postgres is restarting every few seconds.
Initially it was working fine with postgres-9.6.4.
Postgres logs:
waiting for server to start....2023-02-15 07:13:45.676 GMT [28605] LOG: skipping missing configuration file "/home/runtime/pgsql/data/postgresql.auto.conf"
2023-02-15 07:13:45.825 GMT [28605] LOG: starting PostgreSQL 15.1 on i686-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44), 32-bit
2023-02-15 07:13:45.825 GMT [28605] LOG: listening on IPv4 address "127.0.0.1", port 5432
2023-02-15 07:13:45.933 GMT [28605] LOG: listening on Unix socket "/home/runtime/pgsql/.s.PGSQL.5432"
2023-02-15 07:13:45.969 GMT [28608] LOG: database system was shut down at 2023-02-15 07:13:35 GMT
2023-02-15 07:13:45.989 GMT [28605] LOG: database system is ready to accept connections
done
server started
ALTER SYSTEM
ALTER SYSTEM
ALTER SYSTEM
ALTER SYSTEM
2023-02-15 07:13:51.480 GMT [28605] LOG: received fast shutdown request
waiting for server to shut down....2023-02-15 07:13:51.512 GMT [28605] LOG: aborting any active transactions
2023-02-15 07:13:51.513 GMT [28605] LOG: background worker "logical replication launcher" (PID 28611) exited with exit code 1
2023-02-15 07:13:51.513 GMT [28606] LOG: shutting down
2023-02-15 07:13:51.536 GMT [28606] LOG: checkpoint starting: shutdown immediate
2023-02-15 07:13:51.908 GMT [28606] LOG: checkpoint complete: wrote 3 buffers (0.0%); 0 WAL file(s) added, 0 removed, 0 recycled; write=0.090 s, sync=0.028 s, total=0.395 s; sync files=2, longest=0.021 s, average=0.014 s; distance=0 kB, estimate=0 kB
2023-02-15 07:13:51.909 GMT [28605] LOG: database system is shut down
done
server stopped
I tried to use postgres-15.0 and postgres-14.4, got the same behavior with both. I am not able to find any open issues w.r.t. shared_preload_libraries extension with new versions of Postgres.
PS: I have built this Postgres from the source code with openssl-1.1.1i.
I am using "citus" library with this.
ALTER SYSTEM SET shared_preload_libraries="citus";
I have generated a new citus.so file from it's source code using postgres-15.1. github.com/citusdata/citus
I have a PostgreSQL 12 database running on CentOS 8 and until today everything was good.
After restarting my database server, my postgresql-12.service doesn't start anymore, I've tried with systemctl like systemctl start postgresql-12.service and I got this:
[postgres#perseus ~]$ sudo systemctl start postgresql-12.service
[sudo] password for postgres:
Job for postgresql-12.service failed because the control process exited with error code.
See "systemctl status postgresql-12.service" and "journalctl -xe" for details.
[postgres#perseus ~]$ sudo systemctl status postgresql-12.service
● postgresql-12.service - PostgreSQL 12 database server
Loaded: loaded (/usr/lib/systemd/system/postgresql-12.service; enabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Tue 2020-08-11 08:57:51 -03; 11s ago
Docs: https://www.postgresql.org/docs/12/static/
Process: 2822 ExecStart=/usr/pgsql-12/bin/postmaster -D ${PGDATA} (code=exited, status=1/FAILURE)
Process: 2816 ExecStartPre=/usr/pgsql-12/bin/postgresql-12-check-db-dir ${PGDATA} (code=exited, status=0/SUCCESS)
Main PID: 2822 (code=exited, status=1/FAILURE)
Aug 11 08:57:49 perseus postmaster[2822]: 2020-08-11 08:57:49.040 -03 [2822] LOG: listening on IPv4 address "0.0.0.0", port 5432
Aug 11 08:57:49 perseus postmaster[2822]: 2020-08-11 08:57:49.040 -03 [2822] LOG: listening on IPv6 address "::", port 5432
Aug 11 08:57:49 perseus postmaster[2822]: 2020-08-11 08:57:49.041 -03 [2822] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
Aug 11 08:57:49 perseus postmaster[2822]: 2020-08-11 08:57:49.042 -03 [2822] LOG: listening on Unix socket "/tmp/.s.PGSQL.5432"
Aug 11 08:57:49 perseus postmaster[2822]: 2020-08-11 08:57:49.068 -03 [2822] LOG: redirecting log output to logging collector process
Aug 11 08:57:49 perseus postmaster[2822]: 2020-08-11 08:57:49.068 -03 [2822] HINT: Future log output will appear in directory "log".
Aug 11 08:57:51 perseus systemd[1]: postgresql-12.service: Main process exited, code=exited, status=1/FAILURE
Aug 11 08:57:51 perseus systemd[1]: postgresql-12.service: Killing process 2824 (postmaster) with signal SIGKILL.
Aug 11 08:57:51 perseus systemd[1]: postgresql-12.service: Failed with result 'exit-code'.
Aug 11 08:57:51 perseus systemd[1]: Failed to start PostgreSQL 12 database server.
And then, googling this error, i've tried some workarounds, like using pg_ctl and initdb comands, but it's also fails, like this:
[postgres#perseus ~]$ /usr/pgsql-12/bin/pg_ctl start -D /var/lib/pgsql/12/data
waiting for server to start....2020-08-11 09:04:44.197 -03 [2897] LOG: starting PostgreSQL 12.3 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 8.3.1 20191121 (Red Hat 8.3.1-5), 64-bit
2020-08-11 09:04:44.197 -03 [2897] LOG: listening on IPv4 address "0.0.0.0", port 5432
2020-08-11 09:04:44.197 -03 [2897] LOG: listening on IPv6 address "::", port 5432
2020-08-11 09:04:44.197 -03 [2897] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2020-08-11 09:04:44.198 -03 [2897] LOG: listening on Unix socket "/tmp/.s.PGSQL.5432"
2020-08-11 09:04:44.222 -03 [2897] LOG: redirecting log output to logging collector process
2020-08-11 09:04:44.222 -03 [2897] HINT: Future log output will appear in directory "log".
.. stopped waiting
pg_ctl: could not start server
Examine the log output.
[postgres#perseus ~]$ /usr/pgsql-12/bin/initdb -D '/var/lib/pgsql/12/data'
The files belonging to this database system will be owned by user "postgres".
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.
initdb: error: directory "/var/lib/pgsql/12/data" exists but is not empty
If you want to create a new database system, either remove or empty
the directory "/var/lib/pgsql/12/data" or run initdb
with an argument other than "/var/lib/pgsql/12/data".
journalctl -xe results:
[postgres#perseus ~]$ sudo systemctl start postgresql-12.service
[sudo] password for postgres:
Job for postgresql-12.service failed because the control process exited with error code.
See "systemctl status postgresql-12.service" and "journalctl -xe" for details.
[postgres#perseus ~]$ sudo journalctl -xe
Aug 11 11:16:49 perseus sudo[3022]: pam_systemd(sudo:session): Cannot create session: Already running in a session or user slice
Aug 11 11:16:49 perseus sudo[3022]: pam_unix(sudo:session): session opened for user root by root(uid=0)
Aug 11 11:16:49 perseus sudo[3022]: pam_unix(sudo:session): session closed for user root
Aug 11 11:20:01 perseus systemd[1]: Starting system activity accounting tool...
-- Subject: Unit sysstat-collect.service has begun start-up
-- Defined-By: systemd
-- Support: https://access.redhat.com/support
--
-- Unit sysstat-collect.service has begun starting up.
Aug 11 11:20:01 perseus systemd[1]: Started system activity accounting tool.
-- Subject: Unit sysstat-collect.service has finished start-up
-- Defined-By: systemd
-- Support: https://access.redhat.com/support
--
-- Unit sysstat-collect.service has finished starting up.
--
-- The start-up result is RESULT.
Aug 11 11:26:10 perseus sudo[3095]: postgres : TTY=pts/0 ; PWD=/var/lib/pgsql ; USER=root ; COMMAND=/bin/journalctl -xe
Aug 11 11:26:10 perseus sudo[3095]: pam_systemd(sudo:session): Cannot create session: Already running in a session or user slice
Aug 11 11:26:10 perseus sudo[3095]: pam_unix(sudo:session): session opened for user root by root(uid=0)
Aug 11 11:26:49 perseus sudo[3095]: pam_unix(sudo:session): session closed for user root
Aug 11 11:26:52 perseus sudo[3107]: postgres : TTY=pts/0 ; PWD=/var/lib/pgsql ; USER=root ; COMMAND=/bin/journalctl -xe
Aug 11 11:26:52 perseus sudo[3107]: pam_systemd(sudo:session): Cannot create session: Already running in a session or user slice
Aug 11 11:26:52 perseus sudo[3107]: pam_unix(sudo:session): session opened for user root by root(uid=0)
Aug 11 11:27:48 perseus sudo[3107]: pam_unix(sudo:session): session closed for user root
Aug 11 11:30:01 perseus systemd[1]: Starting system activity accounting tool...
-- Subject: Unit sysstat-collect.service has begun start-up
-- Defined-By: systemd
-- Support: https://access.redhat.com/support
--
-- Unit sysstat-collect.service has begun starting up.
Aug 11 11:30:01 perseus systemd[1]: Started system activity accounting tool.
-- Subject: Unit sysstat-collect.service has finished start-up
-- Defined-By: systemd
-- Support: https://access.redhat.com/support
--
-- Unit sysstat-collect.service has finished starting up.
--
-- The start-up result is RESULT.
Aug 11 11:34:13 perseus sudo[3167]: postgres : TTY=pts/0 ; PWD=/var/lib/pgsql ; USER=root ; COMMAND=/bin/systemctl start postgresql-12.service
Aug 11 11:34:13 perseus sudo[3167]: pam_systemd(sudo:session): Cannot create session: Already running in a session or user slice
Aug 11 11:34:13 perseus sudo[3167]: pam_unix(sudo:session): session opened for user root by root(uid=0)
Aug 11 11:34:13 perseus systemd[1]: Starting PostgreSQL 12 database server...
-- Subject: Unit postgresql-12.service has begun start-up
-- Defined-By: systemd
-- Support: https://access.redhat.com/support
--
-- Unit postgresql-12.service has begun starting up.
Aug 11 11:34:13 perseus postmaster[3176]: 2020-08-11 11:34:13.373 -03 [3176] LOG: starting PostgreSQL 12.3 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 8.3.1 20191121 (Red Hat 8.3.1-5), 64-bit
Aug 11 11:34:13 perseus postmaster[3176]: 2020-08-11 11:34:13.373 -03 [3176] LOG: listening on IPv4 address "0.0.0.0", port 5432
Aug 11 11:34:13 perseus postmaster[3176]: 2020-08-11 11:34:13.373 -03 [3176] LOG: listening on IPv6 address "::", port 5432
Aug 11 11:34:13 perseus postmaster[3176]: 2020-08-11 11:34:13.375 -03 [3176] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
Aug 11 11:34:13 perseus postmaster[3176]: 2020-08-11 11:34:13.380 -03 [3176] LOG: listening on Unix socket "/tmp/.s.PGSQL.5432"
Aug 11 11:34:13 perseus postmaster[3176]: 2020-08-11 11:34:13.399 -03 [3176] LOG: redirecting log output to logging collector process
Aug 11 11:34:13 perseus postmaster[3176]: 2020-08-11 11:34:13.399 -03 [3176] HINT: Future log output will appear in directory "log".
Aug 11 11:34:17 perseus systemd[1]: postgresql-12.service: Main process exited, code=exited, status=1/FAILURE
Aug 11 11:34:17 perseus systemd[1]: postgresql-12.service: Killing process 3177 (postmaster) with signal SIGKILL.
Aug 11 11:34:17 perseus systemd[1]: postgresql-12.service: Failed with result 'exit-code'.
Aug 11 11:34:17 perseus systemd[1]: Failed to start PostgreSQL 12 database server.
-- Subject: Unit postgresql-12.service has failed
-- Defined-By: systemd
-- Support: https://access.redhat.com/support
--
-- Unit postgresql-12.service has failed.
--
-- The result is RESULT.
Aug 11 11:34:17 perseus sudo[3167]: pam_unix(sudo:session): session closed for user root
Aug 11 11:34:38 perseus sudo[3188]: postgres : TTY=pts/0 ; PWD=/var/lib/pgsql ; USER=root ; COMMAND=/bin/journalctl -xe
Aug 11 11:34:38 perseus sudo[3188]: pam_systemd(sudo:session): Cannot create session: Already running in a session or user slice
Aug 11 11:34:38 perseus sudo[3188]: pam_unix(sudo:session): session opened for user root by root(uid=0)
Database log with verbose mode:
2020-08-11 15:23:01.400 -03 [7405] LOG: 00000: database system was interrupted; last known up at 2020-08-07 11:37:10 -03
2020-08-11 15:23:01.400 -03 [7405] LOCATION: StartupXLOG, xlog.c:6305
2020-08-11 15:23:05.160 -03 [7405] FATAL: 58P01: could not open directory "": No such file or directory
2020-08-11 15:23:05.160 -03 [7405] LOCATION: ReadDirExtended, fd.c:2563
2020-08-11 15:23:05.161 -03 [7403] LOG: 00000: startup process (PID 7405) exited with exit code 1
2020-08-11 15:23:05.161 -03 [7403] LOCATION: LogChildExit, postmaster.c:3675
2020-08-11 15:23:05.161 -03 [7403] LOG: 00000: aborting startup due to startup process failure
2020-08-11 15:23:05.161 -03 [7403] LOCATION: reaper, postmaster.c:2945
2020-08-11 15:23:05.163 -03 [7403] LOG: 00000: database system is shut down
2020-08-11 15:23:05.163 -03 [7403] LOCATION: UnlinkLockFiles, miscinit.c:860
The PGDATA directory:
[postgres#perseus ~]$ ll -la /var/lib/pgsql/12/data/
total 88
drwx------. 20 postgres postgres 4096 Aug 11 15:49 .
drwx------. 4 postgres postgres 66 Aug 11 14:55 ..
drwx------. 26 postgres postgres 4096 Jul 28 09:29 base
-rw------- 1 postgres postgres 30 Aug 11 15:49 current_logfiles
drwx------. 2 postgres postgres 4096 Aug 11 09:34 global
-rw-r--r-- 1 root root 560 May 29 10:05 global.sql
drwx------. 2 postgres postgres 188 Aug 11 15:50 log
drwx------. 2 postgres postgres 6 May 22 09:16 pg_commit_ts
drwx------. 2 postgres postgres 6 May 22 09:16 pg_dynshmem
-rw------- 1 postgres postgres 4329 May 28 09:07 pg_hba.conf
-rw-------. 1 postgres postgres 1636 May 22 09:16 pg_ident.conf
drwx------. 4 postgres postgres 68 Aug 7 11:37 pg_logical
drwx------. 4 postgres postgres 36 May 22 09:16 pg_multixact
drwx------. 2 postgres postgres 18 Aug 11 15:49 pg_notify
drwx------. 2 postgres postgres 6 May 22 09:16 pg_replslot
drwx------. 2 postgres postgres 6 May 22 09:16 pg_serial
drwx------. 2 postgres postgres 6 May 22 09:16 pg_snapshots
drwx------. 2 postgres postgres 6 Jul 24 14:45 pg_stat
drwx------. 2 postgres postgres 4096 Aug 11 15:49 pg_stat_tmp
drwx------. 2 postgres postgres 18 Jul 28 09:36 pg_subtrans
drwx------. 2 postgres postgres 6 May 22 09:16 pg_tblspc
drwx------. 2 postgres postgres 6 May 22 09:16 pg_twophase
-rw-------. 1 postgres postgres 3 May 22 09:16 PG_VERSION
drwx------. 3 postgres postgres 4096 Jul 31 17:16 pg_wal
drwx------. 2 postgres postgres 4096 Jun 3 11:51 pg_xact
-rw-------. 1 postgres postgres 88 May 22 09:16 postgresql.auto.conf
-rw------- 1 postgres postgres 26808 Aug 11 15:22 postgresql.conf
-rw------- 1 postgres postgres 58 Aug 11 15:49 postmaster.opts
-rw-r--r-- 1 root root 1160 May 29 09:08 teste.backup
Edited with more data.
I have followed below steps for switchover and switchback.
Step 1:-
Disconnect application services from 10.x.x.10 and do the following
#Master(10.x.x.10)
pg_ctl -D /DATA_VEC/pgdata stop --mode=fast
#DR(20.x.x.20)
promote DR as read write mode
Step 2:- Start master as DR from new primary
#Master(10.x.x.10)
create recovery.conf
standby_mode = 'on'
primary_conninfo = 'user= password= host=20.x.x.20 port=9999
trigger_file = '/tmp/node1'
restore_command = 'cp /DATA_VEC/restore/%f "%p"'
pg_ctl -D /DATA_VEC/pgdata start
after promotion new standby, old primary not getting syncing with new primary server(old standby)
Logs from DR server which was primary.
2019-12-01 18:46:56 IST LOG: database system was shut down in recovery at 2019-12-01 18:46:53 IST
2019-12-01 18:46:56 IST LOG: entering standby mode
cp: cannot stat `/DATA_VEC/restore/00000002.history': No such file or directory
2019-12-01 18:46:56 IST LOG:
2019-12-01 18:46:56 IST LOG: restored log file "00000002000000000000000C" from archive
2019-12-01 18:46:57 IST LOG: consistent recovery state reached at 0/C000090
2019-12-01 18:46:57 IST LOG: record with zero length at 0/C000090
2019-12-01 18:46:57 IST LOG: database system is ready to accept read only connections
2019-12-01 18:46:57 IST LOG: started streaming WAL from primary at 0/C000000 on timeline 2
2019-12-01 18:46:57 IST LOG: replication terminated by primary server
2019-12-01 18:46:57 IST DETAIL: End of WAL reached on timeline 2 at 0/C000090.
2019-12-01 18:46:57 IST LOG: restored log file "00000002000000000000000C" from archive
2019-12-01 18:46:57 IST LOG: record with zero length at 0/C000090
2019-12-01 18:46:57 IST LOG: restarted WAL streaming at 0/C000000 on timeline 2
2019-12-01 18:46:57 IST LOG: replication terminated by primary server
2019-12-01 18:46:57 IST DETAIL: End of WAL reached on timeline 2 at 0/C000090.
#Master(10.x.x.10)
Pg_xlog content
-bash-4.1$ cd pg_xlog
-bash-4.1$ ll
total 65552
-rw------- 1 postgres postgres 302 Dec 1 12:52 00000002000000000000000A.00000028.backup
-rw------- 1 postgres postgres 16777216 Dec 1 13:52 00000002000000000000000B
-rw------- 1 postgres postgres 16777216 Dec 1 14:28 00000002000000000000000C
-rw------- 1 postgres postgres 16777216 Dec 1 12:52 00000002000000000000000D
-rw------- 1 postgres postgres 16777216 Dec 1 12:52 00000002000000000000000E
-rw------- 1 postgres postgres 41 Dec 1 13:57 00000002.history
-rw------- 1 postgres postgres 83 Dec 1 13:57 00000003.history
drwx------ 2 postgres postgres 4096 Dec 1 13:57 archive_status
#in restore_command location content:-
-bash-4.1$ cd /DATA_VEC/restore/
-bash-4.1$ ll
total 49156
-rw------- 1 postgres postgres 16777216 Dec 1 18:45 00000002000000000000000A
-rw------- 1 postgres postgres 16777216 Nov 30 21:22 00000002000000000000000B
-rw------- 1 postgres postgres 16777216 Dec 1 18:45 00000002000000000000000C
-rw------- 1 postgres postgres 83 Dec 1 18:45 00000003.history
-bash-4.1$
as per_pg_xlog timeline history file 00000003.historyarrived at standby still not starting streaming from new primary.
Question:-
1. Is it mandatory parameter recover_target_timeline='latest' in recovery.conf file" to get latest timeline id from new primary through streaming to start streaming replication?
2.If yes, is it for all PostgreSQL Version? like from 9.3 to 11.5
If you want switch-back functionality, you will have to set recovery_target_timeline='latest', as any promotion will increment the timeline. Using a fixed target timeline is usually reserved for very specific cases (i.e., you need to recover changes after a split-brain, diverged-timeline scenario).
To answer your specific questions:
Yes
Yes
I want to move my postgresql databases to an external hard drive (HDD 2TB USB 3.0). I copied the whole directory:
/var/lib/postgresql/9.4/main/
to the external drive, preserving permissions, with a command (ran by the user postgres):
$ rsync -aHAX /var/lib/postgresql/9.4/main/* new_dir_path
First run of this command was interrupted, but in the second attempt I copied everything (basically one database of size 800 GB). In the file
/etc/postgresql/9.4/main/postgresql.conf
I changed the line
data_directory = '/var/lib/postgresql/9.4/main'
to point to the new location. I restarted the postgresql service, and when from the user postgres I run the command psql, I get:
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 didn't change any other settings. There is no pidfile 'postmaster.pid' in the new location (or in the old one). When I run a command
$ /usr/lib/postgresql/9.4/bin/postgres --single -D /etc/postgresql/9.4/main -P -d 1
I get
2017-03-16 20:47:39 CET [2314-1] DEBUG: mmap with MAP_HUGETLB failed, huge pages disabled: Cannot allocate memory
2017-03-16 20:47:39 CET [2314-2] NOTICE: database system was shut down at 2017-03-16 20:01:23 CET
2017-03-16 20:47:39 CET [2314-3] DEBUG: checkpoint record is at 647/4041B3A0
2017-03-16 20:47:39 CET [2314-4] DEBUG: redo record is at 647/4041B3A0; shutdown TRUE
2017-03-16 20:47:39 CET [2314-5] DEBUG: next transaction ID: 1/414989450; next OID: 112553
2017-03-16 20:47:39 CET [2314-6] DEBUG: next MultiXactId: 485048384; next MultiXactOffset: 1214064579
2017-03-16 20:47:39 CET [2314-7] DEBUG: oldest unfrozen transaction ID: 259446705, in database 12141
2017-03-16 20:47:39 CET [2314-8] DEBUG: oldest MultiXactId: 476142442, in database 12141
2017-03-16 20:47:39 CET [2314-9] DEBUG: transaction ID wrap limit is 2406930352, limited by database with OID 12141
2017-03-16 20:47:39 CET [2314-10] DEBUG: MultiXactId wrap limit is 2623626089, limited by database with OID 12141
2017-03-16 20:47:39 CET [2314-11] DEBUG: starting up replication slots
2017-03-16 20:47:39 CET [2314-12] DEBUG: oldest MultiXactId member is at offset 1191132700
2017-03-16 20:47:39 CET [2314-13] DEBUG: MultiXact member stop limit is now 1191060352 based on MultiXact 476142442
PostgreSQL stand-alone backend 9.4.9
backend>
but I don't now how to understand this output. When I revert the changes in the postgresql.conf file, everything works fine. Interestingly, few months ago I moved the database in the same way, but to the local directory, and it worked.
I use postgresql-9.4 and debian-jessie.
Thanks for your help!
UPDATE
Content of the log file:
$ cat /var/log/postgresql/postgresql-9.4-main.log
2017-03-14 17:07:16 CET [13822-2] LOG: received fast shutdown request
2017-03-14 17:07:16 CET [13822-3] LOG: aborting any active transactions
2017-03-14 17:07:16 CET [13827-3] LOG: autovacuum launcher shutting down
2017-03-14 17:07:16 CET [13824-1] LOG: shutting down
2017-03-14 17:07:16 CET [13824-2] LOG: database system is shut down
psql (PostgreSQL) 9.5.5
sorry for my eng lang.
can't connect to DataBase.
postgresql.service - LSB: PostgreSQL RDBMS server
Loaded: loaded (/etc/init.d/postgresql; bad; vendor preset: enabled)
Active: active (exited) since Thu 2016-12-01 00:53:23 UTC; 2s ago
Docs: man:systemd-sysv-generator(8)
Process: 25257 ExecStop=/etc/init.d/postgresql stop (code=exited, status=0/SUCCESS)
Process: 24764 ExecReload=/etc/init.d/postgresql reload (code=exited, status=0/SUCCESS)
Process: 25293 ExecStart=/etc/init.d/postgresql start (code=exited, status=0/SUCCESS)
Main PID: 1058 (code=exited, status=0/SUCCESS)
Dec 01 00:53:23 Ubuntu-1604-xenial-64-minimal systemd[1]: Starting LSB: PostgreSQL RDBMS server...
Dec 01 00:53:23 Ubuntu-1604-xenial-64-minimal systemd[1]: Started LSB: PostgreSQL RDBMS server.
Try to connect:
psql -h localhost -p 5432 -U postgres -W
Password for user postgres:
psql: could not connect to server: Connection refused
Is the server running on host "localhost" (127.0.0.1) and accepting
TCP/IP connections on port 5432?
In my postgresql.conf i have listen all = '*' and port 5432
sudo netstat -pant | grep postgres - nothing show
root#Ubuntu-1604-xenial-64-minimal /var/log # tail postgresql/postgresql-9.5-main.log
2016-11-28 23:58:21 UTC [897-3] LOG: invalid record length at 0/14CC9C90
2016-11-28 23:58:21 UTC [897-4] LOG: redo is not required
2016-11-28 23:58:21 UTC [897-5] LOG: MultiXact member wraparound protections are now enabled
2016-11-28 23:58:21 UTC [847-1] LOG: database system is ready to accept connections
2016-11-28 23:58:21 UTC [909-1] LOG: autovacuum launcher started
2016-11-28 23:58:21 UTC [915-1] [unknown]#[unknown] LOG: incomplete startup packet
2016-11-29 22:43:00 UTC [847-2] LOG: received smart shutdown request
2016-11-29 22:43:00 UTC [909-2] LOG: autovacuum launcher shutting down
2016-11-29 22:43:00 UTC [906-1] LOG: shutting down
2016-11-29 22:43:00 UTC [906-2] LOG: database system is shut down
postgres#Ubuntu-1604-xenial-64-minimal:~/9.5/main$ ls
base global pg_clog pg_commit_ts pg_dynshmem pg_logical pg_multixact pg_notify pg_replslot pg_serial pg_snapshots pg_stat pg_stat_tmp pg_subtrans pg_tblspc pg_twophase PG_VERSION pg_xlog postgresql.auto.conf postmaster.opts
And
root#Ubuntu-1604-xenial-64-minimal ~ # sudo systemctl start postgresql
root#Ubuntu-1604-xenial-64-minimal ~ # sudo su - postgres -c psql
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"?
After reboot check status
● postgresql.service - LSB: PostgreSQL RDBMS server
Loaded: loaded (/etc/init.d/postgresql; bad; vendor preset: enabled)
Active: active (exited) since Thu 2016-12-01 02:21:43 UTC; 13min ago
Docs: man:systemd-sysv-generator(8)
Dec 01 02:21:43 Ubuntu-1604-xenial-64-minimal systemd[1]: Starting LSB: PostgreSQL RDBMS server...
Dec 01 02:21:43 Ubuntu-1604-xenial-64-minimal systemd[1]: Started LSB: PostgreSQL RDBMS server.
Dec 01 02:25:56 Ubuntu-1604-xenial-64-minimal systemd[1]: Started LSB: PostgreSQL RDBMS server.
I would look at /var/log to see if it wrote a log.
If it did not, I would attempt to start it manually to the database:
su - postgres
postgres -d 5 -D /var/db/postgres/data96
The -d 5 command sets debugging to level 5. The -D command tells PostgreSQL where the database files are. The above directory is the location where PostgreSQL 9.6 runs on FreeBSD. If you are running Ubuntu, the directory should be /var/lib/postgresql/[PostgreSQL version]/data/. The PostgreSQL default data directory is /usr/local/pgsql/data.