Cambiar el tipo de instancia de Amazon AWS de T2 a T3.medium

Ya me llega el momento de renovar el contrato de instancias reservadas de Amazon AWS y he visto que hace algún tiempo que existen las instancias T3 que, además, son más baratas que las T2 y con mejor rendimiento. Así que comienzo a migrar mi instancia T2 a T3, pero no va a ser tan fácil como yo creía en un principio.

Compruebo que actualmente, la talla es, efectivamente, T2.medium:

AWS T2.medium

Cambiar la talla de la instancia requiere que esté parada, así que la paro, hago un snapshot del volumen raíz (sistema operativo), por si acaso e intento cambiar la talla desde el menú de la consola de EC2.

AWS EC2 Change instance type
AWS EC2 Change instance type 2

Pero no puedo cambiar el tipo de instancia debido a que no tengo habilitada la red mejorada (Enhanced Network Adapter), tal y como se puede apreciar en el siguiente error.

AWS EC2 Enhanced Network adapter is required

Habilitar Enhanced Network Adapter

Para habilitar la red mejorada, sigo las instrucciones de la documentación oficial de AWS. Pero mejor muestro todos los comandos que he ejecutado:

  • Descargo los drivers de ENA

[root@prt53ws1 ~]# git clone https://github.com/amzn/amzn-drivers
Cloning into ‘amzn-drivers’…
remote: Counting objects: 560, done.
remote: Compressing objects: 100% (27/27), done.
remote: Total 560 (delta 0), reused 8 (delta 0), pack-reused 532
Receiving objects: 100% (560/560), 413.18 KiB | 541.00 KiB/s, done.
Resolving deltas: 100% (235/235), done.
[root@prt53ws1 ~]#

  • Compilo el código fuente descargado:

[root@prt53ws1 rpm]# make
(cd /root/amzn-drivers && \
git archive –format=tar –prefix=ena-1.6.0/ ena_linux_1.6.0 \
kernel/linux/{common,ena}) > ena-1.6.0.tar
rpmbuild -bs –define ‘_topdir %(pwd)’ –define ‘_ntopdir %(pwd)’ –define ‘_builddir %{_ntopdir}/build’ –define ‘_buildrootdir %{_builddir}’ –define ‘_sourcedir %{_ntopdir}’ –define ‘_specdir %{_ntopdir}’ –define ‘_rpmdir %{_ntopdir}’ –define ‘_srcrpmdir %{_ntopdir}’ ena.spec
rpm: no arguments given for query
error: Macro %kernel_version has empty body
Wrote: /root/amzn-drivers/kernel/linux/rpm/ena-1.6.0-1.el7.8.src.rpm
[root@prt53ws1 rpm]#

[root@prt53ws1 ena]# cd ..
[root@prt53ws1 linux]# git archive –format=tar –prefix=ena-1.5.3/ -o rpm/ena-1.5.3.tar ena_linux_1.5.3
[root@prt53ws1 rpm]# pwd
/root/amzn-drivers/kernel/linux/rpm
[root@prt53ws1 rpm]#

  • Construyo el RPM y añado el módulo al kernel:

