Instalando servicio mysql en Cloud Foundry

Introducción

En esta entrada vamos a ver cómo instalar el servicio mysql en la plataforma Cloud Foundry. Para ello utilizaremos nuestro entorno de pruebas Clound Foundry local.

A pesar de su nombre, el servicio mysql está compuesto por un servidor MariaDB Galera Cluster. MariaDB es una alternativa con licencia GPL que es totalmente compatible con el servidor MySQL de Oracle.

 

Instalando servicio mysql

Vamos a desplegar el servicio con la última versión disponible, en el momento de hacer este tutorial la última versión es cf-mysql-26.

$ cd ~/workspace
$ git clone https://github.com/cloudfoundry/cf-mysql-release.git
$ cd cf-mysql-release/
$ bosh upload release releases/cf-mysql-26.yml

Ejecutamos el script que genera el manifest necesario para nuestra instancia Cloud Foundry local creada con BOSH-lite.

$ ./scripts/generate-bosh-lite-manifest 
Target set to `Bosh Lite Director'
Logged in as `admin'
Deployment set to `/home/developer/workspace/cf-mysql-release/cf-mysql.yml'
CF-MySQL Manifest was generated at /home/developer/workspace/cf-mysql-release/cf-mysql.yml

Desplegamos cf-mysql en nuestra instancia Cloud Foundry. Este proceso se encargará de generar todas las máquinas virtuales que componen el servicio mysql, en mi caso este proceso me llevó 29 minutos.

$ bosh deploy

Registramos el service broker con el comando errand de BOSH.

$ bosh run errand broker-registrar

Comprobamos que el servicio cf-mysql está ejecutando correctamente.

# comprobamos el despliegue
$ bosh deployments
Acting as user 'admin' on 'Bosh Lite Director'
+-----------------+--------------+--------------------------------------------------+--------------+
| Name | Release(s) | Stemcell(s) | Cloud Config |
+-----------------+--------------+--------------------------------------------------+--------------+
| cf-warden | cf/233+dev.1 | bosh-warden-boshlite-ubuntu-trusty-go_agent/3147 | none |
+-----------------+--------------+--------------------------------------------------+--------------+
| cf-warden-mysql | cf-mysql/26 | bosh-warden-boshlite-ubuntu-trusty-go_agent/3147 | none |
+-----------------+--------------+--------------------------------------------------+--------------+

Deployments total: 2
# Comprobamos las vms
$ bosh vms
Acting as user 'admin' on 'Bosh Lite Director'
Deployment `cf-warden'

Director task 43

Task 43 done

+---------------------------------------------------------------------------+---------+-----+-----------+--------------+
| VM | State | AZ | VM Type | IPs |
+---------------------------------------------------------------------------+---------+-----+-----------+--------------+
| api_z1/0 (16276c0c-e04e-4f7c-9b87-63befd2a8092) | running | n/a | large_z1 | 10.244.0.138 |
| blobstore_z1/0 (795376e9-9c63-4d6c-8ad3-63db5d6ebe39) | running | n/a | medium_z1 | 10.244.0.130 |
| consul_z1/0 (076fe93b-c8c4-4afe-b8cc-bb44179c2c88) | running | n/a | small_z1 | 10.244.0.54 |
| doppler_z1/0 (0fd0fcdd-f8f4-482d-bc6c-edb89f0457b0) | running | n/a | medium_z1 | 10.244.0.146 |
| etcd_z1/0 (f831c7be-5332-4eb0-a919-48769e369462) | running | n/a | medium_z1 | 10.244.0.42 |
| ha_proxy_z1/0 (3443d111-3de9-45da-a1c8-75bf7620b17d) | running | n/a | router_z1 | 10.244.0.34 |
| hm9000_z1/0 (56df7e19-93cd-45ff-a1c2-227666165ceb) | running | n/a | medium_z1 | 10.244.0.142 |
| loggregator_trafficcontroller_z1/0 (86ba7bad-cae1-41cc-930b-82f8b2d94886) | running | n/a | small_z1 | 10.244.0.150 |
| nats_z1/0 (da17e1c6-9eb8-4e3e-b9ea-7ddd320b1c98) | running | n/a | medium_z1 | 10.244.0.6 |
| postgres_z1/0 (05fad25a-62ef-4875-90c4-e8a62017f7d4) | running | n/a | medium_z1 | 10.244.0.30 |
| router_z1/0 (acc7625e-2405-4667-a0b2-2c60089c7178) | running | n/a | router_z1 | 10.244.0.22 |
| runner_z1/0 (a455e873-a4fd-46b3-bd9e-d74bcfb92c1e) | running | n/a | runner_z1 | 10.244.0.26 |
| uaa_z1/0 (3b4d91c8-a790-4281-92d2-ce98b7c7a059) | running | n/a | medium_z1 | 10.244.0.134 |
+---------------------------------------------------------------------------+---------+-----+-----------+--------------+

VMs total: 13
Deployment `cf-warden-mysql'

Director task 44

Task 44 done

+-------------------------------------------------------------+---------+-----+--------------------+--------------+
| VM | State | AZ | VM Type | IPs |
+-------------------------------------------------------------+---------+-----+--------------------+--------------+
| arbitrator_z3/0 (0083d6ce-53fe-4b5f-8055-c22b0f163848) | running | n/a | arbitrator_z3 | 10.244.9.6 |
| cf-mysql-broker_z1/0 (a2646fac-05ec-4b13-aecf-1a7f61f11156) | running | n/a | cf-mysql-broker_z1 | 10.244.7.130 |
| cf-mysql-broker_z2/0 (f7f7995a-0280-4317-b69c-769014c19dfb) | running | n/a | cf-mysql-broker_z2 | 10.244.8.130 |
| mysql_z1/0 (14a46361-575f-47fd-987d-11c21dd9bfc5) | running | n/a | mysql_z1 | 10.244.7.2 |
| mysql_z2/0 (eb6f2919-fafa-4699-84b9-778fa7f3eca3) | running | n/a | mysql_z2 | 10.244.8.2 |
| proxy_z1/0 (8fd27e50-c3f7-4ab8-918a-342d184dd4ec) | running | n/a | proxy_z1 | 10.244.7.6 |
| proxy_z2/0 (01fae5fb-b381-4c9b-92d6-c42453d709f9) | running | n/a | proxy_z2 | 10.244.8.6 |
+-------------------------------------------------------------+---------+-----+--------------------+--------------+

VMs total: 7

 

En este punto ya tenemos configurado el servicio mysql correctamente en nuestra instancia de Cloud Foundry local. A partir de este momento podremos desplegar aplicaciones que utilicen la base de datos MySQL/MariaDB para almacenar la información.

Sobre el autor

Apasionado de las tecnologías, entusiasta del desarrollo de software. Especializado en Java EE. Cofundador de www.logrosxbox.com.