Difference between revisions of "Moving a repository"

From EPrints Documentation
Jump to: navigation, search
 
(13 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
[[Category:Management]]
 
[[Category:Management]]
{{ep2}}
+
[[Category:Howto]]
  
'''Moving an archive from one machine to another is a three-step process:'''
+
This Howto has been written for EPrints 3.3. You may need to adjust the instructions for earlier versions.
  
# Transfer Mysql Database
+
You will require your database name, username and password, which can be found in:
# Transfer Eprints Configuration Files
 
# Reconfigure The Archive On the New Machine
 
  
'''Note: All of these steps are performed from the NEW machine.'''
+
archives/[archiveid/cfg/cfg.d/database.pl
  
--------
+
The remainder of this page assumes your database name and repository are called 'myrepo' and your database username and password are 'myrepo'/'XYXY'.
  
!!Transfer Mysql Database
+
==Migrate the MySQL database==
  
Back up the Mysql database on the old machine.
+
Dump the MySQL database for the repository:
  
  shell> ssh 172.20.1.13    # you will be asked for the password
+
$ mysqldump --user=myrepo --password=XYXY myrepo | gzip > myrepo.sql.gz
  shell> cd /root          #run the following command from root directory
 
  shell> mysqldump -p --quick test1 | gzip > test1.old.gz
 
  shell> exit              #leave the old server
 
  
Move the file to the new server and install it (do this as root).
+
Transfer the MySQL dump file to your new server e.g.:
  
Note: The eprints indexer should not be running
+
$ scp myrepo.sql.gz user@mynewserver:/tmp
  
  shell> sftp 172.20.1.13  #remote login to FTP
+
Create the MySQL database on the new server and give it the appropriate permissions:
  sftp > get /root/test1.old.gz /root
 
  sftp > quit
 
  shell> bin/indexer stop # just in case it is running
 
  shell> mysqladmin -p create test1
 
  shell> gunzip < /root/test1.old.gz | mysql -p test1
 
  shell> mysql -p
 
  mysql> show databases;    #test1 should be in the list
 
  mysql> quit
 
  shell> bin/indexer start
 
 
 
  
-------
+
$ mysql --user=root --password
 +
{ root password }
 +
mysql> create database myrepo;
 +
mysql> grant all privileges on myrepo.* to myrepo@localhost identified by 'XYXY';
  
!!Transfer Eprints Configuration Files
+
Load the database:
  
Tar up files on old server (logged on as root).
+
$ gunzip -c /tmp/myrepo.sql.gz | mysql --user=myrepo --password=XYXY myrepo
  
  shell> ssh 172.20.1.13    # you will be asked for the password
+
==Install EPrints on the new server==
  shell> cd /opt/eprints2/archives
 
  shell> tar cvf test1.tar /opt/eprints2/archives/test1
 
  shell> exit
 
  
Be sure you are logged onto the new server as root
+
Install the version of EPrints that you want to migrate to (e.g. you may want to upgrade). Take a note of the EPrints user and group, as you may need to re-assign the ownership of the transferred repository files.
  
  shell> sftp 172.20.1.13
+
==Migrate the repository==
  sftp > get /opt/eprints2/archives/test1.tar /opt/eprints2/archives
 
  sftp > get /opt/eprints2/archives/test1.xml /opt/eprints2/archives
 
  sftp > quit
 
  shell> cd /
 
  shell> ls -l /opt/eprints2/archives    #check the ownership of files
 
  
If the files test1.tar and test1.xml are not owned by eprints, do the following:
+
Use tar and ssh to transfer your repository to the new server ('''note''' the space in the source!):
  
  shell> chown eprints:eprints /opt/eprints2/archives/test1.xml
+
$ tar -czf - -C /opt/eprints3/archives myrepo/ | ssh user@mynewserver "tar -xzf - -C /opt/eprints3/archives"
  shell> chown eprints:eprints /opt/eprints2/archives/test1.xml
 
  
Log on or su to the eprints user and untar the file (be sure you are in the root (/) directory!):
+
Fix permissions and ownership:
  
  shell> tar xvf /opt/eprints2/archives/test1.tar
+
$ sudo chown -R eprints:eprints /opt/eprints3/
 +
$ sudo chmod -R 02775 /opt/eprints3/archives/
  
---------
+
===Migrate the repository's Apache configuration===
  
 +
If you have customised your Apache configuration you will need to transfer it:
  
!!Reconfigure The Archive On the New Machine
+
$ scp /opt/eprints3/cfg/apache/myrepo.conf user@mynewserver:/opt/eprints3/cfg/apache/myrepo.conf
 +
$ scp /opt/eprints3/cfg/apache_ssl/myrepo.conf user@mynewserver:/opt/eprints3/cfg/apache_ssl/myrepo.conf
  
Move to the eprints2 directory.
+
==Upgrading the repository==
  
  shell> cd /opt/eprints2.  #must be here to run following command
+
'''Skip if you installed the same EPrints version'''
  shell> bin/configure_archive test1
 
  
'''Note1:''' As you go through configure_archive, be very sure that if you change any of the settings from the default you know what you are doing and why!
+
$ ./bin/epadmin upgrade myrepo
  
'''Note2:''' If you are going to use the same URL on the new machine as you did on the old one, do not forget to update your local DNS server to point the URL to the new server.
+
==Finishing==
  
'''Note3:''' You will be asked if you want to create the database or archive files. You do not want to do that as they are already there.
+
Make sure your repository is OK:
  
  shell> bin/generate_static test1
+
$ ./bin/epadmin test
  
If you get an access denied error for the Mysql database, it is probably because the user has not been identified in Mysql. Add a new user (in this case, ''eprints'' is the new user) as follows:
+
For example you may need to install extra dependencies.
  
  shell> mysql -p  #you will be prompted for the password
+
Generate any missing Apache configuration:
  mysql> grant all on test1.* to eprints@localhost;
 
  mysql> set password for eprints@localhost = password('eprints4ever');
 
  mysql> quit
 
  
Once generate_static completes without errors, continue:
+
$ ./bin/generate_apacheconf
  
  shell> bin/generate_abstracts test1
+
Restart Apache.
  shell> bin/generate_views test1
 
  shell> bin/generate_apacheconf
 
  
Do not forget to stop and start the apache server so the above changes can be applied.
+
'''Optional''' you may - especially when upgrading - need to clear out static files:
  
--------
+
  $ rm -rf /opt/eprints3/archives/myrepo/html/*
 
 
'''Contributor'''
 
 
 
->Archie Trammell
 
->SIL International
 
->7500 W Camp Wisdom Road
 
->Dallas, TX USA
 
->archie_trammell@sil.org
 

Latest revision as of 15:55, 18 May 2012


This Howto has been written for EPrints 3.3. You may need to adjust the instructions for earlier versions.

You will require your database name, username and password, which can be found in:

archives/[archiveid/cfg/cfg.d/database.pl

The remainder of this page assumes your database name and repository are called 'myrepo' and your database username and password are 'myrepo'/'XYXY'.

Migrate the MySQL database

Dump the MySQL database for the repository:

$ mysqldump --user=myrepo --password=XYXY myrepo | gzip > myrepo.sql.gz

Transfer the MySQL dump file to your new server e.g.:

$ scp myrepo.sql.gz user@mynewserver:/tmp

Create the MySQL database on the new server and give it the appropriate permissions:

$ mysql --user=root --password
{ root password }
mysql> create database myrepo;
mysql> grant all privileges on myrepo.* to myrepo@localhost identified by 'XYXY';

Load the database:

$ gunzip -c /tmp/myrepo.sql.gz | mysql --user=myrepo --password=XYXY myrepo

Install EPrints on the new server

Install the version of EPrints that you want to migrate to (e.g. you may want to upgrade). Take a note of the EPrints user and group, as you may need to re-assign the ownership of the transferred repository files.

Migrate the repository

Use tar and ssh to transfer your repository to the new server (note the space in the source!):

$ tar -czf - -C /opt/eprints3/archives myrepo/ | ssh user@mynewserver "tar -xzf - -C /opt/eprints3/archives"

Fix permissions and ownership:

$ sudo chown -R eprints:eprints /opt/eprints3/
$ sudo chmod -R 02775 /opt/eprints3/archives/

Migrate the repository's Apache configuration

If you have customised your Apache configuration you will need to transfer it:

$ scp /opt/eprints3/cfg/apache/myrepo.conf user@mynewserver:/opt/eprints3/cfg/apache/myrepo.conf
$ scp /opt/eprints3/cfg/apache_ssl/myrepo.conf user@mynewserver:/opt/eprints3/cfg/apache_ssl/myrepo.conf

Upgrading the repository

Skip if you installed the same EPrints version

$ ./bin/epadmin upgrade myrepo

Finishing

Make sure your repository is OK:

$ ./bin/epadmin test

For example you may need to install extra dependencies.

Generate any missing Apache configuration:

$ ./bin/generate_apacheconf

Restart Apache.

Optional you may - especially when upgrading - need to clear out static files:

$ rm -rf /opt/eprints3/archives/myrepo/html/*