[root@prt53ws1 rpm]# rpmbuild -bs –define ‘_topdir %(pwd)’ –define ‘_ntopdir %(pwd)’ –define ‘_builddir %{_ntopdir}’ –define ‘_sourcedir %{_ntopdir}’ –define ‘_specdir %{_ntopdir}’ –define ‘_rpmdir %{_ntopdir}’ –define ‘_srcrpmdir %{_ntopdir}’ ena.spec
rpm: no arguments given for query
error: Macro %kernel_version has empty body
Wrote: /root/amzn-drivers/kernel/linux/rpm/ena-1.6.0-1.el7.8.src.rpm
[root@prt53ws1 rpm]#
[root@prt53ws1 rpm]# depmod
[root@prt53ws1 rpm]# dracut -f -v
Executing: /sbin/dracut -f -v
dracut module ‘busybox’ will not be installed, because command ‘busybox’ could not be found!
dracut module ‘plymouth’ will not be installed, because command ‘plymouthd’ could not be found!
dracut module ‘plymouth’ will not be installed, because command ‘plymouth’ could not be found!
dracut module ‘crypt’ will not be installed, because command ‘cryptsetup’ could not be found!
dracut module ‘dmraid’ will not be installed, because command ‘dmraid’ could not be found!
dracut module ‘dmsquash-live-ntfs’ will not be installed, because command ‘ntfs-3g’ could not be found!
dracut module ‘mdraid’ will not be installed, because command ‘mdadm’ could not be found!
dracut module ‘multipath’ will not be installed, because command ‘multipath’ could not be found!
dracut module ‘cifs’ will not be installed, because command ‘mount.cifs’ could not be found!
dracut module ‘fcoe’ will not be installed, because command ‘dcbtool’ could not be found!
dracut module ‘fcoe’ will not be installed, because command ‘fipvlan’ could not be found!
dracut module ‘fcoe’ will not be installed, because command ‘lldpad’ could not be found!
dracut module ‘fcoe’ will not be installed, because command ‘fcoemon’ could not be found!
dracut module ‘fcoe’ will not be installed, because command ‘fcoeadm’ could not be found!
dracut module ‘fcoe-uefi’ will not be installed, because command ‘dcbtool’ could not be found!
dracut module ‘fcoe-uefi’ will not be installed, because command ‘fipvlan’ could not be found!
dracut module ‘fcoe-uefi’ will not be installed, because command ‘lldpad’ could not be found!
dracut module ‘iscsi’ will not be installed, because command ‘iscsistart’ could not be found!
dracut module ‘iscsi’ will not be installed, because command ‘iscsi-iname’ could not be found!
dracut module ‘nbd’ will not be installed, because command ‘nbd-client’ could not be found!
dracut module ‘biosdevname’ will not be installed, because command ‘biosdevname’ could not be found!
*** Including module: bash ***
*** Including module: modsign ***
*** Including module: nss-softokn ***
*** Including module: rdma ***
*** Including module: i18n ***
*** Including module: network ***
*** Including module: ifcfg ***
*** Including module: btrfs ***
*** Including module: dm ***
Skipping udev rule: 64-device-mapper.rules
Skipping udev rule: 60-persistent-storage-dm.rules
Skipping udev rule: 55-dm.rules
*** Including module: kernel-modules ***
*** Including module: lvm ***
Skipping udev rule: 64-device-mapper.rules
Skipping udev rule: 56-lvm.rules
Skipping udev rule: 60-persistent-storage-lvm.rules
*** Including module: nfs ***
*** Including module: resume ***
*** Including module: rootfs-block ***
*** Including module: terminfo ***
*** Including module: udev-rules ***
Skipping udev rule: 40-redhat-cpu-hotplug.rules
Skipping udev rule: 91-permissions.rules
*** Including module: systemd ***
*** Including module: usrmount ***
*** Including module: base ***
*** Including module: fs-lib ***
*** Including module: microcode_ctl-fw_dir_override ***
microcode_ctl module: hacking fw_dir
microcode_ctl: processing data directory «/usr/share/microcode_ctl/ucode_with_caveats/intel-06-4f-01″…
microcode_ctl: processing file «intel-ucode/06-4f-01»
intel-06-4f-01: model ‘GenuineIntel 06-4f-01’, path ‘ intel-ucode/06-4f-01’, kvers ‘ 4.17.0 3.10.0-894 3.10.0-862.6.1 3.10.0-693.35.1 3.10.0-514.52.1 3.10.0-327.70.1 2.6.32-754.1.1 2.6.32-573.58.1 2.6.32-504.71.1 2.6.32-431.90.1 2.6.32-358.90.1’
intel-06-4f-01: blacklist »
microcode_ctl: caveats check for kernel version «3.10.0-862.11.6.el7.x86_64» passed, adding «/lib/firmware/3.10.0-862.11.6.el7.x86_64» to fw_dir variable
*** Including module: shutdown ***
*** Including modules done ***
*** Installing kernel module dependencies and firmware ***
*** Installing kernel module dependencies and firmware done ***
*** Resolving executable dependencies ***
*** Resolving executable dependencies done***
*** Hardlinking files ***
*** Hardlinking files done ***
*** Stripping files ***
*** Stripping files done ***
*** Generating early-microcode cpio image contents ***
*** Constructing AuthenticAMD.bin ****
*** Store current command line parameters ***
*** Creating image file ***
*** Creating microcode section ***
*** Created microcode section ***
*** Creating image file done ***
*** Creating initramfs image file ‘/boot/initramfs-3.10.0-862.11.6.el7.x86_64.img’ done ***
[root@prt53ws1 rpm]#

  • Finalmente, configuro grub, tal y como indica en la documentación, para desactivar los nombres de interfaz predecibles:

