Next Steps

by Vinod Kurup
OpenACS docs are written by the named authors, but may be edited by OpenACS documentation staff.

Backup Strategy

Here are some tips from Don Baccus regarding backup strategy:

The need for making backups should be self-explanatory. There are several strategies you can use. My own strategy for minimizing the odds that I'll lose all my data is quite simple:

  • The database is stored on a mirrored (RAID 1) disk.

  • The machine has battery backup.

  • Backups are made nightly onto a third disk on another controller

  • FTP is used to copy the resulting backup to two separate remote servers in two locations

Rather than making remote copies, you might choose to dump to tape or writeable CD media. Whatever strategy you use, it is important to routinely check dumps to make sure they can be reloaded. The strategy outlined above means that in the case of catastrophic failure, I'll lose at most one day's data.

By mirroring disks and using a battery backup, preferably one that can trigger an automatic and controlled shutdown of the system when the battery runs low, you greatly lower the odds of ever having to use your nightly backup. Despite this, it is important to take backups seriously if the data stored at your site is valuable to you or your users.

Set Up Nightly Oracle Exports

While you're working with Oracle, you should configure it to do automatic exports. An export is a separate backup copy of the database. This copy includes all of the database's state at the time that the export was initiated. If your database is corrupted, you can restore from one of these backups. You should do this step as root.

  • Download the backup script. Save the file export-oracle.txt as /tmp/export-oracle.txt

  • Login as root. The following commands will install the export script:

    joeuser:~$ su -
    Password: ***********
    root:~# cp /tmp/export-oracle.txt /usr/sbin/export-oracle
    root:~# chmod 700 /usr/sbin/export-oracle
  • Setup the export directory; this is the directory where backups will be stored. We recommend the directory /ora8/m02/oracle-exports.

    root:~# mkdir /ora8/m02/oracle-exports
    root:~# chown oracle.dba /ora8/m02/oracle-exports
    root:~# chmod 770 /ora8/m02/oracle-exports
  • Now edit /usr/sbin/export-oracle and change the SERVICE_NAME and DATABASE_PASSWORD fields to their correct values. If you want to use a directory other than /ora8/m02/oracle-exports, you also need to change the exportdir setting.

    Test the export procedure by running the command:

    root:~# /usr/sbin/export-oracle
    mv: /ora8/m02/oracle-exports/oraexport-service_name.dmp.gz: No such file or directory
    
    Export: Release 8.1.6.1.0 - Production on Sun Jun 11 18:07:45 2000
    
    (c) Copyright 1999 Oracle Corporation.  All rights reserved.
    
    
    Connected to: Oracle8i Enterprise Edition Release 8.1.6.1.0 - Production
    With the Partitioning option
    JServer Release 8.1.6.0.0 - Production
    Export done in US7ASCII character set and US7ASCII NCHAR character set
    . exporting pre-schema procedural objects and actions
    . exporting foreign function library names for user SERVICE_NAME 
    . exporting object type definitions for user SERVICE_NAME 
    About to export SERVICE_NAME's objects ...
    . exporting database links
    . exporting sequence numbers
    . exporting cluster definitions
    . about to export SERVICE_NAME's tables via Conventional Path ...
    . exporting synonyms
    . exporting views
    . exporting stored procedures
    . exporting operators
    . exporting referential integrity constraints
    . exporting triggers
    . exporting indextypes
    . exporting bitmap, functional and extensible indexes
    . exporting posttables actions
    . exporting snapshots
    . exporting snapshot logs
    . exporting job queues
    . exporting refresh groups and children
    . exporting dimensions
    . exporting post-schema procedural objects and actions
    . exporting statistics
    Export terminated successfully without warnings.

    If you don't have any warnings, proceed to automate the backups.

  • Automating backups is accomplished using the UNIX crontab facility.

    While still root, run the following command. You can replace the EDITOR="emacs -nw" portion with whatever editor your prefer, such as EDITOR=vi.

    root:~# export EDITOR="emacs -nw"
    root:~# crontab -e

    Now add the following line on a line by itself

    0 23 * * * /usr/sbin/export-oracle

    Save the file, exit the editor. Verify that the addition succeeded by checking the output of the following command.

    root:~# crontab -l | grep export-oracle
    0 23 * * * /usr/sbin/export-oracle
    root:~# exit
    ; Logout

    If you see the line, go ahead and log out.

