<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> <!--Converted with LaTeX2HTML 2008 (1.71) original version by: Nikos Drakos, CBLU, University of Leeds * revised and updated by: Marcus Hennecke, Ross Moore, Herb Swan * with significant contributions from: Jens Lippmann, Marek Rouchal, Martin Wilck and others --> <HTML> <HEAD> <TITLE>Installing and Configuring SQLite</TITLE> <META NAME="description" CONTENT="Installing and Configuring SQLite"> <META NAME="keywords" CONTENT="main"> <META NAME="resource-type" CONTENT="document"> <META NAME="distribution" CONTENT="global"> <META NAME="Generator" CONTENT="LaTeX2HTML v2008"> <META HTTP-EQUIV="Content-Style-Type" CONTENT="text/css"> <LINK REL="STYLESHEET" HREF="main.css"> <LINK REL="next" HREF="Catalog_Maintenance.html"> <LINK REL="previous" HREF="Installing_Configuring_Post.html"> <LINK REL="up" HREF="Bacula_Main_Reference.html"> <LINK REL="next" HREF="Catalog_Maintenance.html"> </HEAD> <BODY > <!--Navigation Panel--> <A NAME="tex2html1988" HREF="Catalog_Maintenance.html"> <IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="next.png"></A> <A NAME="tex2html1982" HREF="Bacula_Main_Reference.html"> <IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="up.png"></A> <A NAME="tex2html1976" HREF="Installing_Configuring_Post.html"> <IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="prev.png"></A> <A NAME="tex2html1984" HREF="Contents.html"> <IMG WIDTH="65" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="contents" SRC="contents.png"></A> <A NAME="tex2html1986" HREF="Thanks.html"> <IMG WIDTH="43" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="index" SRC="index.png"></A> <BR> <B> Next:</B> <A NAME="tex2html1989" HREF="Catalog_Maintenance.html">Catalog Maintenance</A> <B> Up:</B> <A NAME="tex2html1983" HREF="Bacula_Main_Reference.html">Bacula Main Reference</A> <B> Previous:</B> <A NAME="tex2html1977" HREF="Installing_Configuring_Post.html">Installing and Configuring PostgreSQL</A> <B> <A NAME="tex2html1985" HREF="Contents.html">Contents</A></B> <B> <A NAME="tex2html1987" HREF="Thanks.html">Index</A></B> <BR> <BR> <!--End of Navigation Panel--> <!--Table of Child-Links--> <A NAME="CHILD_LINKS"><STRONG>Subsections</STRONG></A> <UL> <LI><A NAME="tex2html1990" HREF="Installing_Configuring_SQLi.html#SECTION004410000000000000000">Installing and Configuring SQLite - Phase I</A> <LI><A NAME="tex2html1991" HREF="Installing_Configuring_SQLi.html#SECTION004420000000000000000">Installing and Configuring SQLite - Phase II</A> <LI><A NAME="tex2html1992" HREF="Installing_Configuring_SQLi.html#SECTION004430000000000000000">Linking Bacula with SQLite</A> <LI><A NAME="tex2html1993" HREF="Installing_Configuring_SQLi.html#SECTION004440000000000000000">Testing SQLite</A> <LI><A NAME="tex2html1994" HREF="Installing_Configuring_SQLi.html#SECTION004450000000000000000">Re-initializing the Catalog Database</A> </UL> <!--End of Table of Child-Links--> <HR> <H1><A NAME="SECTION004400000000000000000"></A> <A NAME="SqlLiteChapter"></A> <BR> Installing and Configuring SQLite </H1> <A NAME="21206"></A> <A NAME="21207"></A> <P> Please note that SQLite both versions 2 and 3 are not network enabled, which means that they must be linked into the Director rather than accessed by the network as MySQL and PostgreSQL are. This has two consequences: <OL> <LI>SQLite cannot be used in the <B>bweb</B> web GUI package. </LI> <LI>If you use SQLite, and your Storage daemon is not on the same machine as your Director, you will need to transfer your database to the Storage daemon's machine before you can use any of the SD tools such as <B>bscan</B>, ... </LI> </OL> <P> <H1><A NAME="SECTION004410000000000000000"> Installing and Configuring SQLite - Phase I</A> </H1> <A NAME="21213"></A> <A NAME="21214"></A> <P> If you use the <B>./configure <code>--</code>with-sqlite</B> statement for configuring <B>Bacula</B>, you will need SQLite version 2.8.16 or later installed. Our standard location (for the moment) for SQLite is in the dependency package <B>depkgs/sqlite-2.8.16</B>. Please note that the version will be updated as new versions are available and tested. <P> Installing and Configuring is quite easy. <P> <OL> <LI>Download the Bacula dependency packages </LI> <LI>Detar it with something like: <P> <PRE> tar xvfz depkgs.tar.gz </PRE> <P> Note, the above command requires GNU tar. If you do not have GNU tar, a command such as: <P> <PRE> zcat depkgs.tar.gz | tar xvf - </PRE> <P> will probably accomplish the same thing. <P> </LI> <LI><B>cd depkgs</B> <P> </LI> <LI><B>make sqlite</B> <P> </LI> </OL> <P> Please note that the <B>./configure</B> used to build <B>Bacula</B> will need to include <B><code>--</code>with-sqlite</B> or <B><code>--</code>with-sqlite3</B> depending one which version of SQLite you are using. You should not use the <B><code>--</code>enable-batch-insert</B> configuration parameter for Bacula if you are using SQLite version 2 as it is probably not thread safe. If you are using SQLite version 3, you may use the <B><code>--</code>enable-batch-insert</B> configuration option with Bacula, but when building SQLite3 you MUST configure it with <B><code>--</code>enable-threadsafe</B> and <B><code>--</code>enable-cross-thread-connections</B>. <P> By default, SQLite3 is now run with <B>PRAGMA synchronous=OFF</B> this increases the speed by more than 30 time, but it also increases the possibility of a corrupted database if your server crashes (power failure or kernel bug). If you want more security, you can change the PRAGMA that is used in the file src/version.h. <P> At this point, you should return to completing the installation of <B>Bacula</B>. <P> <H1><A NAME="SECTION004420000000000000000"></A> <A NAME="phase2"></A> <BR> Installing and Configuring SQLite - Phase II </H1> <A NAME="21238"></A> <A NAME="21239"></A> <P> This phase is done <B>after</B> you have run the <B>./configure</B> command to configure <B>Bacula</B>. <P> <B>Bacula</B> will install scripts for manipulating the database (create, delete, make tables etc) into the main installation directory. These files will be of the form *_bacula_* (e.g. create_bacula_database). These files are also available in the bacula-src/src/cats directory after running ./configure. If you inspect create_bacula_database, you will see that it calls create_sqlite_database. The *_bacula_* files are provided for convenience. It doesn't matter what database you have chosen; create_bacula_database will always create your database. <P> At this point, you can create the SQLite database and tables: <P> <OL> <LI>cd install-directory <P> This directory contains the Bacula catalog interface routines. <P> </LI> <LI>./make_sqlite_tables <P> This script creates the SQLite database as well as the tables used by <B> Bacula</B>. This script will be automatically setup by the <B>./configure</B> program to create a database named <B>bacula.db</B> in <B>Bacula's</B> working directory. </LI> </OL> <P> <H1><A NAME="SECTION004430000000000000000"> Linking Bacula with SQLite</A> </H1> <A NAME="21255"></A> <A NAME="21256"></A> <P> If you have followed the above steps, this will all happen automatically and the SQLite libraries will be linked into <B>Bacula</B>. <P> <H1><A NAME="SECTION004440000000000000000"> Testing SQLite</A> </H1> <A NAME="21259"></A> <A NAME="21260"></A> <P> We have much less "production" experience using SQLite than using MySQL. SQLite has performed flawlessly for us in all our testing. However, several users have reported corrupted databases while using SQLite. For that reason, we do not recommend it for production use. <P> If Bacula crashes with the following type of error when it is started: <PRE> Using default Catalog name=MyCatalog DB=bacula Could not open database "bacula". sqlite.c:151 Unable to open Database=/var/lib/bacula/bacula.db. ERR=malformed database schema - unable to open a temporary database file for storing temporary tables </PRE> <P> this is most likely caused by the fact that some versions of SQLite attempt to create a temporary file in the current directory. If that fails, because Bacula does not have write permission on the current directory, then you may get this errr. The solution is to start Bacula in a current directory where it has write permission. <P> <H1><A NAME="SECTION004450000000000000000"> Re-initializing the Catalog Database</A> </H1> <A NAME="21264"></A> <A NAME="21265"></A> <P> After you have done some initial testing with <B>Bacula</B>, you will probably want to re-initialize the catalog database and throw away all the test Jobs that you ran. To do so, you can do the following: <P> <PRE> cd <install-directory> ./drop_sqlite_tables ./make_sqlite_tables </PRE> <P> Please note that all information in the database will be lost and you will be starting from scratch. If you have written on any Volumes, you must write an end of file mark on the volume so that Bacula can reuse it. Do so with: <P> <PRE> (stop Bacula or unmount the drive) mt -f /dev/nst0 rewind mt -f /dev/nst0 weof </PRE> <P> Where you should replace <B>/dev/nst0</B> with the appropriate tape drive device name for your machine. <P> <HR> <!--Navigation Panel--> <A NAME="tex2html1988" HREF="Catalog_Maintenance.html"> <IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="next.png"></A> <A NAME="tex2html1982" HREF="Bacula_Main_Reference.html"> <IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="up.png"></A> <A NAME="tex2html1976" HREF="Installing_Configuring_Post.html"> <IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="prev.png"></A> <A NAME="tex2html1984" HREF="Contents.html"> <IMG WIDTH="65" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="contents" SRC="contents.png"></A> <A NAME="tex2html1986" HREF="Thanks.html"> <IMG WIDTH="43" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="index" SRC="index.png"></A> <BR> <B> Next:</B> <A NAME="tex2html1989" HREF="Catalog_Maintenance.html">Catalog Maintenance</A> <B> Up:</B> <A NAME="tex2html1983" HREF="Bacula_Main_Reference.html">Bacula Main Reference</A> <B> Previous:</B> <A NAME="tex2html1977" HREF="Installing_Configuring_Post.html">Installing and Configuring PostgreSQL</A> <B> <A NAME="tex2html1985" HREF="Contents.html">Contents</A></B> <B> <A NAME="tex2html1987" HREF="Thanks.html">Index</A></B> <!--End of Navigation Panel--> <ADDRESS> 2010-06-14 </ADDRESS> </BODY> </HTML>