lunes, 7 de enero de 2019

Agregar lun a rhel cluster 5


Verificamos las wwn online y pedimos la lun.

#   cat /sys/class/fc_host/*/port_name
0x21000024ff219f38
0x21000024ff219f39
0x21000024ff2194ac
0x21000024ff2194ad
#   cat /sys/class/fc_host/*/port_state
Online
Online
Linkdown
Linkdown

Una vez que nos asignaron las luns rescaneamos, identificamos la lun y la editamos el /etc/multipath.conf para modificarle el nombre. (TODO ESTO EN LOS DOS NODOS)

# rescan-scsi-bus.sh
# multipath -F; multipath -v2
create: mpath27 (360050768018285d270000000000005b5)  IBM,2145
[size=200G][features=0][hwhandler=0][n/a]
\_ round-robin 0 [prio=50][undef]
 \_ 1:0:1:26 sdcm 69:160 [undef][ready]
 \_ 2:0:1:26 sdco 69:192 [undef][ready]
\_ round-robin 0 [prio=10][undef]
 \_ 1:0:0:26 sdcl 69:144 [undef][ready]
 \_ 2:0:0:26 sdcn 69:176 [undef][ready]
 
# vi /etc/multipath.conf
 ### Agregamos algo como esto
         multipath {
               wwid                    360050768018285d270000000000005b5
               alias                   mp_storage_u11
        }
        
# multipath -F; multipath -v2       

Con el disco reconocido por el sistema operativo procedemos a formatearlo, agregarlo a lvm.
# fdisk /dev/mapper/mp_storage_u11
[ ponemos todas las opciones que van  n - p - 1 - enter - enter 
  t 8e w ]
  
# pvcreate /dev/mapper/mp_storage_u11p1
# vgcreate vgstorage_u11 /dev/mapper/mp_storage_u11p1
# lvcreate -n lv_u11 -l 100%FREE vgstorage_u11 
Aca faltaria crear el fs y agregarlo al cluster el tema es que el tipo de fs es gfs2 asi que hay que darle un vueltita de rosca mas.

Con gfs2.tool buscamos la etiquieta de locktable que tienen los fs montados y la cantidad de journals (deberia ser un journal por nodo que lo monta)

# gfs2_tool list
253:52 gatclu:u10
253:58 gatclu:utsm
253:57 gatclu:uarchive
253:60 gatclu:gfs2
253:53 gatclu:u08
253:51 gatclu:u07
253:50 gatclu:u06
253:48 gatclu:gfs2-u05
253:61 gatclu:u04
253:59 gatclu:u03
253:56 gatclu:u02
253:55 gatclu:u01
253:54 gatclu:u00

# gfs2_tool journals /u09
journal1 - 128MB
journal0 - 128MB
2 journal(s) found.

Creamos entonces los fs y los agregamos al cluster.

mkfs.gfs2  -p lock_dlm -t gatclu:u11 -j2 /dev/vgstorage_u11/lv_u11
mount -t gfs2 /dev/vgstorage_u11/lv_u11 /u11

vi /etc/cluster/cluster.conf 
### Cambiar la config_version en la seccion cluster
<cluster config_version="48" name="gatclu">
### Agrego en la seccion resources TENER en cuenta el fsid que no se repita
<clusterfs device="/dev/vgstorage_u11/lv_u11" force_unmount="1" fsid="58377" 
fstype="gfs2" mountpoint="/u11" name="gfs2-u11" options="noatime,defaults"/>
### Agrego en la seccion service
<clusterfs ref="gfs2-u11">
</clusterfs>
Una vez revisado todo updateo la configuracion del cluster:

ccs_tool update /etc/cluster/cluster.conf

viernes, 4 de enero de 2019

Instalando wordpress en rhel con docker


Partimos de dos servidores con rhel 7, con docker instalado.
El servidor stlinux tiene salida a internet a traves de proxy y el dlstlinux1 no sale a ningun lado pero se publica el blog ahi y todos pueden acceder.

Los pasos a seguir eran bajar las imagenes de docker al plstlinux, exportarlas, copiarlas al dlstlinux1 y finalmente importarlas. Este fue el procedimiento:

Agregar el proxy al servicio docker en plstlinux.

vi /etc/systemd/system/docker.service.d/https-proxy.conf
 [Service]
 Environment="HTTPS_PROXY=https://DOMINIO\usuario:Mipassword2019@proxy:8080"

Reiniciar la confi de sysctl y el demonio de docker y chequear la configuracion recien editada.

