2009年5月13日水曜日

ubuntu 9.04 に Berkeley DB XML をインストールする

Berkeley DB XML は組み込み型のXMLデータベースです。XQuery で検索が出きるとのことなので使ってみる。今日の目標はインストールまで。

ドキュメント関係はここからダウンロードする。日本語のドキュメント無いかな?
あった。Berkeley DB XML関係 に日本語訳があった。

インストール
ダウンロードサイトから最新版をダウンロードする。ダウンロードしたファイルは dbxml-2.4.16.tar.gz

$ tar zxvf dbxml-2.4.16.tar.gz
$ cd dbxml-2.4.16/
$ ./buildall.sh
Start DB build: 2009年 5月 13日 水曜日 22:37:56 JST
Configuring Berkeley DB
checking build system type... i686-pc-linux-gnu
checking host system type... i686-pc-linux-gnu
checking if building in the top-level or dist directories... no
checking if --disable-cryptography option specified... no
checking if --disable-hash option specified... no
checking if --disable-mutexsupport option specified... no
checking if --disable-queue option specified... no
checking if --disable-replication option specified... no
checking if --disable-statistics option specified... no
checking if --disable-verify option specified... no
checking if --enable-compat185 option specified... no
checking if --enable-cxx option specified... yes
checking if --enable-debug option specified... no
checking if --enable-debug_rop option specified... no
checking if --enable-debug_wop option specified... no
checking if --enable-diagnostic option specified... no
checking if --enable-dump185 option specified... no
checking if --enable-java option specified... no
checking if --enable-mingw option specified... no
checking if --enable-fine_grained_lock_manager option specified... no
checking if --enable-o_direct option specified... no
checking if --enable-posixmutexes option specified... no
checking if --enable-pthread_api option specified... no
checking if --enable-rpc option specified... no
checking if --enable-smallbuild option specified... no
checking if --enable-tcl option specified... no
checking if --enable-test option specified... no
checking if --enable-uimutexes option specified... no
checking if --enable-umrw option specified... no
checking if --with-mutex=MUTEX option specified... no
checking if --with-tcl=DIR option specified... no
checking if --with-uniquename=NAME option specified... no
checking for chmod... chmod
checking for cp... cp
checking for ln... ln
checking for mkdir... mkdir
checking for rm... rm
checking for sh... /bin/sh
checking for a BSD-compatible install... /usr/bin/install -c
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking for an ANSI C-conforming const... yes
checking for inline... inline
checking whether we are using the GNU C++ compiler... no
checking whether g++ accepts -g... no
checking how to run the C++ preprocessor... /lib/cpp
configure: error: C++ preprocessor "/lib/cpp" fails sanity check
See `config.log' for more details.


GNU C++のコンパイラと g++ が無いと怒られる。
$ sudo apt-get install gcc g++


インストール先を /opt/oracle/dbxml-2.4.16 にして、Javaを使用可能にし、インストールを実行する。
$ sudo ./buildall.sh --prefix=/opt/oracle/dbxml-2.4.16 --enable-java --enable-debug


インストールが無事済んだようなので、コマンドラインのdbxmlを使えるようにする。
$ vi ~/.bashrc

以下のPATHを追加し、保存。
DBXML_HOME=/opt/oracle/dbxml-2.4.16
LD_LIBRARY_PATH=$DBXML_HOME/lib
LD_RUN_PATH=$DBXML_HOME/lib
PATH="$PATH":$DBXML_HOME/bin

設定を有効にする。
$ source ~/.bashrc

DBXMLコマンドを実行してみる。
$ dbxml
dbxml>

を!動いた。
では、「qune: Berkeley DB XML で NXD みたいなことをしてみる」に掲載されていたサンプルを実行してみる。
dbxml> createContainer sample.xmldb
Creating node storage container

dbxml> addDocument doc1 '<?xml version="1.0"?><foo>bar</foo>'
Document added, name = doc1

dbxml> getMetaData doc1
Metadata for document: doc1
http://www.sleepycat.com/2002/dbxml:name

dbxml> addDocument doc2 '<?xml version="1.0"?><foo>Hello,World!</foo>'
Document added, name = doc2

dbxml> query 'collection("sample.xmldb")/foo'
2 objects returned for eager expression 'collection("sample.xmldb")/foo'

dbxml> print
<foo>bar</foo>
<foo>Hello,World!</foo>

今日はここまでかな〜。

0 コメント:

コメントを投稿