Set up nightly Postgres exports

Dowload this script to /tmp. At the top of the script are several variables that you'll need to customize:

  • bak - location where you want local backups to be saved

  • servername - name of your server (and database instance)

  • ftp_user - username on your ftp account

  • ftp_password - password on your ftp account

  • ftp_dir - path on the remote server where your backups will be uploaded

  • ftp_server - your ftp server

Next, we'll save this file to our server's tcl directory so that it will be loaded on startup. It will automatically be run every night at midnight. Note that this script only backs up the database - not the OpenACS scripts and file content.

joeuser:~$ cp /tmp/acs-pgbackup-init.txt ~/web/birdnotes/tcl/acs-pgbackup-init.tcl
joeuser:~$ restart-aolserver birdnotes

That's it! The script will email you with each successful backup (or if it fails, it will send you an email with the reason)

Vacuum Postgres nightly

The "vacuum" command must be run periodically to reclaim space. The "vacuum analyze" form additionally collects statistics on the disbursion of columns in the database, which the optimizer uses when it calculates just how to execute queries. The availability of this data can make a tremendous difference in the execution speed of queries. This command can also be run from cron, but it probably makes more sense to run this command as part of your nightly backup procedure - if "vacuum" is going to screw up the database, you'd prefer it to happen immediately after (not before!) you've made a backup! The "vacuum" command is very reliable, but conservatism is the key to good system management. So, if you're using the export procedure described above, you don't need to do this extra step.

Edit your crontab:

joeuser:~$ crontab -e

We'll set vacuum up to run nightly at 1 AM. Add the following line:

0 1 * * * /usr/local/pgsql/bin/vacuumdb birdnotes

How to add a second server on a different port

Starting another server is simply a matter of configuring another aolserver instance, creating another database and pointing this aolserver instance at a fresh copy of the OpenACS-4 code. We'll call our new server birdnotes-dev

  1. You can either copy your current OpenACS installation:

    joeuser:~$ cp -r web/birdnotes web/birdnotes-dev

    Or Download the OpenACS 4 software into /tmp again.

    joeuser:~$ cd web
    joeuser:~/web$ tar xzvf /tmp/openacs-4-5-release.tgz
    joeuser:~/web$ mv openacs-4 birdnotes-dev
  2. Download another copy of openacs4.tcl.txt into /tmp.

    joeuser:~/web$ cp /tmp/openacs4.tcl.txt ./birdnotes-dev/nsd.tcl
    joeuser:~/web$ chmod 600 birdnotes-dev/nsd.tcl
    joeuser:~/web$ emacs birdnotes-dev/nsd.tcl

    Just like in the section called “Configuring AOLserver”, you'll need to set the server parameters appropriately. Be sure to choose a different port than your original server and to set server to birdnotes-dev.

  3. Create a new database instance called birdnotes-dev. Follow the instructions in Prepare Oracle for OpenACS or Prepare PostgreSQL for OpenACS.

  4. Start your new server!

    joeuser:~/web$ cd
    joeuser:~/web$ /usr/local/aolserver/bin/nsd-postgres -t /home/joeuser/web/birdnotes-dev/nsd.tcl

    Visit the site with a web browser (using the port that you set above). You should see the OpenACS installer. Once you install the OpenACS datamodel, you'll also need to add your new aolserver instance to /etc/inittab (or daemontools) so it restarts automatically.

Set up site-wide search

