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