]> git.sur5r.net Git - bacula/docs/blob - docs/manuals/en/main/sqlite.tex
Tweak update copyrights
[bacula/docs] / docs / manuals / en / main / sqlite.tex
1 %%
2 %%
3
4 \chapter{Installing and Configuring SQLite}
5 \label{SqlLiteChapter}
6 \index[general]{Installing and Configuring SQLite }
7 \index[general]{SQLite!Installing and Configuring }
8
9 Note: SQLite3 implementation remains in the source code, but SQLite3
10 is no longer supported by the Bacula project.  We recommend that you
11 use either MySQL or PostgreSQL.
12
13 Please note that SQLite3 is not network enabled,
14 which means that it must be linked into the Director rather than accessed
15 by the network as MySQL and PostgreSQL are. This has two consequences:
16 \begin{enumerate}
17 \item SQLite cannot be used in the {\bf bweb} web GUI package.
18 \item If you use SQLite, and your Storage daemon is not on the same
19 machine as your Director, you will need to transfer your database
20 to the Storage daemon's machine before you can use any of the SD tools
21 such as {\bf bscan}, ...
22 \end{enumerate}
23
24 \section{Installing and Configuring SQLite -- Phase I}
25 \index[general]{Phase I!Installing and Configuring SQLite -- }
26 \index[general]{Installing and Configuring SQLite -- Phase I }
27
28 If you use the {\bf ./configure \verb:--:with-sqlite} statement for configuring {\bf
29 Bacula}, you will need SQLite version 2.8.16 or later installed. Our standard
30 location (for the moment) for SQLite is in the dependency package {\bf
31 depkgs/sqlite-2.8.16}. Please note that the version will be updated as new
32 versions are available and tested. 
33
34 Installing and Configuring is quite easy. 
35
36 \begin{enumerate}
37 \item Download the Bacula dependency packages  
38 \item Detar it with something like:
39
40 \begin{verbatim}
41    tar xvfz depkgs.tar.gz
42 \end{verbatim}
43
44    Note, the above command requires GNU tar. If you do not  have GNU tar, a
45    command such as:
46
47 \begin{verbatim}
48    zcat depkgs.tar.gz | tar xvf -
49 \end{verbatim}
50
51    will probably accomplish the same thing. 
52
53 \item {\bf cd depkgs}
54
55 \item {\bf make sqlite}  
56
57 \end{enumerate}
58
59
60 Please note that the {\bf ./configure} used to build {\bf Bacula} will need
61 to include {\bf \verb:--:with-sqlite3}.  You should not use the {\bf When
62 building SQLite3 you MUST configure it with {\bf \verb:--:enable-threadsafe} and
63 {\bf \verb:--:enable-cross-thread-connections}.
64
65 By default, SQLite3 is now run with {\bf PRAGMA synchronous=OFF} this
66 increases the speed by more than 30 time2, but it also increases the 
67 possibility of a corrupted database if your server crashes (power failure
68 or kernel bug).  If you want more security, you can change the PRAGMA
69 that is used in the file src/version.h.
70
71
72 At this point, you should return to completing the installation of {\bf
73 Bacula}. 
74
75
76 \section{Installing and Configuring SQLite -- Phase II}
77 \label{phase2}
78 \index[general]{Phase II!Installing and Configuring SQLite -- }
79 \index[general]{Installing and Configuring SQLite -- Phase II }
80
81 This phase is done {\bf after} you have run the {\bf ./configure} command to
82 configure {\bf Bacula}. 
83
84 {\bf Bacula} will install scripts for manipulating the database (create,
85 delete, make tables etc) into the main installation directory. These files
86 will be of the form *\_bacula\_* (e.g. create\_bacula\_database). These files
87 are also available in the \lt{}bacula-src\gt{}/src/cats directory after
88 running ./configure. If you inspect create\_bacula\_database, you will see
89 that it calls create\_sqlite\_database. The *\_bacula\_* files are provided
90 for convenience. It doesn't matter what database you have chosen;
91 create\_bacula\_database will always create your database. 
92
93 At this point, you can create the SQLite database and tables: 
94
95 \begin{enumerate}
96 \item cd \lt{}install-directory\gt{}
97
98    This directory contains the Bacula catalog  interface routines.  
99
100 \item ./make\_sqlite\_tables
101
102    This script creates the SQLite database as well as the  tables used by {\bf
103    Bacula}. This script will be  automatically setup by the {\bf ./configure}
104    program  to create a database named {\bf bacula.db} in {\bf Bacula's}  working
105    directory. 
106 \end{enumerate}
107
108 \section{Linking Bacula with SQLite}
109 \index[general]{SQLite!Linking Bacula with }
110 \index[general]{Linking Bacula with SQLite }
111
112 If you have followed the above steps, this will all happen automatically and
113 the SQLite libraries will be linked into {\bf Bacula}. 
114
115 \section{Testing SQLite}
116 \index[general]{SQLite!Testing }
117 \index[general]{Testing SQLite }
118
119 We have much less "production" experience using SQLite than using MySQL.
120 SQLite has performed reasonably well for us in all our testing.  However,
121 several users have reported corrupted databases while using SQLite.  For
122 that reason, we do not recommend it for production use.
123
124 If Bacula crashes with the following type of error when it is started:
125 \footnotesize
126 \begin{verbatim}
127 Using default Catalog name=MyCatalog DB=bacula
128 Could not open database "bacula".
129 sqlite.c:151 Unable to open Database=/var/lib/bacula/bacula.db.
130 ERR=malformed database schema - unable to open a temporary database file
131 for storing temporary tables
132 \end{verbatim}
133 \normalsize
134
135 this is most likely caused by the fact that some versions of
136 SQLite attempt to create a temporary file in the current directory.
137 If that fails, because Bacula does not have write permission on
138 the current directory, then you may get this errr.  The solution is
139 to start Bacula in a current directory where it has write permission.
140
141
142 \section{Re-initializing the Catalog Database}
143 \index[general]{Database!Re-initializing the Catalog }
144 \index[general]{Re-initializing the Catalog Database }
145
146 After you have done some initial testing with {\bf Bacula}, you will probably
147 want to re-initialize the catalog database and throw away all the test Jobs
148 that you ran. To do so, you can do the following: 
149
150 \footnotesize
151 \begin{verbatim}
152   cd <install-directory>
153   ./drop_sqlite_tables
154   ./make_sqlite_tables
155 \end{verbatim}
156 \normalsize
157
158 Please note that all information in the database will be lost and you will be
159 starting from scratch. If you have written on any Volumes, you must write an
160 end of file mark on the volume so that Bacula can reuse it. Do so with: 
161
162 \footnotesize
163 \begin{verbatim}
164    (stop Bacula or unmount the drive)
165    mt -f /dev/nst0 rewind
166    mt -f /dev/nst0 weof
167 \end{verbatim}
168 \normalsize
169
170 Where you should replace {\bf /dev/nst0} with the appropriate tape drive
171 device name for your machine.