Fix SQL in migrating data. Bug https://bugs.launchpad.net/evergreen/+bug/720068 repor...
[working/Evergreen.git] / 2.0 / admin / Upgrading-Evergreen-2.0.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="upgradingevergreen-2.0">\r
4         <info>\r
5                 <title>Upgrading Evergreen to 2.0</title>\r
6                 <abstract>\r
7                         <para>This Chapter will explain the step-by-step process of upgrading <application>Evergreen\r
8                         </application> to 2.0, including steps to upgrade <application>OpenSRF</application>. Before \r
9                         upgrading, it is important to carefully plan an upgrade strategy to minimize system downtime and \r
10                         service interruptions. All of the steps in this chapter are to be completed from the command line.</para>\r
11                         \r
12                 </abstract>\r
13         </info>    \r
14                 <para>Evergreen 2.0 has several software requirements:</para>\r
15                 <itemizedlist>\r
16                         <listitem>PostgreSQL: Version 8.4 is the minimum supported version of PostgreSQL. </listitem>\r
17                         <listitem>Linux: Evergreen 2.0 has been tested on Debian Squeeze (6.0) and Ubuntu Lucid Lynx (10.04). If you are runnung an older version of these distributions, \r
18                         you may want to upgrade befor installing Evergreen 2.0. For instructions om upgrading these distribuitions, visit the \r
19                         <ulink url="http://www.debian.org/releases/squeeze/">Debian</ulink> or <ulink url="https://help.ubuntu.com/community/LucidUpgrades">Ubuntu</ulink> websites.</listitem>\r
20                 </itemizedlist>\r
21                 <para>In the following instructions, you are asked to perform certain steps as either the <systemitem class="username">root</systemitem>  or \r
22                 <systemitem class="username">opensrf</systemitem> user.</para>\r
23                 <itemizedlist>\r
24                         <listitem>Debian: To become the <systemitem class="username">root</systemitem> user, issue the <command>su</command> command and enter the password of the \r
25                         <systemitem class="username">root</systemitem> user.</listitem>\r
26                         <listitem>Ubuntu: To become the <systemitem class="username">root</systemitem> user, issue the <command>sudo su</command> command and enter the password of your current user.</listitem>\r
27                 </itemizedlist>\r
28                 <para>To switch from the <systemitem class="username">root</systemitem> user to a different user, issue the <command>su - [user]</command> command; for example, \r
29                 <command>su - opensrf</command>. Once you have become a non-root user, to become the <systemitem class="username">root</systemitem> user again simply issue the exit command.</para> \r
30                 <para>In the following instructions, <filename class='directory'>/path/to/OpenSRF/</filename> represents the path to the OpenSRF source directory.</para>\r
31         <section xml:id="upgradingevergreen-stop_evergreen">\r
32                 <title>Backing Up Data</title>\r
33                 <procedure>\r
34                         <step>\r
35                                 <para>As <systemitem class="username">root</systemitem>, stop the <application>Apache</application> \r
36                                 web server<indexterm><primary>web server</primary><secondary>Apache</secondary></indexterm>.</para>\r
37                         </step>\r
38                         <step>\r
39                                 <para>As the <systemitem class="username">opensrf</systemitem> user, stop all \r
40                                 <application>Evergreen</application>\r
41                                 and <application>OpenSRF</application> services:</para>\r
42                                 <screen><userinput>osrf_ctl.sh -l -a stop_all</userinput></screen>\r
43                         </step>\r
44                         <step>\r
45                                 <para>Back up of the <filename class='directory'>/openils</filename> \r
46                                 directory.</para>\r
47                         </step>\r
48                         <step>\r
49                                 <para><link linkend="backingup">Back up the <application>evergreen\r
50                                 </application> database</link>.</para>\r
51                         </step>\r
52                 </procedure>\r
53         </section>\r
54         <section xml:id="upgradingevergreen-upgradingOpenSRF">\r
55                 <title>Upgrading OpenSRF to 1.6.2</title><indexterm><primary>OpenSRF</primary></indexterm>\r
56                 <procedure>\r
57                         <step>\r
58                                 <para>As the <systemitem class="username">opensrf</systemitem> user, download and extract the source files for <application>OpenSRF</application> \r
59                                 1.6.2:</para>\r
60 <screen><userinput>\r
61 wget http://open-ils.org/downloads/OpenSRF-1.6.2.tar.gz\r
62 tar xzf OpenSRF-1.6.2.tar.gz\r
63 </userinput></screen>\r
64                                 <para>A new directory OpenSRF-1.6.2 is created.</para>\r
65                                 <note><para>For the latest edition of OpenSRF, check the Evergreen download page at \r
66                                 <ulink url="http://www.open-ils.org/downloads.php" />.\r
67                                 </para></note>\r
68                         </step>\r
69                         <step>  \r
70                                 <para>As the <systemitem class="username">root</systemitem> user, install the software prerequisites using the automatic \r
71                                 prerequisite installer.</para> \r
72 <screen><userinput>\r
73 aptitude install make\r
74 cd /home/opensrf/OpenSRF-1.6.2\r
75 </userinput></screen>           \r
76                                 <para>Replace <option>[distribution]</option> below with the following value \r
77                                 for your distribution:</para>\r
78                                 <itemizedlist>\r
79                                         <listitem>\r
80                                                 <para><option>debian-squeeze</option> for <systemitem class="osname">Debian Squeeze (6.0)</systemitem>\r
81                                                 <indexterm><primary>Linux</primary><secondary>Debian</secondary></indexterm></para>\r
82                                         </listitem>\r
83                                         <listitem>\r
84                                                 <para><option>ubuntu-lucid</option> for <systemitem class="osname">Ubuntu Lucid Lynx\r
85                                                 (10.04)</systemitem><indexterm><primary>Linux</primary><secondary>Ubuntu</secondary></indexterm></para>\r
86                                         </listitem>\r
87                                         <listitem>\r
88                                                 <para><option>centos</option> for <systemitem class="osname">CentOS 5</systemitem>\r
89                                                 <indexterm><primary>Linux</primary><secondary>CentOS</secondary></indexterm></para>\r
90                                         </listitem>\r
91                                         <listitem>\r
92                                                 <para><option>rhel</option> for <systemitem class="osname">Red Hat Enterprise Linux 5</systemitem>\r
93                                                 <indexterm><primary>Linux</primary><secondary>Red Hat</secondary></indexterm></para>\r
94                                         </listitem>\r
95                                 </itemizedlist>\r
96 <screen><userinput>\r
97 cd /path/to/OpenSRF\r
98 make -f src/extras/Makefile.install [distribution]\r
99 </userinput></screen>\r
100                                 <para>This will install a number of packages required by OpenSRF on your system, \r
101                                 including some Perl modules from <systemitem class="resource">CPAN</systemitem><indexterm><primary>Perl</primary><secondary>CPAN</secondary>\r
102                                 </indexterm>. You can type <userinput>no</userinput> to the initial <systemitem class="resource">CPAN</systemitem> \r
103                                 configuration prompt to allow it to automatically configure itself to download \r
104                                 and install Perl modules from <systemitem class="resource">CPAN</systemitem>. The <systemitem class="resource">CPAN</systemitem> installer will ask you a number of \r
105                                 times whether it should install prerequisite modules - type <userinput>yes</userinput>.</para>\r
106                         </step>\r
107                         <step>  \r
108                                 <para>As the <systemitem class="username">opensrf</systemitem> user, configure and compile OpenSRF:</para> \r
109                                 <note>You can include the <option>–enable-python</option> and <option>–enable-java</option> configure options if \r
110                                 you want to include support for Python<indexterm><primary>Python</primary></indexterm> and Java\r
111                                 <indexterm><primary>Java</primary></indexterm>, respectively.</note>\r
112 <screen><userinput>\r
113 cd /home/opensrf/OpenSRF-1.6.2\r
114 ./configure --prefix=/openils --sysconfdir=/openils/conf\r
115 make\r
116 </userinput></screen>           \r
117                         </step>\r
118                         <step>  \r
119                                 <para>As the <systemitem class="username">root</systemitem> user, return to your OpenSRF build directory and install \r
120                                 OpenSRF:</para>\r
121 <screen><userinput>\r
122 cd /home/opensrf/OpenSRF-1.6.2\r
123 make install\r
124 </userinput></screen>\r
125                         </step>\r
126                         <step>\r
127                                 <para>As the <systemitem class="username">root</systemitem> user, change the ownership of the installed files to the \r
128                                 <systemitem class="username">opensrf</systemitem> user:</para>\r
129                                 <screen><userinput>chown -R opensrf:opensrf /openils</userinput></screen>\r
130                         </step>\r
131                         <step>\r
132                                 <para>Restart and Test OpenSRF</para>\r
133 <screen><userinput>\r
134 osrf_ctl.sh -l -a start_all\r
135 /openils/bin/srfsh\r
136 srfsh#  request opensrf.math add 2 2\r
137 </userinput></screen>\r
138                                 <para>You should see output such as:</para>\r
139 <screen>\r
140 Received Data: 4\r
141 \r
142 ------------------------------------\r
143 Request Completed Successfully\r
144 Request Time in seconds: 0.007519\r
145 ------------------------------------\r
146 \r
147 srfsh#\r
148 </screen>       \r
149                                 <para>If test completed successfully move onto the next section. \r
150                                 Otherwise, refer to the <link linkend="troubleshooting">troubleshooting</link> chapter \r
151                                 of this documentation.</para> \r
152                         </step> \r
153                 </procedure>    \r
154         </section>\r
155         <section xml:id="upgradingevergreen-upgrading_from_1.6_to_2.0">\r
156                 <title>Upgrade <application>Evergreen</application> from 1.6.1 to 2.0</title>\r
157                 <note><para>8.4 is the minimum supported version of PostgreSQL. Evergreen 2.0 has been tested on Debian Squeeze (6.0) and Ubuntu Lucid (10.04). If you are runnung an older version of \r
158                         these distributions, you may want to upgrade befor installing Evergreen 2.0. For instructions om upgrading these distribuitions, visit the \r
159                         <ulink url="http://www.debian.org/releases/squeeze/">Debian</ulink> or <ulink url="https://help.ubuntu.com/community/LucidUpgrades">Ubuntu</ulink> websites.</para></note>\r
160                 <procedure>\r
161                         <step>\r
162                                 <para>As the <systemitem class="username">opensrf</systemitem> user, download and extract <application>Evergreen 2.0</application>\r
163                                 </para>\r
164 <screen><userinput>\r
165 wget http://www.open-ils.org/downloads/Evergreen-ILS-2.0.1.tar.gz\r
166 tar xzf Evergreen-ILS-2.0.1.tar.gz\r
167 </userinput></screen>\r
168                                 <note><para>For the latest edition of Evergreen 2.0, check the Evergreen download page at\r
169                                 <ulink url="http://www.open-ils.org/downloads.php" /> and adjust upgrading instructions accordingly.</para></note>\r
170                         </step>\r
171                         <step>\r
172                                 <para>As the <systemitem class="username">root</systemitem> user, install the prerequisites:</para> \r
173                                 <screen><userinput>cd /home/opensrf/Evergreen-ILS-2.0.1</userinput></screen>    \r
174                                 <para>On the next command, replace <option>[distribution]</option> with one of \r
175                                 these values for your distribution of Debian or Ubuntu:</para>\r
176                                 <itemizedlist>\r
177                                         \r
178                                         <listitem>\r
179                                                 <para><option>debian-squeeze</option> for <systemitem class="osname">Debian Squeeze (6.0)</systemitem></para>\r
180                                         </listitem>\r
181                                         \r
182                                         <listitem>\r
183                                                 <para><option>ubuntu-lucid</option> for  <systemitem class="osname">Ubuntu Lucid Lynx \r
184                                                 (10.04)</systemitem></para>\r
185                                         </listitem>\r
186                                 </itemizedlist>\r
187                                 <screen><userinput>make -f Open-ILS/src/extras/Makefile.install <option>[distribution]</option></userinput></screen>\r
188                         </step>\r
189                         <step>\r
190                                 <para>As the <systemitem class="username">opensrf</systemitem> user, configure and compile \r
191                                 <application>Evergreen</application>:</para>\r
192                                 <screen><userinput>cd /home/opensrf/Evergreen-ILS-2.0.1</userinput></screen>\r
193                                 <screen><userinput>./configure --prefix=/openils --sysconfdir=/openils/conf</userinput></screen>\r
194                                 <screen><userinput>make</userinput></screen>\r
195                         </step>\r
196                         <step>\r
197                                 <para>As the <systemitem class="username">root</systemitem> user, install \r
198                                 <application>Evergreen</application>:</para>\r
199                                 <screen><userinput>make STAFF_CLIENT_BUILD_ID=rel_2_0_1 install</userinput></screen>\r
200                         </step>\r
201                         <step>\r
202                                 <para>Change to the <application>Evergreen</application> installation \r
203                                 directory:</para>\r
204                                 <screen><userinput>cd /home/opensrf/Evergreen-ILS-2.0.1</userinput></screen>\r
205                         </step>\r
206                         <step>\r
207                                 <para>As the <emphasis>root</emphasis> user, change all files to be owned by the \r
208                                 <emphasis>opensrf</emphasis> user and group:</para>\r
209                                 <screen><userinput>chown -R opensrf:opensrf /openils</userinput></screen>\r
210                         </step>                 \r
211                         <step>\r
212                                 <para>As the <systemitem class="username">opensrf</systemitem> user, update server symlink in <filename class="directory">/openils/var/web/xul/</filename>:</para>\r
213 <screen><userinput>\r
214 cd /openils/var/web/xul/\r
215 rm server\r
216 ln -s rel_2_0_1/server\r
217 </userinput></screen>\r
218                         </step>\r
219                         <step>\r
220                                 <para>Update the <database>evergreen</database> database:</para>\r
221                                 <note><para>It is recommended that you <link linkend="backingup">back up your Evergreen database</link> in order to restore your data if anything goes wrong.</para></note>\r
222 <screen>\r
223 <userinput>\r
224 psql -U evergreen -h localhost -f Open-ILS/src/sql/Pg/1.6.1-2.0-upgrade-db.sql evergreen\r
225 psql -U evergreen -h localhost -f Open-ILS/src/sql/Pg/2.0.0-2.0.1-upgrade-db.sql evergreen\r
226 </userinput>\r
227 </screen>       \r
228                         </step>\r
229 <step>\r
230                                 <para>Run the <filename>reingest-1.6-2.0.pl</filename> script to generate an sql script. Then use the sql file to reingest bib records into your \r
231                                 <database>evergreen</database> database. This is required to make the new facet sidebar in OPAC search results work and to upgrade the keyword indexes to use \r
232                                 the revised NACO normalization routine.</para>\r
233                                 <note><para>If you are running a large Evergreen installation, it is recommend that you examine the script first. Reingesting a large number of bibliographic records \r
234                                 may take several hours.</para></note>\r
235 <screen><userinput>perl Open-ILS/src/sql/Pg/reingest-1.6-2.0.pl</userinput></screen>\r
236 <screen><userinput>psql -U evergreen -h localhost -f Open-ILS/src/sql/Pg/reingest-1.6-2.0.sql evergreen</userinput></screen>\r
237                         </step>\r
238                         <step>\r
239                                 <para>As the <systemitem class="username">opensrf</systemitem> user, \r
240                                 copy <filename>/openils/conf/oils_web.xml.example</filename> to <filename>/openils/conf/oils_web.xml</filename>\r
241                                 <indexterm><primary>configuration files</primary><secondary>oils_web.xml</secondary></indexterm>\r
242                                 (needed for acquisitions templates).</para>\r
243                                 <screen><userinput>cp /openils/conf/oils_web.xml.example /openils/conf/oils_web.xml</userinput></screen>\r
244                         </step>\r
245                         <step>\r
246                                 <para>Update <filename>opensrf_core.xml</filename> and <filename>opensrf.xml</filename> by copying the new example files \r
247                                 (<filename>/openils/conf/opensrf_core.xml.example</filename> and <filename>/openils/conf/opensrf.xml</filename>).</para>\r
248                                 <indexterm><primary>configuration files</primary><secondary>opensrf.xml</secondary></indexterm>\r
249                                 <screen><userinput>cp /openils/conf/opensrf_core.xml.example /openils/conf/opensrf_core.xml</userinput></screen>\r
250                                 <indexterm><primary>configuration files</primary><secondary>opensrf_core.xml</secondary></indexterm>\r
251                                 <screen><userinput>cp /openils/conf/opensrf.xml.example /openils/conf/opensrf.xml</userinput></screen>\r
252                         </step>\r
253                         <step>\r
254                                 <para>Update <filename>opensrf.xml</filename> with the database connection info:</para>\r
255 <screen><userinput>\r
256 perl Open-ILS/src/support-scripts/eg_db_config.pl --update-config --service all --create-offline --user evergreen \\r
257 --password evergreen --hostname localhost --port 5432 --database evergreen\r
258 </userinput></screen>\r
259                         </step>\r
260                         <step>\r
261                                 <para>Update /etc/apache2/startup.pl by copying the example from \r
262                                 Open-ILS/examples/apache/startup.pl.</para><indexterm><primary>configuration files</primary><secondary>startup.pl</secondary></indexterm>\r
263                         </step>\r
264                         <step>\r
265                                 <para>Update /etc/apache2/eg_vhost.conf by copying the example from \r
266                                 Open-ILS/examples/apache/eg_vhost.conf.</para><indexterm><primary>configuration files</primary><secondary>eg_vhost.conf</secondary></indexterm>\r
267                         </step>\r
268                         <step>\r
269                         <para>Update /etc/apache2/sites-available/eg.conf by copying the example from Open-ILS/\r
270                         examples/apache/eg.conf.</para><indexterm><primary>configuration files</primary><secondary>eg.conf</secondary></indexterm>\r
271                         </step>\r
272                         <step>\r
273                                 <para>Recover customizations you have made to the <application>Apache</application><indexterm><primary>Apache</primary></indexterm> \r
274                                 configuration files. For example, if you purchased an SSL certificate, you \r
275                                 will need to edit <filename>eg.conf</filename> to point to the appropriate SSL certificate files.</para>\r
276                                 <indexterm><primary>SSL</primary><secondary>certificates</secondary></indexterm>\r
277                         </step> \r
278                 </procedure>    \r
279         </section>\r
280         <section xml:id="testing_after_upgrade">\r
281                 <title>Restart Evergreen and Test</title>\r
282                 <procedure>\r
283                         <step>\r
284                                 <para>As the <systemitem class="username">opensrf</systemitem> user, start all \r
285                                 <application>Evergreen</application> and <application>OpenSRF</application> \r
286                                 services:</para>\r
287                                 <screen><userinput>osrf_ctl.sh -l -a start_all</userinput></screen>\r
288                         </step>\r
289                         <step>\r
290                                 <para>As the <systemitem class="username">opensrf</systemitem> user, run <command>autogen</command> to refresh the static \r
291                                 organizational data files:</para><indexterm><primary>autogen</primary></indexterm>\r
292 <screen><userinput>\r
293 cd /openils/bin\r
294 ./autogen.sh -c /openils/conf/opensrf_core.xml -u\r
295 </userinput></screen>\r
296                                         \r
297                         </step>\r
298                         <step>\r
299                                 <para>Start <command>srfsh</command> and try logging in  using your <application>Evergreen</application>\r
300                                 username and password:</para>\r
301 <screen>\r
302 <userinput>/openils/bin/srfsh</userinput>\r
303 <prompt>srfsh%</prompt> <userinput>login <option>username</option> <option>password</option></userinput>\r
304 </screen> \r
305                         </step> \r
306                         <step>\r
307                                 <para>Start the <application>Apache</application> web server.</para>\r
308                         </step>\r
309                 </procedure>\r
310                 <note>\r
311                         <para>If you encounter errors, refer to the <link linkend="troubleshooting">troubleshooting \r
312                         section</link> of this documentation for tips \r
313                         on finding solutions and seeking further assistance from the Evergreen community.</para>  \r
314                 </note>\r
315         </section>\r
316         <section xml:id="upgrading_Postgresqlto8.4">\r
317                 <title>Upgrading PostgreSQL from 8.2 to 8.4 (if required)</title>\r
318                 <para>Evergreen 1.6.1 supports PostgreSQL version 8.4 and it is recommended that you upgrade PostgreSQL when you upgrade Evergreen to 1.6.</para>\r
319                 <note><para>The order of the following steps is very important.</para></note><indexterm><primary>databases</primary><secondary>PostgreSQL</secondary></indexterm>\r
320                 <procedure>\r
321                         <step>\r
322                                 <para>As <systemitem class="username">opensrf</systemitem>, stop the evergreen and opensrf services:</para>\r
323                                 <screen><userinput>osrf_ctl.sh -l -a stop_all</userinput></screen>\r
324                         </step>                 \r
325                         <step>\r
326                                 <para><link linkend="backingup">Backup the Evergreen database data</link></para>\r
327                         </step>\r
328                         <step>\r
329                                 <para>Upgrade to Postgresql 8.4 by removing old version and installing Postgresql 8.4</para>\r
330                         </step>\r
331                         <step>                  \r
332                                 <para>Create an empty Evergreen database in postgresql 8.4 by issuing the following commands as the postgres user:</para>\r
333 <screen>\r
334 <userinput>\r
335 createdb -E UNICODE evergreen\r
336 createlang plperl   evergreen\r
337 createlang plperlu  evergreen\r
338 createlang plpgsql  evergreen\r
339 psql -f /usr/share/postgresql/8.4/contrib/tablefunc.sql evergreen\r
340 psql -f /usr/share/postgresql/8.4/contrib/tsearch2.sql evergreen\r
341 psql -f /usr/share/postgresql/8.4/contrib/pgxml.sql evergreen\r
342 </userinput>\r
343 </screen>               \r
344                         </step>\r
345                         <step>\r
346                                 <para>As the <systemitem class="username">postgres</systemitem> user on the PostgreSQL server, create a PostgreSQL user named <systemitem class="username">evergreen</systemitem> for the database cluster:</para>\r
347                                 <screen><userinput>createuser -P -s evergreen</userinput></screen>\r
348                                 <para>Enter the password for the new PostgreSQL superuser (<systemitem class="username">evergreen</systemitem>)</para>  \r
349                         </step>                 \r
350                         <step>\r
351                                 <para>Restore data from backup created in step 1.</para>\r
352                         </step>\r
353                         <step>\r
354                                 <para>To point tsearch2 to proper function names in 8.4, run the SQL script \r
355                                 <filename>/home/opensrf/Evergreen-ILS*/Open-ILS/src/sql/Pg/000.english.pg84.fts-config.sql</filename> using the <command>psql</command> command.</para>\r
356                                 <screen><userinput>cd /home/opensrf/Evergreen-ILS*</userinput></screen>\r
357                                 <screen><userinput>psql -f /Open-ILS/src/sql/Pg/000.english.pg84.fts-config.sql evergreen</userinput></screen>\r
358                         </step>\r
359                         <step>\r
360                                 <para><link linkend="upgraderestart">Restart Evergreen and OpenSRF services</link></para>\r
361                         </step>\r
362                         <step>\r
363                                 <para>For additional information regarding upgrading PostgreSQL, see the following documentation in PostgreSQL:</para>\r
364                                 <para><ulink url="http://www.postgresql.org/docs/8.4/static/install-upgrading.html" /></para>\r
365                                 <para><ulink url="http://www.postgresql.org/docs/8.4/interactive/textsearch-migration.html" /> \r
366                                 </para>\r
367                                 <para><ulink url="http://www.postgresql.org/docs/current/static/tsearch2.html#AEN102824" /></para>\r
368                         </step>\r
369                 </procedure>\r
370         </section>\r
371 </chapter>\r