Debian Codegraph @

manuals/en/main/mysql.tex

raw
1 %%
2 %%
3
4 \chapter{Installing and Configuring \mysql{}}
5 \label{blb:MySqlChapter}
6 \index[general]{\mysql{}!Installing and Configuring }
7 \index[general]{Installing and Configuring \mysql{} }
8
9 \section{Installing and Configuring \mysql{} -- Phase I}
10 \index[general]{Installing and Configuring \mysql{} -- Phase I }
11 \index[general]{Phase I!Installing and Configuring \mysql{} -- }
12
13 If you use the \btool{./configure {-}{-}with-mysql=mysql-directory} statement for
14 configuring \textbf{\bacula{}}, you will need \mysql{} version 4.1 or later installed
15 in the \bdirectoryname{mysql-directory}. If you are using one of the new modes such as
16 \acs{ANSI}/\acs{ISO} compatibility, you may experience problems.
17
18 If \mysql{} is installed in the standard system location, you need only enter
19 \textbf{{-}{-}with-mysql} since the configure program will search all the
20 standard locations. If you install \mysql{} in your home directory or some
21 other non-standard directory, you will need to provide the full path to it.
22
23 Installing and Configuring \mysql{} is not difficult but can be confusing the
24 first time. As a consequence, below, we list the steps that we used to install
25 it on our machines. Please note that our configuration leaves \mysql{} without
26 any user passwords. This may be an undesirable situation if you have other
27 users on your system.
28
29 The notes below describe how to build \mysql{} from the source tar files. If
30 you have a pre-installed \mysql{}, you can return to complete the installation
31 of \bacula{}, then come back to \bilink{Phase II}{blb:mysql_phase2} of the \mysql{} installation. If you
32 wish to install \mysql{} from rpms, you will probably need to install
33 the following:
34
35 \begin{bVerbatim}
36 mysql-<version>.rpm
37 mysql-server-<version>.rpm
38 mysql-devel-<version>.rpm
39 \end{bVerbatim}
40
41 If you wish to install them from debs, you will probably need the
42 following:
43
44 \begin{bVerbatim}
45 mysql-server-<version>.deb
46 mysql-client-<version>.deb
47 libmysqlclient15-dev-<version>.deb
48 libmysqlclient15off-<version>.deb
49 \end{bVerbatim}
50
51 The names of the packages may vary from distribution to
52 distribution. It is important to have the \textbf{devel} or \textbf{dev} package loaded as
53 it contains the libraries and header files necessary to build
54 \bacula{}. There may be additional packages that are required to
55 install the above, for example, \btool{zlib} and \btool{openssl}.
56
57 Once these packages are installed, you will be able to build \bacula{} (using
58 the files installed with the \bhighlight{mysql} package, then run \mysql{} using the
59 files installed with \bhighlight{mysql-server}. If you have installed \mysql{} by debs or rpms,
60 please skip Phase I below, and return to complete the installation of
61 \bacula{}, then come back to Phase II of the \mysql{} installation when indicated
62 to do so.
63
64 Beginning with \bacula{} version 1.31, the thread safe version of the
65 \mysql{} client library is used, and hence you should add the
66 \textbf{{-}{-}enable-thread-safe-client} option to the \btool{./configure}
67 as shown below:
68
69 \begin{benumerate}
70 \item Download \mysql{} source code from
71 \bref{http://www.mysql.com/downloads}{www.mysql.com/downloads}
72
73 \item Detar it with something like:
74 \begin{bVerbatim}
75 tar xvfz mysql-filename
76 \end{bVerbatim}
77
78 Note, the above command requires GNU \tar{}. If you do not have GNU \tar{}, a
79 command such as:
80
81 \begin{bVerbatim}
82 zcat mysql-filename | tar xvf -
83 \end{bVerbatim}
84
85 will probably accomplish the same thing.
86
87 \item \begin{bVerbatim}
88 cd mysql-source-directory
89 \end{bVerbatim}
90
91 where you replace \bdirectoryname{mysql-source-directory} with the directory name where
92 you put the \mysql{} source code.
93
94 \item \begin{bVerbatim}
95 ./configure --enable-thread-safe-client --prefix=mysql-directory
96 \end{bVerbatim}
97
98 where you replace \bdirectoryname{mysql-directory} with the directory name where you
99 want to install mysql. Normally for system wide use this is \bdirectoryname{/usr/local/mysql}.
100 In my case, I use \bdirectoryname{\~{}kern/mysql}.
101
102 \item \begin{bVerbatim}
103 make
104 \end{bVerbatim}
105
106 This takes a bit of time.
107
108 \item make install
109
110 This will put all the necessary binaries, libraries and support files into
111 the \bdirectoryname{mysql-directory} that you specified above.
112
113 \item \begin{bVerbatim}
114 ./scripts/mysql\_install\_db
115 \end{bVerbatim}
116
117 This will create the necessary \mysql{} databases for controlling user access.
118 Note, this script can also be found in the \bdirectoryname{bin} directory in the
119 installation directory
120
121 \end{benumerate}
122
123 The \mysql{} client library \textbf{mysqlclient} requires the \btool{gzip} compression
124 library \bfilename{libz.a} or \bfilename{libz.so}. If you are using rpm packages, these
125 libraries are in the \textbf{libz-devel} package. On Debian systems, you will
126 need to load the \textbf{zlib1g-dev} package. If you are not using rpms or debs,
127 you will need to find the appropriate package for your system.
128
129 At this point, you should return to completing the installation of
130 \textbf{\bacula{}}. Later after \bacula{} is installed, come back to this chapter to
131 complete the installation. Please note, the installation files used in the
132 second phase of the \mysql{} installation are created during the \bacula{}
133 Installation.
134
135 \label{blb:mysql_phase2}
136 \section{Installing and Configuring \mysql{} -- Phase II}
137 \index[general]{Installing and Configuring \mysql{} -- Phase II }
138 \index[general]{Phase II!Installing and Configuring \mysql{} -- }
139
140 At this point, you should have built and installed \mysql{}, or already have a
141 running \mysql{}, and you should have configured, built and installed
142 \textbf{\bacula{}}. If not, please complete these items before proceeding.
143
144 Please note that the \btool{./configure} used to build \textbf{\bacula{}} will need to
145 include \textbf{{-}{-}with-mysql=mysql-directory}, where \bdirectoryname{mysql-directory} is the
146 directory name that you specified on the \btool{./configure} command for configuring
147 \mysql{}. This is needed so that \bacula{} can find the necessary include headers
148 and library files for interfacing to \mysql{}.
149
150 \textbf{\bacula{}} will install scripts for manipulating the database (create,
151 delete, make tables etc) into the main installation directory. These files
152 will be of the form \bfilename{*\_bacula\_*} (e.g. \bfilename{create\_bacula\_database}). These files
153 are also available in the \bdirectoryname{\bbracket{bacula-src}/src/cats} directory after
154 running \btool{./configure}. If you inspect \bfilename{create\_bacula\_database}, you will see
155 that it calls \bfilename{create\_mysql\_database}. The \bfilename{*\_bacula\_*} files are provided for
156 convenience. It doesn't matter what database you have chosen;
157 \bfilename{create\_bacula\_database} will always create your database.
158
159 Now you will create the \bacula{} \mysql{} database and the tables that \bacula{} uses.
160
161
162 \begin{benumerate}
163 \item Start \btool{mysql}. You might want to use the \btool{startmysql} script
164 provided in the \bacula{} release.
165
166 \item \begin{bVerbatim}
167 cd <install-directory>
168 \end{bVerbatim}
169 This directory contains the \bacula{} catalog interface routines.
170
171 \item \begin{bVerbatim}
172 ./grant_mysql_privileges
173 \end{bVerbatim}
174 This script creates unrestricted access rights for the user \textbf{bacula}.
175 You may want to modify it to suit your situation. Please
176 note that none of the userids, including root, are password protected.
177 If you need more security, please assign a password to the root user
178 and to bacula. The program \btool{mysqladmin} can be used for this.
179
180 \item \begin{bVerbatim}
181 ./create_mysql_database
182 \end{bVerbatim}
183 This script creates the \mysql{} \textbf{bacula} database. The databases you
184 create as well as the access databases will be located in
185 \bdirectoryname{\bbracket{install-dir}/var/} in a subdirectory with the name of the
186 database, where \bdirectoryname{\bbracket{install-dir}} is the directory name that you
187 specified on the \textbf{prefix} option. This can be important to
188 know if you want to make a special backup of the \bacula{} database or to
189 check its size.
190
191 \item \begin{bVerbatim}
192 ./make\_mysql\_tables
193 \end{bVerbatim}
194 This script creates the \mysql{} tables used by \textbf{\bacula{}}.
195 \end{benumerate}
196
197 Each of the three scripts (\bfilename{grant\_mysql\_privileges}, \bfilename{create\_mysql\_database}
198 and \bfilename{make\_mysql\_tables}) allows the addition of a command line argument. This
199 can be useful for specifying the user and or password. For example, you might
200 need to add \textbf{-u root} to the command line to have sufficient privilege to
201 create the \bacula{} tables.
202
203 To take a closer look at the access privileges that you have setup with the
204 above, you can do:
205
206 \begin{bVerbatim}
207 <mysql-directory>/bin/mysql -u root mysql
208 select * from user;
209 \end{bVerbatim}
210
211 \section{Re-initializing the Catalog Database}
212 \index[general]{Database!Re-initializing the Catalog }
213 \index[general]{Re-initializing the Catalog Database }
214
215 After you have done some initial testing with \textbf{\bacula{}}, you will probably
216 want to re-initialize the catalog database and throw away all the test Jobs
217 that you ran. To do so, you can do the following:
218
219 \begin{bVerbatim}
220 cd <install-directory>
221 ./drop_mysql_tables
222 ./make_mysql_tables
223 \end{bVerbatim}
224
225 Please note that all information in the database will be lost and you will be
226 starting from scratch. If you have written on any Volumes, you must write an
227 end of file mark on the volume so that \bacula{} can reuse it. Do so with:
228
229 \begin{bVerbatim}
230 (stop Bacula or unmount the drive)
231 mt -f /dev/nst0 rewind
232 mt -f /dev/nst0 weof
233 \end{bVerbatim}
234
235 Where you should replace \bfilename{/dev/nst0} with the appropriate tape drive
236 device name for your machine.
237
238 \section{Linking \bacula{} with \mysql{}}
239 \index[general]{Linking \bacula{} with \mysql{} }
240 \index[general]{\mysql{}!Linking \bacula{} with }
241 \index[general]{Upgrading}
242
243 After configuring \bacula{} with
244
245 \btool{./configure {-}{-}enable-thread-safe-client --prefix=\bbracket{mysql-directory}}
246 where \bdirectoryname{\bbracket{mysql-directory}} is in my case \bdirectoryname{/home/kern/mysql}, you may
247 have to configure the loader so that it can find the \mysql{} shared libraries.
248 If you have previously followed this procedure and later add the
249 \textbf{{-}{-}enable-thread-safe-client} options, you will need to rerun the \btool{ldconfig}
250 program shown below. If you put \mysql{} in a standard place such as
251 \bdirectoryname{/usr/lib} or \bdirectoryname{/usr/local/lib} this will not be necessary, but in my
252 case it is. The description that follows is Linux specific. For other
253 operating systems, please consult your manuals on how to do the same thing:
254
255 First edit: \bfilename{/etc/ld.so.conf} and add a new line to the end of the file
256 with the name of the mysql-directory. In my case, it is:
257
258 \bdirectoryname{/home/kern/mysql/lib/mysql} then rebuild the loader's cache with:
259
260 \btool{/sbin/ldconfig}. If you upgrade to a new version of \textbf{\mysql{}}, the shared
261 library names will probably change, and you must re-run the \btool{/sbin/ldconfig}
262 command so that the runtime loader can find them.
263
264 Alternatively, your system my have a loader environment variable that can be
265 set. For example, on a Solaris system where I do not have root permission, I
266 use:
267 \begin{bVerbatim}
268 LD_LIBRARY_PATH=/home/kern/mysql/lib/mysql
269 \end{bVerbatim}
270 Finally, if you have encryption enabled in \mysql{}, you may need to add
271 \textbf{-lssl -lcrypto} to the link. In that case, you can either export the
272 appropriate LDFLAGS definition, or alternatively, you can include them
273 directly on the \btool{./configure} line as in:
274
275 \begin{bVerbatim}
276 LDFLAGS="-lssl -lcyrpto" ./configure <your-options>
277 \end{bVerbatim}
278
279 \section{Installing \mysql{} from RPMs}
280 \index[general]{\mysql{}!Installing from RPMs}
281 \index[general]{Installing \mysql{} from RPMs}
282 If you are installing \mysql{} from \acsp{RPM}, you will need to install
283 both the \mysql{} binaries and the client libraries. The client
284 libraries are usually found in a devel package, so you must
285 install:
286
287 \begin{bVerbatim}
288 mysql
289 mysql-devel
290 \end{bVerbatim}
291
292 This will be the same with most other package managers too.
293
294 \section{Upgrading \mysql{}}
295 \index[general]{Upgrading \mysql{} }
296 \index[general]{Upgrading!\mysql{} }
297 \index[general]{Upgrading}
298 If you upgrade \mysql{}, you must reconfigure, rebuild, and re-install
299 \bacula{} otherwise you are likely to get bizarre failures. If you
300 install from rpms and you upgrade \mysql{}, you must also rebuild \bacula{}.
301 You can do so by rebuilding from the source rpm. To do so, you may need
302 to modify the \bfilename{bacula.spec} file to account for the new \mysql{} version.
303
304
305 \section{\mysql{} Configuration Caution}
306 \index[general]{\mysql{} Caution}
307 Bacula requires that at least one of the \textbf{TIMESTAMP} fields in the
308 database schema to have a valid value of zero. If you turn on the
309 \textbf{SQL\_MODE} \textbf{STRICT\_ALL\_TABLES}, you must be sure that you
310 turn off the \textbf{NO\_ZERO\_DATA} and the \textbf{NO\_ZERO\_IN\_DATE}
311 restrictions or Bacula will not function correctly.