MySQL

About

Use this component to deploy a MySQL server and databases.

How to use

How to deploy a MySQL server?

  1. Drop the MySQLServer component on a Compute.
  2. (Optional) Specify the root_password. If the password is not specified, it is auto-generated.

Fig. MySQL server

How to create MySQL database and user?

  1. Drop more than one MySQLDatabase components on the MySQLServer.
  2. Specify the database name, encoding, user and password accordingly.

Fig. MySQL database

Expect result

  • By default, MySQL server is installed at: /var/lib/mysql.

How to move the default datadir to a location on a Block Storage?

  1. Drop the BlockStorage and LinuxFileSystem components on the Compute.
  2. Click LinuxFileSystem and specify the mount point in the location field (e.g., /mnt).
  3. Connect config_filesystem_as_datadir (on the right) of the MySQLServer to the feature point (on the left) of the LinuxFileSystem.

Fig. MySQL datadir

Expect result

  • The Block Storage is mount to the VM at: /mnt.
  • MySQL server is installed in the new datadir at: /mnt/mysql.
  • AppArmor (for Debian) and SELinux (for Redhat) are configured to allow access to the new location.

Advance: How to define a connection to MySQL database using TOSCA?

  • Define a TOSCA ConnectsTo relationship. For example:
otc.relationships.NextcloudConnectsToDb:
derived_from: tosca.relationships.ConnectsTo
interfaces:
Configure:
description: Start installing nextcloud and connect to MySQL database
post_configure_source:
inputs:
MYSQL_HOST: { get_attribute: [TARGET, database_endpoint, ip_address] }
MYSQL_DB: { get_property: [TARGET, name] }
MYSQL_USER: { get_property: [TARGET, user] }
MYSQL_PASSWORD: { get_property: [TARGET, password] }
implementation: playbooks/nextcloud-post-configure-source.yaml

Links