systemctl daemon-reload
systemctl restart docker
systemctl show --property=Environment docker

Bajar las imagenes de docker y exportarlas a archivo.

docker pull mariadb:latest
docker pull wordpress:latest
docker save -o mariadb.docker mariadb
docker save -o wordpress.docker wordpress

Ahora las copio a dlstlinux1 las importo y sigo el procedimiento de instalacion que haya sacado de internet.

docker load -i mariadb.docker
docker load -i wordpress.docker 

docker run -e MYSQL_ROOT_PASSWORD=coneja -e MYSQL_DATABASE=wordpress --name wordpressdb \
-v "/docker/madb":/var/lib/mysql -d mariadb
docker run -e WORDPRESS_DB_PASSWORD=coneja --name wordpress --link wordpressdb:mysql \
 -p 8001:80 -v "/docker/wp":/var/www/html -d wordpress

Listo ya tengo instalado un mysql con un wordpress en el puerto 8001 del equipo.

Ahora borra la confi del proxy asi no te bloquea la pass y stopeo el docker del plstlinux que solo lo uso para bajar las imagenes.

rm -f /etc/systemd/system/docker.service.d/https-proxy.conf
systemctl daemon-reload
systemctl stop docker

jueves, 27 de diciembre de 2018

Cambiar/Agregar Semaforos

Para cambiar/ agregar semaforos en el sistema operativo, realizar :

Chequear los parametros actuales
~]# ipcs -sl

------ Semaphore Limits --------
max number of arrays = 128
max semaphores per array = 250
max semaphores system wide = 32000
max ops per semop call = 32

semaphore max value = 32767

ipcs -s | wc -l

129

Con esto, cambio los valores 
echo kernel.sem = 250 64000 32 256 >>/etc/sysctl.conf

Con esto relee el archivo systctl.conf
sysctl -p 

Chequeo que haya tomado efecto los cambios
# ipcs -sl

------ Semaphore Limits --------
max number of arrays = 256
max semaphores per array = 250
max semaphores system wide = 64000
max ops per semop call = 32
semaphore max value = 32767

# sysctl kernel.sem
kernel.sem = 250        64000   32      256
[root@webmail-03 ~]#

# grep sem /etc/sysctl.conf
kernel.sem = 250 64000 32 256




Instalar Centrify

Para instalar Centrify por primera vez, Si esta instalado el Access Control previamente, primero desisntalar el AC

# /opt/CA/eTrustAccessControl/lbin/uninstall_AC
Trying to unload CA ControlMinder...
CA ControlMinder is successfully unloaded.

UnInstalling CA ControlMinder from /opt/CA/eTrustAccessControl

The uninstall utility is about to remove the entire
CA ControlMinder directory: /opt/CA/eTrustAccessControl
If you wish to keep certain files for future use or
reference, do NOT continue.

Continue with uninstall now? [Y/n]:   y
Removing CA ControlMinder service from /etc/services
Removing CA ControlMinder system call loader.
Trying to remove references to CA ControlMinder from the system init files.
Removing CA ControlMinder PAM module from your system.
Restoring /etc/pam.d/login by removing last changes made to file
Removing CA ControlMinder Admin tools binaries and directories.
Removing CA ControlMinder Admin tools X-resource files.
The CA ControlMinder Admin tools files have now
been removed from your system.
Removing seos.ini from /etc
The token global.AC_Version, now set to 'none', (was '12.81.0.19')
Removing ControlMinder from AccessControl Shared dependency list
Removing AccessControl Shared
Removing CAPKI.
Removing CA ControlMinder binaries and directories.

UnInstall complete.

The CA ControlMinder files have now been removed.

Warning: If you have replaced /bin/passwd with sepass,
         You must restore the original /bin/passwd.

         You may edit your /etc/passwd and /etc/group
         files, in order to remove unnecessary users.

#

Una vez desinstalado el AC,  borrar el archivo  /lib/security y crearlo como un directorio
mkdir /lib/security

Ahora si, instalo el Centrify

yum localinstall CentrifyDC-openssl-5.5.0-rhel5.x86_64.rpm  CentrifyDC-openldap-5.5.0-rhel5.x86_64.rpm CentrifyDC-curl-5.5.0-rhel5.x86_64.rpm \
CentrifyDC-5.5.0-rhel5.x86_64.rpm  CentrifyDC-nis-5.5.0-rhel5.x86_64.rpm CentrifyDA-3.5.0-rhel5.x86_64.rpm -y

