Bacula 1.29 User's Guide Chapter 19
Back
Restoring Files with a Bootstrap File
Index
Index
Next
Installing and Configuring SQLite

Installing and Configuring MySQL

Installing and Configuring MySQL -- Phase I

If you use the ./configure --with-mysql=mysql-directory statement for configuring Bacula, you will need MySQL version 3.23.33 or later installed in the mysql-directory (we are currently using 3.23.40). If MySQL is installed in the standard system location, you need only enter --with-mysql since the configure program will search all the standard locations. If you install MySQL in your home directory or some other non-standard directory, you will need to provide the full path to it.

To minimize the problems you may encounter in finding and installing MySQL, we provide a copy of the MySQL source code that we use in the depkgs1 package.

Installing and Configuring MySQL is not difficult but can be confusing the first time. As a consequence, below, we list the steps that we used to install it on our machines. Please note that our configuration leaves MySQL without any user passwords. This may be an undesirable situation if you have other users on your system.

  1. Download MySQL source code from www.mysql.com/downloads or download our depkgs-mysql package with the same release number as Bacula.

  2. Detar it with something like:

    tar xvfz mysql-filename

    Note, the above command requires GNU tar. If you do not have GNU tar, a command such as:

    zcat mysql-filename | tar xvf -

    will probably accomplish the same thing.

  3. cd mysql-source-directory

    where you replace mysql-source-directory with the directory name where you put the MySQL source code.
  4. ./configure --prefix=mysql-directory

    where you replace mysql-directory with the directory name where you want to install mysql. Normally for system wide use this is /usr/local/mysql. In my case, I use ~kern/mysql.
  5. make

    This takes a bit of time.
  6. make install

    This will put all the necessary binaries, libraries and support files into the mysql-directory that you specified above.
  7. ./scripts/mysql_install_db

    This will create the necessary MySQL databases for controlling user access. Note, this script can also be found in the bin directory in the installation directory
At this point, you should return to completing the installation of Bacula. Later after Bacula is installed, come back to this chapter to complete the installation. Please note, the installation files used in the second phase of the MySQL installation are created during the Bacula Installation.

Installing and Configuring MySQL -- Phase II

At this point, you should have built and installed MySQL, or already have a running MySQL, and you should have configured, built and installed Bacula. If not, please complete these items before proceeding.

Please note that the ./configure used to build Bacula will need to include --with-mysql=mysql-directory, where mysql-directory is the directory name that you specified on the ./configure command for configuring MySQL. This is needed so that Bacula can find the necessary include headers and library files for interfacing to MySQL.

Now you will create the Bacula MySQL database and the tables that Bacula uses.

  1. Start mysql. You might want to use the startmysql script provided in the Bacula release.
  2. cd <bacula-src>/src/cats

    This directory contains the Bacula catalog interface routines.
  3. ./grant_mysql_privileges

    This script creates unrestricted access rights for kern, kelvin, and bacula. You may want to modify it to suit your situation. Please note that none of these userids including root are password protected.
  4. ./create_mysql_database

    This script creates the MySQL bacula database. The databases you create as well as the access databases will be located in <install-dir>/var/ in a subdirectory with the name of the database, where <install-dir> is the directory name that you specified on the --prefix option. This can be important to know if you want to make a special backup of the Bacula database or to check its size.
  5. ./make_mysql_tables

    This script creates the MySQL tables used by Bacula.

To take a closer look at the access privileges that you have setup with the above, you can do:
mysql-directory/bin/mysql -u root mysql
select * from user;

Re-initializing the Catalog Database

After you have done some initial testing with Bacula, you will probably want to re-initialize the catalog database and throw away all the test Jobs that you ran. To do so, you can do the following:
  cd <bacula-source>/src/cats
  ./drop_mysql_tables
  ./make_mysql_tables
Please note that all information in the database will be lost and you will be starting from scratch. If you have written on any Volumes, you must write and end of file mark on the volume so that Bacula can reuse it. Do so with:
   (stop Bacula or unmount the drive)
   mt -f /dev/nst0 rewind
   mt -f /dev/nst0 weof
Where you should replace /dev/nst0 with the appropriate tape drive device name for your machine.

Linking Bacula with MySQL

After configuring Bacula with

./configure --prefix=<mysql-directory>

where <mysql-directory> is in my case /home/kern/mysql, you may have to configure the loader so that it can find the MySQL shared libraries. If you put MySQL in a standard place such as /usr/lib or /usr/local/lib this will not be necessary, but in my case it is. The description that follows is Linux specific. For other operating systems, please consult your manuals on how to do the same thing:

First edit: /etc/ld.so.conf and add a new line to the end of the file with the name of the mysql-directory. In my case, it is:

/home/kern/mysql/lib/mysql

then rebuild the loader's cache with:

/sbin/ldconfig

If you upgrade to a new version of MySQL, the shared library names will probably changes, and you must re-run the /sbin/ldconfig command so that the runtime loader can find them.

Alternatively, your system my have a loader environment variable that can be set. For example, on a Solaris system where I do not have root permission, I use:

LD_LIBRARY_PATH=/home/kern/mysql/lib/mysql


Back
Restoring Files with a Bootstrap File
Index
Index
Next
Installing and Configuring SQLite
Bacula 1.29 User's Guide
The Network Backup Solution
Copyright © 2000-2003
Kern Sibbald and John Walker