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