Created
March 17, 2023 09:25
-
-
Save cabecada/812de8362eaf4219452755cb3d9c50ae to your computer and use it in GitHub Desktop.
pg_filenode.map global deleted and recovery
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
postgres@pg:~/temp$ initdb -D db1 | |
postgres@pg:~/temp$ pg_ctl -D db1 -l db1.log start | |
waiting for server to start.... done | |
server started | |
postgres@pg:~/temp$ | |
postgres@pg:~/temp$ pg_basebackup -D replica -R -c fast -C -S replica -d "port=5432" | |
postgres@pg:~/temp$ vim replica/postgresql.auto.conf | |
postgres@pg:~/temp$ pg_ctl -D db2 -l db2.log start | |
pg_ctl: directory "db2" does not exist | |
postgres@pg:~/temp$ pg_ctl -D replica -l replica.log start | |
waiting for server to start.... done | |
server started | |
postgres@pg:~/temp$ | |
postgres@pg:~/temp$ psql | |
psql (14.5 (Ubuntu 14.5-2.pgdg22.04+2)) | |
Type "help" for help. | |
postgres=# create database db1; | |
CREATE DATABASE | |
postgres=# \c db1 | |
You are now connected to database "db1" as user "postgres". | |
db1=# | |
\q | |
postgres@pg:~/temp$ pgbench -i -s 2 db1 | |
postgres@pg:~/temp$ pgbench -i -s 2 db1 | |
dropping old tables... | |
NOTICE: table "pgbench_accounts" does not exist, skipping | |
NOTICE: table "pgbench_branches" does not exist, skipping | |
NOTICE: table "pgbench_history" does not exist, skipping | |
NOTICE: table "pgbench_tellers" does not exist, skipping | |
creating tables... | |
generating data (client-side)... | |
200000 of 200000 tuples (100%) done (elapsed 0.14 s, remaining 0.00 s) | |
vacuuming... | |
creating primary keys... | |
done in 0.35 s (drop tables 0.00 s, create tables 0.01 s, client-side generate 0.18 s, vacuum 0.07 s, primary keys 0.09 s). | |
postgres@pg:~/temp$ psql -p 5433 db1 | |
psql (14.5 (Ubuntu 14.5-2.pgdg22.04+2)) | |
Type "help" for help. | |
db1=# \dt | |
List of relations | |
Schema | Name | Type | Owner | |
--------+------------------+-------+---------- | |
public | pgbench_accounts | table | postgres | |
public | pgbench_branches | table | postgres | |
public | pgbench_history | table | postgres | |
public | pgbench_tellers | table | postgres | |
(4 rows) | |
db1=# | |
\q | |
postgres@pg:~/temp$ | |
db1=# checkpoint; | |
CHECKPOINT | |
db1=# | |
db1=# \dt | |
List of relations | |
Schema | Name | Type | Owner | |
--------+------------------+-------+---------- | |
public | pgbench_accounts | table | postgres | |
public | pgbench_branches | table | postgres | |
public | pgbench_history | table | postgres | |
public | pgbench_tellers | table | postgres | |
(4 rows) | |
##in session two | |
i backed up global/pg_filenode.map from primary and replica to /tmp | |
postgres@pg:~/temp/db1$ find . -name "*filenode*" | |
./base/13760/pg_filenode.map | |
./base/13761/pg_filenode.map | |
./base/16384/pg_filenode.map | |
./base/1/pg_filenode.map | |
./global/pg_filenode.map | |
postgres@pg:~/temp$ psql [14/14] | |
psql: error: connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: FATAL: could not open file "global/pg_file | |
node.map": No such file or directory | |
postgres@pg:~/temp$ psql | |
psql: error: connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: FATAL: could not open file "global/pg_file | |
node.map": No such file or directory | |
postgres@pg:~/temp$ | |
postgres@pg:~/temp$ cksum /tmp/pg_filenode.map_* | |
415486395 512 /tmp/pg_filenode.map_primary | |
415486395 512 /tmp/pg_filenode.map_replica | |
postgres@pg:~/temp$ cp /tmp/pg_filenode.map_replica db1/global/pg_filenode.map | |
postgres@pg:~/temp$ chmod 700 db1/global/pg_filenod.map | |
postgres@pg:~/temp$ psql | |
psql (14.5 (Ubuntu 14.5-2.pgdg22.04+2)) | |
Type "help" for help. | |
postgres=# | |
\q | |
postgres@pg:~/temp$ psql db1 -c 'select now()'; | |
now | |
---------------------------------- | |
2023-03-17 14:54:33.134525+05:30 | |
(1 row) | |
postgres@pg:~/temp$ tail -2 db1.log | |
2023-03-17 14:49:34.865 IST [1363] FATAL: could not open file "global/pg_filenode.map": No such file or directory | |
2023-03-17 14:49:45.818 IST [1367] FATAL: could not open file "global/pg_filenode.map": No such file or directory |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment