Friday, December 31, 2010

DSpace 1.7.0 Upgrade Procedure

This blog covers the upgrade procedure from DSpace 1.6.2 to DSpace 1.7.0 under CentOS 5.5 Linux

i) Upgrade Apache-Maven

First upgrade apache-maven to the latest version available:

login as root

cd /usr/local/apache-maven/
lynx http://maven.apache.org/download.html
tar -xzvf apache-maven-3.0.1-bin.tar.gz

nano /etc/profile

Change the M2_HOME variable to point to the new installation of maven:
M2_HOME=/usr/local/apache-maven/apache-maven-3.0.1

Logout and log back in again.
Check the version of maven installed:

mvn --version
Apache Maven 3.0.1 (r1038046; 2010-11-23 10:58:32+0000)
Java version: 1.6.0_13
Java home: /usr/java/jdk1.6.0_13/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux" version: "2.6.18-92.el5xen" arch: "i386" Family: "unix"


ii) Upgrade PostgreSQL

It is necessary to upgrade PostgreSQL from the default version of 8.1.22 as provided with CentOS 5.5 to PostgreSQL version 8.4.5. This is because DSpace 1.7.0 will only work with versions of PostgreSQL above 8.2

The process used to successfully upgrade PostgreSQL is given below:

Log in as the root user.

Obtain the compat-postgresql-libs-4-1PGDG.rhel5.i686.rpm package. After quite a bit of searching I found it on the Web and downloaded it to our cd server, to ensure it was available in future.

I downloaded the compat-postgresql-libs-4-1PGDG.rhel5.i686.rpm package from the cd server onto our test server and installed it as follows:

lynx http://cd.bromley.ac.uk/compat-postgresql-libs-4-1PGDG.rhel5.i686.rpm
rpm -iv --replacefiles compat-postgresql-libs-4-1PGDG.rhel5.i686.rpm

If the above step is missed out removing the old version of postgresql will also strip out a lot of vital system packages!

Remove the old version of PostgreSQL and install the new version:

mkdir /pgbak
chown postgres:postgres /pgbak
su - postgres
pg_dumpall > /pgbak/backup.sql
exit
service postgresql stop
cp /var/lib/pgsql/data/pg_hba.conf /pgbak
mv /var/lib/pgsql/data /pgbak
yum remove postgresql*
yum install postgresql84-server
/etc/init.d/postgresql initdb
cp /pgbak/pg_hba.conf /var/lib/pgsql/data/pg_hba.conf
chkconfig --level 35 postgresql on
service postgresql start
su - postgres
psql -f /pgbak/backup.sql postgres
vacuumdb -a -z
exit

And just to make sure:

rpm -qa | grep postgresql
postgresql84-server-8.4.5-1.el5_5.1
postgresql84-libs-8.4.5-1.el5_5.1
compat-postgresql-libs-4-1PGDG.rhel5
postgresql84-8.4.5-1.el5_5.1


iii) Upgrade DSpace to version 1.7.0

Note that this upgrade process involves building DSpace from source because we use a custom hierarchical authentication module at Bromley.

su to user dspace
download the source code:
lynx http://sourceforge.net/projects/dspace/files/DSpace%20Stable/1.7.0/

unpack the source and change to the src directory:
tar -xzvf dspace-1.7.0-src-release.tar.gz
cd dspace-1.7.0-src-release

Stop Tomcat and the handle server:

su - root
service tomcat stop
service handle stop (n/a with standbyvle test server)
exit

Apply the Bromley College customisations to the following default files:

Replace the getSpecialGroups code with the customised version (this is
specifically for our installation)

nano /home/dspace/dspace-1.7.0-src-release/dspace-api/src/main/java/org/dspace/authenticate/LDAPHierarchicalAuthentication.java

Copy over the stylesheets and the Bromley College logo from version 1.6.2:

cp /home/dspace/dspace-1.6.2-src-release/dspace-jspui/dspace-jspui-webapp/src/main/webapp/styles.css.jsp
/home/dspace/dspace-1.7.0-src-release/dspace-jspui/dspace-jspui-webapp/src/main/webapp/styles.css.jsp

cp /home/dspace/dspace-1.6.2-src-release/dspace-jspui/dspace-jspui-webapp/src/main/webapp/layout/header-default.jsp
/home/dspace/dspace-1.7.0-src-release/dspace-jspui/dspace-jspui-webapp/src/main/webapp/layout/header-default.jsp

cp /home/dspace/dspace-1.6.2-src-release/dspace-jspui/dspace-jspui-webapp/src/main/webapp/layout/footer-default.jsp
/home/dspace/dspace-1.7.0-src-release/dspace-jspui/dspace-jspui-webapp/src/main/webapp/layout/footer-default.jsp

cp /home/dspace/dspace-1.6.2-src-release/dspace-jspui/dspace-jspui-webapp/src/main/webapp/home.jsp
/home/dspace/dspace-1.7.0-src-release/dspace-jspui/dspace-jspui-webapp/src/main/webapp/home.jsp

cp /home/dspace/dspace-1.6.2-src-release/dspace-jspui/dspace-jspui-webapp/src/main/webapp/image/logo.gif
/home/dspace/dspace-1.7.0-src-release/dspace-jspui/dspace-jspui-webapp/src/main/webapp/image/logo.gif

With reference to dspace.cfg for the 1.6.2 build, apply the Bromley
College customisations to the default dspace.cfg.

nano /home/dspace/dspace-1.7.0-src-release/dspace/config/dspace.cfg
cp /home/dspace/dspace-1.7.0-src-release/dspace/config/dspace.cfg /home/dspace/config/dspace.cfg

Build DSpace (note can take up to 15 minutes):

cd
cd dspace-1.7.0-src-release/dspace
mvn -U clean package

Update DSpace:

cd /home/dspace/dspace-1.7.0-src-release/dspace/target/dspace-1.7.0-build.dir
ant -Dconfig=/home/dspace/config/dspace.cfg update

Apply the database update script:

psql -U dspace -f /home/dspace/dspace-1.7.0-src-release/dspace/etc/postgres/database_schema_16-17.sql dspace

Generate the browse and search indexes:

/home/dspace/bin/dspace index-init

As the root user, start Tomcat and the handle server. Restart Apache and it works :)

su - root
service tomcat stop
service tomcat start
service handle start
service httpd restart
exit

Later I noticed that the thumbnail images weren't being displayed for newly uploaded image files. After a bit of investigation I found I'd omitted updating the dspace crontab with the latest settings. The settings now in use are shown below:

# Send out subscription e-mails at 01:00 every day
0 1 * * * /home/dspace/bin/dspace sub-daily
# Run the media filter at 02:00 every day
0 2 * * * /home/dspace/bin/dspace filter-media
# Run the checksum checker at 03:00
0 3 * * * /home/dspace/bin/dspace checker -lp
# Mail the results to the sysadmin at 04:00
0 4 * * * /home/dspace/bin/dspace dsrun org.dspace.checker.DailyReportEmailer -c
# Run stat analyses
0 1 * * * /home/dspace/bin/dspace stat-general
0 1 * * * /home/dspace/bin/dspace stat-monthly
0 2 * * * /home/dspace/bin/dspace stat-report-general
0 2 * * * /home/dspace/bin/dspace stat-report-monthly
20 4 * * * cd /home/dspace/vacuumdb && ( PGPASSWORD=`cat .pgpass` /usr/bin/vacuumdb --analyze -v -h 127.0.0.1 -U dspace dspace )