wiki:SopUpdateBbmriApp

Version 35 (modified by antonak, 12 years ago) (diff)

--

How to update bbmri app

Quick tutorial

1) Copy the mysqldump from the live server to the test server
2) Deploy the new war file on the testserver
2.1) Check if there are errors according to changes in the model. There are 2 ways:

  • compare the mysql from the live and the testserver
  • check in the application if there are errors

2.2) If there are changes, make the migration script

Detailed tutorial

1. Export war & mysql file locally

1.1 Run the app on your molgenis-legacy workspace (using tomcat, not standalone)

  1. Export the war file
    1. In eclipse: File--> export --> Web --> war file
  2. The database is updated as follows: apply the mysql changes that you have made locally to the database on the server, so that you have the latest version of data for the server and the changes you want applied there. About the database changes you need to track them in a migration a file like one in the end of this document.

2. Deploy to test server

  1. As also listed here: http://www.molgenis.org/wiki/MolgenisServers the test server is at molgenis35(https://molgenis35.target.rug.nl/biobanks/) and the production server at molgenis14(https://catalogue.bbmri.nl/biobanks/) .
  2. First deploy at test server, notify david.van.enckevort AT nbic.nl. He will notify BBMRI office, they will review the changes and if everything is ok proceed to updating bbmri production server.
  3. Deploy at test server: molgenis35 (Take a look here also http://www.molgenis.org/wiki/SopCreateMolgenisVM#SopDeploymentForDevs ) :
    1. Ask credentials for molgenis35/molgenis14 from Pieter or Morris.

2.1 Create migration script according to data in live server

  1. If you know the exact changes of the database, compared to the old version in live server, then the migration script is consisted of the commands that synchornize the two versions.
  2. You do not know, you can can compare the mysql dump files between the live and the local version. This is easier if you dump only the schemas (not the data) .
    1. First ssh to molgenis14, create file & copy it
      1. ssh molgenis@…
      2. create a dump file: mysqldump --no-data, -d bbmri -u molgenis –pmolgenis > ~/databaseDumps/<date>bbmriDBlive.mysql
      3. LOCALLY : scp molgenis@…:./databaseDumps/<date>bbmriDB.mysql ./mysql<date>LIVEdata.mysql
    2. create a local dump file: mysqldump --no-data, -d bbmri -u molgenis –pmolgenis > ~/databaseDumps/<date>bbmriDBlocal.mysql
    3. diff <date>bbmriDBlive.mysql <date>bbmriDBlocal.mysql

2.2 Copy war file & migration script from your computer to test server

  1. Copy the war file and the mysql migration script from your computer to the server as follows:
    1. scp <filename>.war molgenis@…:./
    2. scp <migrationScriptFilename> molgenis@…:./

2.3 Copy live data from your computer to test server

  1. scp ./mysql<date>LIVEdata.mysql molgenis@…:./databaseDumps/mysql<date>LIVEdata.mysql

2.4 Deploy at test server

  1. Ssh to the server:
    • ssh molgenis@molgenis35.target.rug.nl
    • You are now at /srv/molgenis/ where your files where copied.

2.5 Backup Database

  1. mysqldump bbmri -u molgenis –pmolgenis > ~/databaseDumps/<date>bbmriDB.mysql
  2. Check the dumbed file if it is not just an error file …

2.6 Insert the data from live server to test server

  • Insert live data (copied from your computer previously)
    • mysql -u molgenis -pmolgenis bbmri < ./databaseDumps/mysql<date>LIVEdata.mysql

2.7 Apply migration steps:

  • mysql -u molgenis –pmolgenis
  • use bbmri
  • <apply mysql commands>

2.8 Backup & replace the war file on server:

  • The war file is in /usr/share/tomcat6/webapps/biobanks.war
  • BACKUP : cp /usr/share/tomcat6/webapps/biobanks.war ~/warFiles/<date_bbmri.war>
  • Delete the old *.war (Do NOT stop tomcat; leave it running): rm /usr/share/tomcat6/webapps/biobanks.war
  • Wait a few seconds; Tomcat will notice the *.war is gone and then it will remove the unzipped folder.
  • Copy the the new *.war to the webapps dir; Tomcat will detect the new *.war and unzip it.
    • cp <filename>.war /usr/share/tomcat6/webapps/biobanks.war
  • You can check the tomcat & mysql service with:
    • sudo service tomcat6 status
    • sudo service mysqld status

3. Check your deployment

4. Inform bbmri office

  • Email David david.van.enckevort AT nbic.nl. and wait till they test the server. When that step is done you can deploy to live server.

5. Deploy at live server

Copy war & db from test to live

  • From your computer:
    • scp molgenis@…:./usr/share/tomcat6/webapps/biobanks.war biobanksLatestTest.war
    • scp molgenis@…:../databaseDumps/mysql<date>LIVEdata.mysql LIVEdataSynchonized.mysql
  • To live server:
    • scp biobanksLatestTest.war molgenis@…:./biobanksLatestTest.war
    • scp LIVEdataSynchonized.mysql molgenis@…:../databaseDumps/LIVEdataSynchonized.mysql
  • in live server :
    • backup your database & application before moving the new files:
      • cp /usr/share/tomcat6/webapps/biobanks.war ~/warFiles/biobanks<date>.war
      • mysqldump bbmri -u molgenis –pmolgenis > ~/databaseDumps/<date>bbmriDB.mysql
    • Replace the war file on server as in step 2.8
  • check your deployment at https://catalogue.bbmri.nl/biobanks/molgenis.do

Appendix

   '''How to update bbmri app'''

Quick tutorial

1) Copy the mysqldump from the live server to the test server
2) Deploy the new war file on the testserver
2.1) Check if there are errors according to changes in the model. There are 2 ways:

  • compare the mysql from the live and the testserver
  • check in the application if there are errors

