Difference between revisions of "Moving a repository"

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