Filtered by category Subsystems Documentation, 71 - 80 of 86 Postings (
all,
summary)
Created by Malte Sussdorff, last modified by Gustaf Neumann 03 Nov 2011, at 02:26 PM
I worked off the work of Dave Bauer and used Macports.
Unfortunately, the default configuration of Mac OS X does not allow suitable amounts of shared memory to be created to run the database server.
Therefore you should edit your /etc/sysctl.conf
On a MacBook Pro with 2GB of RAM, the author's sysctl.conf contains:
kern.sysv.shmmax=1610612736
kern.sysv.shmall=393216
kern.sysv.shmmin=1
kern.sysv.shmmni=32
kern.sysv.shmseg=8
kern.maxprocperuid=512
kern.maxproc=2048
Download and install MacPorts from http://www.macports.org/install.php and get the latest version (1.7.1 as of 2009-04-18)
Install PostgreSQL 8.4
sudo port -k install postgresql84
cd `port work postgresql84`/postgresql-8.4.7/contrib/ltree
make all
sudo make install
sudo port install postgresql84-server
This installs expat, gperf, libiconv, ncursesw, ncurses, gettext, m4, bison, zlib, libxml2, libxslt1, openssl, readline, postgresql82. The macports install then says
To create a database instance, after install do
sudo mkdir -p /opt/local/var/db/postgresql84/defaultdb
sudo chown postgres:postgres /opt/local/var/db/postgresql84/defaultdb
sudo su postgres -c '/opt/local/lib/postgresql84/bin/initdb -D /opt/local/var/db/postgresql84/defaultdb'
Then after initdb postgres says to start postgresql. Before that edit the config file to make it compatible with ACS
sudo emacs -nw /opt/local/var/db/postgresql84/defaultdb/postgresql.conf
Once you have emacs open, change the following config items:
autovacuum = on
add_missing_from = on
default_with_oids = on
regex_flavor = extended
Now start the PostgreSQL Server
sudo su postgres -c '/opt/local/lib/postgresql84/bin/postgres -D /opt/local/var/db/postgresql84/defaultdb' &
Install plpgsql as a language
/opt/local/lib/postgresql84/bin/createlang plpgsql template1 -U postgres
Last but not least, put postgresql under launchctl so you can start and stop it:
sudo launchctl load -w /Library/LaunchDaemons/org.macports.postgresql84-server.plist
To start it from then on just call
sudo launchctl start org.macports.postgresql84-server
To stop it:
sudo launchctl stop org.macports.postgresql84-server
Install AOLserver 4.5
sudo port install tcl +threads +headers
This will install Tcl with threads enabled, which is needed for AOLserver.
sudo port install aolserver
Now we have AOLserver installed into /opt/local/aolserver. You now need to configure the server to your needs. You might want to create another user (e.g. aolserver) to run the server. First get all the files:
cd /usr/local/src
mkdir aolserver
cd aolserver
TCLLIB=1.13
XOTCL=1.6.7
# Path for the AOLserver installation
NS=/opt/local/aolserver
cvs -z3 -d:pserver:anonymous@aolserver.cvs.sourceforge.net:/cvsroot/aolserver co nssha1
cvs -z3 -d:pserver:anonymous@aolserver.cvs.sourceforge.net:/cvsroot/aolserver co nspostgres
echo "Getting TDOM ..."
git clone git://github.com/tDOM/tdom.git
echo "Getting TCL modules ..."
curl -L -O http://downloads.sourceforge.net/tcllib/tcllib-${TCLLIB}.tar.bz2
curl -L -O http://downloads.sourceforge.net/tcl/thread2.6.5.tar.gz
curl -L -O http://media.wu-wien.ac.at/download/xotcl-${XOTCL}.tar.gz
Now install nssha1
cd nssha1
sudo make install NSHOME=${NS}
cd ..
Now go for nspostgres
cd nspostgres/
# Edit the Makefile so it reads (adding the "-lnsdb")
MODLIBS = -L$(PGLIB) -lpq -lnsdb
sudo make install AOLSERVER=/opt/local/aolserver/ PGCONFIG=/opt/local/lib/postgresql84/bin/pg_config POSTGRES=/opt/local PGINC=/opt/local/include/postgresql84/ PGLIB=/opt/local/lib/postgresql84/ ACS=1
cd ..
tDOM
cd tDOM-0.8.2/unix
../configure --mandir=/usr/local/share/man --libdir=/opt/local/aolserver/lib --with-tcl=/opt/local/lib --with-aolserver=/opt/local/aolserver
sudo make install
cd ../..
Thread
tar xvfz thread2.6.5.tar.gz
cd thread2.6.5/unix
../configure --mandir=/usr/local/share/man --libdir=/Library/Tcl --with-tcl=/System/Library/Frameworks/Tcl.framework --with-tclinclude=/System/Library/Frameworks/Tcl.framework/Headers --with-aolserver=/opt/local/aolserver
sudo make install
cd ../..
XOTcl
The private header files of Tcl are missing, therefore I got the source and recompiled Tcl:
curl -L -O http://downloads.sourceforge.net/tcl/tcl8.5.9-src.tar.gz
tar xfz tcl8.5.9-src.tar.gz
cd tcl8.5.9/unix
./configure --enable-threads --prefix=/opt/local --disable-corefoundation
sudo make install
cd ../..
tar xvfz xotcl-1.6.7.tar.gz
cd xotcl-1.6.7
NS=/opt/local/aolserver/
./configure --enable-threads --enable-symbols --prefix=${NS} --exec-prefix=${NS} --with-tcl=/opt/local/lib
sudo make install-aol
cd ..
Now we finish off with tcllib
tar xvfj tcllib-1.13.tar.bz2
cd tcllib-1.13
./configure --prefix=/opt/local/aolserver/
sudo make install
Type in terminal before starting nsd
ulimit -n 256
I would recommend to install the server in ~/Sites/
yourserver if you don't intend to run multiple different servers with access rights on your machine. Checkout the OpenACS code and Edit ~/Sites/
yourserver/etc/config.tcl and make the following changes
# Change the server root
set serverroot "~/Sites/${server}"
# Make sure that OpenACS finds PostgreSQL. Add two lines to the $database if statement
if { $database eq "oracle" } {
set db_password "mysitepassword"
} else {
set db_host localhost
set db_port ""
set db_user $server
ns_section "ns/db/driver/postgres"
ns_param pgbin /opt/local/lib/postgresql84/bin/
}
# Change the AOLserver location
set homedir /opt/local/aolserver
Now you can start up your server. First try ist with /opt/local/aolserver/bin/nsd -t ~/Sites/yourserver/etc/config.tcl. If this works you might want to create a launchctl entry as you did above for postgresql
Edit /Library/LaunchDaemons/org.openacs.YOURSERVER.plist and enter the following
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>org.openacs.YOURSERVER</string>
<key>OnDemand</key>
<false/>
<key>ProgramArguments</key>
<array>
<string>/Users/youruser/Sites/yourserver/etc/daemontools/run</string>
</array>
<key>ServiceDescription</key>
<string>OpenACS Service</string>
<key>UserName</key>
<string>youruser</string>
<key>GroupName</key>
<string>staff</string>
</dict>
</plist>
Now put yourserver under launchctl so you can start and stop it:
sudo launchctl load -w /Library/LaunchDaemons/org.openacs.yourserver.plist
To start it from then on just call
sudo launchctl start org.openacs.yourserver
To stop it:
sudo launchctl stop org.openacs.yourserver
It is a good idea to schedule regular backups for your server(s). To do this create a shell script, e.g. backup.sh which executes your backups and then create a launchdaemon plist to run your backups nightly
Edit /Library/LaunchDaemons/org.openacs.backup.plist and enter the following
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>org.openacs.backup</string>
<key>ProgramArguments</key>
<array>
<string>/Users/youruser/Sites/backup.sh</string>
</array>
<key>LowPriorityIO</key>
<true/>
<key>Nice</key>
<integer>1</integer>
<key>StartCalendarInterval</key>
<dict>
<key>Hour</key>
<integer>3</integer>
<key>Minute</key>
<integer>15</integer>
</dict>
</dict>
</plist>
If you intend to run AOLserver on a continous basis remember that it is a great idea to make sure it responds properly. To do this you can run a keepalive service.
Edit /Library/LaunchDaemons/org.openacs.keepalive.plist and enter the following
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>org.openacs.keepalive.plist</string>
<key>ProgramArguments</key>
<array>
<string>/Users/youruser/Sites/keepalive.sh</string>
<string>yourserver</string>
<string>yourport</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>StartInterval</key>
<integer>180</integer>
</dict>
</plist>
Your keepalive.sh could look like this
#!/bin/bash
GREP=/usr/bin/grep
HEAD="/usr/bin/head -1"
INSTANCE="$1";
PORT="$2"
[ -z "$1" ] && exit
[ -z "$2" ] && exit
MAIL_ADDR=""
WGET_FILE=/tmp/.output-keepalive-${INSTANCE}
URL_TEST="http://127.0.0.1:${PORT}/SYSTEM/dbtest"
[ -f ${WGET_FILE} ] && rm -f ${WGET_FILE}
_restartwebserver ()
{
/bin/launchctl start org.openacs.$INSTANCE
sleep 3
/bin/launchctl start org.openacs.$INSTANCE
}
_sendmail ()
{
echo "${1}" |mailx -s AolWebserver ${MAIL_ADDR}
}
while [ 1 -eq 1 ];
do
[ -f ${WGET_FILE} ] && /bin/rm -f ${WGET_FILE}
/usr/bin/curl -s -o $WGET_FILE --connect-timeout 3 --retry 3 "${URL_TEST}"
if [ -f ${WGET_FILE} ]
then
FIRST_LINE=`${HEAD} ${WGET_FILE} | ${GREP} -i "success"`
[ -z "${FIRST_LINE}" ] && _restartwebserver && _sendmail "I just restarted the $INSTANCE webserver on `uname -n`" && echo "`date +'%D-%H:%M'` :: FAILURE" || echo "`date +'%D-%H:%M'` :: success $INSTANCE" >>/Users/malte/Sites/keepalive.log
else
_restartwebserver && _sendmail "I just restarted the $INSTANCE webserver on `uname -n`"
# _restartwebserver
echo "`date +'%D-%H:%M'` :: FAILURE"
fi
done
If you intend to run AOLserver on a continous basis remember that it is a great idea to restart your server once per night, otherwise the memory footprint will grow and grow and grow.
Edit /Library/LaunchDaemons/org.openacs.restart.plist and enter the following
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>org.openacs.restart</string>
<key>OnDemand</key>
<false/>
<key>ProgramArguments</key>
<array>
<string>/Users/youruser/Sites/restart.sh</string>
</array>
<key>LowPriorityIO</key>
<true/>
<key>Nice</key>
<integer>1</integer>
<key>StartCalendarInterval</key>
<dict>
<key>Hour</key>
<integer>4</integer>
<key>Minute</key>
<integer>15</integer>
</dict>
</dict>
</plist>
Now put scripts under launchctl so they will run in the night:
sudo launchctl load -w /Library/LaunchDaemons/org.openacs.backup.plist
sudo launchctl load -w /Library/LaunchDaemons/org.openacs.restart.plist
sudo launchctl load -w /Library/LaunchDaemons/org.openacs.keepalive.plist
Your restart.sh could look like this
#!/bin/bash
echo "cognovis"
sudo launchctl stop org.openacs.yourserver
sleep 10
sudo launchctl start org.openacs.yourserver
Created by OpenACS community, last modified by Ryan Gallimore 10 Apr 2010, at 06:49 PM
Testing with TCLWebtest
by Simon Carstensen and Joel Aufrecht
Tclwebtest is primarily for testing user interface and acceptance testing.
API testing is only part of testing your package - it doesn't test the
code in our adp/tcl pairs. For this, we can use TCLWebtest (see sourceforge). TCLWebtest provides a library of functions
(see command reference) that make it easy to call a page through HTTP, examine the results, and
drive forms. TCLwebtest's functions overlap slightly with
acs-automated-testing; see the example provided for one approach on
integrating them.
TCLWebtest
must be installed for to work. Since automated testing uses it, it should be part of every OpenACS installation. Note that TCLwebtest is installed automatically by Malte's install script.
Forum Posts:
Command Reference:
- http://tclwebtest.sourceforge.net/doc/api_public.html
Articles:
- Automated Testing Best Practices see: https://openacs.org/doc/automated-testing-best-practices.html
- testing packages for release en:Package_Testing_Process_
Tools:
- Webtest-Recorder Firefox extension (TwtR) see http://www.km.co.at/km/twtr This module is a plugin for Firefox. It is used to generate/edit a tclwebtest script which can be used later
for regression testing without the need of a browser. There is a
certain overlap of the application range between selenium and TwtR.
This plugin was developed by Åsmund Realfsen for regression/load
testing of the assessment module.
Here are some guidelines on how to write automated tests with TCLWebtest. It is a joy to work with automated testing once you get the hang of it. We will use the "myfirstpackage" as an example.
Create the directory that will contain the test
script and edit the script file. The directory location and file name are standards which are recognized by the automated testing package:
[$OPENACS_SERVICE_NAME www]$ mkdir /var/lib/aolserver/$OPENACS_SERVICE_NAME/packages/myfirstpackage/tcl/test
[$OPENACS_SERVICE_NAME www]$ cd /var/lib/aolserver/$OPENACS_SERVICE_NAME/packages/myfirstpackage/tcl/test
[$OPENACS_SERVICE_NAME test]$ emacs myfirstpackages-procs.tcl
Write the tests. This is obviously the big step :) The script should first call ad_library like any normal -procs.tcl file:
ad_library {
...
}
To create a test case you call
aa_register_case test_case_name..
Once you've created the test case you start writing the needed logic.
We'll use the tutorial package, "myfirstpackage," as an example.
Let's say you just wrote an API for adding and deleting notes in the
notes packages and wanted to test that. You'd probably want to write a
test that first creates a note, then verifies that it was inserted,
then perhaps deletes it again, and finally verifies that it is
gone.
Naturally this means you'll be adding a lot of bogus data to the
database, which you're not really interested in having there. To avoid
this I usually do two things. I always put all my test code inside a
call to aa_run_with_teardown which basically means that all the
inserts, deletes, and updates will be rolled back once the test has
been executed. A very useful feature. Instead of inserting bogus data
like: set name "Simon", I tend to generate a random script in order avoid inserting a value that's already in the database:
set name [ad_generate_random_string]
Here's how the test case looks so far:
aa_register_case mfp_basic_test {
My test
} {
aa_run_with_teardown \
-rollback \
-test_code {
}
}
Now look at the actual test code. That's the code that
goes inside -test_code {}. We want to implement test case API-001, "Given an object id from API-001, invoke mfp::note::get. Proc should return the specific word in the title."
set name [ad_generate_random_string]
set new_id [mfp::note::add -title $name]
aa_true "Note add succeeded" [exists_and_not_null new_id]
To test our simple case, we must load the test file into the system (just as with the /tcl file in the basic tutorial, since the file didn't exist when the system started, the system doesn't know about it.) To make this file take effect, go to the APM and choose "Reload changed" for "MyFirstPackage". Since we'll be changing it frequently, select "watch this file" on the next page. This will cause the system to check this file every time any page is requested, which is bad for production systems but convenient for developing. We can also add some aa_register_case flags to make it easier to run the test. The -procs flag, which indicates which procs are tested by this test case, makes it easier to find procs in your package that aren't tested at all. The -cats flag, setting categories, makes it easier to control which tests to run. The smoke test setting means that this is a basic test case that can and should be run any time you are doing any test. (a definition of "smoke test")
Once the file is loaded, go to ACS Automated Testing and click on myfirstpackage. You should see your test case. Run it and examine the results.
Example
Now we can add the rest of the API tests, including a test with deliberately bad data. The complete test looks like:
ad_library {
Test cases for my first package.
}
aa_register_case \
-cats {smoke api} \
-procs {mfp::note::add mfp::note::get mfp::note::delete} \
mfp_basic_test \
{
A simple test that adds, retrieves, and deletes a record.
} {
aa_run_with_teardown \
-rollback \
-test_code {
set name [ad_generate_random_string]
set new_id [mfp::note::add -title $name]
aa_true "Note add succeeded" [exists_and_not_null new_id]
mfp::note::get -item_id $new_id -array note_array
aa_true "Note contains correct title" [string equal $note_array(title) $name]
mfp::note::delete -item_id $new_id
set get_again [catch {mfp::note::get -item_id $new_id -array note_array}]
aa_false "After deleting a note, retrieving it fails" [expr $get_again == 0]
}
}
aa_register_case \
-cats {api} \
-procs {mfp::note::add mfp::note::get mfp::note::delete} \
mfp_bad_data_test \
{
A simple test that adds, retrieves, and deletes a record, using some tricky data.
} {
aa_run_with_teardown \
-rollback \
-test_code {
set name {-Bad [BAD] \077 { $Bad}}
append name [ad_generate_random_string]
set new_id [mfp::note::add -title $name]
aa_true "Note add succeeded" [exists_and_not_null new_id]
mfp::note::get -item_id $new_id -array note_array
aa_true "Note contains correct title" [string equal $note_array(title) $name]
aa_log "Title is $name"
mfp::note::delete -item_id $new_id
set get_again [catch {mfp::note::get -item_id $new_id -array note_array}]
aa_false "After deleting a note, retrieving it fails" [expr $get_again == 0]
}
}
aa_register_case \
-cats {web smoke} \
-libraries tclwebtest \
mfp_web_basic_test \
{
A simple tclwebtest test case for the tutorial demo package.
@author Peter Marklund
} {
# we need to get a user_id here so that it's available throughout
# this proc
set user_id [db_nextval acs_object_id_seq]
set note_title [ad_generate_random_string]
# NOTE: Never use the aa_run_with_teardown with the rollback switch
# when running Tclwebtest tests since this will put the test code in
# a transaction and changes won't be visible across HTTP requests.
aa_run_with_teardown -test_code {
#-------------------------------------------------------------
# Login
#-------------------------------------------------------------
# Make a site-wide admin user for this test
# We use an admin to avoid permission issues
array set user_info [twt::user::create -admin -user_id $user_id]
# Login the user
twt::user::login $user_info(email) $user_info(password)
#-------------------------------------------------------------
# New Note
#-------------------------------------------------------------
# Request note-edit page
set package_uri [apm_package_url_from_key myfirstpackage]
set edit_uri "${package_uri}note-edit"
aa_log "[twt::server_url]$edit_uri"
twt::do_request "[twt::server_url]$edit_uri"
# Submit a new note
tclwebtest::form find ~n note
tclwebtest::field find ~n title
tclwebtest::field fill $note_title
tclwebtest::form submit
#-------------------------------------------------------------
# Retrieve note
#-------------------------------------------------------------
# Request index page and verify that note is in listing
tclwebtest::do_request $package_uri
aa_true "New note with title \"$note_title\" is found in index page" \
[string match "*${note_title}*" [tclwebtest::response body]]
#-------------------------------------------------------------
# Delete Note
#-------------------------------------------------------------
# Delete all notes
# Three options to delete the note
# 1) go directly to the database to get the id
# 2) require an API function that takes name and returns ID
# 3) screen-scrape for the ID
# all options are problematic. We'll do #1 in this example:
set note_id [db_string get_note_id_from_name "
select item_id
from cr_items
where name = :note_title
and content_type = 'mfp_note'
" -default 0]
aa_log "Deleting note with id $note_id"
set delete_uri "${package_uri}note-delete?item_id=${note_id}"
twt::do_request $delete_uri
# Request index page and verify that note is in listing
tclwebtest::do_request $package_uri
aa_true "Note with title \"$note_title\" is not found in index page after deletion." \
![string match "*${note_title}*" [tclwebtest::response body]]
} -teardown_code {
twt::user::delete -user_id $user_id
}
}
Created by Gustaf Neumann, last modified by Gustaf Neumann 06 Dec 2008, at 10:36 AM
The following pre-packaged installations for OpenACS and .LRN under Linux are available:
OpenACS and .LRN can be installed certainly as well from scratch using the guidelines for stepwise installation of all necessary components.
In general, OpenACS and its components works very well under Linux. It is used in many large installation with up to 10 million hits per day. For most applications, the systems runs nicely with a wide range of versions of Linux and its components. Due to some library changes in some Linux versions (especially in the native Linux thread installations), some precautions might be necessary. In case of problems on sites with high loads (e.g. server hangs) we recommend the following versions
- Linux Kernel <2.6.9 or better, >2.6.25
- NTPL >= 2.7
- gcc >= 4.2
- Tcl libthread should be > 2.6.5 (including changes from 2008-05-22)
Created by OpenACS community, last modified by Ryan Gallimore 03 Oct 2008, at 06:27 PM
A quick install guide for Postgres 8.2 which takes everything into account can be found at http://cognovis.de/developer/en/pg82
For RPMs, see http://yum.pgsqlrpms.org/
These instructions should work for 7.4 to 8.2.
Get the source code
http://www.postgresql.org/download/
Install from source
Unpack PostgreSQL 7.4.7. If you have downloaded the postgresql tarball to /var/tmp/postgresql-7.4.7.tar.gz
[root root]# cd /usr/local/src
[root src]# tar xzf /var/tmp/postgresql-7.4.7.tar.gz
[root src]#
cd /usr/local/src
tar xzf /var/tmp/postgresql-7.4.7.tar.gz
If you have downloaded the postgresql tarball to /var/tmp/postgresql-7.4.7.tar.bz2
[root root]# cd /usr/local/src
[root src]# tar xfj /var/tmp/postgresql-7.4.7.tar.bz2
[root src]#
cd /usr/local/src
tar xfj /var/tmp/postgresql-7.4.7.tar.bz2
Create the Postgres user. Create a user and group (if you haven't done so before) for PostgreSQL. This is the account that PostgreSQL will run as since it will not run as root. Since nobody will log in directly as that user, we'll leave the password blank.
[root src]# groupadd web
[root src]# useradd -g web -d /usr/local/pgsql postgres
[root src]# mkdir -p /usr/local/pgsql
[root src]# chown -R postgres.web /usr/local/pgsql /usr/local/src/postgresql-7.4.7
[root src]# chmod 750 /usr/local/pgsql
[root src]#
groupadd web
useradd -g web -d /usr/local/pgsql postgres
mkdir -p /usr/local/pgsql
chown -R postgres.web /usr/local/pgsql /usr/local/src/postgresql-7.4.7
chmod 750 /usr/local/pgsql
Set up postgres's environment variables. They are necessary for the executable to find its supporting libraries. Put the following lines into the postgres user's environment.
[root src]# su - postgres
[postgres ~] emacs ~postgres/.bashrc
Paste this line into .bash_profile:
source $HOME/.bashrc
Paste these lines into .bashrc:
export PATH=/usr/local/bin/:$PATH:/usr/local/pgsql/bin
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/pgsql/lib
Test this by logging in as postgres and checking the paths; you should see /usr/local/pgsql/bin
[root src]# su - postgres
[postgres pgsql]$ env | grep PATH
LD_LIBRARY_PATH=:/usr/local/pgsql/lib
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/usr/bin/X11:/usr/X11R6/bin:/root/bin:/usr/local/pgsql/bin:/usr/local/pgsql/bin
[postgres pgsql]$ exit
Don't continue unless you see correct output from env | grep PATH
Compile and install PostgreSQL. Change to the postgres user and run ./configure to set the compilation options automatically. This is the point at which you can configure PostgreSQL in various ways. To see what the possibilities, run ./configure --help.
[root src]# su - postgres
[postgres pgsql]$ cd /usr/local/src/postgresql-7.4.7
[postgres postgresql-7.4.7]$ ./configure
creating cache ./config.cache
checking host system type... i686-pc-linux-gnu
(many lines omitted>
linking ./src/makefiles/Makefile.linux to src/Makefile.port
linking ./src/backend/port/tas/dummy.s to src/backend/port/tas.s
[postgres postgresql-7.4.7]$ make all
make -C doc all
make[1]: Entering directory `/usr/local/src/postgresql-7.4.7/doc'
(many lines omitted)
make[1]: Leaving directory `/usr/local/src/postgresql-7.4.7/src'
All of PostgreSQL successfully made. Ready to install.
[postgres postgresql-7.4.7]$ make install
make -C doc install
make[1]: Entering directory `/usr/local/src/postgresql-7.4.7/doc'
(many lines omitted)
Thank you for choosing PostgreSQL, the most advanced open source database
engine.
su - postgres
cd /usr/local/src/postgresql-7.4.7
./configure
make all
make install
Start PostgreSQL. The initdb command initializes the database. pg_ctl is used to start up PostgreSQL.
[postgres postgresql-7.4.7]$ /usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data
The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.
(17 lines omitted)
or
/usr/local/pgsql/bin/pg_ctl -D /usr/local/pgsql/data -l logfile start
[postgres postgresql-7.4.7]$ /usr/local/pgsql/bin/pg_ctl -D /usr/local/pgsql/data -l /usr/local/pgsql/data/server.log start
postmaster successfully started
[postgres postgresql-7.4.7]$
/usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data
/usr/local/pgsql/bin/pg_ctl -D /usr/local/pgsql/data -l /usr/local/pgsql/data/server.log start
PostgreSQL errors will be logged in /usr/local/pgsql/data/server.log
Install Pl/pgSQL.Set up plpgsq and allow your user to have access. Plpgsql is a PL/SQL-like language. We add it to template1, which is the template from which all new databases are created. We can verify that it was created with the createlang command in list mode.
[postgres postgresql-7.4.7]$ createlang plpgsql template1
[postgres pgsql]$ createlang -l template1
Procedural languages
Name | Trusted?
---------+----------
plpgsql | t
(1 row)
[postgres pgsql-7.4.7]$
createlang plpgsql template1
createlang -l template1
If you are installing Postgres 8.x, follow additional instructions at en:How_to_install_in_Postgres_8.x
If you are installing tsearch2, follow additional instructions at en:postgresql-tsearch2
Test PostgreSQL (OPTIONAL). Create a database and try some simple commands. The output should be as shown.
[postgres pgsql]$ createdb mytestdb
CREATE DATABASE
[postgres pgsql]$ psql mytestdb
Welcome to psql, the PostgreSQL interactive terminal.
Type: \copyright for distribution terms
\h for help with SQL commands
\? for help on internal slash commands
\g or terminate with semicolon to execute query
\q to quit
mytestdb=# select current_timestamp;
timestamptz
-------------------------------
2003-03-07 22:18:29.185413-08
(1 row)
mytestdb=# create function test1() returns integer as 'begin return 1; end;' language 'plpgsql';
CREATE
mytestdb=# select test1();
test1
-------
1
(1 row)
mytestdb=# \q
[postgres pgsql]$ dropdb mytestdb
DROP DATABASE
[postgres pgsql]$ exit
logout
[root src]#
Set PostgreSQL to start on boot. First, we copy the SERVERROOT/packages/acs-core-docs/www/files/postgresql.txt init script, which automates startup and shutdown, to the distribution-specific init.d directory. Then we verify that it works. Then we automate it by setting up a bunch of symlinks that ensure that, when the operating system changes runlevels, postgresql goes to the appropriate state. Red Hat and Debian and SuSE each work a little differently. Be sure to check OS distribution notes for specifics (and examples)
Once installed, PostgreSQL should start automatically each time you boot up and it should shutdown gracefully each time you shut down.
Created by Gustaf Neumann, last modified by Dave Bauer 21 Nov 2007, at 03:03 PM
In order to create an index conditionally (e.g. only, if it does not exist) in postgresql or in oracle, one can use the following two idioms
Postgres
create or replace function inline_0() returns integer as '
declare v_exists integer;
begin
select into v_exists count(*) from pg_class where relname = ''acs_permissions_object_id_idx'';
if v_exists = 0 then
create index acs_permissions_object_id_idx on acs_permissions(object_id);
end if;
return null;
end;' language 'plpgsql'
select inline_0();
drop function inline_0();
Oracle
declare v_exists integer;
begin
select count(*) into v_exists from user_indexes where lower(index_name)='acs_permissions_object_id_idx';
if v_exists = 0 then
execute immediate 'create index acs_permissions_object_id_idx on acs_permissions(object_id)';
end if;
end;
/
show errors
These examples were posted by Dave Bauer OpenACS Development forum and can be used in a similar style for conditionally creating tables, etc.
Created by OpenACS community, last modified by Torben Brosten 07 Mar 2007, at 05:18 AM
Should you decide to Install OpenACS from source using general en:openacs-system-install instructions, refer to these notes for changes:
See threads:
Created by OpenACS community, last modified by Torben Brosten 25 Oct 2006, at 10:37 AM
PostgreSQL
PostgreSQL is an open-source, ACID-compliant RDBMS
What others say about PostgreSQL
OpenACS uses Postgresql with PL/PgSQL.
Using PostgreSQL with OpenACS
Install PostgreSQL en:postgresql-install
Administrating PostgreSQL en:postgresql-admin
Created by OpenACS community, last modified by Torben Brosten 25 Aug 2006, at 10:51 PM
OpenACS is a n-tier architecture web application toolkit built on these software components:
- OpenACS toolkit en:openacs-subsystem
- an interpretive, markup language en:tcl
- a robust, http server en:aolserver
- a mature, relational database management system (RDMS) en:postgresql or en:oracle that follows the SQL standard (Why not MySQL?) and uses a procedural language (PL/SQL or PL/pgSQL).
- unix-like operating system en:os-nix
And works well with minimum hardware requirements (en:docs-install).
Chart Showing the parts of OpenACS
The blue dotted line hints at the path of a dynamic page request --from client to server and back. Each of the subsystems on the left can be directly accessed by a page request, whereas the database is only indirectly accessible. The arrows represent the pools of database connections that help manage queries --one of the key reasons that OpenACS performs well.
Created by OpenACS community, last modified by Torben Brosten 10 Aug 2006, at 11:12 PM
Using tDOM with OpenACS
Created by OpenACS community, last modified by Robert Taylor 07 Aug 2006, at 03:22 AM
Install Full Text Search using Tsearch2
By Dave Bauer, Joel Aufrecht, and Malte Sussdorff, with help from Tsearch V2 Introduction by Andrew J. Kopciuch
Install Tsearch2 module
This is a PostgreSQL module that the OpenACS tsearch2-driver package requires.
If you want full text search (FTS), and you are running PostgreSQL version 7.3 or greater, install this module to support FTS. Do this step after you have installed both PostgreSQL and AOLserver. The tsearch2 module is included with the PostgreSQL full source distribution. It is also available with the PostgreSQL contrib package provided by most distribution ports.
-
For PostgreSQL 7.3, refer to the Installation docs for details, because the Tsearch2 project has revised the installation since PostgreSQL 7.3 was deprecated.
For PostgreSQL 7.4, download the http://www.sai.msu.su/~megera/postgres/gist/tsearch/V2/regprocedure_7.4.patch.gz tsearch2 patch to correctly restore from a pg_dump backup. To apply this patch, download the mentioned file and place it in your postgreSQL source tree ($PGSQL_SRC). This patch makes the backup and restore procedures very simple.
[postgres pgsql]$ cd /tmp
[postgres tmp]$ wget http://www.sai.msu.su/~megera/postgres/gist/tsearch/V2/regprocedure_7.4.patch.gz
[postgres pgsql]$ cd /usr/local/src/postgresql-7.4.5/
[postgres postgresql-7.4.5] gunzip /tmp/regprocedure_7.4.patch.gz
[postgres postgresql-7.4.5] patch -b -p1 < regprocedure_7.4.patch
If you installed tsearch2 from a ports package, you can use the http://www.sai.msu.su/~megera/postgres/gist/tsearch/V2/regprocedure_update.sql regprocedure script to update the database after tsearch2 is installed into it.
If you have a working version of tsearch2 in your database, you do not need to re-install the tsearch2 module. Just apply the patch and run make. This patch only affects the tsearch2.sql file. You can run the SQL script found : [right here] This script will make the modifications found in the patch, and update the fields from the existing data. From this point on, you can dump and restore the database in a normal fashion. Without this patch, you must follow the instructions at the Tsearch2 project website for backup and restore.
Postgresql 8.0 and above include the latest stable release with the above patch(es) applied.
-
Install Tsearch2. These instructions assume you are using the latest point release of PostgreSQL 7.4.5.
[root root]# su - postgres
[postgres pgsql]$ cd /usr/local/src/postgresql-7.4.5/contrib/tsearch2/
[postgres tsearch2]$ make
[postgres tsearch2]$ make install
mkdir /usr/local/pgsql/share/contrib
mkdir /usr/local/pgsql/doc/contrib
(2 lines omitted)
/bin/sh ../../config/install-sh -c -m 755 libtsearch.so.0.0 /usr/local/pgsql/lib/tsearch.so
[postgres tsearch]$ exit
logout
[root root]#
su - postgres
cd /usr/local/src/postgresql-7.4.5/contrib/tsearch2
make
make install
exit