From Technical Knowledge to IT Service Management

Archive for February 2007

Working with TAF – Transparent Application Fail-Over

I’ll try to write a tutorial on TAF, it seems to be very efficient but i’ve never really used it in real condition, just test. If you want to connect to TAFTEST, first it will try ton connect to NUXORA01, if something’s wrong it will try to connect to NUXORA02

DBPROD =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = NUXORA01)(PORT = 1521))
(CONNECT_DATA =
(SID = ORADB01)
)
)
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = NUXORA02)(PORT = 1521))
(CONNECT_DATA =
(SID = ORADB02)
)
)
)

Lister un répertoire de manière sélective

Le plus souvent on utilisera grep
$ ls -l backup/2007 | grep Feb

mais parfois il peut s’aveer plus utile d’utliser awk
$ ls -l backup/2007 | awk ‘$6 == “Feb”‘

Apache – Directive Listen

Au moment de son démarrage, Apache ecoute sur un port et à une IP definié dans http.conf
Par defaut il ecoute sur toutes les adresses IP et sur le port 80
Il est possible de créer des combinaisons IP/port. Cette possibilité peut s’averer utile dans le cadre de la definiton de Virtual hosts

Par exemple:

pour que Apache accepte les connexions sur les ports 80 et 8080:

Listen 80
Listen 8080

Pour que Apache accepte les connexions sur deux combinaisons IP/ports précises:

Listen 192.168.1.1:80
Listen 192.168.1.20:8080

create a directory tree

If you want to quick, don’t forget to use the ‘-p’ option

wrong way:
[john@host john]$ mkdir dev
[john@host john]$ cd dev
[john@host dev]$ mkdir first
[john@host dev]$ cd first
[john@host first]$ mkdir alpha
[john@host dev]$ mkdir second
[john@host dev]$ ll
[john@host dev]$ cd ..
[john@host john]$ mkdir prod
[john@host john]$ cd prod
[john@host prod]$ mkdir first
[john@host prod]$ mkdir second

good way:
[john@host john]$ mkdir -p dev/first/alpha

best way:
[john@host john]$ mkdir -p dev/{first/alpha,second},prod/{first,second}

How to extract files from a tar.gz

usually people do:
$ cd backup/2007/02
$ tar -zxvf data.tar.gz

you can simply do:
tar -zxvf -C backup/2007/02 data.tar.gz

or even do it better:
cd backup/2007/02 && tar -zxvf data.tar.gz

the best way:
cd backup/2007/02 || mkdir -p backup/2007/02 && tar -zxvf data.tar.gz

Definition d’un datasource sous jboss

Pour mettre en place, une datasource, il suffit de prendre un exemple ici /usr/local/jboss/docs/examples/jca/*-ds.xml

oracle-ds.xml par exemple

copier le /usr/local/jboss/server/default/deploy/ sous le nom fichier_de_datasource.xml

il faudra y faire reference dans les fichiers de config xml de l’appli qui sera deployer sous jboss:

Jboss_datasource_definition

Monter une iso

Pour monter directement un fichier iso sous linux:

mount -o loop -t iso9660 fichier.iso /mnt/iso

On a ainsi dans /mnt/iso le contenu de l’iso, ca evite de graver ;-)

Transfer easily a Mysql Dump between two servers

#Dump of the master database
$ mysqldump -u user -p db_test > /var/dump/db_test.dat

#Copy the dump file db_test.dat with scp to the slave mysql database
$ scp /var/dump/db_test.dat user@nuxora.com:/var/backup/db_test.dat

#Restore database on the slave server from the master server
$ ssh user@nuxora.com ‘mysql -u user -p db_test < /var/backup/db_test.dat’

it is quite simple and efficient.

But if you are a real geek you’d prefer this one:

#Dump from master database to slave one with ssh
$ mysqldump db_test | ssh user@nuxora.com mysql db_test