Next Steps
by Vinod Kurup
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:
nsadmin:~$ 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.
nsadmin:~$ cp /tmp/acs-pgbackup-init.txt /web/birdnotes/tcl/acs-pgbackup-init.tcl
nsadmin:~$ 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:
nsadmin:~$ 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
Download another copy of openacs4.tcl.txt
into /tmp.
nsadmin:~$ cp /tmp/openacs4.tcl.txt ./birdnotes-dev.tcl
nsadmin:~$ chmod 660 birdnotes-dev.tcl
nsadmin:~$ emacs birdnotes-dev.tcl
Just like in ,
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.
Create a new database instance called
birdnotes-dev. Follow the instructions in
or .
You can either copy your current OpenACS installation:
nsadmin:~$ cd /web
nsadmin:~$ cp -r birdnotes birdnotes-dev
Or Download the OpenACS
4 software into /tmp again.
nsadmin:~$ cd /web
nsadmin:/web$ tar xzvf /tmp/alpha2.tgz
nsadmin:/web$ mv openacs-4 birdnotes-dev
Start your new server!
nsadmin:/web$ cd
nsadmin:~$ /usr/local/aolserver/bin/nsd-postgres -t /usr/local/aolserver/birdnotes-dev.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. You'll need to have the Tcl development
libraries and headers installed. (Debian users:
apt-get install tcl8.3-dev)
As root, download the
Search-OpenFTS driver.
nsadmin:~$ su -
Password: **********
root:~# cd /tmp
root:/tmp# wget http://prdownloads.sourceforge.net/openfts/Search-OpenFTS-tcl-0.2.tar.gz
root:~# cd /usr/local/src
root:/usr/local/src# tar xzf /tmp/Search-OpenFTS-tcl-0.2.tar.gz
root:/usr/local/src# chown -R nsadmin.web Search-OpenFTS-tcl-0.2
root:/usr/local/src# exit
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
nsadmin:~$ cd /usr/local/src/Search-OpenFTS-tcl-0.2
nsadmin:/usr/local/src/Search-OpenFTS-tcl-0.2$ ./configure --with-aolserver-src=/usr/local/src/aolserver/aolserver
In order to compile on Debian, I had to edit my
Makefile.global. Add
-I/usr/include/tcl8.3 to the
line where INC is defined, so it looks like this:
INC = ../include -I/usr/include/tcl8.3
Then compile it:
nsadmin:/usr/local/src/Search-OpenFTS-tcl-0.2$ make
nsadmin:/usr/local/src/Search-OpenFTS-tcl-0.2$ cd aolserver
nsadmin:/usr/local/src/Search-OpenFTS-tcl-0.2/aolserver$ make
Install it. You need to do this step as root since some of the
libraries will be installed alongside your TCL libraries and some
alongside your PostgreSQL libraries.
nsadmin:/usr/local/src/Search-OpenFTS-tcl-0.2/aolserver$ su -
Password: ***********
root:~# cd /usr/local/src/Search-OpenFTS-tcl-0.2
root:/usr/local/src/Search-OpenFTS-tcl-0.2# make install
root:/usr/local/src/Search-OpenFTS-tcl-0.2# exit
nsadmin:/usr/local/src/Search-OpenFTS-tcl-0.2/aolserver$ cp nsfts.so /usr/local/aolserver/bin/
Add the following line to your aolserver config file (in our
example:
/usr/local/aolserver/birdnotes.tcl)
in the "ns_section ns/server/${server}/modules" section:
ns_param nsfts ${bindir}/nsfts.so
Load the openFTS code into your database:
nsadmin:/usr/local/src/Search-OpenFTS-tcl-0.2/aolserver$ cd
nsadmin:~$ psql -f /web/birdnotes/packages/openfts-driver/sql/postgresql/load.sql birdnotes
nsadmin:~$ restart-aolserver birdnotes
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.
Click on the "Install packages" link and follow the instructions
to install the Note package and the OpenFTS Driver 4.2 package.
Restart your server.
nsadmin:~$ restart-aolserver birdnotes
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"
Create a "new sub folder" under "Main Site". Call the url
"openfts".
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)
Click on "Set parameters" for the OpenFTS instance
and make sure that openfts_tcl_src_path properly points to your
local copy of the Search package source code. If you've followed
these directions strictly, you shouldn't need to change it.
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.
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.
Restart the server.
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.
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.
Click on the link to "install" the FtsEngineDriver. Also, click
the link to install the Note content provider.
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: next-steps.xml,v 1.2.2.1 2002/05/15 23:26:19 vinodk Exp $)