manuales:servidor_systemimager
Diferencias
Muestra las diferencias entre dos versiones de la página.
Próxima revisión | Revisión previa | ||
manuales:servidor_systemimager [2010/08/20 17:14] – creado cayu | manuales:servidor_systemimager [2015/01/09 19:01] (actual) – [Procedimiento de recuperación] cayu | ||
---|---|---|---|
Línea 10: | Línea 10: | ||
* Actualización periódica de las Imágenes de los servidores | * Actualización periódica de las Imágenes de los servidores | ||
* Recuperación de un equipo a partir de una Imagen, minimizando la intervención manual dentro del procedimiento | * Recuperación de un equipo a partir de una Imagen, minimizando la intervención manual dentro del procedimiento | ||
+ | * Que se pueda utilizar cualquier hardware disponible sin tener que perder tiempo generando configuraciones especiales | ||
+ | * Proceso lo mas desatendido posible | ||
===== Esquema de implementación ===== | ===== Esquema de implementación ===== | ||
Línea 43: | Línea 45: | ||
^ Image Client | Es cualquiera de los servidores a los cuales se les realiza backup en el imageserver | | ^ Image Client | Es cualquiera de los servidores a los cuales se les realiza backup en el imageserver | | ||
^ Imagen | Se hace referencia al nombre que tendrá la imagen almacena en el **Image Sever**, preferentemente debera ser el hostname del **Image Client** | | ^ Imagen | Se hace referencia al nombre que tendrá la imagen almacena en el **Image Sever**, preferentemente debera ser el hostname del **Image Client** | | ||
+ | |||
+ | ==== Servidor ==== | ||
Pasos para la implementación | Pasos para la implementación | ||
Línea 48: | Línea 52: | ||
* Se realizó una instalación base del sistema operativo | * Se realizó una instalación base del sistema operativo | ||
* Se descargaron los paquetes oficiales de System Imager | * Se descargaron los paquetes oficiales de System Imager | ||
- | + | * Se procedieron a instalar dichos paquetes de la siguiente manera< | |
- | < | + | # rpm -i perl-AppConfig-1.66-1.el5.rf.noarch.rpm |
# rpm -i systemconfigurator-2.2.11-1.noarch.rpm | # rpm -i systemconfigurator-2.2.11-1.noarch.rpm | ||
- | # perl-AppConfig-1.66-1.el5.rf.noarch.rpm | ||
# yum install perl-XML-Simple | # yum install perl-XML-Simple | ||
# rpm -i systemimager-common-4.1.6-1.noarch.rpm | # rpm -i systemimager-common-4.1.6-1.noarch.rpm | ||
Línea 59: | Línea 62: | ||
==== Nomenclatura y estructura de archivos y directorios | ==== Nomenclatura y estructura de archivos y directorios | ||
+ | |||
+ | * **/ | ||
+ | * //Script de inicio para el servicio de SystemImager, | ||
* **/ | * **/ | ||
Línea 65: | Línea 71: | ||
* **/ | * **/ | ||
* // | * // | ||
+ | |||
+ | * **/ | ||
+ | * // | ||
+ | |||
+ | * **/ | ||
+ | * //Scripts preparados para facilitar la puesta en marcha de los clientes// | ||
+ | * **activar_sync.sh**< | ||
+ | #!/bin/sh | ||
+ | # Prepara systemimager para obtener la imagen desde el servidor | ||
+ | |||
+ | if [ -z " | ||
+ | echo " | ||
+ | exit 1 | ||
+ | fi | ||
+ | |||
+ | si_prepareclient -server $1 -yes -kernel / | ||
+ | </ | ||
* **/ | * **/ | ||
* // | * // | ||
+ | |||
+ | * **/ | ||
+ | * //Archivo donde configuramos los archivos y directorios que no creemos necesarios almacenar de la Imagen//< | ||
+ | # SELinux stuff | ||
+ | /selinux/* | ||
+ | |||
+ | # eventfs in SuSE | ||
+ | / | ||
+ | |||
+ | # mounted media devices not reported by mount | ||
+ | /media/* | ||
+ | |||
+ | # NFS stuff | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | |||
+ | # LVM caches and backups (automatically re-created at the first boot) | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | |||
+ | # Skip persistent names associated to the network interfaces (Ubuntu). | ||
+ | /etc/iftab | ||
+ | / | ||
+ | / | ||
+ | |||
+ | # udev network persistent naming rules (Debian). | ||
+ | / | ||
+ | / | ||
+ | |||
+ | # remove blkid mappings: this allows to use images cloned from golden clients | ||
+ | # with raid, lvm, etc. block devices and image other clients that use different | ||
+ | # block device types (non-raid, non-lvm, etc.) or vice versa. | ||
+ | / | ||
+ | / | ||
+ | |||
+ | # Cache de Squid | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | |||
+ | # Cache de paquetes de Red Hat | ||
+ | / | ||
+ | |||
+ | # Otros | ||
+ | /tmp/* | ||
+ | / | ||
+ | / | ||
+ | </ | ||
+ | |||
+ | ==== Clientes ==== | ||
+ | |||
+ | * Si el equipo cliente es un Red Hat deberemos ejecutar lo siguiente< | ||
+ | # rpm -i perl-AppConfig-1.66-1.el5.rf.noarch.rpm | ||
+ | # rpm -i systemconfigurator-2.2.11-1.noarch.rpm | ||
+ | # yum install perl-XML-Simple | ||
+ | # rpm -i systemimager-common-4.1.6-1.noarch.rpm | ||
+ | # rpm -i systemimager-i386initrd_template-4.1.6-1.noarch.rpm | ||
+ | # rpm -i systemimager-client-4.1.6-1.noarch.rpm | ||
+ | </ | ||
+ | |||
+ | * En cambio si el equipo cliente es un Debian deberemos ejecutar lo siguiente< | ||
+ | # apt-get install systemconfigurator | ||
+ | # dpkg -i systemimager-initrd-template-i386_4.1.6_all.deb systemimager-common_4.1.6_all.deb systemimager-client_4.1.6_all.deb | ||
+ | </ | ||
+ | |||
+ | Para preparar el cliente System Imager | ||
+ | |||
+ | < | ||
+ | # si_prepareclient --server ip_systemimager | ||
+ | |||
+ | Welcome to the SystemImager si_prepareclient command. | ||
+ | the following files to prepare your golden client for having it's image | ||
+ | retrieved by the imageserver. | ||
+ | directory and fill it with information about your golden client. | ||
+ | files will be backed up with the .before_systemimager-4.1.6 extension. | ||
+ | |||
+ | / | ||
+ | This file defines the port numbers used by certain software on your system. | ||
+ | | ||
+ | |||
+ | / | ||
+ | This is a temporary configuration file that rsync needs on your golden client | ||
+ | in order to make your filesystem available to your SystemImager server. | ||
+ | |||
+ | inetd configuration: | ||
+ | | ||
+ | until it's image is retrieved by your SystemImager server. | ||
+ | | ||
+ | | ||
+ | an rsync daemon will be started using the temporary configuration file | ||
+ | | ||
+ | |||
+ | See " | ||
+ | |||
+ | Continue? (y/ | ||
+ | |||
+ | *********************************** WARNING *********************************** | ||
+ | This utility starts an rsync daemon that makes all of your files accessible | ||
+ | by anyone who can connect to the rsync port of this machine. | ||
+ | case until you reboot, or kill the 'rsync --daemon' | ||
+ | default, once you use si_getimage to retrieve this image on your imageserver, | ||
+ | these contents will become accessible to anyone who can connect to the rsync | ||
+ | port on your imageserver. | ||
+ | access to these files on the imageserver. | ||
+ | for a more secure method of making images available to clients. | ||
+ | *********************************** WARNING *********************************** | ||
+ | |||
+ | Continue? (y/ | ||
+ | |||
+ | Using " | ||
+ | /dev/sda | ||
+ | |||
+ | Using " | ||
+ | /dev/sdb | ||
+ | |||
+ | WARNING: cannot find the version of LVM or LVM version is not supported! | ||
+ | WARNING: Couldn' | ||
+ | >>> | ||
+ | >>> | ||
+ | skipping directory kernel | ||
+ | skipping directory misc | ||
+ | >>> | ||
+ | >> | ||
+ | >> | ||
+ | >> | ||
+ | >> | ||
+ | >> | ||
+ | >> | ||
+ | >> | ||
+ | >> | ||
+ | >> | ||
+ | >> | ||
+ | >> | ||
+ | >> | ||
+ | >> | ||
+ | >> | ||
+ | >> | ||
+ | >> | ||
+ | >> | ||
+ | >> | ||
+ | >> | ||
+ | >> | ||
+ | >> | ||
+ | >> | ||
+ | >> | ||
+ | >> | ||
+ | >> | ||
+ | >> | ||
+ | >> | ||
+ | >> | ||
+ | >> | ||
+ | >> | ||
+ | >> | ||
+ | >> | ||
+ | >> | ||
+ | >> | ||
+ | >> | ||
+ | >> | ||
+ | >> | ||
+ | >> | ||
+ | >> | ||
+ | >> | ||
+ | >> | ||
+ | >> | ||
+ | >> | ||
+ | >> | ||
+ | >> | ||
+ | >> | ||
+ | >> | ||
+ | >> | ||
+ | >> | ||
+ | >> | ||
+ | >> | ||
+ | >> | ||
+ | >> | ||
+ | >> | ||
+ | >> | ||
+ | >> | ||
+ | >> | ||
+ | >>> | ||
+ | >>> | ||
+ | >> | ||
+ | 170149 blocks | ||
+ | >> | ||
+ | -rw-r--r-- 1 root root 36636427 Aug 20 16:14 / | ||
+ | |||
+ | >> Evaluating initrd size to be added in the kernel boot options | ||
+ | >> (e.g. / | ||
+ | >> | ||
+ | |||
+ | >>> | ||
+ | >> | ||
+ | -rw-r--r-- 1 root root 2287264 Aug 20 16:14 / | ||
+ | |||
+ | Starting or re-starting rsync as a daemon..... | ||
+ | done! | ||
+ | |||
+ | This client is ready to have its image retrieved. | ||
+ | the " | ||
+ | |||
+ | Your client has been successfully prepared. | ||
+ | this Linux distribution) and an initrd.img (generated by the | ||
+ | initrd_template package) can be found in / | ||
+ | |||
+ | Automatically create configuration file for systemconfigurator: | ||
+ | >> / | ||
+ | </ | ||
+ | |||
+ | Luego de ejecutado este paso, dentro de nuestro equipo cliente nos quedara un proceso como este | ||
+ | |||
+ | < | ||
+ | 9782 ? Ss 0:00 rsync --daemon --port=873 --config=/ | ||
+ | </ | ||
+ | |||
+ | Donde en el archivo **/ | ||
+ | |||
+ | <code ini> | ||
+ | # | ||
+ | # " | ||
+ | # | ||
+ | # This file: / | ||
+ | # | ||
+ | list = yes | ||
+ | timeout = 900 | ||
+ | dont compress = *.gz *.tgz *.zip *.Z *.ZIP *.bz2 *.deb *.rpm *.dbf | ||
+ | uid = root | ||
+ | gid = root | ||
+ | hosts allow = ip_systemimager/ | ||
+ | log file = / | ||
+ | |||
+ | [root] | ||
+ | path = / | ||
+ | exclude = / | ||
+ | </ | ||
+ | |||
+ | Aclaración : este es un archivo temporal que se genera automáticamente y su nombre no es importante. | ||
+ | |||
+ | |||
+ | También hay que configurar en **/ | ||
+ | |||
+ | < | ||
+ | 02 1 * * * root / | ||
+ | </ | ||
+ | |||
+ | Para que re-ejecute el servicio cliente de ImageServer, | ||
+ | |||
+ | **/ | ||
+ | <code bash> | ||
+ | #!/bin/sh | ||
+ | # prepara systemimager para obtener la imagen desde el servidor | ||
+ | |||
+ | if [ -z " | ||
+ | echo " | ||
+ | exit 1 | ||
+ | fi | ||
+ | |||
+ | si_prepareclient -server $1 -yes -kernel / | ||
+ | </ | ||
+ | |||
+ | |||
+ | Dentro del servidor para capturar la Imagen del Cliente | ||
+ | |||
+ | < | ||
+ | # si_getimage --golden-client ip_cliente --image nombre_de_la_imagen | ||
+ | </ | ||
+ | |||
+ | |||
+ | ==== Monitoreo ==== | ||
+ | |||
+ | <code php> | ||
+ | # | ||
+ | <?php | ||
+ | $lista_imagenes = shell_exec(" | ||
+ | $lista_imagenes = preg_split("/ | ||
+ | $fecha_actual = date(' | ||
+ | foreach($lista_imagenes as $imagen) { | ||
+ | if(strlen($imagen)> | ||
+ | if(@!$i) { | ||
+ | $i=1; | ||
+ | } | ||
+ | $imagen = preg_split("/ | ||
+ | $imagenes[$i][' | ||
+ | $imagenes[$i][' | ||
+ | $imagenes[$i][' | ||
+ | if($imagen[4] == $fecha_actual) { | ||
+ | $imagenes[$i][' | ||
+ | } else { | ||
+ | $imagenes[$i][' | ||
+ | $critical=1; | ||
+ | } | ||
+ | $i++; | ||
+ | } | ||
+ | } | ||
+ | |||
+ | if(@$critical) { | ||
+ | $head = " | ||
+ | $exit = 2; | ||
+ | } else { | ||
+ | $head = "OK - Todas las imagenes actualizadas a la fecha\n"; | ||
+ | $exit = 0; | ||
+ | } | ||
+ | print $head; | ||
+ | foreach($imagenes as $imagen) { | ||
+ | if(strlen($imagen[' | ||
+ | $tab = " | ||
+ | } else { | ||
+ | $tab = " | ||
+ | } | ||
+ | if($imagen[' | ||
+ | print "OK - " | ||
+ | } else { | ||
+ | print " | ||
+ | } | ||
+ | } | ||
+ | exit($exit); | ||
+ | ?> | ||
+ | </ | ||
+ | |||
+ | |||
+ | ==== Procedimiento de recuperación ==== | ||
+ | |||
+ | Para recuperar la imagen almacenada en el servidor, para RH lo ideal es ejecutar el procedimiento kickstart, en este caso lo que hacemos es recuperar un script que ejecuta todos los comandos necesarios para generar una maquina virtual. | ||
+ | |||
+ | Dicho script obtiene el archivo / | ||
+ | |||
+ | |||
+ | ^Disco^Sistema de archivos^Tamaño^Punto de montaje^ | ||
+ | |hda4|swap|1000|swap| | ||
+ | |hda1|ext3|15119|/ | ||
+ | |hda2|ext3|3024|/ | ||
+ | |hda3|ext3|10080|/ | ||
+ | |||
+ | |||
+ | El Kickstart para esa maquina | ||
+ | |||
+ | < | ||
+ | install | ||
+ | url --url http:// | ||
+ | key 6c2e0645686a4a06 | ||
+ | |||
+ | lang es_ES.UTF-8 | ||
+ | keyboard es | ||
+ | |||
+ | #network --device eth0 --bootproto static --ip 10.1.2.142 --netmask 255.255.255.0 --gateway 10.1.2.1 --nameserver 10.1.1.3 --hostname proxy1-dom0 | ||
+ | network --bootproto=dhcp | ||
+ | |||
+ | rootpw --iscrypted $1$56iPwDr8$C59yfOfHe/ | ||
+ | firewall --disabled | ||
+ | authconfig --enableshadow --enablemd5 | ||
+ | selinux --disabled | ||
+ | timezone --utc America/ | ||
+ | bootloader --location=mbr --driveorder=cciss/ | ||
+ | |||
+ | clearpart --all --drives=sda | ||
+ | part /boot --fstype ext3 --size=100 --ondisk=sda | ||
+ | part pv.100000 --size=0 --grow --ondisk=sda | ||
+ | volgroup VolGroup00 --pesize=32768 pv.100000 | ||
+ | logvol / --fstype ext3 --name=LogVol00 --vgname=VolGroup00 --size=15184 | ||
+ | logvol swap --fstype swap --name=LogVol01 --vgname=VolGroup00 --size=596 --grow --maxsize=992 | ||
+ | |||
+ | %packages | ||
+ | @spanish-support | ||
+ | @virtualization | ||
+ | wget | ||
+ | rsync | ||
+ | kernel-xen | ||
+ | xen-libs | ||
+ | |||
+ | %post --interpreter=/ | ||
+ | |||
+ | echo " | ||
+ | </ | ||
+ | |||
+ | Y el archivo / | ||
+ | |||
+ | < | ||
+ | name = " | ||
+ | memory = " | ||
+ | disk = [ | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ] | ||
+ | |||
+ | vif = [ ' | ||
+ | |||
+ | uuid = " | ||
+ | bootloader="/ | ||
+ | vcpus=2 | ||
+ | on_reboot | ||
+ | on_crash | ||
+ | </ | ||
+ | |||
+ | |||
+ | **/ | ||
+ | |||
+ | En este archivo se especifican las opciones de booteo de la maquina física que contiene la maquina virtual, | ||
+ | |||
+ | En la linea | ||
+ | |||
+ | < | ||
+ | kernel / | ||
+ | </ | ||
+ | |||
+ | se especifica el kernel de Xen (dom0) y las opciones de booteo.\\ | ||
+ | Una vez que esta instalada la maquina virtual podemos aplicar la configuración de esta manera para que solo asigne 96M de RAM a la maquina fisica (dom0), | ||
+ | |||
+ | < | ||
+ | kernel / | ||
+ | </ | ||
+ | |||
+ | luego en la configuración de la maquina virtual de Xen le asignamos la memoria RAM sobrante, ya que esta depende cuanta memoria tenga la maquina que consigamos para esta tarea. | ||
+ | |||
+ | |||
+ | < | ||
+ | # | ||
+ | default=0 | ||
+ | timeout=5 | ||
+ | splashimage=(hd0, | ||
+ | hiddenmenu | ||
+ | title Red Hat Enterprise Linux Server (2.6.18-164.6.1.el5xen) | ||
+ | root (hd0,0) | ||
+ | kernel / | ||
+ | module / | ||
+ | module / | ||
+ | </ | ||
+ | |||
+ | Script de recuperacion de la VM | ||
+ | |||
+ | <code bash> | ||
+ | #!/bin/bash | ||
+ | #Script para automatizar el deploy de una vm | ||
+ | domU=$1 | ||
+ | imageserver=10.1.202.224 | ||
+ | |||
+ | function error() { | ||
+ | if [ $1 == 0 ]; then | ||
+ | echo ' | ||
+ | else | ||
+ | echo ' | ||
+ | exit 1 | ||
+ | fi | ||
+ | } | ||
+ | |||
+ | if [ $# != 1 ]; then | ||
+ | echo "Uso: $0 nombredelaimagen" | ||
+ | exit 1 | ||
+ | fi | ||
+ | |||
+ | |||
+ | if [ -e / | ||
+ | echo / | ||
+ | exit 1 | ||
+ | fi | ||
+ | |||
+ | if [ $(which xm) != 0 ]; then | ||
+ | xm=1 | ||
+ | else | ||
+ | echo "No encuentro xm, no voy a poder arrancar la VM." | ||
+ | xm=0 | ||
+ | fi | ||
+ | |||
+ | vgs=$(vgdisplay | grep "VG Name"| uniq | wc -l ) | ||
+ | vgs=`echo $vgs | sed " | ||
+ | |||
+ | case $vgs in | ||
+ | 0) | ||
+ | echo "No encontre ningun Volume Group, crear VG antes de correr este script" | ||
+ | exit 1 | ||
+ | ;; | ||
+ | 1) | ||
+ | vg=$(vgdisplay | grep "VG Name"| awk {' | ||
+ | echo " | ||
+ | ;; | ||
+ | # *) | ||
+ | # while [ -z $vg ]; do | ||
+ | # echo $(vgdisplay |grep "VG Name" | ||
+ | # read -p " | ||
+ | # grep $REPLY /tmp/vgs && vg=$REPLY | ||
+ | # done | ||
+ | # ;; | ||
+ | esac | ||
+ | |||
+ | echo -n " | ||
+ | rsync $imageserver:: | ||
+ | error $? | ||
+ | mkdir -p /mnt/$domU | ||
+ | |||
+ | #Calculo de espacio libre en el VG | ||
+ | vgfree=$(vgs VolGroup00 --noheadings --units M -o vg_free|cut -dM -f1|tr -d " "| cut -d, -f1) | ||
+ | vgfree=`echo " | ||
+ | |||
+ | for DISK in $( cat / | ||
+ | SIZE=$(echo $DISK | cut -d, -f3) | ||
+ | TSIZE=$(($TSIZE +SIZE)) | ||
+ | TSIZE=`echo " | ||
+ | done | ||
+ | |||
+ | echo "En total voy a necesitar $TSIZE Mb " | ||
+ | |||
+ | if [ $vgfree -lt $TSIZE | ||
+ | echo "No hay espacio suficiente en el VG seleccionado, | ||
+ | exit 1 | ||
+ | fi | ||
+ | |||
+ | for DISK in $(cat / | ||
+ | |||
+ | DEV=$(echo $DISK | cut -d, -f1) | ||
+ | FSTYPE=$(echo $DISK | cut -d, -f2) | ||
+ | SIZE=$(echo $DISK | cut -d, -f3) | ||
+ | MNT=$(echo $DISK | cut -d, -f4) | ||
+ | |||
+ | case $MNT in | ||
+ | '/' | ||
+ | lvname=$domU-root | ||
+ | ;; | ||
+ | ' | ||
+ | lvname=$domU-swap | ||
+ | ;; | ||
+ | *) | ||
+ | lvname=$domU-$( echo $MNT | sed s%/%-%g | /bin/cut -c1 --complement) | ||
+ | ;; | ||
+ | esac | ||
+ | |||
+ | echo -n " | ||
+ | if [ -e / | ||
+ | echo " | ||
+ | exit 1 | ||
+ | else | ||
+ | lvcreate -L$SIZE -n $lvname $vg > /dev/null | ||
+ | error $? | ||
+ | if [ $FSTYPE = " | ||
+ | mkswap / | ||
+ | else | ||
+ | echo -n " | ||
+ | mkfs.$FSTYPE -q / | ||
+ | error $? | ||
+ | mkdir -p / | ||
+ | echo -n " | ||
+ | mount / | ||
+ | error $? | ||
+ | fi | ||
+ | fi | ||
+ | |||
+ | done | ||
+ | |||
+ | echo -n " | ||
+ | rsync -vaSH --quiet | ||
+ | error $? | ||
+ | |||
+ | #for DISK in $(cat / | ||
+ | for DISK in $(cat / | ||
+ | FSTYPE=$(echo $DISK | cut -d, -f2) | ||
+ | MNT=$(echo $DISK | cut -d, -f4) | ||
+ | if [ $FSTYPE != ' | ||
+ | echo -n " | ||
+ | umount / | ||
+ | error $? | ||
+ | fi | ||
+ | done | ||
+ | |||
+ | echo -n " | ||
+ | rsync $imageserver:: | ||
+ | error $? | ||
+ | |||
+ | #if [ $xm == ' | ||
+ | # echo -n " | ||
+ | # xm create -c / | ||
+ | #fi | ||
+ | |||
+ | ln -s / | ||
+ | |||
+ | # Ajustando parametros de booteo del sistema | ||
+ | sed -e ' | ||
+ | </ | ||
+ | |||
+ | Lo único que tendremos que editar es el archivo de configuración de la maquina virtual de Xen, ajustandole el parametro memory acorde a los recursos prensentes en el hardware nuevo. | ||
+ | |||
+ | {{ : |
manuales/servidor_systemimager.txt · Última modificación: 2015/01/09 19:01 por cayu