DatabaseSetup

Not logged in - Log In / Register

Revision 3 as of 2010-08-12 19:31:45

Clear message

Launchpad Database Setup

There are two ways to set up your launchpad database.

Automated Launchpad Database Setup

To set up postgres for running Launchpad, try using the launchpad-database-setup script from the Launchpad source tree. If you have one (see RocketFuelSetup), you should find it in utilities/.

WARNING: Do not use this script if you are using postgres for anything besides Launchpad. The script expects a freshly installed postgresql database, so It will destroy any postgres databases you already have on your system. If that is a problem for you, use the manual procedure instead and adapt to your needs.

Manual Launchpad Database Setup

These installation instructions apply to the new PostgreSQL database infrastructure as found in Ubuntu Breezy and later, and Debian Etch and later.

The initial Launchpad database should be done on your system with the following sequence of commands:

  1. Shutdown any existing PostgreSQL instances you may have installed
    • sudo -u postgres pg_ctlcluster 7.4 main stop
      sudo -u postgres pg_ctlcluster 8.0 main stop
      sudo -u postgres pg_ctlcluster 8.1 main stop
      sudo -u postgres pg_ctlcluster 8.2 main stop
  2. If you have any other postgres databasese on your system: To avoid conflicting usage of ports by PostgreSQL 8.2 and any earlier versions, ensure that any existing PostgreSQL clusters are not running on port 5432.

    • Edit /etc/postgresql/{7.4,8.0,8.1,8.2}/*/postgresql.conf and change the port= settings to 5433, 5434, 5435 etc. For example, if you have postgresql 8.2 installed and nothing fancy (only one cluster) edit /etc/postgresql/8.2/main/postgresql.conf:

      port = 5432
      and replace that by
      port = 5433
      You may also want to edit `/etc/postgresql/{7.4,8.0,8.1,8.2}/*/start.conf to select which instances are run on startup, or even uninstall the earlier PostgreSQL versions.
  3. Install packages (Done by rocketfuel-setup, if you used that.):
    • sudo aptitude install launchpad-database-dependencies
      which is equivalent to:
      sudo aptitude install postgresql-8.4 postgresql-client-8.4 postgresql-contrib-8.4 postgresql-plpython-8.4 python-psycopg2
  4. Nuke the default database and recreate with the current required locale:
    • $ sudo pg_dropcluster 8.4 main --stop-server
      
      $ LC_ALL=C sudo pg_createcluster 8.4 main --start --encoding UNICODE
  5. add the following lines at the top of the file /etc/postgresql/8.4/main/pg_hba.conf:

    • # allow unauthenticated connections to localhost
      local   all         all                               trust
      host    all         all         127.0.0.1/32          trust

      Note that this gives all accounts on your local box full access to PostgreSQL - if this is a problem talk to StuartBishop for more detailed instructions (this requires occasional maintenance).

  6. Add the following options to /etc/postgresql/8.4/main/postgresql.conf:
    • # Enable launchpad full text searching in database
      search_path='"$user",public,ts2'
      add_missing_from=false
      #enable_seqscan=false
      log_statement='all'
      log_line_prefix='[%t] %q%u@%d '
      fsync = off
      max_fsm_relations = 2000

      The first two are required. enable_seqscan helps tune queries as it forces PostgreSQL to use indexes if they are available (PostgreSQL often won't use them with our sample data because it is more efficient to simply scan the entire table), but will cause things to run a bit slower. The log_* statements output all queries sent to the server to /var/log/postgresql/postgresql-8.4-main.log, which helps you debug and understand what your code (and in particular SQLObject) is doing. The fsync = off line improves performance at the slightly increased risk of database integrity loss, by disabling fsyncs from postgresql. This change makes certain development tasks more efficient, for example, the amount of time required to create a new database can be dramatically reduced. In exchange, if your computer crashes, you would need to recreate the whole postgresql cluster.

  7. Restart the postgres server:
    • sudo invoke-rc.d postgresql-8.4 restart
  8. make sure your default PostgreSQL user is a superuser. Your default PostgreSQL user has the same name as your login account (if it existed already, and it was not a superuser, drop it first):
    • sudo -u postgres dropuser $(id -un)
      sudo -u postgres createuser -s -d $(id -un)
  9. create the databases, users, permissions and populate it with sampledata:
    • cd $your_launchpad_checkout; make schema
  10. Profit! Enjoy your shiny new launchpad database.