]> git.sur5r.net Git - bacula/docs/blobdiff - docs/manual-de/postgresql.tex
Eliminate compiler warnings
[bacula/docs] / docs / manual-de / postgresql.tex
index d5bc08479aa440f277d5aa69502baaaf111ffaeb..e8df71a732dccd239c069dfaceeaf7b368395185 100644 (file)
 \addcontentsline{toc}{subsection}{Installing and Configuring PostgreSQL --
 Phase I}
 
-If you use the {\bf ./configure \verb{--{with-postgresql=PostgreSQL-Directory}
+If you use the {\bf ./configure \verb:--:with-postgresql=PostgreSQL-Directory}
 statement for configuring {\bf Bacula}, you will need PostgreSQL version 7.3
 or later installed. NOTE! PostgreSQL versions earlier than 7.3 do not work
 with Bacula. If PostgreSQL is installed in the standard system location, you
-need only enter {\bf \verb{--{with-postgresql} since the configure program will
+need only enter {\bf \verb:--:with-postgresql} since the configure program will
 search all the standard locations. If you install PostgreSQL in your home
 directory or some other non-standard directory, you will need to provide the
-full path with the {\bf \verb{--{with-postgresql} option. 
+full path with the {\bf \verb:--:with-postgresql} option. 
 
 Installing and configuring PostgreSQL is not difficult but can be confusing
 the first time. If you prefer, you may want to use a package provided by your
@@ -54,7 +54,7 @@ a running PostgreSQL, and you should have configured, built and installed {\bf
 Bacula}. If not, please complete these items before proceeding. 
 
 Please note that the {\bf ./configure} used to build {\bf Bacula} will need to
-include {\bf \verb{--{with-postgresql=PostgreSQL-directory}, where {\bf
+include {\bf \verb:--:with-postgresql=PostgreSQL-directory}, where {\bf
 PostgreSQL-directory} is the directory name that you specified on the
 ./configure command for configuring PostgreSQL (if you didn't specify a
 directory or PostgreSQL is installed in a default location, you do not need to
@@ -84,6 +84,30 @@ user).
 \item ./create\_bacula\_database
 
    This script creates the PostgreSQL {\bf bacula} database.  
+   If it fails, it is probably because the database is owned by a
+   user other than yourself. On many systems, the database owner is
+   {\bf pgsql} and on others such as RedHat and Fedora it is {\bf postgres}.
+   You can find out which it is by examining your /etc/passwd file.
+   To create a new user under either your name or with say the name
+   {\bf bacula}, you can do the following:
+
+\begin{verbatim}
+   su
+   (enter root password)
+   password pgsql (or postgres)
+   (enter a password for this account)
+   exit
+   su pgsql (or postgres)
+   (enter password just created)
+   createuser kern (or perhaps bacula)
+   Shall the new user be allowed to create databases? (y/n) y
+   Shall the new user be allowed to create more new users? (y/n) (choose
+         what you want)
+   exit
+\end{verbatim}
+    
+    At this point, you should be able to execute the
+    ./create\_bacula\_database command.
 
 \item ./make\_bacula\_tables
 
@@ -111,6 +135,90 @@ PostgreSQL-directory/bin/psql --command \\dp bacula
 \end{verbatim}
 \normalsize
 
+Also, I had an authorization problem with the password. In the end,
+I had to modify my {\bf pg_hba.conf} file (in /var/lib/pgsql on my machine)
+from:
+
+\footnotesize
+\begin{verbatim}
+  local   all    all        ident
+to
+  local   all    all        trust
+\end{verbatim}
+\normalsize
+
+This solved the problem for me, but it is not always a good thing
+to do from a security standpoint.  However, it allowed me to run
+my regression scripts without having a password.
+
+A more secure way to perform database authentication is with md5
+password hashes.  Begin by editing the {\bf pg_hba.conf} file, and
+just prior the the existing ``local'' and ``host'' lines, add the line:
+
+\footnotesize
+\begin{verbatim}
+  local bacula bacula md5
+\end{verbatim}
+\normalsize
+
+and restart the Postgres database server (frequently, this can be done
+using "/etc/init.d/postgresql restart") to put this new authentication
+rule into effect.
+
+Next, become the Postgres administrator, postgres, either by logging
+on as the postgres user, or by using su to become root and then using
+su - postgres to become postgres.  Add a password to the bacula
+database for the bacula user using:
+
+\footnotesize
+\begin{verbatim}
+  \$ psql bacula
+  bacula=# alter user bacula with password 'secret';
+  ALTER USER
+  bacula=# \\q
+\end{verbatim}
+\normalsize
+
+Next, you'll have to add this password to two locations in the
+bacula-dir.conf file: once to the Catalog resource and once to the
+RunBeforeJob entry in the BackupCatalog Job resource.  With the
+password in place, these two lines should look something like:
+
+\footnotesize
+\begin{verbatim}
+  dbname = bacula; user = bacula; password = "secret"
+    ... and ...
+  RunBeforeJob = "/etc/make_catalog_backup bacula bacula secret"
+\end{verbatim}
+\normalsize
+
+Naturally, you should choose your own significantly more random
+password, and ensure that the bacula-dir.conf file containing this
+password is readable only by the root.
+
+Even with the files containing the database password properly
+restricted, there is still a security problem with this approach: on
+some platforms, the environment variable that is used to supply the
+password to Postgres is unavoidable made available to all users of the
+local system.  To eliminate this problem, the Postgres team have
+deprecated the use of the environment variable password-passing
+mechanism and recommend the use of a .pgpass file instead.  To use
+this mechanism, create a file named .pgpass containing the single
+line:
+
+\footnotesize
+\begin{verbatim}
+  localhost:5432:bacula:bacula:secret
+\end{verbatim}
+\normalsize
+
+This file should be copied into the home directory of all accounts
+that will need to gain access to the database: typically, root,
+bacula, and any users who will make use of any of the console
+programs.  The files must then have the owner and group set to match
+the user (so root:root for the copy in ~root, and so on), and the mode
+set to 600, limiting access to the owner of the file.
+
 \subsection*{Re-initializing the Catalog Database}
 \index[general]{Database!Re-initializing the Catalog }
 \index[general]{Re-initializing the Catalog Database }
@@ -144,6 +252,25 @@ end of file mark on the volume so that Bacula can reuse it. Do so with:
 Where you should replace {\bf /dev/nst0} with the appropriate tape drive
 device name for your machine. 
 
+\subsection*{Installing PostgreSQL from RPMs}
+\index[general]{PostgreSQL!Installing from RPMs}
+\index[general]{Installing PostgreSQL from RPMs}
+\addcontentsline{toc}{subsection}{Installing PostgreSQL from RPMs}
+If you are installing PostgreSQL from RPMs, you will need to install
+both the PostgreSQL binaries and the client libraries.  The client
+libraries are ususally found in a devel package, so you must
+install:
+
+\footnotesize
+\begin{verbatim}
+  postgresql
+  postgresql-devel
+\end{verbatim}
+\normalsize
+
+This will be the same with most other package managers too.
+
+
 \subsection*{Converting from MySQL to PostgreSQL}
 \index[general]{PostgreSQL!Converting from MySQL to }
 \index[general]{Converting from MySQL to PostgreSQL }
@@ -268,11 +395,21 @@ SELECT SETVAL('pool_poolid_seq', (SELECT MAX(poolid) FROM pool));
 
 \item At this point, start up Bacula, verify your volume library and  perform
    a test backup to make sure everything is working  properly. 
-   \end{enumerate}
+\end{enumerate}
+
+\subsection*{Upgrading PostgreSQL}
+\index[general]{Upgrading PostgreSQL }
+\index[general]{Upgrading!PostgreSQL }
+\addcontentsline{toc}{subsection}{Upgrading PostgreSQL}
+If you upgrade PostgreSQL, you must reconfigure, rebuild, and re-install 
+Bacula otherwise you are likely to get bizarre failures.  If you
+to modify the bacula.spec file to account for the new PostgreSQL version.
+You can do so by rebuilding from the source rpm. To do so, you may need
+install from rpms and you upgrade PostgreSQL, you must also rebuild Bacula.
+
 
 \subsection*{Credits}
 \index[general]{Credits }
 \addcontentsline{toc}{subsection}{Credits}
-
 Many thanks to Dan Langille for writing the PostgreSQL driver. This will
 surely become the most popular database that Bacula supports.