| |
313 |
313 |
</orderedlist> |
| |
314 |
314 |
</listitem> |
| |
315 |
315 |
<listitem> |
| |
316 |
316 |
<formalpara id="install-openacs-prepare-postgres"> |
| |
317 |
317 |
<title>Prepare PostgreSQL for an OpenACS Service</title> |
| |
318 |
318 |
<para></para> |
| |
319 |
319 |
</formalpara> |
| |
320 |
320 |
<itemizedlist> |
| |
321 |
321 |
<listitem id="create-service-db-user"> |
| |
322 |
322 |
<para>PostgreSQL:</para> |
| |
323 |
323 |
<para>Create a user in the database matching the service |
| |
324 |
324 |
name. With default PostgreSQL authentication, a system user connecting locally automatically authenticates as the postgres user of the same name, if one exists. We currently use postgres "super-users" for everything, which means that anyone with access to any of the openacs system accounts on a machine has full access to all postgresql databases on that machine.</para> |
| |
325 |
325 |
<screen>[root root]# <userinput>su - postgres</userinput> |
| |
326 |
326 |
[postgres pgsql]$ <userinput>createuser -a -d <replaceable>$OPENACS_SERVICE_NAME</replaceable></userinput> |
| |
327 |
327 |
CREATE USER |
| |
328 |
328 |
[postgres pgsql]$ <userinput>exit</userinput> |
| |
329 |
329 |
logout |
| |
330 |
330 |
[root root]#</screen> |
| |
331 |
331 |
</listitem> |
| |
332 |
332 |
<listitem id="create-database"> |
| |
333 |
|
<para>Create a database with the same name as our service name, <replaceable>$OPENACS_SERVICE_NAME</replaceable>.</para> |
| |
334 |
|
<screen>[root root]# <userinput>su - postgres</userinput> |
| |
335 |
|
[postgres pgsql]$ <userinput>createdb -E UNICODE -U <replaceable>$OPENACS_SERVICE_NAME</replaceable> <replaceable>$OPENACS_SERVICE_NAME</replaceable></userinput> |
| |
|
333 |
<para>Create a database with the same name as our service name, <replaceable>$OPENACS_SERVICE_NAME</replaceable>. The full pathname for <computeroutput>createdb</computeroutput> needs to be used, since the pgsql directory has not been added to the $OPENACS_SERVICE_NAME bash profile.</para> |
| |
|
334 |
<screen>[root root]# <userinput>su - <replaceable>$OPENACS_SERVICE_NAME</replaceable></userinput> |
| |
|
335 |
[$OPENACS_SERVICE_NAME $OPENACS_SERVICE_NAME]$ <userinput>/usr/local/pgsql/bin/createdb -E UNICODE <replaceable>$OPENACS_SERVICE_NAME</replaceable></userinput> |
| |
336 |
336 |
CREATE DATABASE |
| |
337 |
|
[postgres pgsql]$ |
| |
338 |
|
<action>su - postgres</replaceable> |
| |
339 |
|
createdb -E UNICODE -U <replaceable>$OPENACS_SERVICE_NAME</replaceable> <replaceable>$OPENACS_SERVICE_NAME</replaceable></action></screen> |
| |
|
337 |
[$OPENACS_SERVICE_NAME $OPENACS_SERVICE_NAME]$ |
| |
|
338 |
<action>su - $OPENACS_SERVICE_NAME</replaceable> |
| |
|
339 |
/usr/local/pgsql/bin/createdb -E UNICODE <replaceable>$OPENACS_SERVICE_NAME</replaceable></action></screen> |
| |
340 |
340 |
</listitem> |
| |
341 |
341 |
<listitem> |
| |
342 |
342 |
<para>Automate daily database Vacuuming. This is a process which cleans out discarded data from the database. A quick way to automate vacuuming is to edit the cron file for the database user. Recommended: <computeroutput>VACUUM ANALYZE</computeroutput> every hour and <computeroutput>VACUUM FULL ANALYZE</computeroutput> every day.</para> |
| |
343 |
343 |
<indexterm> |
| |
344 |
344 |
<primary>Postgres</primary> |
| |
345 |
345 |
<secondary>Vacuuming</secondary> |
| |
346 |
346 |
</indexterm> |
| |
347 |
347 |
<screen>[$OPENACS_SERVICE_NAME $OPENACS_SERVICE_NAME]$ <userinput>export EDITOR=emacs;crontab -e</userinput></screen> |
| |
348 |
348 |
<para>Add these lines to the file. The vacuum command cleans up temporary structures within a PostGreSQL database, and can improve performance. We vacuum gently every hour and completely every day. The numbers and stars at the beginning are cron columns that specify when the program should be run - in this case, whenever the minute is 0 and the hour is 1, i.e., 1:00 am every day, and every (*) day of month, month, and day of week. Type <computeroutput>man 5 crontab</computeroutput> for more information.</para> |
| |
349 |
349 |
<programlisting>0 1-23 * * * /usr/local/pgsql/bin/vacuumdb --analyze <replaceable>$OPENACS_SERVICE_NAME</replaceable> |
| |
350 |
350 |
0 0 * * * /usr/local/pgsql/bin/vacuumdb --full --analyze <replaceable>$OPENACS_SERVICE_NAME</replaceable></programlisting> |
| |
351 |
351 |
|
| |
352 |
352 |
<para>Depending on your distribution, you may receive |
| |
353 |
353 |
email when the crontab items are executed. If you |
| |
354 |
354 |
don't want to receive email for those crontab items, |
| |
355 |
355 |
you can add <computeroutput>> /dev/null |
| |
356 |
356 |
2>&1</computeroutput> to the end of each crontab |
| |
357 |
357 |
line</para> |
| |
358 |
358 |
|
| |
359 |
359 |
</listitem> |