<?xml version="1.0" encoding="UTF-8"?>
<section xml:id="setting-up-sql-database-postgresql"
    xmlns="http://docbook.org/ns/docbook"
    xmlns:xi="http://www.w3.org/2001/XInclude"
    xmlns:xlink="http://www.w3.org/1999/xlink" version="5.0">
    <title>Configuring the SQL Database (PostgreSQL) on the Cloud Controller</title>

    <para>Optionally, if you choose not to use MySQL, you can install
    and configure PostgreSQL for all your databases. Here's a
    walkthrough for the Nova database:</para>
    <screen os="ubuntu"><prompt>$</prompt> <userinput>sudo apt-get install postgresql postgresql-client</userinput></screen>
    <screen os="rhel;centos;fedora"><prompt>$</prompt> <userinput>sudo yum install postgresql postgresql-server</userinput></screen>
    <screen os="opensuse"><prompt>$</prompt> <userinput>zypper install postgresql postgresql-server</userinput></screen>
    <para>Start the PostgreSQL command line client by running:</para>
    <para><userinput>sudo su - postgres</userinput></para>
    <para>Enter the postgresql root user's password if prompted.</para>
    <para>To configure the database, create the nova database.</para>
    <para><screen>postgres> psql
postgres=# CREATE USER novadbadmin;
postgres=# ALTER USER novadbadmin WITH PASSWORD '<replaceable>[YOUR_NOVADB_PASSWORD]</replaceable>';
postgres=# CREATE DATABASE nova;
postgres=# GRANT ALL PRIVILEGES ON DATABASE nova TO novadbadmin;
postgres=# \q
postgres> exit</screen></para>
    <para>The database is created and we have a privileged user that
    controls the database. Now we have to install the packages that
    will help Nova access the database.</para>

    <screen os="ubuntu"><prompt>$</prompt> <userinput>sudo apt-get install python-sqlalchemy python-psycopg2</userinput></screen>
    <screen os="rhel;centos;fedora"><prompt>$</prompt> <userinput>sudo yum install python-sqlalchemy python-psycopg2</userinput></screen>
    <screen os="opensuse"><prompt>$</prompt> <userinput>sudo zypper install python-SQLAlchemy  python-psycopg2</userinput></screen>

    <para>Configure the <filename>/etc/nova/nova.conf</filename> file,
    to ensure it knows to use the PostgreSQL database:</para>

    <literallayout class="monospaced">[database]
connection = postgres://novadbadmin:[<replaceable>[YOUR_NOVADB_PASSWORD]</replaceable>]@127.0.0.1/nova</literallayout>
    <para>The command to populate the database is described later in the
        documentation, in the section entitled <link
        linkend="compute-db-sync">Configuring the Database for Compute</link>.
    </para>
</section>