MySQL server

1. About

Use this component to deploy a MySQL server and databases.

2. How to use

2.1. 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.

../_images/mysql1.png

Figure 1. MySQL server

2.2. 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.

../_images/mysql2.png

Figure 2. MySQL database

Expect result

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

2.3. 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.

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.

2.4 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