OpenACS uses the OpenFTS package to implement site-wide-search. As of this writing, the current version is 0.3.2. There are good instructions included in the OpenFTS instructions which I will repeat here. Be sure to look at those instructions if you're installing a version later than 0.3.2; the instructions may have changed. You'll need to have the Tcl development libraries and headers installed. (Debian users: apt-get install tcl8.3-dev)

  1. As root, download the latest TCL version of the Search-OpenFTS driver from SourceForge into /tmp. Extract the source into /usr/local/src

    joeuser:~$ su -
    Password: **********
    root:~# cd /usr/local/src
    root:/usr/local/src# tar xzf /tmp/Search-OpenFTS-tcl-0.3.2.tar.gz
    root:/usr/local/src# chown -R root.root Search-OpenFTS-tcl-0.3.2
    root:/usr/local/src# cd Search-OpenFTS-tcl-0.3.2
  2. Configure it. Note that you may need to set --with-tcl=(your Tcl library location). For Debian, add this to the end of the ./configure command: --with-tcl=/usr/lib/tcl8.3

    root:/usr/local/src/Search-OpenFTS-tcl-0.3.2# ./configure --with-aolserver-src=/usr/local/src/aolserver/aolserver
  3. Then compile it, copy the module to your AOLserver bin directory, and copy the TCL files to your AOLserver tcl directory:

    root:/usr/local/src/Search-OpenFTS-tcl-0.3.2# cd aolserver
    root:/usr/local/src/Search-OpenFTS-tcl-0.3.2/aolserver# make
    root:/usr/local/src/Search-OpenFTS-tcl-0.3.2/aolserver# cp nsfts.so /usr/local/aolserver/bin
    root:/usr/local/src/Search-OpenFTS-tcl-0.3.2/aolserver# cd ..
  4. Load the tsearch module SQL into your database and then compile the openfts module in the Postgresql contrib directory.

    root:/usr/local/src/Search-OpenFTS-tcl-0.3.2# cp -r pgsql_contrib_openfts /usr/local/src/postgresql-7.2.3/contrib
    root:/usr/local/src/Search-OpenFTS-tcl-0.3.2# cd /usr/local/src/postgresql-7.2.3/contrib/pgsql_contrib_openfts
    root:/usr/local/src/postgresql-7.2.3/contrib/pgsql_contrib_openfts# make
    root:/usr/local/src/postgresql-7.2.3/contrib/pgsql_contrib_openfts# su postgres
    postgres:/usr/local/src/postgresql-7.2.3/contrib/pgsql_contrib_openfts$ make install
    postgres:/usr/local/src/postgresql-7.2.3/contrib/pgsql_contrib_openfts$ /usr/local/pgsql/bin/psql birdnotes -f /usr/local/src/postgresql-7.2.3/contrib/tsearch/tsearch.sql
    postgres:/usr/local/src/postgresql-7.2.3/contrib/pgsql_contrib_openfts$ /usr/local/pgsql/bin/psql birdnotes -f openfts.sql
    postgres:/usr/local/src/postgresql-7.2.3/contrib/pgsql_contrib_openfts$ exit
    root:/usr/local/src/postgresql-7.2.3/contrib/pgsql_contrib_openfts# exit
  5. Uncomment the following line in your aolserver config file (in our example: ~/web/birdnotes/nsd.tcl) in the "ns_section ns/server/${server}/modules" section:

            ns_param   nsfts           ${bindir}/nsfts.so
  6. Open a browser and go to your server (http://yourserver:port). Click on the "Package Manager" link in the "Quick Links" section on the right side of the page.

  7. Click on the "Install packages" link and follow the instructions to install the Note package and the OpenFTS Driver 4.2 package.

  8. Restart your server.

    joeuser:~$ svc -t /service/birdnotes

  9. Give the server a few minutes to restart and then go back to your server's front page and click on "Site Map" from the "Quick Links"

  10. Create a "new sub folder" under "Main Site". Call the url "openfts".

  11. Click "mount" to mount the OpenFTS driver at the url "openfts" (despite what the system says about these packages not being meant to be mounted)

  12. Click the "Set parameters" link next to OpenFTS. Change the openfts_tcl_src_path to /usr/local/src/Search-OpenFTS-tcl-0.3.2

  13. Create another folder under "Main Site" at the url "search". Create a "new application". Call the application "Search" and choose the "Search" package from the drop-down list.

  14. Create a third folder under "Main Site" at the url "notes". Create a "new application". Call the application "Notes" and choose the "Note" package from the drop-down list.

  15. Restart the server.

  16. Return to your home page. Near the bottom of the page, Click on the "OpenFTS Driver" link. Then click on "Administration". Finally, click on "Initialize OpenFTS Engine". Accept the defaults and continue.

  17. Click on the "Main Site" link to get back to the home page. Now, click on the "ACS Service Contract" link near the bottom of the home page.

  18. Click on the link to "install" the FtsEngineDriver. Also, click the link to install the Note content provider.

  19. Restart the server. You can try inserting some notes and then going to the search page to search for stuff. Note that the content may not get indexed immediately, so give it a few minutes.

($Id: nextsteps.html,v 1.6.2.2 2003/01/24 04:14:32 vinodk Exp $)
View comments on this page at openacs.org