[c5c522c] | 1 | $Id: pgsql_drv.txt,v 1.5.3 2011/06/28 00:13:48 sbajic Exp $ |
---|
| 2 | |
---|
| 3 | COPYRIGHT (C) 2002-2012 DSPAM Project |
---|
| 4 | http://dspam.sourceforge.net |
---|
| 5 | |
---|
| 6 | LICENSE |
---|
| 7 | |
---|
| 8 | This program is free software: you can redistribute it and/or modify |
---|
| 9 | it under the terms of the GNU Affero General Public License as |
---|
| 10 | published by the Free Software Foundation, either version 3 of the |
---|
| 11 | License, or (at your option) any later version. |
---|
| 12 | |
---|
| 13 | This program is distributed in the hope that it will be useful, |
---|
| 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 16 | GNU Affero General Public License for more details. |
---|
| 17 | |
---|
| 18 | You should have received a copy of the GNU Affero General Public License |
---|
| 19 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
---|
| 20 | |
---|
| 21 | ABOUT |
---|
| 22 | |
---|
| 23 | pgsql_drv is a PostgreSQL storage driver for DSPAM v3.0 and above. |
---|
| 24 | This driver enables DSPAM to read and write all token, signature, |
---|
| 25 | and statistics data from a PostgreSQL database. The advantages of |
---|
| 26 | using a SQL backend are obvious: |
---|
| 27 | |
---|
| 28 | - Centralized data storage |
---|
| 29 | - Structured queries for information |
---|
| 30 | - No need for context locking mechanisms |
---|
| 31 | |
---|
| 32 | REQUIREMENTS |
---|
| 33 | |
---|
| 34 | pgsql_drv storage driver requires PostgreSQL version 7.3 or higher. |
---|
| 35 | |
---|
| 36 | 1. CONFIGURING DSPAM |
---|
| 37 | |
---|
| 38 | To configure DSPAM to use pgsql_drv, use the following arguments while running |
---|
| 39 | DSPAM's configure: |
---|
| 40 | |
---|
| 41 | --with-storage-driver=pgsql_drv |
---|
| 42 | Tells DSPAM to use the pgsql_drv driver |
---|
| 43 | |
---|
| 44 | --with-pgsql-libraries=/path/to/libs |
---|
| 45 | Tells DSPAM where to find the Postgres client libraries. They are usually |
---|
| 46 | located in /usr/local/pgsql/lib |
---|
| 47 | |
---|
| 48 | --with-pgsql-includes=/path/to/libs |
---|
| 49 | Tells DSPAM where to find the Postgres headers. They are usually located in |
---|
| 50 | /usr/local/pgsql/include |
---|
| 51 | |
---|
| 52 | --enable-virtual-users |
---|
| 53 | Tells DSPAM to create virtual user ids for each dspam user. Use this if your |
---|
| 54 | users don't really exist on the system (e.g. via getpwuid) or if you're doing |
---|
| 55 | something weird like sharing uids. |
---|
| 56 | |
---|
| 57 | After configure has successfully finished, build and install DSPAM using the |
---|
| 58 | instructions from DSPAM's readme. |
---|
| 59 | |
---|
| 60 | 2. CREATING PGSQL OBJECTS |
---|
| 61 | |
---|
| 62 | Before pgsql_drv will function, you must run pgsql_objects.sql file |
---|
| 63 | (located in src/tools.pgsql_drv) to create the table objects required by the |
---|
| 64 | driver. |
---|
| 65 | |
---|
| 66 | If you plan on enabling virtual users (something you'll need to do if the users |
---|
| 67 | don't actually exist on your system), also run virtual_users.sql. |
---|
| 68 | |
---|
| 69 | NOTE: If you are running pgsql < v8.0, you may get an error when running |
---|
| 70 | pgsql_objects.sql. It is safe to disregard this error, as it is for a function |
---|
| 71 | that is only used in v8.0+. |
---|
| 72 | |
---|
| 73 | NOTE: Install 'plpgsql' language on your dspam database before creating |
---|
| 74 | actual dspam objects if postgresql server version 8.0 or higher: |
---|
| 75 | $ createlang plpgsql dspam_db |
---|
| 76 | |
---|
| 77 | 3. CREATING A CONNECT DATA FILE |
---|
| 78 | |
---|
| 79 | pgsql_drv needs to know how to connect to your PostgreSQL database. You will |
---|
| 80 | need to specify this in dspam.conf. The file should already contain an example |
---|
| 81 | as shown below: |
---|
| 82 | |
---|
| 83 | PgSQLServer 127.0.0.1 |
---|
| 84 | PgSQLPort 5432 |
---|
| 85 | PgSQLUser dspam |
---|
| 86 | PgSQLPass changeme |
---|
| 87 | PgSQLDb dspam |
---|
| 88 | |
---|
| 89 | Or if you'd like to connect using /tmp/.s.PGSQL.5432, use: |
---|
| 90 | |
---|
| 91 | PgSQLServer /tmp |
---|
| 92 | PgSQLPort |
---|
| 93 | PgSQLUser dspam |
---|
| 94 | PgSQLPass changeme |
---|
| 95 | PgSQLDb dspam |
---|
| 96 | |
---|
| 97 | DSPAM checks to see if the first character of the HOSTNAME field is a slash, |
---|
| 98 | and if so will treat it like a socket file. |
---|
| 99 | |
---|
| 100 | 4. NIGHTLY PURGE |
---|
| 101 | |
---|
| 102 | If you would like to purge the many stale tokens DSPAM will have lying around |
---|
| 103 | the database, you should run one of the provided purge scripts nightly. The |
---|
| 104 | dspam_clean tool may also be used for deeper cleansing. See DSPAM's README |
---|
| 105 | for more information about the dspam_clean tool. |
---|
| 106 | |
---|
| 107 | If you are supporting TOE-mode users on your system, you will want to do one |
---|
| 108 | of the following: |
---|
| 109 | |
---|
| 110 | 1. TOE-Mode a user preference |
---|
| 111 | |
---|
| 112 | If you will support TOE-mode as a user option (preference), it is |
---|
| 113 | recommended that you enable preferences-extension support and recompile, |
---|
| 114 | then use the purge-pe.sql script nightly. The preferences-extension will |
---|
| 115 | store user preferences in the database so that Postgres can query them. |
---|
| 116 | |
---|
| 117 | NOTE: You should add a preference for any global users on your system, so |
---|
| 118 | that their data is purged as if TOE-based (since global user data is |
---|
| 119 | rarely updated). You can do this using: |
---|
| 120 | |
---|
| 121 | dspam_admin add pref [username] trainingMode TOE |
---|
| 122 | |
---|
| 123 | 2. Global TOE Support |
---|
| 124 | |
---|
| 125 | If you will be using TOE mode globally (for all users), then you should |
---|
| 126 | use purge.sql, but remove the following lines: |
---|
| 127 | |
---|
| 128 | DELETE FROM dspam_token_data |
---|
| 129 | WHERE CURRENT_DATE - last_hit > 90; |
---|
| 130 | |
---|
| 131 | This will prevent the purging of stale tokens, which could cause serious |
---|
| 132 | data loss in TOE databases (because tokens are never touched unless |
---|
| 133 | an error has occured). All other purges should be safe even for TOE-mode |
---|
| 134 | users. |
---|
| 135 | |
---|
| 136 | If you will NOT be supporting TOE users on your system, you may simply run |
---|
| 137 | the purge.sql script nightly, as-is. |
---|
| 138 | |
---|
| 139 | 5. TUNING |
---|
| 140 | |
---|
| 141 | PostgreSQL use sequential scan for newly created objects which will slow |
---|
| 142 | down everything. To use index scan force statistics collection by executing |
---|
| 143 | "ANALYSE" query manually, right after training first few mails. "ANALYSE" is |
---|
| 144 | included in purge.sql script. Thus new statistics will be collected daily. |
---|
| 145 | |
---|
| 146 | By default PostgreSQL sets tuneable parameters to minimum (i.e. shared memory |
---|
| 147 | size). To increase performance change "shared_buffers" and other values in |
---|
| 148 | postgresql.conf file. Kernel's shared memory related parameters also need to |
---|
| 149 | be tuned. |
---|
| 150 | |
---|
| 151 | ERRORS |
---|
| 152 | |
---|
| 153 | Any SQL errors will be reported to LOGDIR/sql.errors as well as the standard |
---|
| 154 | syslog facilities (although the query will be truncated). |
---|
| 155 | |
---|
| 156 | QUESTIONS |
---|
| 157 | |
---|
| 158 | Please contact the dspam-dev mailing list with any questions or constructive |
---|
| 159 | feedback. |
---|
| 160 | |
---|
| 161 | Initial storage driver written by Rustam Aliyev <rustam@azernews.com> and later |
---|
| 162 | enhanced by Stevan Bajic <stevan@bajic.ch> for DSPAM 3.9.0. |
---|