Using a9s MySQL for PCF

This topic describes how to use a9s MySQL for Pivotal Cloud Foundry (PCF) after it has been successfully installed. For more information, see the Installing and Configuring a9s MySQL for PCF topic.

Use a9s MySQL for PCF with an App

To use a9s MySQL for PCF with an app, create a service instance and bind the service instance to your app. For more information about managing service instances, see Managing Service Instances with the cf CLI.

View the a9s MySQL for PCF Service

After the tile is installed, you can see the service a9s-mysql101 and its service plans appear in your PCF marketplace. Run cf marketplace to see the service listing:

$ cf marketplace
Getting services from marketplace in org test / space test as admin...
service         plans                                                                           description
a9s-mysql101    mysql-single-small, mysql-single-big, mysql-cluster-small, mysql-cluster-big    This is the anynines MySQL 10 service.

For more information about available service plans, see Configure Service Plans.

Create a Service Instance

To provision a MySQL database, run cf create-service. For example.

$ cf create-service a9s-mysql101 mysql-single-small my-mysql-service-instance

Depending on your infrastructure and service broker utilization, it might take several minutes to create the service instance.

Run the cf services command to view the creation status. This command displays a list of all your service instances. To view the status of a specific service instance, run cf service NAME-OF-YOUR-SERVICE-INSTANCE.

Bind an App to a Service Instance

After your database is created, run cf bind-service to bind the service to your app:

$ cf bind-service a9s-mysql-app my-mysql-service-instance

Restage or Restart Your App

To enable your app to access the service instance, run cf restage or cf restart to restage or restart your app.

Obtain Credentials for Accessing Your Service Instance

After a service instance is bound to an app, the credentials of your MySQL database are stored in the environment variables of the app. Run cf env APP-NAME to display the environment variables.

You can find the credentials in the VCAP_SERVICES key.

$ cf env a9s-mysql-app
Getting env variables for app a9s-mysql-app in org test / space test as admin...

  "a9s-mysql101": [
    "credentials": {
      "host": "EXAMPLE-HOST",
      "port": 3306,
      "username": "EXAMPLE-USERNAME"
      "password": "EXAMPLE-PASSWORD",
    "label": "a9s-mysql101",
    "name": "my-mysql-service-instance",
    "plan": "mysql-single-small",

You can use the host and password values to connect to your database with a MySQL client.

Delete a a9s MySQL for PCF Service Instance

WARNING: Before deleting a service instance, you must backup data stored in your database. This operation cannot be undone and all the data is lost when the service instance is deleted.

Before you can delete a service instance, you must unbind it from all apps.

List Available Services

Run cf services to list available services.

$ cf services

Getting services in org test / space test as admin...

name                          service          plan                 bound apps        last operation
my-mysql-service-instance     a9s-mysql101     mysql-single-small   a9s-mysql-app     create succeeded

This example shows that my-mysql-service-instance is bound to the a9s-mysql-app app.

Unbind a Service Instance

Run cf unbind-service to unbind the service from your app:

$ cf unbind-service a9s-mysql-app my-mysql-service-instance

Delete a Service Instance

After unbinding the service, it is no longer bound to an app. Run cf delete-service to delete the service:

$ cf delete-service my-mysql-service-instance

It might take several minutes to delete the service. Deleting a service deprovisions the corresponding infrastructure resources. Run the cf services command to view the deletion status.

Upgrade the Service Instance to Another Service Plan

Once created, you can upgrade your service instance to another, larger service plan. A larger service plan provides more CPU, RAM and storage. For more information, see Update a Service Instance of the Managing Service Instances with the cf CLI.

$ cf update-service my-mysql-service-instance -p a-bigger-plan

Here are the plans you can upgrade to depending on the one you are currently using:

  • If you are currently using the mysql-single-small plan, you can upgrade to mysql-single-big plan.
  • If you are currently using the mysql-replica-small plan, you can upgrade to mysql-replica-big plan.

Add a Graphite Endpoint

If you want to monitor your service with Graphite, you can set an endpoint to where to information will be sent with the cf update-service command. This command expects the -c flag and a JSON string containing the graphite and metrics_prefix keys.

$ cf update-service my-mysql-service-instance -c '{ "graphite": [""], "metrics_prefix": "" }'

Add a Syslog Endpoint

The cf update-service command used with the -c flag can let you stream your syslog to a third-party service. In this case, the command expects a JSON string containing the syslog key.

$ cf update-service my-mysql-service-instance -c '{ "syslog": [""] }'
Create a pull request or raise an issue on the source for this page in GitHub