martes, 2 de abril de 2019

[EN] rc.local on Ubuntu 18.x

On Ubuntu 18.04/18.10 I have missed the rc.local file that had helped me a few (thousand) times. Have you missed it too? By default, the file does not exit, but the service behind is present, so not everything is lost.
If you want to enable this feature on your Ubuntu, you are just few steps away.

First of all, let's create the file and set the correct perms

> touch /etc/rc.local
> chmod +x /etc/rc.local

and then let's give it the correct format


> echo "#!/bin/bash
exit 0" > /etc/rc.local


and it will work. You can check the state of the service as well with


> systemctl status rc-local

and start/stop it if you want to make any test.

martes, 26 de marzo de 2019

[EN] High CPU -> Ubuntu + Docker + Jenkins

Sometimes, suddenly a Jenkins environment can turn upside down and take all the CPU resources even when no job is being processed. Any job launched gets eternal and the CPU load gets so high that almost reaches the moon while you try to fix it with no luck at all.

In that moment, a good idea may be clean old jobs and update your Jenkins.




For cleaning old builds
  • find out which is your jenkins home (you can get it from "Manage Jenkins" -> "Configure System" -> "Home Directory")
  • navigate to that directory, and then move inside the 'jobs' folder. Those are your jobs, and inside each of them there is a "builds" folder that keeps the builds. Delete as much as you want, let's say leaving just one month.
  • after that, reload your configuration; you can restart your container

  •   > docker container restart jenkins

    or just reload the configuration from "Manage Jenkins" -> "Reload Configuration from Disk" 

For updating your Jenkins (using Docker)
  • First of all, copy the war URL to download it; you can copy it from your Jenkins. To get it, go to "Manage Jenkins" and scroll to the top of the page; there is a warning if there are new available versions, and you can copy the link from there
  • Once you have your link, you have to download the war inside the container and move it instead the current; so lets get inside it using
  • > docker container exec -u 0 -it jenkins bash ##important you use "-u 0" option to force the user; otherwise bash may crash or have other issues
    >> cd /usr/share/jenkins
    >> mv jenkins.war jenkins-OLD.war
    >> wget http://updates.jenkins-ci.org/download/war/x.yyy.z/jenkins.war ## in your case, the URL you got on the previous step   
    >> chown jenkins:jenkins jenkins.war
    >> exit

  • now let's restart the container using

    > docker container restart jenkins

    log on on your Jenkins again, and check your installed plugins; some of them may be outdated and you'll have to make some adjustments.


miércoles, 20 de febrero de 2019

Pinceladas de git

Hoy traigo otra cheat sheet, esta vez se trata de una chuleta de comandos git. Para el que haya llegado aquí por casualidad, git es un software de control de versiones muy utilizado no sólo por equipos de desarrollo sino por cualquiera que prefiera trabajar con un repositorio seguro.

En este caso, quiero que le echéis un ojo a esta chuleta; las hay mucho más completas con miles de comandos, pero esta me gusta porque es muy simple y sencilla, y para alguien que está empezando o que sólo hace tareas más básicas, es genial.


No dispongo de la fuente original, ya que esto lo saqué de Pinterest, de una cuenta que sigo, pero si alguien la conoce, que me lo haga llegar y prometo actualizar el post.


Muchas gracias!

lunes, 24 de diciembre de 2018

Pinceladas de Docker (IV) - Comandos

Hacía tiempo que quería subir una pequeña receta con los comandos de docker que más utilizo y que pueden ser útiles a alguien, y ya tenía el post escrito cuando he encontrado una sheet que me parece muy útil y totalmente recomendable, muy completa y muy organizada. Así que en lugar de subir mi artículo, os dejo esta sheet que os va a ser mucho más útil.

Si hacéis click sobre la imagen se hace más grande; o podéis descargarlas en formato PDF para tenerlas siempre a mano aquí.



Fuente: Linoxide.Com

lunes, 29 de octubre de 2018

Distribuciones Linux

¿Sabéis cuántas distribuciones linux "oficiales" hay? 10? 20? Pues no, son unas cuantas más...
Os dejo una imagen de la wiki donde están todas las distros, de dónde salieron y las escisiones que se han formado. Podéis acceder a la web aquí



sábado, 1 de septiembre de 2018

Ampliar LVM sobre disco virtual (libvirtd) sin GPARTED

Hola! Esta es mi receta para dar de alta discos sin gparted

Espero que os sea de utilidad!

1) Parar servidor y añadir un disco nuevo. Arrancar servidor de nuevo

2) formatearlo (fdisk), añadir partición nueva y darle el formato de "Linux LVM" (8e). Escribir los
cambios en la tabla (w) y salir

root@Server:~# fdisk /dev/sdb
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-2610, default 1): "enter"
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-2610, default 2610): "enter"
Using default value 2610
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@Server:~# 

3) Hacer del nuevo disco un volumen físico (VP)

