Prepare the new machine with the same version PostgreSQL, ( in this case , we use 10.6 , On Slackware machine ).
PostgreSQL session :
- Install PostgreSQL using this link http://slackbuilds.org/repository/14.2/system/postgresql/
- Change version download source into :
https://ftp.postgresql.org/pub/source/v10.6/postgresql-10.6.tar.gz
- Change version postgresql.SlackBuild ( 10.6 ) , edit line :
VERSION=${VERSION:-10.6}
PG_VERSION=${PG_VERSION:-10.6}
- Build using script :
# bash postgresql.SlackBuild
- next install with :
# installpkg /tmp/postgresql-10.6-x86_64-1_SBo.tgz
Data dir restoration
copy the data dir PostgreSQL from the crash machine to new machine
# /var/lib/pgsql/10.6/data/
into the same directory :
# /var/lib/pgsql/10.6/data/
change the ownership into postgres environment
# chown -Rh postgres:postgres /var/lib/pgsql/10.6/data
run the service postgres : ( please note : suffix "new" on this script because i was already install postgres with different version )
# bash /etc/rc.d/rc.postgresql.new start
the service will not running, so we have to check logs :
# tail -f /var/log/postgresql-10.6
# tail -f /var/lib/pgsql/10.6/data/log/postgresql-Sat.log
Because the service won't start, it's from the log that was a checkpoint record in the transaction log that probably doesn't exist or is corrupted. so we can use :
# su - postgres
$ pg_resetwal 10.6/data/
because the transaction log was corrupted, we will use -f option :
all right then, that was success
and next run the service and check the data.
# bash /etc/rc.d/rc.postgresql.new start
# su - postgres
$ psql
and the database was safe. next we should check di content of data in each table.
source : https://stackoverflow.com/questions/8799474/postgresql-error-panic-could-not-locate-a-valid-checkpoint-record/26158818
No comments:
Post a Comment