http://qs321.pair.com?node_id=1172148

Perl_Love has asked for the wisdom of the Perl Monks concerning the following question:

I am running Perl script on CentOS7, BerkeleyDB data is generated continuously, because of a sudden power failure, the database is damaged, I can not read any data, there are 52G data.

I try to fix it, but did not succeed, __db.001 , __db.002 , __db.003 have been removed in the repair process, please help me, what is the method to get the data?

Thank you!

Below this is the way to produce data:

...... sub DB{ $env=new BerkeleyDB::Env -Home=>$db_home, -Flags=>DB_CREATE|DB_INIT_MPOOL || die; $db=tie(%hash,"BerkeleyDB::Btree", -Filename=>$db_name, -Flags=>DB_CREATE, -Env=>$env) || die; } ......

The following is a reading method, but is no work

$|=1; use BerkeleyDB; my $env=new BerkeleyDB::Env -Home=>'/home/root/URL/DB' #-Flags=>DB_CREATE#|DB_INIT_MPOOL || die; my %hash; my $db=tie(%hash,"BerkeleyDB::Btree", -Filename=>'URL.db', # -Flags=>DB_CREATE, -Env=>$env) || die; while(my ($k,$v)=each %hash){ print "$k\t$v\n"; } untie $db;

Replies are listed 'Best First'.
Re: [OT] How to fix the BerkeleyDB 52G data ?
by davido (Cardinal) on Sep 19, 2016 at 15:25 UTC
Re: [OT] How to fix the BerkeleyDB 52G data ?
by stevieb (Canon) on Sep 19, 2016 at 15:27 UTC

    This doesn't appear to be a Perl issue, but a DB issue.

    After a quick Google, I found db_recover. If that, or other Berkeley DB recovery techniques don't work, you may have to restore the DB from a backup.