[root@prt53ws1 rpm]# grep net /etc/default/grub
GRUB_CMDLINE_LINUX=»console=tty0 crashkernel=auto console=ttyS0,115200 net.ifnames=0 «
[root@prt53ws1 rpm]#
[root@prt53ws1 rpm]# grub2-mkconfig -o /boot/grub2/grub.cfg
Generating grub configuration file …
Found linux image: /boot/vmlinuz-3.10.0-862.11.6.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-862.11.6.el7.x86_64.img
Found linux image: /boot/vmlinuz-3.10.0-862.9.1.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-862.9.1.el7.x86_64.img
Found linux image: /boot/vmlinuz-3.10.0-862.6.3.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-862.6.3.el7.x86_64.img
Found linux image: /boot/vmlinuz-3.10.0-862.3.3.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-862.3.3.el7.x86_64.img
Found linux image: /boot/vmlinuz-0-rescue-8bd05758fdfc1903174c9fcaf82b71ca
Found initrd image: /boot/initramfs-0-rescue-8bd05758fdfc1903174c9fcaf82b71ca.img
done
[root@prt53ws1 rpm]#

Paro el servidor.

Me conecto a otra instancia EC2 de administración con el AWS CLI instalado y los roles pertinentes, para habilitar el soporte de ENA:

[root@ip-10-0-4-252 ~]# aws configure
AWS Access Key ID [****************JYNQ]:
AWS Secret Access Key [****************2F0Q]:
Default region name [eu-west1a]: eu-west-1
Default output format [None]:
[root@ip-10-0-4-252 ~]# aws ec2 modify-instance-attribute –instance-id i-0093481eeaab71526 –ena-support
[root@ip-10-0-4-252 ~]#

Al arrancar la instancia de nuevo para cargar la nueva configuración del kernel, el sistema operativo no encontraba el disco de sistema. He tenido que desasignar y volver a asignar el volumen de root desde el menú «Volumes» de EC2, con el nombre /dev/sda1. Entonces, sí que ha arrancado el sistema operativo con normalidad.

AWS EC2 Attach sda1

Continuamos migrando la talla del servidor de T2 a T3

Una vez solucionado el problema de red mejorada, vuelvo a parar la instancia, ya que es un requerimiento para poder modificar la talla.

Esta vez, el menú de la consola de EC2 ya funciona.

AWS EC2 T3.medium Migrated

La instancia que he migrado ha sido un Centos 7.

[root@prt53ws1 ~]# lsb_release -a
LSB Version: :core-4.1-amd64:core-4.1-noarch
Distributor ID: CentOS
Description: CentOS Linux release 7.5.1804 (Core)
Release: 7.5.1804
Codename: Core
[root@prt53ws1 ~]#

0&bids=507388
COMPÁRTEME

Deja un comentario