Si necesito Desinstalar el Centrify, el orden es el siguiente:
rpm -e CentrifyDA-3.5.0-155.x86_64
rpm -e CentrifyDC-nis-5.5.0-200.x86_64
rpm -e CentrifyDC-5.5.0-200.x86_64
rpm -e CentrifyDC-curl-5.5.0-200.x86_64
rpm -e CentrifyDC-openldap-5.5.0-200.x86_64
rpm -e CentrifyDC-openssl-5.5.0-200.x86_64

miércoles, 6 de junio de 2018

Copiar luns en caliente con pvmove en lvm

Una maniobra tipica cuando queremos cambiar de caja de storage presentada en un equipo sin corte de servicio.

Una vez asignadas las luns nuevas al equipo las reconocemos y la metemos dentro de lvm.
Para reconocerlas utilizaremos rescan-scsi-bus.sh que viene en el pkg sg3_utils asi que vamos a comenzar instalandolo.

yum install sg3_utils

Rescaneamos discos y lo agregamos a multipath:

rescan-scsi-bus.sh
multipath -F;multipath -v2
multipath -ll

Agregamos los devices a la configuracion de multipath y volvemos a rescanear.
vi /etc/multipath.conf
multipaths {
        multipath {
                wwid                 XXXXXXXXXXXXXXXXX
                alias                   mp_01
        }
multipaths {
        multipath {
                wwid                 XXXXXXXXXXXXXXXXX
                alias                   mp_02
        }
Volvemos a refrescar la configuracion de multipath para que tome los cambios. 
multipath -F; multipath -v2

Creamos las particiones
fdisk /dev/mpath/mp_01 
( n - p - 1 - enter - enter - w )
fdisk /dev/mpath/mp_02 
( n - p - 1 - enter - enter - w )

partprobe /dev/mapper/mp_01
partprobe /dev/mapper/mp_02

Lo agregamos a lvm
pvcreate /dev/mapper/mp_01p1
pvcreate /dev/mapper/mp_02p1

Lo agregamos al vg
vgextend vgst /dev/mapper/mp_01p1
vgextend vgst_backup /dev/mapper/mp_02p1



Es muy importante si es un cluster freezar el servicio
clusvcadm -Z SERV1

Movemos la info de un pv a otro
pvmove /dev/dm-XX /dev/mapper/mp_01p1
pvmove /dev/dm-XY /dev/mapper/mp_02p1

Sacamos los pv viejos del vg
vgreduce vgst /dev/dm-XX
vgreduce vgst_backup /dev/dm-XY

Sacamos los discos de la configuracion.
pvremove /dev/dm-XX
pvremove /dev/dm-XY



miércoles, 28 de febrero de 2018

Agregar relay host para envio de mails en postfix o sendmail

Primero lo comun a ambos. Verificar que llegemos al relay y al puerto 25

el relay host es smtp2.midominio.com.ar

Primero vemos si se resuelve el hostname con ping.

ping smtp2
PING smtp2.midominio.com.ar (10.4.33.103) 56(84) bytes of data.
64 bytes from 10.4.33.103: icmp_seq=1 ttl=127 time=0.861 ms
64 bytes from 10.4.33.103: icmp_seq=2 ttl=127 time=0.633 ms
^C
--- smtp2.midominio.com.ar ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1408ms
rtt min/avg/max/mdev = 0.633/0.747/0.861/0.114 ms

En caso que no funcione agregamos la ip al /etc/hosts o configuramos correctamente el /etc/resolv.conf para que resuelva por dns

telnet smtp02 25
220 mailbox.midominio.com.ar Microsoft ESMTP MAIL Service ready at Wed, 28 Feb 2018 14:42:15 -0300
helo
250 mailbox.midominio.com.ar Hello [XX.XX.XX.XX]
quit
221 2.0.0 Service closing transmission channel
Connection closed by foreign host.


Con esto aseguramos que llegamos al relay.


Ahora el agregado es muy sencillo en postfix agregamos o modificamos el parametro relayhost en /etc/postfix/main.cf
tiene que qedar asi:
relayhost=[smtp2.midominio.com.ar]

en caso de que sea sendmail modificamos en /etc/mail/sendmail.cf  la linea que empieza con DS para que quede asi:
DS[smtp2.midominio.com.ar]


En cualquiera de los dos casos reiniciamos el servicio de correo
con alguno de estos comandos

systemctl restart postfix
service postfix restart

systemctl restart sendmail
service sendmail restart


Probamos un envio de mail.
echo "This is a test." | mail -vvv -s "Prueba" nicolasm@midominio.com.ar

martes, 24 de octubre de 2017

Agregar espacio a un filesystem agregando un disco con lvm

Tenemos un equipo, para el que necesitamos hacer crecer un filesystem de aplicacion en 50gb.

Asi se ve el fs antes de aplicar cualquier cambio.

[root@linux3 ~]# df -h | grep opt
/dev/mapper/VG_optaplicacion-lv_optaplicacion
                      118G  100G   13G  89% /opt/aplicacion

La tarea se divide en cuatro partes principales
#1   Agregar el disco/lun fisicamente.
#2   Reconocer/Formatear el disco dentro del sistema operativo.
#3   Agregar el device dentro de lvm.
#4   Hacer crecer el file system.


#1   Agregar el disco/lun fisicamente.
Este equipo es una virtual de vmware, lo vemos asi

[root@linux3 ~]#  dmidecode -t system | less
# dmidecode 2.12
SMBIOS 2.4 present.

Handle 0x0001, DMI type 1, 27 bytes

System Information
        Manufacturer: VMware, Inc.
        Product Name: VMware Virtual Platform

Por lo que, el disco, se lo agrego desde el vcenter, como muestra en las siguientes imagenes (estan editadas para no mostrar info sensible)

Edit Settings:
 Add:
 Hard Disk:






#2   Reconocer/Formatear el disco dentro del sistema operativo.

El disco ya esta asignado al equipo fisicamente, lo buscamos con:
[root@linux3 ~]# fdisk -l
...
...
Disk /dev/sdg: 53.7 GB, 53687091200 bytes
64 heads, 32 sectors/track, 51200 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

Como vemos, el disco, no tiene particion, asi que se la creamos con fdisk

[root@linux3 ~]#  fdisk /dev/sdg
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0x5883c851.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)


WARNING: DOS-compatible mode is deprecated. It's strongly recommended to

         switch off the mode (command 'c') and change display units to
         sectors (command 'u').

Command (m for help): n

Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-51200, default 1): 
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-51200, default 51200): 
Using default value 51200

