Storage Element (SE) name change

In case the FQDN of a SE changes, some entries need to be modified in the LFC databases.

Oracle LFC

In this section you describe how to the update with an Oracle LFC.


Case 1 : a few entries need to be updated (<100, 000 rows)

Presentation of the script

This is taken care of automatically by the PL/SQL script update_sfn_path.sql.

It is not yet included in any LFC RPM, but can be found in the gLite CVS repository :

  • under LCG-DM/script/change-se-name

This script is composed of two functions:

  • update_host_name (host_to_replace varchar2, host_name_replacing varchar2) which allows replacing the Cns_file_replica.host column = host_to_replace with host_name_replacing;
  • update_sfn (sfn_prefix_to_replace varchar2, sfn_prefix_replacing varchar2, host_cond varchar2 default NULL) which allows replacing the Cns_file_replica.sfn column starts with sfn_prefix_to_replace with sfn_prefix_replacing. An extra condition must be given is the host entry.


Installation of the script (to do only the first time)

As it is a PL/SQL script, it needs to be compiled on the DB. To do so, launch a sqlplus command line and connect to the DB. Then type, @<path_to_plsql_script>/update_sfn_path.sql.


Example of usage

Updating the host name
To change the host lxb5409.cern.ch to lxn1177.cern.ch, you need to do as follows:

sqlplus> set serveroutput on;
sqlplus> variable rescode varchar2(1000);
sqlplus> exec :rescode:=update_host_name('lxb5409.cern.ch','lxn1177.cern.ch');
sqlplus>print rescode;
The script should return rescode=SUCCESSFUL_UPDATE if the update has been done correctly.

Updating the sfn entries
There are two possible scenarii:
  • I want to replace all the sfns which start with srm://sc.cr.cnaf.infn.it/castor/cnaf.infn.it/grid/lcg/atlas/datafile with srm://storm-fe.cr.cnaf.infn.it/atlas/datafiles/. You need to use the script as follows:
    sqlplus> set serveroutput on;
    sqlplus> variable rescode varchar2(1000);
    sqlplus> exec :rescode:=update_sfn('srm://sc.cr.cnaf.infn.it/castor/cnaf.infn.it/grid/lcg/atlas/datafile/','srm://storm-fe.cr.cnaf.infn.it/atlas/datafiles/');
    sqlplus>print rescode;
    
    The script should return rescode=SUCCESSFUL_UPDATE if the update has been done correctly.

  • I want to replace all the sfns which start with srm://sc.cr.cnaf.infn.it/castor/cnaf.infn.it/grid/lcg/atlas/datafile with srm://storm-fe.cr.cnaf.infn.it/atlas/datafiles/ AND which are located on host='DCTAPE_00'

You need to use the script as follows:

sqlplus> set serveroutput on;
sqlplus> variable rescode varchar2(1000);
sqlplus> exec :rescode:=update_sfn('srm://sc.cr.cnaf.infn.it/castor/cnaf.infn.it/grid/lcg/atlas/datafile/','srm://storm-fe.cr.cnaf.infn.it/atlas/datafiles/','DCTAPE_00' );
sqlplus>print rescode;
The script should return rescode=SUCCESSFUL_UPDATE if the update has been done correctly.

Note: in the two previous scenarii, if you have already registered your new sfn, the script deletes the entry with the old sfn.

Case 2 : many rows need to be updated

