Diff for "DatabaseSetup"

Not logged in - Log In / Register

Differences between revisions 5 and 6
Revision 5 as of 2011-08-31 21:58:43
Size: 4614
Editor: mwhudson
Comment:
Revision 6 as of 2015-09-24 09:22:34
Size: 4484
Editor: wgrant
Comment: Modernise (8.4 -> 9.3, IPv6, blah blah)
Deletions are marked like this. Additions are marked like this.
Line 16: Line 16:
 1. Shutdown any existing PostgreSQL instances you may have installed
    {{{
sudo -u postgres pg_ctlcluster 8. main stop
sudo -u postgres pg_ctlcluster 8.3 main stop
sudo -u postgres pg_ctlcluster 8.4 main stop
sudo -u postgres pg_ctlcluster 9.1 main stop
}}}
 1. '''If you have any versions of PostgreSQL other than 9.3 on your system:''' Launchpad requires PostgreSQL 9.3 on port 5432. Ensure that any existing PostgreSQL clusters are not running on port 5432.
Line 24: Line 18:
 1. '''If you have any other postgres databases 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/$OTHER_VERSION/*/postgresql.conf` and change the `port=` settings to 5433, 5434, 5435 etc.
Line 26: Line 20:
  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:
  For example, if you have postgresql 9.1 installed and nothing fancy (only one cluster) edit /etc/postgresql/9.1/main/postgresql.conf:
Line 37: Line 29:
  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.   You may also want to edit `/etc/postgresql/$OTHER_VERSION/*/start.conf to select which instances are run on startup, or even uninstall the earlier PostgreSQL versions.
Line 45: Line 37:
sudo aptitude install postgresql-8.4 postgresql-client-8.4 postgresql-contrib-8.4 postgresql-plpython-8.4 python-psycopg2 sudo aptitude install postgresql-9.3, postgresql-contrib-9.3, postgresql-plpython-9.3, postgresql-client-9.3, postgresql-9.3-slony1-2, postgresql-9.3-debversion
Line 51: Line 43:
$ sudo pg_dropcluster 8.4 main --stop-server $ sudo pg_dropcluster 9.3 main --stop-server
Line 53: Line 45:
$ LC_ALL=C sudo pg_createcluster 8.4 main --start --encoding UNICODE $ LC_ALL=C sudo pg_createcluster 9.3 main --start --encoding UNICODE
Line 62: Line 54:
host all all ::1/128 trust
Line 66: Line 59:
 1. Add the following options to /etc/postgresql/8.4/main/postgresql.conf:  1. Add the following options to /etc/postgresql/9.3/main/postgresql.conf:
Line 70: Line 63:
search_path='"$user",public,ts2'
add_missing_from=false
search_path='$user,public,ts2'
# Per Bug #90809, standard_conforming_strings should be 'on'
standard_conforming_strings=off
escape_string_warning=off
Line 73: Line 69:
log_statement='all' log_statement='none'
Line 76: Line 72:
max_fsm_relations = 2000
Line 79: Line 75:
    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.     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-9.3-main.log`, which helps you debug and understand what your code (and in particular Storm) 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.
Line 81: Line 77:
 1. Restart the postgres server:  1. Restart the PostgreSQL server:
Line 84: Line 80:
sudo invoke-rc.d postgresql-8.4 restart sudo service postgresql restart
Line 87: Line 83:
 1. 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):  1. 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):
Line 94: Line 90:
 1. create the databases, users, permissions and populate it with sampledata:  1. Create the databases, users, permissions and populate it with sampledata:

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

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

  1. If you have any versions of PostgreSQL other than 9.3 on your system: Launchpad requires PostgreSQL 9.3 on port 5432. Ensure that any existing PostgreSQL clusters are not running on port 5432.

    • Edit /etc/postgresql/$OTHER_VERSION/*/postgresql.conf and change the port= settings to 5433, 5434, 5435 etc. For example, if you have postgresql 9.1 installed and nothing fancy (only one cluster) edit /etc/postgresql/9.1/main/postgresql.conf:

      port = 5432
      and replace that by
      port = 5433
      You may also want to edit `/etc/postgresql/$OTHER_VERSION/*/start.conf to select which instances are run on startup, or even uninstall the earlier PostgreSQL versions.
  2. Install packages (Done by rocketfuel-setup, if you used that.):
    • sudo apt-get install launchpad-database-dependencies
      which is equivalent to:
      sudo aptitude install postgresql-9.3, postgresql-contrib-9.3, postgresql-plpython-9.3, postgresql-client-9.3, postgresql-9.3-slony1-2, postgresql-9.3-debversion
  3. Nuke the default database and recreate with the current required locale:
    • $ sudo pg_dropcluster 9.3 main --stop-server
      
      $ LC_ALL=C sudo pg_createcluster 9.3 main --start --encoding UNICODE
  4. 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
      host    all         all         ::1/128               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).

  5. Add the following options to /etc/postgresql/9.3/main/postgresql.conf:
    • # Enable launchpad full text searching in database
      search_path='$user,public,ts2'
      # Per Bug #90809, standard_conforming_strings should be 'on'
      standard_conforming_strings=off
      escape_string_warning=off
      
      #enable_seqscan=false
      log_statement='none'
      log_line_prefix='[%t] %q%u@%d '
      fsync = off

      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-9.3-main.log, which helps you debug and understand what your code (and in particular Storm) 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.

  6. Restart the PostgreSQL server:
    • sudo service postgresql restart
  7. 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)
  8. Create the databases, users, permissions and populate it with sampledata:
    • cd $your_launchpad_checkout; make schema
  9. Profit! Enjoy your shiny new launchpad database.

DatabaseSetup (last edited 2020-07-16 16:47:53 by doismellburning)