Command (m for help): t

Selected partition 1
Hex code (type L to list codes): 8e
Changed system type of partition 1 to 8e (Linux LVM)

Command (m for help): w

The partition table has been altered!

Calling ioctl() to re-read partition table.

Syncing disks.
[root@linux3 ~]# 



#3   Agregar el device dentro de lvm.

Necesito meter el disco recien agregado dentro del vg de lvm que estoy utilizando. Arriba de todo, habia tirado un df -h que me mostraba que el vg en cuestion es VG_optaplicacion

[root@linux3 ~]# vgs
  VG            #PV #LV #SN Attr   VSize   VFree
  VG_logaplicacion   1   1   0 wz--n- 249.99g    0 
  VG_optaplicacion   3   1   0 wz--n- 119.99g    0 
  VolGroup00      2   7   0 wz--n- 149.56g 9.56g

lo amplio:

[root@linux3 ~]# vgextend VG_optaplicacion /dev/sdg1  
  Physical volume "/dev/sdg1" successfully created
  Volume group "VG_optaplicacion" successfully extended

Ahora, hago crecer el lv del tamaño de todo el disco que le puse.

[root@linux3 ~]# lvextend /dev/VG_optaplicacion/lv_optaplicacion /dev/sdg1
  Size of logical volume VG_optaplicacion/lv_optaplicacion changed from 119.99 GiB (30717 extents) to 169.98 GiB (43516 extents).
  Logical volume lv_optaplicacion successfully resized.


#4   Hacer crecer el file system.

Ahora, solo hace falta hacer crecer el fs, o sea, que se vea cuando tiro un df y que se pueda usar.

[root@linux3 ~]# resize2fs /dev/VG_optaplicacion/lv_optaplicacion 
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/VG_optaplicacion/lv_optaplicacion is mounted on /opt/aplicacion; on-line resizing required
old desc_blocks = 8, new_desc_blocks = 11
Performing an on-line resize of /dev/VG_optaplicacion/lv_optaplicacion to 44560384 (4k) blocks.
The filesystem on /dev/VG_optaplicacion/lv_optaplicacion is now 44560384 blocks long.


Chequeo que todo este bien y listo el pollo.

[root@linux3 ~]# df -h | grep opt
/dev/mapper/VG_optaplicacion-lv_optaplicacion
                      168G  100G   60G  63% /opt/aplicacion