MySQL
About
Use this component to deploy a MySQL server and databases.
How to use
How to deploy a MySQL server?
- Drop the MySQLServer component on a Compute.
- (Optional) Specify the root_password. If the password is not specified, it is auto-generated.
How to create MySQL database and user?
- Drop more than one MySQLDatabase components on the MySQLServer.
- Specify the database name, encoding, user and password accordingly.
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?
- Drop the BlockStorage and LinuxFileSystem components on the Compute.
- Click LinuxFileSystem and specify the mount point in the location field (e.g.,
/mnt
). - 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.
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
- See the template example in: Topology template /
Nextcloud
. - See how this service catalog is modelled in TOSCA format.