root@Server:~# pvcreate /dev/sdb1
Physical volume "/dev/sdb1" successfully created

4) 'Extender' el volume group (VG) que ya existe (en este caso se llama Mega) añadiéndole el
nuevo disco

root@Server:~# vgextend Mega /dev/sdb1
Volume group "Mega" successfully extended

Para saber cómo se llama el volumen a extender, podéis ejecutar vgdisplay, que muestra todos
los volúmenes definidos
Con pvscan podréis comprobar que el nuevo disco forma parte del volumen al que lo habéis
añadido:

root@Server:~# pvscan
PV /dev/sda5 VG Mega lvm2 [19.76 GiB / 0 free]
PV /dev/sdb1 VG Mega lvm2 [19.99 GiB / 19.99 GiB free]
Total: 2 [39.75 GiB] / in use: 2 [39.75 GiB] / in no VG: 0 [0 ]


5) Vamos ahora a ampliar el espacio del disco propiamente dicho; el disco en realidad es un LV
(volumen lógico)

root@Server:~# lvextend /dev/Mega/root /dev/sdb1
Extending logical volume root to 38.90 GiB
Logical volume root successfully resized

y por último, reformateamos el sistema de archivos para que se adapte al nuevo disco:

root@Server:~# resize2fs /dev/Mega/root
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/Mega/root is mounted on /; on-line resizing required
old desc_blocks = 2, new_desc_blocks = 3
Performing an on-line resize of /dev/Mega/root to 10196992 (4k) blocks.
The filesystem on /dev/Mega/root is now 10196992 blocks long.


martes, 24 de julio de 2018

Ampliar LVM sobre disco virtual (libvirtd) usando GPARTED

Hola!
Esta es mi receta para ampliar discos discos virtuales con LVM montado. Espero que os sea útil!

1) parar mv y haz una copia del disco.

2) con el comando vgs vemos que grupos de volumenes existen:
    VG #PV #LV #SN Attr VSize VFree
    vgdata 1 3 0 wz--n- 219,09g 37,44g
    vgsys 1 3 0 wz--n- 16,61g 4,00m

3) con el comando lvs vemos que volumenes logicos existen:
    LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
    datos2 vgdata -wi-ao---- 167,00g
    home vgdata -wi-ao---- 4,88g
    opt vgdata -wi-ao---- 9,77g
    root vgsys -wi-ao---- 9,77g
    tmp vgsys -wi-ao---- 1,95g
    var vgsys -wi-ao---- 4,88g

4) con el comando vgs vemos que discos hacen referencia a los grupos de volumenes
existentes:
    PV VG Fmt Attr PSize PFree
    /dev/vda2 vgsys lvm2 a-- 16,61g 4,00m
    /dev/vda3 vgdata lvm2 a-- 219,09g 37,44g
5) ampliamos la imagen del disco del servidor (desde el host)

> qemu-img resize /path/to/server.qcow2 +200GB

6) modificamos el servidor para que arranque desde cd (desde el host):

> virsh edit server > con este comando editamos su configuración
<boot dev='cdrom'/> > añadimos una unidad de cdrom
<boot dev='hd'/>
<disk type='file' device='cdrom'> enlazamos la imagen iso de GParted a la unidad de cdrom
<driver name='qemu' type='raw'/>
<source file='/opt/ISO/gparted-live-0.26.0-2-i686.iso'/>
<target dev='hdc' bus='ide'/>
<readonly/>
<address type='drive' controller='0' bus='1' unit='0'/>
</disk>

7) iniciamos de nuevo el servidor, booteará desde la iso de GParted

8) Veremos el nuevo espacio como "unallocated" , lo movemos hasta poder añadirlo al disco que deseemos (el que haga referencia al grupo de volumenes que deseamos ampliar)

9) eliminamos la configuración del servidor para que no vuelva a arrancar desde cd (eliminando lo añadido en el paso 6) y reiniciamos el servidor

10) creamos el nuevo volumen logico, datos2 en este caso y lo asignamos al grupo que deseemos, en este caso vgdata.

> lvcreate --size 167G --name datos2 vgdata

11) creamos el sistema de archivos en el volumen logico:

> mkfs.ext4 /dev/mapper/vgdata-datos2

12) modificamos el fichero /etc/fstab para montar la nueva unidad

> /dev/mapper/vgdata-datos2 /datos2 ext4 defaults 1 2

13) creamos el directorio /datos2 donde se montara el fs

14) montamos el filesystem

> mount -a



Documentación:
http://www.randomhacks.co.uk/how-to-resize-a-qcow2-harddrive-images/
http://www.vilecha.com/hellguest/lvm2_creacion.asp
http://www.naturalborncoder.com/virtualization/2014/12/05/increasing-the-size-of-a-qcow2- image-under-kvm/
https://www.rootusers.com/use-gparted-to-increase-disk-size-of-a-linux-native-partition/