Difference between revisions of "Moving a repository"

From EPrints Documentation
Jump to: navigation, search
 
 
(15 intermediate revisions by 3 users not shown)
Line 1: Line 1:
'''Moving an archive from one machine to another is a three-step process:'''
+
[[Category:Management]]
 +
[[Category:Howto]]
  
# Transfer Mysql Database
+
This Howto has been written for EPrints 3.3. You may need to adjust the instructions for earlier versions.
# Transfer Eprints Configuration Files
+
# Reconfigure The Archive On the New Machine
+
  
'''Note: All of these steps are performed from the NEW machine.'''
+
You will require your database name, username and password, which can be found in:
  
--------
+
archives/[archiveid/cfg/cfg.d/database.pl
  
!!Transfer Mysql Database
+
The remainder of this page assumes your database name and repository are called 'myrepo' and your database username and password are 'myrepo'/'XYXY'.
  
Back up the Mysql database on the old machine.
+
==Migrate the MySQL database==
  
  shell> ssh 172.20.1.13    # you will be asked for the password
+
Dump the MySQL database for the repository:
  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).
+
$ mysqldump --user=myrepo --password=XYXY myrepo | gzip > myrepo.sql.gz
  
Note: The eprints indexer should not be running
+
Transfer the MySQL dump file to your new server e.g.:
  
  shell> sftp 172.20.1.13  #remote login to FTP
+
$ scp myrepo.sql.gz user@mynewserver:/tmp
  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
+
 
+
  
-------
+
Create the MySQL database on the new server and give it the appropriate permissions:
  
!!Transfer Eprints Configuration Files
+
$ mysql --user=root --password
 +
{ root password }
 +
mysql> create database myrepo;
 +
mysql> grant all privileges on myrepo.* to myrepo@localhost identified by 'XYXY';
  
Tar up files on old server (logged on as root).
+
Load the database:
  
  shell> ssh 172.20.1.13    # you will be asked for the password
+
$ gunzip -c /tmp/myrepo.sql.gz | mysql --user=myrepo --password=XYXY myrepo
  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 EPrints on the new server==
  
  shell> sftp 172.20.1.13
+
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.
  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:
+
==Migrate the repository==
  
  shell> chown eprints:eprints /opt/eprints2/archives/test1.xml
+
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
+
  
Log on or su to the eprints user and untar the file (be sure you are in the root (/) directory!):
+
$ tar -czf - -C /opt/eprints3/archives myrepo/ | ssh user@mynewserver "tar -xzf - -C /opt/eprints3/archives"
  
  shell> tar xvf /opt/eprints2/archives/test1.tar
+
Fix permissions and ownership:
  
---------
+
$ sudo chown -R eprints:eprints /opt/eprints3/
 +
$ sudo chmod -R 02775 /opt/eprints3/archives/
  
 +
===Migrate the repository's Apache configuration===
  
!!Reconfigure The Archive On the New Machine
+
If you have customised your Apache configuration you will need to transfer it:
  
Move to the eprints2 directory.
+
$ 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
  
  shell> cd /opt/eprints2.  #must be here to run following command
+
==Upgrading the repository==
  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!
+
'''Skip if you installed the same EPrints version'''
  
'''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.
+
$ ./bin/epadmin upgrade myrepo
  
'''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.
+
==Finishing==
  
  shell> bin/generate_static test1
+
Make sure your repository is OK:
  
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:
+
$ ./bin/epadmin test
  
  shell> mysql -p  #you will be prompted for the password
+
For example you may need to install extra dependencies.
  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:
+
Generate any missing Apache configuration:
  
  shell> bin/generate_abstracts test1
+
$ ./bin/generate_apacheconf
  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.
+
Restart Apache.
  
--------
+
'''Optional''' you may - especially when upgrading - need to clear out static files:
  
'''Contributor'''
+
  $ rm -rf /opt/eprints3/archives/myrepo/html/*
 
+
->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/*