I have a set of Berkeley DB files on my Linux file system that I'd like to examine.
我在我的Linux文件系统上有一组Berkeley DB文件,我想检查一下。
What useful tools exist for getting a quick overview of the contents? I can write Perl scripts that use BDB modules for examining them, but I'm looking for some CLI utility to be able to take a look inside without having to start writing scripts.
有什么有用的工具可以快速浏览内容?我可以编写使用BDB模块来检查它们的Perl脚本,但是我正在寻找一些CLI实用程序,以便能够在不需要开始编写脚本的情况下查看其中的内容。
8 个解决方案
#1
23
Check out the db-utils package. If you use apt, you can install it with the following: apt-get install db4.4-util
(or apt-get install db4.8-util
or whatever version you have or prefer.)
检查db-utils包。如果您使用apt,您可以将其安装到以下版本中:apt-get install db4.4-util(或apt-get install db4.8-util或您拥有或喜欢的任何版本)。
Additional links:
额外的链接:
- http://rpmfind.net/linux/rpm2html/search.php?query=db-utils
- http://rpmfind.net/linux/rpm2html/search.php?query=db-utils
- http://packages.ubuntu.com/search?keywords=db4.4-util
- http://packages.ubuntu.com/search?keywords=db4.4-util
- Man page of db4.4_dump
- 手册页的db4.4_dump
#2
23
Use the db_dump
program. It is contained in the package core/db
(Arch), db-util
(Debian, Ubuntu), sys-libs/db
(Gentoo, note that here the binary is called db4.8_dump
or whatever version you are using).
使用db_dump程序。它包含在包的核心/db (Arch), db-util (Debian, Ubuntu), sys-libs/db (Gentoo,注意这里的二进制文件被称为db4.8_dump或您正在使用的任何版本)。
On some systems the man pages are not installed, in that case the documentation can be found here. By default, db_dump
outputs some hex numbers, which is not really useful if you are trying to analyse the content of a database. Use the -p
argument to change this.
在某些系统上,没有安装手册页,在这种情况下,文档可以在这里找到。默认情况下,db_dump会输出一些十六进制数字,如果您试图分析数据库的内容,那么这些数字并不是很有用。用-p参数来改变这个。
Show everything that’s in the file database.db
:
显示文件数据库中的所有内容。
db_dump -p database.db
List the databases in the file database.db
:
在文件数据库中列出数据库。
db_dump -l database.db
Show only the content of the database mydb
in the file database.db
:
在文件数据库中只显示数据库mydb的内容。
db_dump -p -s mydb database.db
#3
12
I found @strickli's answer to be the most helpful, as I didn't want to add any new packages to the machine with the database I was on. However, the db file I was reading was of type btree, not hash, so I had to use bsddb
我发现@strickli的答案是最有帮助的,因为我不想在机器上添加任何新包。但是,我正在读取的db文件类型为btree,而不是散列,所以我必须使用bsddb
# file foo.db
foo.db: Berkeley DB (Btree, version 9, native byte-order)
# python
>>> import bsddb
>>> for k, v in bsddb.btopen("*<db filename here...>*").iteritems():
... print k,v
...
#4
9
As mentioned in the other answers, the db-utils package (db4-utils under RHEL) has some tools. However, db_dump can be unhelpful, since the output is 'bytevalue' format.
正如在其他答案中提到的,db-utils包(RHEL下的db4-utils)有一些工具。但是,db_dump可能没有帮助,因为输出是“bytevalue”格式。
For a quick'n'dirty viewer, use python:
对于快速查看器,请使用python:
me@machine$ python
Python 2.7.3 (default, Sep 26 2013, 20:03:06)
>>> import dbhash
>>> for k, v in dbhash.open( *<db filename here...>* ).iteritems(): print k, v
...
Note that dbhash is deprecated since python 2.6.
注意,自python 2.6以来,dbhash被弃用了。
#5
6
The db_hotbackup utility creates "hot backup" or "hot failover" snapshots of Berkeley DB database environments. Install it with the following
db_hotbackup实用程序创建Berkeley DB数据库环境的“热备份”或“热故障转移”快照。安装它与以下
apt-get install db-util
apt-get安装db-util
then run following command to take hot backup
然后运行以下命令进行热备份
db_hotbackup [-cDEguVv] [-d data_dir ...] [-h home] [-l log_dir] [-P password] -b backup_dir
db_hotbackup [-cDEguVv] [-d data_dir…[-h home] [-l log_dir] [-P密码]-b backup_dir
#6
5
Once you have installed the db utils you can simple do a db_dump on the db file.
一旦安装了db utils,就可以在db文件上简单地执行db_dump。
#7
2
Note that the initial answer says to use "db-utils" package, but the example shows the correct "db-util" package. (with no "s")
注意,最初的答案是使用“db-utils”包,但是示例显示了正确的“db-util”包。(没有“s”)
#8
1
Under Amazon Linux you can install it with:
在Amazon Linux下,您可以安装:
yum install db43-utils
yum安装db43-utils
#1
23
Check out the db-utils package. If you use apt, you can install it with the following: apt-get install db4.4-util
(or apt-get install db4.8-util
or whatever version you have or prefer.)
检查db-utils包。如果您使用apt,您可以将其安装到以下版本中:apt-get install db4.4-util(或apt-get install db4.8-util或您拥有或喜欢的任何版本)。
Additional links:
额外的链接:
- http://rpmfind.net/linux/rpm2html/search.php?query=db-utils
- http://rpmfind.net/linux/rpm2html/search.php?query=db-utils
- http://packages.ubuntu.com/search?keywords=db4.4-util
- http://packages.ubuntu.com/search?keywords=db4.4-util
- Man page of db4.4_dump
- 手册页的db4.4_dump
#2
23
Use the db_dump
program. It is contained in the package core/db
(Arch), db-util
(Debian, Ubuntu), sys-libs/db
(Gentoo, note that here the binary is called db4.8_dump
or whatever version you are using).
使用db_dump程序。它包含在包的核心/db (Arch), db-util (Debian, Ubuntu), sys-libs/db (Gentoo,注意这里的二进制文件被称为db4.8_dump或您正在使用的任何版本)。
On some systems the man pages are not installed, in that case the documentation can be found here. By default, db_dump
outputs some hex numbers, which is not really useful if you are trying to analyse the content of a database. Use the -p
argument to change this.
在某些系统上,没有安装手册页,在这种情况下,文档可以在这里找到。默认情况下,db_dump会输出一些十六进制数字,如果您试图分析数据库的内容,那么这些数字并不是很有用。用-p参数来改变这个。
Show everything that’s in the file database.db
:
显示文件数据库中的所有内容。
db_dump -p database.db
List the databases in the file database.db
:
在文件数据库中列出数据库。
db_dump -l database.db
Show only the content of the database mydb
in the file database.db
:
在文件数据库中只显示数据库mydb的内容。
db_dump -p -s mydb database.db
#3
12
I found @strickli's answer to be the most helpful, as I didn't want to add any new packages to the machine with the database I was on. However, the db file I was reading was of type btree, not hash, so I had to use bsddb
我发现@strickli的答案是最有帮助的,因为我不想在机器上添加任何新包。但是,我正在读取的db文件类型为btree,而不是散列,所以我必须使用bsddb
# file foo.db
foo.db: Berkeley DB (Btree, version 9, native byte-order)
# python
>>> import bsddb
>>> for k, v in bsddb.btopen("*<db filename here...>*").iteritems():
... print k,v
...
#4
9
As mentioned in the other answers, the db-utils package (db4-utils under RHEL) has some tools. However, db_dump can be unhelpful, since the output is 'bytevalue' format.
正如在其他答案中提到的,db-utils包(RHEL下的db4-utils)有一些工具。但是,db_dump可能没有帮助,因为输出是“bytevalue”格式。
For a quick'n'dirty viewer, use python:
对于快速查看器,请使用python:
me@machine$ python
Python 2.7.3 (default, Sep 26 2013, 20:03:06)
>>> import dbhash
>>> for k, v in dbhash.open( *<db filename here...>* ).iteritems(): print k, v
...
Note that dbhash is deprecated since python 2.6.
注意,自python 2.6以来,dbhash被弃用了。
#5
6
The db_hotbackup utility creates "hot backup" or "hot failover" snapshots of Berkeley DB database environments. Install it with the following
db_hotbackup实用程序创建Berkeley DB数据库环境的“热备份”或“热故障转移”快照。安装它与以下
apt-get install db-util
apt-get安装db-util
then run following command to take hot backup
然后运行以下命令进行热备份
db_hotbackup [-cDEguVv] [-d data_dir ...] [-h home] [-l log_dir] [-P password] -b backup_dir
db_hotbackup [-cDEguVv] [-d data_dir…[-h home] [-l log_dir] [-P密码]-b backup_dir
#6
5
Once you have installed the db utils you can simple do a db_dump on the db file.
一旦安装了db utils,就可以在db文件上简单地执行db_dump。
#7
2
Note that the initial answer says to use "db-utils" package, but the example shows the correct "db-util" package. (with no "s")
注意,最初的答案是使用“db-utils”包,但是示例显示了正确的“db-util”包。(没有“s”)
#8
1
Under Amazon Linux you can install it with:
在Amazon Linux下,您可以安装:
yum install db43-utils
yum安装db43-utils