In that case, you should schedule a downtime for your LFC. The LFC daemon should be stopped. To update the host name in the sfn field (we take the same example as in the previous section), do as follows (order is important).
>alter table Cns_file_replica drop constraint pk_repl_sfn;
>lock table cns_file_replica in exclusive mode nowait;
>delete from Cns_file_replica where sfn like 'srm://sc.cr.cnaf.infn.it/castor/cnaf.infn.it/grid/lcg/atlas/datafile/%' and replace(sfn,'srm://sc.cr.cnaf.infn.it/castor/cnaf.infn.it/grid/lcg/atlas/datafile/','srm://storm-fe.cr.cnaf.infn.it/atlas/datafiles/') in (select sfn from cns_file_replica);
>commit;
>lock table cns_file_replica in exclusive mode nowait;
>update cns_file_replica set sfn=replace(sfn,'srm://sc.cr.cnaf.infn.it/castor/cnaf.infn.it/grid/lcg/atlas/datafile/','srm://storm-fe.cr.cnaf.infn.it/atlas/datafiles/'),host='storm-fe.cr.cnaf.infn.it' where sfn like 'srm://sc.cr.cnaf.infn.it/castor/cnaf.infn.it/grid/lcg/atlas/datafile/%' ;
>commit;
>alter table cns_file_replica add constraint pk_repl_sfn primary key(sfn);
Note it may happen that the constraint does not exist, then you should do drop index repl_sfn and then recreate the constraint as primary key and not as an index. Then you can restart your LFC.

MySQL LFC

If you have a MySQL LFC, you can do as follows:

mysql> use cns_db
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed

mysql> update Cns_file_replica set sfn = replace(sfn,'sfn://se01.cern.ch/old/path/','srm://new-se01.cern.ch/my/new/path/');
Query OK, 38 rows affected (0.01 sec)
Rows matched: 2107  Changed: 38  Warnings: 0

mysql> update Cns_file_replica set host = replace(host,'se01.cern.ch','new-se01.cern.ch');
Query OK, 38 rows affected (0.01 sec)
Rows matched: 2107  Changed: 38  Warnings: 0

If you have millions of entries then you need to limit the number of rows to update via limit and retype the command unitl you see 0 rows affected

mysql> use cns_db
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed

mysql> update Cns_file_replica set sfn = replace(sfn,'sfn://se01.cern.ch/old/path/','srm://new-se01.cern.ch/my/new/path/') limit 1000;
Query OK, 1000 rows affected (0.01 sec)
Rows matched: 32000  Changed: 1000  Warnings: 0

mysql> update Cns_file_replica set sfn = replace(sfn,'sfn://se01.cern.ch/old/path/','srm://new-se01.cern.ch/my/new/path/') limit 1000;
Query OK, 1000 rows affected (0.01 sec)
Rows matched: 32000  Changed: 1000  Warnings: 0

mysql> update Cns_file_replica set sfn = replace(sfn,'sfn://se01.cern.ch/old/path/','srm://new-se01.cern.ch/my/new/path/') limit 1000;
Query OK, 0 rows affected (0.01 sec)
Rows matched: 32000  Changed: 1000  Warnings: 0


WARNING: if the new files have already been registered in the LFC, you will get a unique violated constraint, to circumvent it, you need to delete the old entries first and then run the update command.



Checks that you can perform afterwards

  • You can rerun the script and check that no entries have been left out. you should of course get that there are no entries to update
  • You can connect directly to the database and check that the HOST field of the main table returns the correct entry (same remark for the sfn column).
select count(*) from Cns_file_replica where HOST='oldSE.cern.ch';


Troubleshooting

In case the script complains about NLS_XXXX parameters, just unset all the NLS_XXXX environment variables before running the script :

unset NLS_LANG
unset ORA_NLS33
unset NLS_DATE_FORMAT


Help !

In case of problems, contact helpdesk@ggusNOSPAMPLEASE.org (remove the NOSPAM !) : your ROC will help you and contact the appropriate experts if needed.


-- SophieLemaitre - 06 Jul 2006

Edit | Attach | Watch | Print version | History: r8 < r7 < r6 < r5 < r4 | Backlinks | Raw View | WYSIWYG | More topic actions
Topic revision: r8 - 2008-12-19 - DavidSmith
 
    • Cern Search Icon Cern Search
    • TWiki Search Icon TWiki Search
    • Google Search Icon Google Search

    LCG All webs login

This site is powered by the TWiki collaboration platform Powered by PerlCopyright & 2008-2019 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback