]> git.evergreen-ils.org Git - working/Evergreen.git/blob - 1.6/admin/AdminMisc.xml
331f46e1ec40430243ee4367f059c7215ad70719
[working/Evergreen.git] / 1.6 / admin / AdminMisc.xml
1 <?xml version='1.0' encoding='UTF-8'?>\r
2 <chapter xmlns="http://docbook.org/ns/docbook" xmlns:xi="http://www.w3.org/2001/XInclude"\r
3             xmlns:xl="http://www.w3.org/1999/xlink" version="5.0" xml:id="adminmisc">\r
4         <info>\r
5                 \r
6         <title>Server Operations</title>\r
7         <indexterm><primary>receipt template editor</primary></indexterm>\r
8                 <abstract>\r
9                         <para>This chapter deals with basic server operations such as starting and stopping <application>Evergreen</application> as well wall \r
10                         security, backing up and troubleshooting <application>Evergreen</application>.</para>\r
11                 </abstract>\r
12         </info>    \r
13         <section xml:id="startingopensrf">\r
14                 <title>Starting, Stopping and Restarting</title>\r
15                 <para>Occasionally, you may need to restart <application>Evergreen</application>. It is imperative that you understand the basic \r
16                 commands to stop and start the <application>Evergreen</application> server. You can start and stop <application>Evergreen</application> from the command line of \r
17                 the server using the <command>osrf_ctl.sh</command> script located in the \r
18                 <filename class="directory">openils/bin</filename> directory.</para>   \r
19                 <note><para><command>The osrf_ctl.sh</command> command must be run as the <systemitem class="username">opensrf</systemitem> user.</para></note>\r
20                 <para>To view help on <command>osrf_ctl.sh</command> and get all of its options, run:</para>\r
21                 <screen><userinput>osrf_ctl.sh -h</userinput></screen>\r
22                 <para>To start Evergreen, run:</para>\r
23                 <screen><userinput>osrf_ctl.sh -l -a start_all</userinput></screen>\r
24                 <para>The <option>-l</option> flag is used to indicate that Evergreen is configured to use <systemitem class="domainname">localhost</systemitem> as \r
25                 the host. If you have configured <filename>opensrf.xml</filename> to use your real hostname, do not use the <option>-l</option> flag. The <option>-a</option> \r
26                 option is required and indicates the <emphasis>action</emphasis> of the command. In this case \r
27                 <option>start_all</option>.    \r
28                 </para> \r
29                 <note>\r
30                         <para>If you receive the error message: <errortext>osrf_ctl.sh: command not found</errortext>, then your environment variable \r
31                         <varname>PATH</varname><indexterm><primary>environment variable</primary><secondary>PATH</secondary></indexterm> does not include the \r
32                         <filename class="directory">/openils/bin</filename> directory. You can set it using the following command:</para>\r
33                         <screen><userinput>export <varname>PATH</varname>=$PATH:<filename class="directory">/openils/bin</filename></userinput></screen>\r
34                         <para>If you receive the error message <errortext>Can't locate OpenSRF/System.pm in @INC â€¦ BEGIN \r
35                         failed–compilation aborted</errortext>, then your environment variable <varname>PERL5LIB</varname><indexterm><primary>environment \r
36                         variable</primary><secondary>PERL5LIB</secondary></indexterm> does not \r
37                         include the <filename class="directory">/openils/lib/perl5</filename> directory.  You can set it \r
38                         using the following command:</para>\r
39                         <screen><userinput>export <varname>PERL5LIB</varname>=$PERL5LIB:<filename class="directory">/openils/lib/perl5</filename></userinput></screen>\r
40                 </note>         \r
41                 <para>It is also possible to start a specific service. For example:</para>\r
42                 <screen><userinput>osrf_ctl.sh -l -a start_router</userinput></screen>\r
43                 <para>will only start the <systemitem class="service">router</systemitem> service.</para>\r
44                 <caution>\r
45                         <para>If you decide to start each service individually, you need to start them in a specific order:</para>\r
46 <screen>\r
47 <userinput>osrf_ctl.sh -l -a start_router</userinput>\r
48 <userinput>osrf_ctl.sh -l -a start_perl</userinput>\r
49 <userinput>osrf_ctl.sh -l -a start_c</userinput>\r
50 </screen>\r
51                 </caution>      \r
52                 <para>After starting or restarting Evergreen, it is also necessary to restart the <systemitem class="service">Apache web server</systemitem>\r
53                 <indexterm><primary>web server</primary><secondary>Apache</secondary></indexterm> for the OPAC to work correctly.</para>  \r
54                 <para>To stop <application>Evergreen</application>, run:</para>\r
55                 <screen><userinput>osrf_ctl.sh -l -a stop_all</userinput></screen>\r
56                 <para>As with starting, you can choose to stop services individually.</para>\r
57                 <para>To restart <application>Evergreen</application>, run:</para>\r
58                 <screen><userinput>osrf_ctl.sh -l -a restart_all</userinput></screen>\r
59                 <simplesect>\r
60                         <title>Starting Specific Perl Services</title>\r
61                         <para>It is also possible to start and stop a specific perl service using <filename>opensrf-perl.pl</filename>.  Here is the syntax for starting a perl service with this command:</para>\r
62 <screen><userinput>opensrf-perl.pl --service <systemitem class="service">&lt;service-name&gt;</systemitem> -a start -p <filename class="directory">&lt;PID-directory&gt;</filename> </userinput></screen>\r
63 <para>Example (starting the booking module):</para>\r
64 <screen><userinput>opensrf-perl.pl --service <systemitem class="service">open-ils.booking</systemitem> -a start -p <filename class="directory">/openils/var/run/opensrf</filename></userinput></screen>\r
65 \r
66 <para>This is the syntax for stopping a perl service with this command:</para>\r
67 <screen><userinput>opensrf-perl.pl --service <systemitem class="service">&lt;service-name&gt;</systemitem> -a stop -p <filename class="directory">&lt;PID-directory&gt;</filename> </userinput></screen>\r
68 <para>Example (stopping the booking module):</para>\r
69 <screen><userinput>opensrf-perl.pl --service <systemitem class="service">open-ils.booking</systemitem> -a stop -p <filename class="directory">/openils/var/run/opensrf</filename></userinput></screen>\r
70                         <para>These commands can be very useful when you edit Perl modules and only need to restart the specific service for changes to take effect.</para>\r
71                         \r
72                         <note>\r
73                         <para>The default for the PID-directory: <filename class="directory">/openils/var/run/opensrf</filename></para>\r
74                         <para>For a clustered server instance of Evergreen, you must store the PIDs on a directory \r
75                         that is local to each server, or else one of your cluster servers may try killing processes on itself that actually have PIDs on other servers.</para>\r
76                         <para>For services running on the local server use the <option>--localhost</option> to force the hostname to be <systemitem class="domainname">localhost</systemitem>, \r
77                         instead of the fully qualified domain name for the machine.</para>\r
78                         <para>To see other options run the command with the <option>-h</option> option:</para>\r
79 <screen><userinput>opensrf-perl.pl  -h</userinput></screen>\r
80                         </note>\r
81 <para>For a list of Evergreen/OpenSRF perl services see: <xref linkend="_evergreen_specific_opensrf_services"/>.</para>\r
82                 </simplesect>\r
83         </section>\r
84         <section xml:id="evergreen_startup_script">\r
85                 <title>Automating Evergreen Startup and Shutdown</title>\r
86                 <para>Once you understand starting and stopping Evergreen, you will want to create a start up script for two purposes:</para>\r
87                 <itemizedlist>\r
88                         <listitem>Allow you to start, restart and stop Evergreen, SIP, reporter and z39.50 services with one command.</listitem>\r
89                         <listitem>Allow Evergreen to stop and start properly during a system restart.</listitem>\r
90                 </itemizedlist>\r
91                 <para>The following procedure is for Debian or Ubuntu distributions of Linux.</para>\r
92                 <procedure>\r
93                         <step>\r
94                                 <para>Create a bash script for starting Evergreen and all associated services. Here is an example script:</para>  \r
95 \r
96 <programlisting><![CDATA[\r
97 #!/bin/bash\r
98 \r
99 OPENILS_BASE="/openils"\r
100 OPENILS_CORE="${OPENILS_BASE}/conf/opensrf_core.xml"\r
101 SRU_LOG="${OPENILS_BASE}/var/log/sru.log"\r
102 \r
103 SIP_PID="${OPENILS_BASE}/var/run"\r
104 SIP_CONF="${OPENILS_BASE}/conf/oils_sip.xml"\r
105 \r
106 REP_LOCK="${OPENILS_BASE}/var/lock/reporter-LOCK"\r
107 REP_NAME="Clark Kent, waiting for trouble"\r
108 \r
109 sru_name='simple2zoom'\r
110 \r
111 if [ $(whoami) != 'opensrf' ]; then\r
112  PERL5LIB='/openils/lib/perl5:$PERL5LIB';\r
113 fi;\r
114 \r
115 start() {\r
116         sleep 3\r
117         echo "Starting Evergreen"\r
118         sudo -u opensrf /bin/bash -c \ \r
119         "PERL5LIB=${PERL5LIB}:${OPENILS_BASE}/lib/perl5 PATH=${PATH}:${OPENILS_BASE}/bin osrf_ctl.sh \\r
120         -l -a start_all"\r
121 }\r
122 \r
123 stop() {\r
124         echo "Stopping Evergreen"\r
125         sudo -u opensrf /bin/bash -c \\r
126         "PERL5LIB=${PERL5LIB}:${OPENILS_BASE}/lib/perl5 PATH=${PATH}:${OPENILS_BASE}/bin osrf_ctl.sh \\r
127         -l -a stop_all"\r
128 }\r
129 \r
130 autogen() {\r
131         echo "Running Autogen Update"\r
132         sudo -u opensrf /bin/bash -c \ \r
133         "PERL5LIB=${PERL5LIB}:${OPENILS_BASE}/lib/perl5 PATH=${PATH}:${OPENILS_BASE}/bin autogen.sh \\r
134          -u -c ${OPENILS_CORE}"\r
135 }\r
136 \r
137 sip_start() {\r
138         sudo -u opensrf /bin/bash -c \\r
139         "PERL5LIB=${PERL5LIB}:${OPENILS_BASE}/lib/perl5 PATH=${PATH}:${OPENILS_BASE}/bin oils_ctl.sh \\r
140         -d ${SIP_PID} \\r
141         -s ${SIP_CONF} \\r
142         -a start_sip"\r
143 }\r
144 \r
145 sip_stop() {\r
146         sudo -u opensrf /bin/bash -c \ \r
147         "PERL5LIB=${PERL5LIB}:${OPENILS_BASE}/lib/perl5 PATH=${PATH}:${OPENILS_BASE}/bin oils_ctl.sh \\r
148         -d ${SIP_PID} \\r
149         -s ${SIP_CONF} \\r
150         -a stop_sip"\r
151 }\r
152 \r
153 sip_restart() {\r
154         sudo -u opensrf /bin/bash -c \\r
155         "PERL5LIB=${PERL5LIB}:${OPENILS_BASE}/lib/perl5 PATH=${PATH}:${OPENILS_BASE}/bin oils_ctl.sh \\r
156         -d ${SIP_PID} \\r
157          -s ${SIP_CONF} \\r
158         -a restart_sip"\r
159 }\r
160 ]]></programlisting>\r
161 <programlisting><![CDATA[\r
162 \r
163 start_rep() {\r
164         pids="$(pidof "$REP_NAME")"\r
165         if [ ! x"$pids" = x ] ; then\r
166           echo FAILURE ; echo $"Starting Reporting: already running as $pids" \r
167           return 1\r
168         fi\r
169         rm -f $REP_LOCK\r
170         sudo -u opensrf bash -c \\r
171         "PERL5LIB=${PERL5LIB}:${OPENILS_BASE}/lib/perl5 PATH=${PATH}:${OPENILS_BASE}/bin clark-kent.pl \\r
172         --lockfile=${REP_LOCK} --boostrap=${OPENILS_CORE} --concurrency=1 --sleep=30 --daemon" ;\r
173         pids="$(pidof "$REP_NAME")"\r
174         if [ x"$pids" = x ] ; then\r
175           echo FAILURE \r
176         else \r
177           echo OK\r
178         fi\r
179         echo "Starting Reporting: $pids" \r
180         return $RETVAL\r
181 }\r
182 \r
183 stop_rep() {\r
184         pids="$(pidof "$REP_NAME")"\r
185         if [ x"$pids" = x ] ; then\r
186           echo FAILURE ; echo $"Stopping Reporting: not running" ; RETVAL=1\r
187         else \r
188           kill $pids ; RETVAL=$?\r
189           if [ $RETVAL ] ; then\r
190             echo OK ; echo $"Stopping Reporting: $pids"\r
191           else\r
192             echo FAILURE \r
193           fi\r
194         fi\r
195         rm -f $REP_LOCK\r
196         return $RETVAL\r
197 }\r
198 \r
199 z39_50_start() {\r
200         pids=`ps -eo pid,args | grep $sru_name | grep -v grep | cut -c1-6`\r
201         if [ ! x"$pids" = x ] ; then\r
202           echo FAILURE ; echo $"Starting Z39.50/SRU: already running as $pids" \r
203           return 1\r
204         fi\r
205         sudo -u opensrf bash -c "touch ${SRU_LOG}"\r
206         sudo bash -c \ \r
207         "PERL5LIB=${PERL5LIB}:${OPENILS_BASE}/lib/perl5 PATH=${PATH}:${OPENILS_BASE}/bin \\r
208         z39_50.sh >> ${SRU_LOG} 2>&1" &\r
209         sleep 1\r
210         pids=`ps -eo pid,args | grep $sru_name | grep -v grep | cut -c1-6`\r
211         if [ x"$pids" = x ] ; then\r
212           echo FAILURE \r
213         else \r
214           echo OK\r
215         fi\r
216         echo "Starting Z39.50/SRU: $pids" \r
217         return $RETVAL\r
218 }\r
219 \r
220 z39_50_stop() {\r
221         pids=`ps -eo pid,args | grep $sru_name | grep -v grep | cut -c1-6`\r
222         if [ x"$pids" = x ] ; then\r
223           echo FAILURE ; echo $"Stopping Z39.50/SRU: not running" ; RETVAL=1\r
224         else \r
225           kill $pids ; RETVAL=$?\r
226           if [ $RETVAL ] ; then\r
227             echo OK ; echo $"Stopping Z39.50/SRU: $pids"\r
228           else\r
229             echo FAILURE \r
230           fi\r
231         fi\r
232         return $RETVAL\r
233 }\r
234 ]]></programlisting>\r
235 <programlisting><![CDATA[\r
236 case "$1" in\r
237     start)\r
238         start\r
239         start_rep\r
240         z39_50_start\r
241         sip_start\r
242     ;;\r
243     stop)\r
244         sip_stop\r
245         z39_50_stop\r
246         stop_rep\r
247         stop\r
248     ;;\r
249     restart)\r
250         echo "Restarting Evergreen, Reporter and Z39.50 Processes"\r
251         sip_stop\r
252         z39_50_stop\r
253         stop_rep\r
254         stop\r
255         start\r
256         start_rep\r
257         z39_50_start\r
258         sip_start\r
259     ;;\r
260     autogen)\r
261         autogen\r
262     ;;\r
263     sip_start)\r
264         sip_start\r
265     ;;\r
266     sip_stop)\r
267         sip_stop\r
268     ;;\r
269     sip_restart)\r
270         sip_restart\r
271     ;;\r
272     start_reporter)\r
273         start_rep\r
274     ;;\r
275     stop_reporter)\r
276         stop_rep\r
277     ;;\r
278     restart_reporter)\r
279         stop_rep\r
280         start_rep\r
281     ;;\r
282     z39_50_start)\r
283         z39_50_start\r
284     ;;\r
285     z39_50_stop)\r
286         z39_50_stop\r
287     ;;\r
288     z39_50_restart)\r
289         z39_50_stop\r
290         z39_50_start\r
291     ;;\r
292     start_router|stop_router|restart_router|start_perl|stop_perl|restart_perl| \\r
293     start_c|stop_c|restart_c|start_osrf|stop_osrf|restart_osrf|stop_all|start_all|restart_all)\r
294         sudo -u opensrf /bin/bash -c \\r
295         "PERL5LIB=${PERL5LIB}:${OPENILS_BASE}/lib/perl5 \ \r
296         PATH=${PATH}:${OPENILS_BASE}/bin osrf_ctl.sh -l -a $1"\r
297     ;;\r
298     *)\r
299         echo " * Usage: /etc/init.d/evergreen {start|stop|restart|autogen"\r
300         echo "  |sip_start|sip_stop|sip_restart"\r
301         echo "  |z39_50_start|z39_50_stop|z39_50_restart"\r
302         echo "  |start_reporter|stop_reporter|restart_reporter"\r
303         echo "  |start_router|stop_router|restart_router|start_perl|stop_perl|restart_perl"\r
304         echo "  |start_c|stop_c|restart_c|start_osrf|stop_osrf|restart_osrf \r
305                 |stop_all|start_all|restart_all}"\r
306         exit 1\r
307     ;;\r
308 esac;\r
309 ]]></programlisting>\r
310                         </step>\r
311                         <step>\r
312                                 <para>Save file in <filename class="directory">/etc/bin</filename> folder as <filename>evergreenstart</filename> \r
313                                 if you would like this as a manual script for starting Evergreen services.</para> \r
314                                 \r
315                                 <para>Save file in <filename class="directory">/etc/init.d</filename> folder as <filename>evergreenstart</filename> \r
316                                 if you would like to run this script automatically during your server's boot process as explained in later steps.</para> \r
317                         </step>\r
318                         <step>\r
319                         <para>Ensure that the script is executable.</para>\r
320 <screen><userinput>sudo chmod 755 evergreenstart </userinput></screen>\r
321                         </step> \r
322                         <step>\r
323                                 <para>Test the script by running it from the command line as the <systemitem class="username">root</systemitem> user.</para>\r
324 <screen><userinput>/etc/init.d/evergreenstart restart</userinput></screen>\r
325                                 <para>You will also need to restart apache as the <systemitem class="username">root</systemitem> user.</para>\r
326 <screen><userinput>/etc/init.d/apache2 restart</userinput></screen>\r
327                         </step> \r
328                         <step>\r
329                                 <note>\r
330                                         <para>The next steps are optional if you want to automate Evergreen so it starts during your server's boot process.</para>\r
331                                 </note>\r
332                                 <para>Update runlevel defaults of the new evergreenstart service as the <systemitem class="username">root</systemitem>  user:</para>\r
333 <screen><userinput>update-rc.d evergreenstart defaults 80 20</userinput></screen>\r
334                                 <note>\r
335                                         <para>For Evergreen to start properly during a reboot, you will want to ensure that the first number \r
336                                         (<option>80</option>) is lower than the assigned \r
337                                         starting priority for Apache, so it starts before Apache. It should also have a larger stopping priority number \r
338                                         (<option>20</option>) than Apache so it stops \r
339                                         after Apache during a boot cycle.</para>\r
340                                 </note>\r
341                         </step> \r
342                         <step>\r
343                         <para>Test the startup script by rebooting the Evergreen Server and checking to ensure that all Evergreen sercices started properly.</para>\r
344                         </step> \r
345                 </procedure>\r
346                 <caution><para>This has not yet been tested in a Evergreen multi-server, <quote>brick</quote> configuration.</para></caution> \r
347                 <para>For more information on update-rc.d you should review the documentation on this topic for \r
348                 <link xl:href="http://www.debuntu.org/how-to-manage-services-with-update-rc.d">\r
349                 Debian</link> or <link xl:href="http://manpages.ubuntu.com/manpages/hardy/man8/update-rc.d.8.html">Ubuntu</link> \r
350                 depending on your distribution of Linux.</para>         \r
351         </section>\r
352         <section xml:id="backingup">\r
353                 <title>Backing Up</title>\r
354                 <indexterm><primary>databases</primary><secondary>backing up</secondary></indexterm>\r
355                 <para>Backing up your system files and data is a critical task for server and database administrators. \r
356                 Having a strategy for backing up and recovery could be the difference between a minor annoyance for users and\r
357                 a complete catastrophe.</para>   \r
358                 <simplesect>\r
359                         <title>Backing up the <application>Evergreen</application> Database</title><indexterm><primary>databases</primary></indexterm>\r
360                         <para>Most of the critical data for an <application>Evergreen</application> system â€“ patrons, bibliographic records, holdings, \r
361                         transactions, bills â€“ is stored in the <application>PostgreSQL</application><indexterm><primary>databases</primary>\r
362                         <secondary>PostgreSQL</secondary></indexterm>  database. You can therefore use normal \r
363                         <application>PostgreSQL</application> backup procedures to backup this data. For example, the simplest method of backing up the Evergreen\r
364                         database is to use the <command>pg_dump</command> command to create a live backup of the database without having to \r
365                         interrupt any Evergreen services. Here is an example pg_dump command which will dump a local Evergreen database into a the file \r
366                         <filename>evergreen_db.backup</filename>:</para>\r
367                         <screen><userinput>pg_dump -U evergreen -h localhost -f evergreen_db.backup evergreen</userinput></screen>\r
368                         <para>To restore the backed up database into a new database, create a new database using the \r
369                         template0 database template and the UTF8 encoding, and run the <command>psql</command> command, specifying the new \r
370                         database as your target:</para>\r
371                         <screen><userinput>createdb -T template0 -E UTF8 -U evergreen -h localhost new_evergreen</userinput></screen>\r
372                         <screen><userinput>psql -U evergreen -h localhost -f evergreen_db.backup new_evergreen</userinput></screen>\r
373                         <note>\r
374                                 <para>This method of backup is only suitable for small Evergreen instances. Larger sites \r
375                                 should consider implementing continuous archiving (also known as <quote>log shipping</quote>) to provide \r
376                                 more granular backups with lower system overhead. More information on backing up <application>PostgreSQL</application> \r
377                                 databases can be found in the official <link xl:href="http://www.postgresql.org/docs/"><application>PostgreSQL</application> \r
378                                 documentation</link>.</para>\r
379                         </note>\r
380                 </simplesect>\r
381                 <simplesect>\r
382                         <title>Backing up Evergreen Files</title>\r
383                         <indexterm><primary>directories</primary><secondary>backing up</secondary></indexterm>\r
384                         <para>When you deploy Evergreen, you will probably customize many aspects of your system including \r
385                         the system configuration files, <application>Apache</application> configuration files, OPAC and Staff Client. In order to \r
386                         protect your investment of time, you should carefully consider the best approach to backing up \r
387                         files.</para>\r
388                         <para>There are a number of ways of tackling this problem. You could create a script that regularly \r
389                         creates a time-stamped tarball of all of these files and copies it to a remote server - but that \r
390                         would build up over time to hundreds of files. You could use <link xl:href="http://www.samba.org/rsync/"><application>rsync</application></link>\r
391                         <indexterm><primary>rsync</primary></indexterm> to ensure that the files of \r
392                         interest are regularly updated on a remote server - but then you would lose track of the changes to \r
393                         the files, should you make a change that introduces a problem down the road.</para>\r
394                         <para>Perhaps one of the best options is to use a version control system like <link xl:href="http://bazaar.canonical.com">\r
395                         <application>Bazaar</application></link><indexterm><primary>Version Control System</primary><secondary>Subversion</secondary></indexterm>, \r
396                         <link xl:href="http://git-scm.com/"><application>git</application></link><indexterm><primary>Version Control System</primary><secondary>git</secondary></indexterm> \r
397                         or <link xl:href="http://subversion.apache.org/"><application>Subversion</application></link><indexterm><primary>Version Control System</primary>\r
398                         <secondary>Subversion</secondary></indexterm> to regularly push updates of the files you care about to a repository on a \r
399                         remote server. This gives you the advantage of quickly being able to run through the history of the \r
400                         changes you made, with a commenting system that reminds you why each change was made, combined with \r
401                         remote storage of the pertinent files in case of disaster on site. In addition, your team can create \r
402                         local copies of the repository and test their own changes in isolation from the production \r
403                         system. Using a version control system also helps to recover system customizations after an \r
404                         upgrade.</para>\r
405                 </simplesect>\r
406                 <simplesect>\r
407                         <title>Full System Backup</title>\r
408                         <para>A full system backup archives every file on the file system. Some basic methods require you \r
409                         to shut down most system processes; other methods can use mirrored RAID<indexterm><primary>RAID</primary></indexterm> setups or \r
410                         SAN<indexterm><primary>SAN</primary></indexterm> storage to \r
411                         take <quote>snapshot</quote> backups of your full system while the system continues to run. The subject of how \r
412                         to implement full system backups is beyond the scope of this documentation.</para>\r
413                 </simplesect>\r
414         </section>\r
415         <section xml:id="security">\r
416                 <title>Security</title>\r
417                 <indexterm><primary>security</primary></indexterm>\r
418                 <para>As with an ILS and resource accessible from the world wide web careful consideration needs to be \r
419                 given to the security of your <application>Evergreen</application> servers and database. While it is impossible to cover all aspects \r
420                 of security, it is important to take several precautions when setting up production <application>Evergreen</application> site.</para>\r
421                 <orderedlist>\r
422                         <listitem>\r
423                                 <para>Change the Evergreen <systemitem class="username">admin</systemitem> password and keep it secure. The \r
424                                 default admin password is known by anyone who has installed <application>Evergreen</application>. It is not a secret \r
425                                 and needs to be changed by the Administrator. It should also only be shared by those who \r
426                                 need the highest level of access to your system.</para>\r
427                         </listitem>\r
428                         <listitem>\r
429                                 <para>Create strong passwords using a combination of numerical and alphabetical characters \r
430                                 for all of the Administrative passwords including the <systemitem class="username">postgres</systemitem> and \r
431                                 <systemitem class="username">opensrf</systemitem> users</para>     \r
432                         </listitem>\r
433                         <listitem>\r
434                                 <para>Open ports in the firewall<indexterm><primary>firewall</primary></indexterm> with caution - It is only necessary to open ports \r
435                                 <systemitem class="protocol">80</systemitem> and <systemitem class="protocol">443</systemitem>\r
436                                 for <systemitem class="protocol">TCP</systemitem> connections to the Evergreen server from the OPAC and the staff client.  It is \r
437                                 critical for administrators to understand the concepts of network security and take precautions to minimize vulnerabilities. \r
438                                 </para>\r
439                         </listitem>\r
440                         <listitem>\r
441                                 <para>Use permissions <indexterm><primary>permissions</primary></indexterm> and permission groups wisely - it is important to understand the \r
442                                 purpose of the permissions and to only give users the level of access that they require.\r
443                                 </para> \r
444                         </listitem>\r
445                                         </orderedlist>  \r
446         </section>\r
447         <section xml:id="logfiles">\r
448                 <title>Managing Log Files</title>\r
449                 <indexterm><primary>logs</primary><secondary>managing</secondary></indexterm>\r
450                 <para><application>Evergreen</application> comes with a sophisticated logging system, but it is important to manage the <application>OpenSRF</application> \r
451                 and <application>Evergreen</application> logs. This section will provide a couple of log management techniques and tools.</para>        \r
452                 <simplesect>\r
453                         <title>Using the <systemitem class="service">logrotate</systemitem> Utility to Manage Log Size</title> \r
454                         <indexterm><primary>logs</primary><secondary>Log Rotate</secondary></indexterm>\r
455                          <para>Fortunately, this is not a new problem for <systemitem class="osname">Unix</systemitem> administrators, and \r
456                         there are a number of ways of keeping your logs under control. \r
457                         On <systemitem class="osname">Debian</systemitem> and <systemitem class="osname">Ubuntu</systemitem>, for example, \r
458                         the <systemitem class="service">logrotate</systemitem> utility controls when old log files are compressed and a new log file is started. \r
459                         <systemitem class="service">logrotate</systemitem> runs once a day and checks all log files that it knows about to see if a \r
460                         threshold of time or size has been reached and rotates the log files if a threshold condition has been met.</para>\r
461                         <para>To teach <systemitem class="service">logrotate</systemitem> to rotate Evergreen logs on a weekly basis, or if they are > 50MB in size, \r
462                         create a new file <filename>/etc/logrotate.d/evergreen</filename> with the following contents: </para>\r
463 <programlisting>\r
464 compress\r
465 /openils/var/log/*.log {\r
466 # keep the last 4 archived log files along with the current log file\r
467  # log log.1.gz log.2.gz log.3.gz log.4.gz\r
468  # and delete the oldest log file (what would have been log.5.gz)\r
469 rotate 5\r
470 # if the log file is > 50MB in size, rotate it immediately\r
471 size 50M\r
472  # for those logs that don't grow fast, rotate them weekly anyway\r
473   weekly\r
474 }\r
475 </programlisting>\r
476                 </simplesect>\r
477                 <simplesect>\r
478                         <title>Changing Logging Level for <application>Evergreen</application></title>\r
479                         <indexterm><primary>logs</primary><secondary>logging levels</secondary></indexterm>\r
480                         <para>Change the Log Levels in your config files. Changing the level of logging will help \r
481                         narrow down errors.</para> \r
482                         <tip>\r
483                                 <para>A high logging level is not wise to do in a production environment since  it \r
484                                 will produce vastly larger log files and thus reduce server performance.</para>\r
485                         </tip>\r
486                         <para>Change logging levels by editing the configuration file \r
487                         <filename>/openils/conf/opensrf_core.xml</filename><indexterm><primary>configuration files</primary><secondary>opensrf_core.xml</secondary></indexterm></para>\r
488                         <para>you will want to search for lines containing &lt;loglevel&gt;.</para>\r
489                         <para> the default setting for loglevel is 3 which will log <emphasis>errors</emphasis>, \r
490                         <emphasis>warnings</emphasis> and <emphasis>information</emphasis>.</para>\r
491                         <para>The next level is 4 which is for debugging and provides additional information \r
492                         helpful for the debugging process.</para>\r
493                         <para>Thus, lines with:</para>\r
494                         <programlisting>&lt;loglevel&gt;3&lt;/loglevel&gt;</programlisting>\r
495                         <para>Should be changed to:</para>\r
496                         <programlisting>&lt;loglevel&gt;4&lt;/loglevel&gt;</programlisting>\r
497                         <para>to allow debugging level logging</para>\r
498                         <para>Other logging levels include <emphasis>0</emphasis> for no logging, \r
499                         <emphasis>1</emphasis> for logging errors and <emphasis>2</emphasis> for logging warnings \r
500                         and errors.</para>\r
501                 </simplesect>\r
502         </section>\r
503         <section xml:id="InstallingPostgreSQL">\r
504                 <title>Installing PostgreSQL from Source</title>\r
505                 <indexterm><primary>databases</primary><secondary>PostgreSQL</secondary></indexterm>\r
506                 <para>Some <systemitem class="osname">Linux</systemitem> distributions, such as <systemitem class="osname">Debian Etch (4.0)</systemitem>, do not offer PostgreSQL \r
507                 version 8.2 as an installable package. Before you continue, examine the software dependencies listed in <xref linkend="serversideinstall-software-dependencies"/> \r
508                 to ensure that your Linux distribution supports the required version of PostgreSQL.</para>\r
509 \r
510                 <note>\r
511                         <para>Some <systemitem class="osname">Linux</systemitem> distributions, such as <systemitem class="osname">Debian Etch (4.0)</systemitem>, do not offer PostgreSQL \r
512                 version 8.2 as an installable package. Before you continue, examine the software dependencies listed in <xref linkend="serversideinstall-software-dependencies"/> \r
513                 to ensure that your Linux distribution supports the required version of PostgreSQL.</para>\r
514                 </note>\r
515                 \r
516                 <procedure>\r
517                         <step>\r
518                                 <para>Install the application <application>stow</application> on your system if it is not already installed. Issue the following command as \r
519                                 the <systemitem class="username">root</systemitem> user:</para>\r
520 <screen>\r
521 <userinput>apt-get install stow</userinput>\r
522 </screen>\r
523                         </step>\r
524                         <step>\r
525                                 <para>Download, compile, and install the latest release for PostgreSQL 8.2 (which was version <literal>8.2.12</literal> at the time of this writing). \r
526                                 As the <systemitem class="username">root</systemitem> user, follow these steps:</para>\r
527                                 \r
528 <screen>\r
529 <userinput>\r
530 wget http://wwwmaster.postgresql.org/redir/198/h/source/v8.2.17/postgresql-8.2.17.tar.bz2\r
531 tar xzf postgresql-8.2.17.tar.gz\r
532 cd postgresql-8.2.17\r
533 ./configure --with-perl --enable-integer-datetimes --with-openssl --prefix=/usr/local/stow/pgsql\r
534 make\r
535 make install\r
536 cd contrib\r
537 make\r
538 make install\r
539 cd xml2\r
540 make\r
541 make install\r
542 cd /usr/local/stow\r
543 stow pgsql\r
544 </userinput>\r
545 </screen>\r
546                                 \r
547                         </step>\r
548                         <step>\r
549                                 <para>Create the new user <systemitem class="username">postgres</systemitem> to run the PostgreSQL processes. \r
550                                 As the <systemitem class="username">root</systemitem> user, execute this command:</para>\r
551                                 <screen><userinput>adduser postgres</userinput></screen>\r
552                         </step>\r
553                         <step>\r
554                                 <para>Initialize the database directory and start up PostgreSQL. As the <systemitem class="username">root</systemitem> user, follow these steps:</para>\r
555                                 \r
556 <screen>\r
557 <userinput>\r
558 mkdir -p /usr/local/pgsql/data\r
559 chown postgres /usr/local/pgsql/data\r
560 su - postgres\r
561 initdb -D /usr/local/pgsql/data -E UNICODE --locale=C\r
562 pg_ctl -D /usr/local/pgsql/data -l /home/postgres/logfile start\r
563 </userinput>\r
564 </screen>\r
565                                 <note>\r
566                                         <para>If an error occurs during the final step above, review the path of the home directory for the \r
567                                         <systemitem class="username">postgres</systemitem> user. It may be <literal>/var/lib/postresql</literal> instead of <literal>/home/postres</literal>.</para>\r
568                                 </note>\r
569                         </step>\r
570                 </procedure>\r
571         </section>\r
572         <section xml:id="configuringPostgreSQL">\r
573                 <title>Configuring PostgreSQL</title>\r
574                 <indexterm><primary>databases</primary><secondary>PostgreSQL</secondary></indexterm>\r
575                 <para>The values of several PostreSQL configuration parameters may be changed for enhanced performance. The following table lists the default values \r
576                 and some suggested updates for several useful parameters:</para>\r
577                 <table>\r
578                         <title>Suggested configuration values</title>\r
579                         <tgroup align="left" cols="3" colsep="1" rowsep="1">\r
580                                 <colspec colnum="1" colwidth="1.0*"/>\r
581                                 <colspec colnum="2" colwidth="1.0*"/>\r
582                                 <colspec colnum="3" colwidth="1.0*"/>\r
583                                 <thead>\r
584                                         <row>\r
585                                                 <entry>Parameter</entry>\r
586                                                 <entry>Default</entry>\r
587                                                 <entry>Suggested</entry>\r
588                                         </row>\r
589                                 </thead>\r
590                                 <tbody>\r
591                                         <row>\r
592                                                 <entry>default_statistics_target</entry>\r
593                                                 <entry>10</entry>\r
594                                                 <entry>100</entry>\r
595                                         </row>\r
596                                         <row>\r
597                                                 <entry>work_mem</entry>\r
598                                                 <entry>4Mb</entry>\r
599                                                 <entry>128Mb</entry>\r
600                                         </row>\r
601                                         <row>\r
602                                                 <entry>shared_buffers</entry>\r
603                                                 <entry>8Mb</entry>\r
604                                                 <entry>512Mb</entry>\r
605                                         </row>\r
606                                         <row>\r
607                                                 <entry>effective_cache_size</entry>\r
608                                                 <entry>128Mb</entry>\r
609                                                 <entry>4Gb</entry>\r
610                                         </row>\r
611                                 </tbody>\r
612                         </tgroup>\r
613                 </table>\r
614         </section>\r
615 </chapter>\r