Project

General

Profile

Update serveru z verze 2.1 na 2.2 (warden.cesnet.cz)

===========================================================
Plan prechodu produkcniho Warden serveru z verze 2.1 na 2.2
===========================================================

Ostry prechod na serveru warden.cesnet.cz
=========================================

- na produkcnim Warden serveru neni nutne resit pripravnou fazi, vse je tam jiz nachystane

1. Nainstalovat balicek warden-client-2.1 - Tom

    - warden client 2.2 nainstalovan do /opt/warden-client-2.1
    - zaregistrovat testovaci klienty:
        - /opt/warden-server-2.2/bin/registerSender.pl -n warden.cesnet.cz -r plesnik@ics.muni.cz -s migration22 -d "Test" -c 195.113.161.41/32
        - /opt/warden-server-2.2/bin/registerReceiver.pl -n warden.cesnet.cz -r plesnik@ics.muni.cz -t _any_ -o -c 195.113.161.41/32

2. Nainstalovat balicek warden-server-2.2. - Tom

    - warden 2.2 nainstalovan do /opt/warden-server-2.2

    ./install.sh -d /opt/warden-server-2.2 -k /etc/ssl/private/warden.cesnet.cz.key -c /etc/ssl/certs/warden.cesnet.cz.pem -a /etc/ssl/certs/tcs-ca-bundle.pem -e plesnik@ics.muni.cz

3. Nainstalovat balicek warden-client-2.1 - Tom

    - warden client 2.1 nainstalovan do /home/plesnik/warden-client

    ./install.sh -u plesnik -d /home/plesnik/ -k /etc/ssl/private/warden.cesnet.cz.key -c /etc/ssl/certs/warden.cesnet.cz.pem -a /etc/ssl/certs/tcs-ca-meta-personal-bundle.pem

3. Vytvořit nove tabulky pro verzi 2.2 - Tom

    - vytvoreni tabulky clients22

create table clients22 like clients;
insert into clients22 select * from clients;
ALTER TABLE clients22 ADD valid varchar(1) DEFAULT 't';

    - vytvoreni tabulky events22

SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
CREATE TABLE `events22` (
  `id` int(11) NOT NULL auto_increment,
  `detected` timestamp NOT NULL default '0000-00-00 00:00:00',
  `received` timestamp NOT NULL default '0000-00-00 00:00:00',
  `type` varchar(64) default NULL,
  `source_type` varchar(64) default NULL,
  `source` varchar(256) default NULL,
  `target_proto` varchar(16) default NULL,
  `target_port` int(2) unsigned default NULL,
  `attack_scale` int(4) unsigned default NULL,
  `note` text,
  `priority` int(1) unsigned default NULL,
  `timeout` int(2) unsigned default NULL,
  `valid` varchar(1) default 't',
  `client_id` int(11) default NULL,
  PRIMARY KEY  (`id`),
  KEY `idx_events_type_valid` (`type`,`valid`),
  KEY `idx_events_client_id` (`client_id`),
  KEY `idx_events_detected` (`detected`)
) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=latin1;
SET character_set_client = @saved_cs_client;

4. Vložit fiktivní zprávu do tabulky events 2.2 s ID vyšším, než nejvyšší současné. - Tom

    - zjistit aktualni nejvyssi ID z 'events' a pricist 100:

    select max(id) from events;
    insert into events22 (id) values ('66822807');

5. Upravit novy server 2.2 tak, aby nevracel zprávy čtenářům, ale přijímal je pouze od
   zapisovatelů.  - Tom

      - v /opt/warden-server-2.2/lib/Warden.pm zakomentovat radek 436 ("return @events;")

6. Vypnout server 2.1, nahodit upravený 2.2. - Tom   

    - zmenit port v /etc/apache2/sites-available/warden-2.2

    <VirtualHost _default_:4443> -> <VirtualHost _default_:443>

     - zmenit loadovane sites pro Apache

/usr/sbin/a2dissite warden-2.1 && /usr/sbin/a2ensite warden-2.2

       - stop Apache

        # /etc/init.d/apache2 stop

    - prejmenovani tabulek

    rename table clients to clients21;
    rename table events to events21;    
    rename table clients22 to clients;
    rename table events22 to events;

    - start Apache

        # /etc/init.d/apache2 start

7. Vytvorit zalozni kopii stavajici neupravene tabulky events 2.1 - Tom

       create table events21_bkp like events21;
    insert into events21_bkp select * from events21;

8. Převést schema tabulky events 2.1 na nový formát - Tom

    ALTER TABLE events21 ADD client_id int(11) DEFAULT NULL;
    UPDATE events21 e, clients21 c SET e.client_id = c.client_id WHERE e.hostname = c.hostname AND e.service = c.service;
    ALTER TABLE events21 DROP COLUMN hostname, DROP COLUMN service;
    UPDATE events21 SET valid = 'o' WHERE client_id is NULL;
    ALTER TABLE events21 ADD INDEX idx_events_type_valid (type,valid), ADD INDEX idx_events_client_id (client_id), ADD INDEX idx_events_detected (detected);

9. Dump tabulky events 2.1 s novym schematem - Tom

    mysqldump -u root -p --no-create-info --compact warden events21 > warden_events_21_compact.sql

10. Import dumpu tabulky events 2.1 s novym schematem do nove tabulky events 2.2. - Tom

    replace 'events21' 'events' -- warden_events_21_compact.sql
    mysql -u root -p warden < warden_events_21_compact.sql

    Kontrola prenesenych udalosti:

    mysql> select count(*) from events21;
    mysql> select count(*) from events where id < '66822807';

10. Smazat fiktivní zprávu v tabulce events 2.2 - Tom

    delete from events where id = '66822807';

11. Upravit server 2.2 na normální odesilaci funkci - Tom

    - v /opt/warden-server-2.2/lib/Warden.pm odkomentovat radek 436 ("return @events;")

12. Restart serveru 2.2 (čtenáři nyní dostanou všechny zprávy od svého posledního ID, cimz o nic
   nepřijdou, jen je dostanou o nějakou dobu později) - Tom

    # /etc/init.d/apache2 restart

13. Overit plnou funkcionalitu prijimaciho/odesilajiciho klienta 2.1 oproti
    Warden serveru 2.2 - Tom

    - pomoci testovacich klientu warden client 2.1

14. Smazat zalozni kopii zalozni databaze 2.1 - Tom

    drop table events21_bkp;