Debian Codegraph @

manuals/en/main/sqlite.tex

raw
1 \chapter{Installing and Configuring \sqlite{}}
2 \label{blb:SqlLiteChapter}
3 \index[general]{Installing and Configuring \sqlite{} }
4 \index[general]{\sqlite{}!Installing and Configuring }
5
6 Note: \sqlite{} implementation remains in the source code, but \sqlite{}
7 is no longer supported by the Bacula project. We strongly recommend that you
8 use either MySQL or PostgreSQL. The code will remain in the source as
9 long as the community contributes fixes for each version.
10
11 Please note that \sqlite{} is not network enabled,
12 which means that it must be linked into the Director rather than accessed
13 by the network as MySQL and PostgreSQL are. This has two consequences:
14 \begin{benumerate}
15 \item \sqlite{} cannot be used in the \textbf{BWeb} web GUI package.
16 \item If you use \sqlite{}, and your Storage daemon is not on the same
17 machine as your Director, you will need to transfer your database
18 to the Storage daemon's machine before you can use any of the SD tools
19 such as \btool{bscan}, \ldots{}
20 \end{benumerate}
21
22 \section{Installing and Configuring \sqlite{} -- Phase I}
23 \index[general]{Phase I!Installing and Configuring \sqlite{} -- }
24 \index[general]{Installing and Configuring \sqlite{} -- Phase I }
25
26 If you use the \btool{./configure {-}{-}with-sqlite} statement for configuring \textbf{\bacula{}},
27 you will need \sqlite{} version 2.8.16 or later installed. Our standard
28 location (for the moment) for \sqlite{} is in the dependency package \bdirectoryname{depkgs/sqlite-2.8.16}. Please note that the version will be updated as new
29 versions are available and tested.
30
31 Installing and Configuring is quite easy.
32
33 \begin{benumerate}
34 \item Download the \bacula{} dependency packages
35 \item Detar it with something like:
36
37 \begin{bVerbatim}
38 tar xvfz depkgs.tar.gz
39 \end{bVerbatim}
40
41 Note, the above command requires \acs{GNU} \tar{}. If you do not have \acs{GNU} \tar{}, a
42 command such as:
43
44 \begin{bVerbatim}
45 zcat depkgs.tar.gz | tar xvf -
46 \end{bVerbatim}
47
48 will probably accomplish the same thing.
49
50 \item and build it:
51 \begin{bVerbatim}
52 cd depkgs
53 make sqlite
54 \end{bVerbatim}
55 \end{benumerate}
56
57
58 Please note that the \btool{./configure} used to build \textbf{\bacula{}} will need to
59 include \textbf{{-}{-}with-sqlite} or \textbf{{-}{-}with-sqlite3} depending
60 one which version of \sqlite{} you are using. You should not use the \textbf{{-}{-}enable-batch-insert}
61 configuration parameter for \bacula{} if you
62 are using \sqlite{} version 2 as it is probably not thread safe. If you
63 are using \sqlite{} version 3, you may use the \textbf{{-}{-}enable-batch-insert}
64 configuration option with \bacula{}, but when building \sqlite{}3 you \textbf{must}
65 configure it with \textbf{{-}{-}enable-threadsafe} and
66 \textbf{{-}{-}enable-cross-thread-connections}.
67
68 By default, \sqlite{}3 is now run with \textbf{PRAGMA synchronous=OFF} this
69 increases the speed by more than 30 times, but it also increases the
70 possibility of a corrupted database if your server crashes (power failure
71 or kernel bug). If you want more security, you can change the PRAGMA
72 that is used in the file \bfilename{src/version.h}.
73
74
75 At this point, you should return to completing the installation of \textbf{\bacula{}}.
76
77
78 \section{Installing and Configuring \sqlite{} -- Phase II}
79 \label{blb:sqlite_phase2}
80 \index[general]{Phase II!Installing and Configuring \sqlite{} -- }
81 \index[general]{Installing and Configuring \sqlite{} -- Phase II }
82
83 This phase is done \textbf{after} you have run the \btool{./configure} command to
84 configure \textbf{\bacula{}}.
85
86 \textbf{\bacula{}} will install scripts for manipulating the database (create,
87 delete, make tables etc) into the main installation directory. These files
88 will be of the form \bfilename{*\_bacula\_*} (e.g. \bfilename{create\_bacula\_database}).
89 These files are also available in the \bdirectoryname{\bbracket{bacula-src}/src/cats} directory after
90 running \btool{./configure}. If you inspect \bfilename{create\_bacula\_database}, you will see
91 that it calls \bfilename{create\_sqlite\_database}. The \bfilename{*\_bacula\_*}files are provided
92 for convenience. It doesn't matter what database you have chosen;
93 \bfilename{create\_bacula\_database} will always create your database.
94
95 At this point, you can create the \sqlite{} database and tables:
96
97 \begin{benumerate}
98 \item cd \bbracket{install-directory}
99
100 This directory contains the \bacula{} catalog interface routines.
101
102 \item \btool{./make\_sqlite\_tables}
103
104 This script creates the \sqlite{} database as well as the tables used by \textbf{\bacula{}}.
105 This script will be automatically setup by the \btool{./configure}
106 program to create a database named \textbf{bacula.db} in \textbf{\bacula{}'s} working
107 directory.
108 \end{benumerate}
109
110 \section{Linking \bacula{} with \sqlite{}}
111 \index[general]{\sqlite{}!Linking \bacula{} with }
112 \index[general]{Linking \bacula{} with \sqlite{} }
113
114 If you have followed the above steps, this will all happen automatically and
115 the \sqlite{} libraries will be linked into \textbf{\bacula{}}.
116
117 \section{Testing \sqlite{}}
118 \index[general]{\sqlite{}!Testing }
119 \index[general]{Testing \sqlite{} }
120
121 We have much less ``production'' experience using \sqlite{} than using \mysql{}.
122 \sqlite{} has performed flawlessly for us in all our testing. However,
123 several users have reported corrupted databases while using \sqlite{}. For
124 that reason, we do not recommend it for production use.
125
126 If \bacula{} crashes with the following type of error when it is started:
127 \begin{bVerbatim}
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{bVerbatim}
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 \textbf{\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 \begin{bVerbatim}
151 cd <install-directory>
152 ./drop_sqlite_tables
153 ./make_sqlite_tables
154 \end{bVerbatim}
155
156 Please note that all information in the database will be lost and you will be
157 starting from scratch. If you have written on any Volumes, you must write an
158 end of file mark on the volume so that \bacula{} can reuse it. Do so with:
159
160 Stop \bacula{} or unmount the drive
161 \begin{bVerbatim}
162 mt -f /dev/nst0 rewind
163 mt -f /dev/nst0 weof
164 \end{bVerbatim}
165
166 Where you should replace \bfilename{/dev/nst0} with the appropriate tape drive
167 device name for your machine.