]> git.sur5r.net Git - bacula/docs/blob - docs/manual/mysql.tex
- Litle fix
[bacula/docs] / docs / manual / 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 \item cd \lt{}install-directory\gt{}
126
127    This directory contains the Bacula catalog  interface routines.  
128
129 \item ./grant\_mysql\_privileges
130
131    This script creates unrestricted access rights for the user {\bf bacula}. 
132    You may  want to modify it to suit your situation. Please
133    note that none of the userids, including root, are password protected.  
134    If you need more security, please assign a password to the root user
135    and to bacula. The program {\bf mysqladmin} can be used for this.
136
137 \item ./create\_mysql\_database
138
139    This script creates the MySQL {\bf bacula} database.  The databases you create
140 as well as the access databases  will be located in \lt{}install-dir\gt{}/var/
141 in a subdirectory  with the name of the database, where \lt{}install-dir\gt{}
142 is the  directory name that you specified on the {\bf \verb:--:prefix} option. This 
143 can be important to know if you want to make a special backup  of the Bacula
144 database or to check its size.  
145
146 \item ./make\_mysql\_tables
147
148    This script creates the MySQL tables used by {\bf Bacula}. 
149 \end{enumerate}
150
151 Each of the three scripts (grant\_mysql\_privileges, create\_mysql\_database
152 and make\_mysql\_tables) allows the addition of a command line argument. This
153 can be useful for specifying the user and or password. For example, you might
154 need to add {\bf -u root} to the command line to have sufficient privilege to
155 create the Bacula tables. 
156
157 To take a closer look at the access privileges that you have setup with the
158 above, you can do: 
159
160 \footnotesize
161 \begin{verbatim}
162 mysql-directory/bin/mysql -u root mysql
163 select * from user;
164 \end{verbatim}
165 \normalsize
166
167 \subsection*{Re-initializing the Catalog Database}
168 \index[general]{Database!Re-initializing the Catalog }
169 \index[general]{Re-initializing the Catalog Database }
170 \addcontentsline{toc}{subsection}{Re-initializing the Catalog Database}
171
172 After you have done some initial testing with {\bf Bacula}, you will probably
173 want to re-initialize the catalog database and throw away all the test Jobs
174 that you ran. To do so, you can do the following: 
175
176 \footnotesize
177 \begin{verbatim}
178   cd <install-directory>
179   ./drop_mysql_tables
180   ./make_mysql_tables
181 \end{verbatim}
182 \normalsize
183
184 Please note that all information in the database will be lost and you will be
185 starting from scratch. If you have written on any Volumes, you must write an
186 end of file mark on the volume so that Bacula can reuse it. Do so with: 
187
188 \footnotesize
189 \begin{verbatim}
190    (stop Bacula or unmount the drive)
191    mt -f /dev/nst0 rewind
192    mt -f /dev/nst0 weof
193 \end{verbatim}
194 \normalsize
195
196 Where you should replace {\bf /dev/nst0} with the appropriate tape drive
197 device name for your machine. 
198
199 \subsection*{Linking Bacula with MySQL}
200 \index[general]{Linking Bacula with MySQL }
201 \index[general]{MySQL!Linking Bacula with }
202 \addcontentsline{toc}{subsection}{Linking Bacula with MySQL}
203
204 After configuring Bacula with 
205
206 ./configure \verb:--:enable-thread-safe-client \verb:--:prefix=\lt{}mysql-directory\gt{}
207 where \lt{}mysql-directory\gt{} is in my case {\bf /home/kern/mysql}, you may
208 have to configure the loader so that it can find the MySQL shared libraries.
209 If you have previously followed this procedure and later add the {\bf
210 \verb:--:enable-thread-safe-client} options, you will need to rerun the {\bf
211 ldconfig} program shown below. If you put MySQL in a standard place such as
212 {\bf /usr/lib} or {\bf /usr/local/lib} this will not be necessary, but in my
213 case it is. The description that follows is Linux specific. For other
214 operating systems, please consult your manuals on how to do the same thing: 
215
216 First edit: {\bf /etc/ld.so.conf} and add a new line to the end of the file
217 with the name of the mysql-directory. In my case, it is: 
218
219 /home/kern/mysql/lib/mysql then rebuild the loader's cache with: 
220
221 /sbin/ldconfig If you upgrade to a new version of {\bf MySQL}, the shared
222 library names will probably change, and you must re-run the {\bf
223 /sbin/ldconfig} command so that the runtime loader can find them. 
224
225 Alternatively, your system my have a loader environment variable that can be
226 set. For example, on a Solaris system where I do not have root permission, I
227 use: 
228
229 LD\_LIBRARY\_PATH=/home/kern/mysql/lib/mysql 
230
231 Finally, if you have encryption enabled in MySQL, you may need to add {\bf
232 -lssl -lcrypto} to the link. In that case, you can either export the
233 appropriate LDFLAGS definition, or alternatively, you can include them
234 directly on the ./configure line as in: 
235
236 \footnotesize
237 \begin{verbatim}
238 LDFLAGS="-lssl -lcyrpto" \
239    ./configure \
240       <your-options>
241 \end{verbatim}
242 \normalsize
243
244 \subsection*{Upgrading MySQL}
245 \index[general]{Upgrading MySQL }
246 \index[general]{Upgrading!MySQL }
247 \addcontentsline{toc}{subsection}{Upgrading MySQL}
248 If you upgrade MySQL, you must reconfigure, rebuild, and re-install 
249 Bacula otherwise you are likely to get bizarre failures.  If you
250 install from rpms and you upgrade MySQL, you must also rebuild Bacula.
251 You can do so by rebuilding from the source rpm. To do so, you may need
252 eo modify the bacula.spec file to account for the new MySQL version.