Setting Up PostgreSQL as the Database on the Cloud Controller
OpenStack can use PostgreSQL as an alternative database. This is a matter of substituting the MySQL steps with PostgreSQL equivalents, as outlined here.
First, install PostgreSQL on the controller node.
apt-fast install postgresql postgresql-server-dev-8.4 python-dev python-psycopg2
Edit /etc/postgresql/8.4/main/postgresql.conf and change the listen_address to listen to all appropriate addresses, PostgreSQL listen only to localhost by default. For example:
To listen on a specific IP address:
# - Connection Settings -
listen_address = '10.1.1.200,192.168.100.2'
To listen on all addresses:
# - Connection Settings -
listen_address = '*'
Add appropriate addresses and networks to /etc/postgresql/8.4/main/pg_hba.conf to allow remote access to PostgreSQL, this should include all servers hosting OpenStack (but not neccessarily those hosted by Openstack). As an example, append the following lines:
host all all 192.168.0.0/16
host all all 10.1.0.0/16
Change the default PostgreSQL user's password:
sudo -u postgres psql template1
template1=#\password
Enter Password:
Enter again:
template1=#\q
Restart PostgreSQL:
service postgresql restart
Create nova databases:
sudo -u postgres createdb nova
sudo -u postgres createdb glance
Create nova database user which will be used for all OpenStack services, note the adduser and createuser steps will prompt for the user's password ($PG_PASS):
adduser nova
sudo -u postgres createuser -PSDR nova
sudo -u postgres psql template1
template1=#GRANT ALL PRIVILEGES ON DATABASE nova TO nova
template1=#GRANT ALL PRIVILEGES ON DATABASE glance TO nova
template1=#\q
For the Cactus version of Nova, the following fix is required for the PostgreSQL database schema. You don't need to do this for Diablo:
sudo -u postgres psql template1
template1=#alter table instances alter instance_type_id type integer using cast(instance_type_id as integer);
template1=#\q
For Nova components that require access to this database the required configuration in /etc/nova/nova.conf should be (replace $PG_PASS with password):
--sql_connection=postgresql://nova:$PG_PASS@control.example.com/nova
At this stage the databases are empty and contain no content. These will be initialised when you do the nova-manage db sync command.