2.2) If there are changes, make the migration script

Detailed tutorial

1. Export war & mysql file locally

1.1 Run the app on your molgenis-legacy workspace (using tomcat, not standalone)

  1. Export the war file
    1. In eclipse: File--> export --> Web --> war file
  2. The database is updated as follows: apply the mysql changes that you have made locally to the database on the server, so that you have the latest version of data for the server and the changes you want applied there. About the database changes you need to track them in a migration a file like one in the end of this document.

2. Deploy to test server

  1. As also listed here: http://www.molgenis.org/wiki/MolgenisServers the test server is at molgenis35(https://molgenis35.target.rug.nl/biobanks/) and the production server at molgenis14(https://catalogue.bbmri.nl/biobanks/) .
  2. First deploy at test server, notify david.van.enckevort AT nbic.nl. He will notify BBMRI office, they will review the changes and if everything is ok proceed to updating bbmri production server.
  3. Deploy at test server: molgenis35 (Take a look here also http://www.molgenis.org/wiki/SopCreateMolgenisVM#SopDeploymentForDevs ) :
    1. Ask credentials for molgenis35/molgenis14 from Pieter or Morris.

2.1 Create migration script according to data in live server

  1. If you know the exact changes of the database, compared to the old version in live server, then the migration script is consisted of the commands that synchornize the two versions.
  2. You do not know, you can can compare the mysql dump files between the live and the local version. This is easier if you dump only the schemas (not the data) .
    1. First ssh to molgenis14, create file & copy it
      1. ssh molgenis@…
      2. create a dump file: mysqldump --no-data, -d bbmri -u molgenis –pmolgenis > ~/databaseDumps/<date>bbmriDBlive.mysql
      3. LOCALLY : scp molgenis@…:./databaseDumps/<date>bbmriDB.mysql ./mysql<date>LIVEdata.mysql
    2. create a local dump file: mysqldump --no-data, -d bbmri -u molgenis –pmolgenis > ~/databaseDumps/<date>bbmriDBlocal.mysql
    3. diff <date>bbmriDBlive.mysql <date>bbmriDBlocal.mysql

2.2 Copy war file & migration script from your computer to test server

  1. Copy the war file and the mysql migration script from your computer to the server as follows:
    1. scp <filename>.war molgenis@…:./
    2. scp <migrationScriptFilename> molgenis@…:./

2.3 Copy live data from your computer to test server

  1. scp ./mysql<date>LIVEdata.mysql molgenis@…:./databaseDumps/mysql<date>LIVEdata.mysql

2.4 Deploy at test server

  1. Ssh to the server:
    • ssh molgenis@…
    • You are now at /srv/molgenis/ where your files where copied.

2.5 Backup Database

  1. mysqldump bbmri -u molgenis –pmolgenis > ~/databaseDumps/<date>bbmriDB.mysql
  2. Check the dumbed file if it is not just an error file …

2.6 Insert the data from live server to test server

  • Insert live data (copied from your computer previously)
    • mysql -u molgenis -pmolgenis bbmri < ./databaseDumps/mysql<date>LIVEdata.mysql

2.7 Apply migration steps:

  • mysql -u molgenis –pmolgenis
  • use bbmri
  • <apply mysql commands>

2.8 Backup & replace the war file on server:

  • The war file is in /usr/share/tomcat6/webapps/biobanks.war
  • BACKUP : cp /usr/share/tomcat6/webapps/biobanks.war ~/warFiles/<date_bbmri.war>
  • Delete the old *.war (Do NOT stop tomcat; leave it running): rm /usr/share/tomcat6/webapps/biobanks.war
  • Wait a few seconds; Tomcat will notice the *.war is gone and then it will remove the unzipped folder.
  • Copy the the new *.war to the webapps dir; Tomcat will detect the new *.war and unzip it.
    • cp <filename>.war /usr/share/tomcat6/webapps/biobanks.war
  • You can check the tomcat & mysql service with:
    • sudo service tomcat6 status
    • sudo service mysqld status

3. Check your deployment

4. Inform bbmri office

  • Email David david.van.enckevort AT nbic.nl. and wait till they test the server. When that step is done you can deploy to live server.

5. Deploy at live server

Copy war & db from test to live

  • From your computer:
    • scp molgenis@…:./usr/share/tomcat6/webapps/biobanks.war biobanksLatestTest.war
    • scp molgenis@…:../databaseDumps/mysql<date>LIVEdata.mysql LIVEdataSynchonized.mysql
  • To live server:
    • scp biobanksLatestTest.war molgenis@…:./biobanksLatestTest.war
    • scp LIVEdataSynchonized.mysql molgenis@…:../databaseDumps/LIVEdataSynchonized.mysql
  • in live server :
    • backup your database & application before moving the new files:
      • cp /usr/share/tomcat6/webapps/biobanks.war ~/warFiles/biobanks<date>.war
      • mysqldump bbmri -u molgenis –pmolgenis > ~/databaseDumps/<date>bbmriDB.mysql
    • Replace the war file on server as in step 2.8
  • check your deployment at https://catalogue.bbmri.nl/biobanks/molgenis.do

Appendix

 CREATE TABLE !`BiobankSubCategory`  (

  !`id`  int(11) NOT NULL,

  PRIMARY KEY (!`id` ),

  CONSTRAINT !`biobanksubcategory_ibfk_1`  FOREIGN KEY (!`id` ) REFERENCES !`OntologyTerm`  (!`id` ) ON DELETE CASCADE

  ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

  INSERT INTO !BiobankSubCategory  (id)

  SELECT id

  FROM !BiobankCategory

  WHERE id  NOT IN ("281", "284", "285") ;

  CREATE TABLE !BiobankPersonRole  (

  id INTEGER NOT NULL

  , PRIMARY KEY(id)

  );

  alter table !OntologyTerm  modify   column !__ Type enum('!OntologyTerm ','!PersonRole ','Species','!AlternateId ','!BiobankCategory ','!BiobankTopic ','!BiobankDataType ', '!BiobankSubCategory ','!BiobankPersonRole ');

  ALTER TABLE Biobank DROP FOREIGN KEY biobank_ibfk_5;

  ALTER TABLE !BiobankSubCategory  ADD FOREIGN KEY (id) REFERENCES !OntologyTerm  (id) ON DELETE CASCADE;

  ALTER TABLE !`BiobankSubCategory`

  ADD CONSTRAINT !`biobank_ibfk_5`

  FOREIGN KEY (!`id` ) REFERENCES !OntologyTerm  (id) ON DELETE CASCADE; this exists already from his creation)

  ALTER TABLE Biobank ADD FOREIGN KEY (!SubCategory ) REFERENCES !BiobankSubCategory  (id) ON DELETE RESTRICT;

  ALTER TABLE !`Biobank`

  ADD CONSTRAINT !`biobank_ibfk_885`

  FOREIGN KEY (!`SubCategory` ) REFERENCES !BiobankSubCategory  (id)  ON DELETE CASCADE;

  DELETE FROM !BiobankCategory

  WHERE id  NOT IN ("281", "284", "285") ;

  ALTER TABLE !BiobankPersonRole  ADD FOREIGN KEY (id) REFERENCES !PersonRole  (id) ON DELETE CASCADE;

  ALTER TABLE !`BiobankPersonRole`

  ADD CONSTRAINT !`BiobankPersonRole_ibfk_33`

  FOREIGN KEY (!`id` ) REFERENCES !PersonRole  (id)  ON DELETE CASCADE;

  UPDATE !OntologyTerm   SET !__ Type="!BiobankSubCategory " WHERE id='282';

  UPDATE !OntologyTerm   SET !__ Type="!BiobankSubCategory " WHERE id='283';

  UPDATE !OntologyTerm   SET !__ Type="!BiobankSubCategory " WHERE id='286';

  UPDATE !OntologyTerm   SET !__ Type="!BiobankSubCategory " WHERE id='287';

  UPDATE !OntologyTerm   SET !__ Type="!BiobankSubCategory " WHERE id='288';

  UPDATE !OntologyTerm   SET !__ Type="!BiobankSubCategory " WHERE id='289';

  UPDATE !OntologyTerm   SET !__ Type="!BiobankSubCategory " WHERE id='290';

  UPDATE !OntologyTerm   SET !__ Type="!BiobankSubCategory " WHERE id='291';

  UPDATE !OntologyTerm   SET !__ Type="!BiobankSubCategory " WHERE id='292';

  UPDATE !OntologyTerm   SET !__ Type="!BiobankSubCategory " WHERE id='293';

  UPDATE !OntologyTerm   SET !__ Type="!BiobankSubCategory " WHERE id='295';

  UPDATE !OntologyTerm   SET !__ Type="!BiobankSubCategory " WHERE id='296';

  UPDATE !OntologyTerm   SET !__ Type="!BiobankSubCategory " WHERE id='297';

  UPDATE !OntologyTerm   SET !__ Type="!BiobankSubCategory " WHERE id='298';

  UPDATE !OntologyTerm   SET !__ Type="!BiobankSubCategory " WHERE id='564';

  UPDATE !OntologyTerm   SET !__ Type="!BiobankSubCategory " WHERE id='299';

  UPDATE !OntologyTerm   SET !__ Type="!BiobankSubCategory " WHERE id='294';

  select * from !OntologyTerm  where name="Software Engineer";

  delete from !OntologyTerm  where id=561;

  select * from !BiobankPersonRole ;

  insert into !BiobankPersonRole  values(561);

  select * from !OntologyTerm  where name="coordinator";

  delete from !OntologyTerm  where id=593;

  select * from !BiobankPersonRole ;

  insert into !BiobankPersonRole  values(277);

  select * from !OntologyTerm  where name="postdoc";

  delete from !OntologyTerm  where id=594;

  select * from !BiobankPersonRole ;

  insert into !BiobankPersonRole  values(278);

  select * from !OntologyTerm  where name="administrator";

  delete from !OntologyTerm  where id=595;

  select * from !BiobankPersonRole ;

  insert into !BiobankPersonRole  values(279);

  select * from !OntologyTerm  where name="IT responsible";

  delete from !OntologyTerm  where id=596;

  select * from !BiobankPersonRole ;

  insert into !BiobankPersonRole  values(280);

  //how to make values of Person Role appear in ui , you have to delete some old from DB :

  create a new Coordinator Role in the ui and remember the id 591 (select * from !PersonRole ; --> the latest one, or check from ui )

  correct the Person table with t he new entry(that is not show in the ui) :

  update Person set Roles=591 where Roles=277

  delete the old one :

  delete from !PersonRole  where id=277;

  delete from  !BiobankPersonRole   where id=277;

  delete from !OntologyTerm   where id=277;

  repeat the same step for all of them

  COMMIT;

  ===========================================================

  !SubCategory

  biobank_ibfk_1

  CONSTRAINT !`biobank_ibfk_5`  FOREIGN KEY (!`SubCategory` ) REFERENCES !`BiobankSubCategory`  (!`id` )

  CONSTRAINT !`biobank_ibfk_5`  FOREIGN KEY (!`SubCategory` ) REFERENCES !`BiobankSubCategory`  (!`id` ),

  CREATE TABLE !BiobankPersonRole  (

  id INTEGER NOT NULL

  , PRIMARY KEY(id)

  );

  ALTER TABLE !BiobankPersonRole  ADD FOREIGN KEY (id) REFERENCES !PersonRole  (id) ON DELETE CASCADE;

  alter table !OntologyTerm  modify   column !__ Type enum('!OntologyTerm ','!PersonRole ','Species','!AlternateId ','!BiobankCategory ','!BiobankTopic ','!BiobankDataType ', '!BiobankSubCategory ','!BiobankPersonRole ');

  UPDATE !OntologyTerm   SET !__ Type="!BiobankSubCategory " WHERE id='282';

  UPDATE !OntologyTerm   SET !__ Type="!BiobankSubCategory " WHERE id='283';

  UPDATE !OntologyTerm   SET !__ Type="!BiobankSubCategory " WHERE id='286';

  UPDATE !OntologyTerm   SET !__ Type="!BiobankSubCategory " WHERE id='287';

  UPDATE !OntologyTerm   SET !__ Type="!BiobankSubCategory " WHERE id='288';

  UPDATE !OntologyTerm   SET !__ Type="!BiobankSubCategory " WHERE id='289';

  UPDATE !OntologyTerm   SET !__ Type="!BiobankSubCategory " WHERE id='290';

  UPDATE !OntologyTerm   SET !__ Type="!BiobankSubCategory " WHERE id='291';

  UPDATE !OntologyTerm   SET !__ Type="!BiobankSubCategory " WHERE id='292';

  UPDATE !OntologyTerm   SET !__ Type="!BiobankSubCategory " WHERE id='293';

  UPDATE !OntologyTerm   SET !__ Type="!BiobankSubCategory " WHERE id='295';

  UPDATE !OntologyTerm   SET !__ Type="!BiobankSubCategory " WHERE id='296';

  UPDATE !OntologyTerm   SET !__ Type="!BiobankSubCategory " WHERE id='297';

  UPDATE !OntologyTerm   SET !__ Type="!BiobankSubCategory " WHERE id='298';

  UPDATE !OntologyTerm   SET !__ Type="!BiobankSubCategory " WHERE id='564';

  /*below we resolve the problem of duplicate entries in ontology term for !PersonRole */

  select * from !OntologyTerm  where name="Software Engineer";

  delete from !OntologyTerm  where id=561;

  select * from !BiobankPersonRole ;

  insert into !BiobankPersonRole  values(561);

  select * from !OntologyTerm  where name="coordinator";

  delete from !OntologyTerm  where id=593;

  select * from !BiobankPersonRole ;

  insert into !BiobankPersonRole  values(277);

  select * from !OntologyTerm  where name="postdoc";

  delete from !OntologyTerm  where id=594;

  select * from !BiobankPersonRole ;

  insert into !BiobankPersonRole  values(278);

  select * from !OntologyTerm  where name="administrator";

  delete from !OntologyTerm  where id=595;

  select * from !BiobankPersonRole ;

  insert into !BiobankPersonRole  values(279);

  select * from !OntologyTerm  where name="IT responsible";

  delete from !OntologyTerm  where id=596;

  select * from !BiobankPersonRole ;

  insert into !BiobankPersonRole  values(280);

  COMMIT;