Updated on 2024-11-20 GMT+08:00

MySQL Monitoring and DR

Introduction

A monitor detects your database status, and automatically triggers traffic switching when the database is abnormal. You can also switch the traffic manually. For details, see Step 4: Switch the MySQL Monitor.

This section uses an example of MySQL monitor to help you quickly get started.

The general process includes:

Step 1: Prepare MySQL Databases

Prepare a MAS instance and two MySQL databases before you start. You can use the databases bought on the Huawei Cloud official website or deployed on two local machines.

This section uses two MySQL databases bought on Huawei Cloud as an example. Deploy the databases in different availability zones (AZs) of the same region for failover and high availability.

  1. Prepare two MySQL databases with the same name, username, and password. For details, see Buying an RDS for MySQL DB Instance.
  2. Bind an EIP by referring to Binding and Unbinding an EIP.
  3. Configure security group rules by referring to Configuring a Security Group Rule. The default port for database access is 3306.

Step 2: Create an Application

Applications isolate resources of different users in an instance. Monitors must be associated with applications.

  1. Log in to the MAS console. On the Multi-Active Instances page, click an instance to go to its console.
  2. Click the Applications tab, and click Create.
  3. Enter the application information, then click OK.
    Table 1 Application parameters

    Parameter

    Description

    Application

    Customize the application name.

    Description

    (Optional) Enter a description about the application.

Step 3: Create a MySQL Monitor

  1. Log in to the MAS console. On the Multi-Active Instances page, click an instance whose namespace type is Intra-city multi-active.
  2. Click the Monitor List tab, and click Create Monitor.
  3. Configure the basic information, then click Next: Data Centers.
    Figure 1 Basic information configurations
    Table 2 Basic information parameters

    Parameter

    Description

    Monitor

    Select MySQL Monitoring.

    Application

    Select the application created in Step 2: Create an Application.

    Monitor Name

    Customize the monitor name.

    Exception Notification

    The default setting (Disabled) is used in this example.

    If this option is enabled, monitor and database alarms will be sent to you in a timely manner with the Huawei Cloud Simple Message Notification (SMN) service. Configure a secret key before enabling this option.

    Monitoring

    The default value is Yes. If No, database exceptions will not be monitored.

    Automatic Switchover

    The default value is Yes. If No, automatic switchover of the databases will not be triggered.

    Username

    Enter the username for logging in to the monitored database.

    Password

    Enter the password for logging in to the monitored database.

    Confirm Password

    Enter the password again.

    Associate with DRS

    The default setting (Disabled) is used in this example.

    If it is enabled, Data Replication Service (DRS) will be associated.

    Enter the username and password you configured in •Step 1: Prepare MySQL Databases.

  4. Configure the information, then click Next: Databases.
    Figure 2 Data center configurations
    Table 3 Data center parameters

    Parameter

    Description

    Cloud

    Select the environments where the MySQL databases are deployed.

    Region

    Select the regions of the MySQL databases created in Step 1: Prepare MySQL Databases.

    IPv4 Address

    Enter the access addresses and ports of the MySQL databases created in Step 1: Prepare MySQL Databases.

    Add Read Database

    Click to add the read database address.

  5. Configure the information, then click Next: Advanced.
    Figure 3 Database configurations
  6. Configure the advanced settings, then click Next: Confirm. Default values are used in the following figure.
    Figure 4 Advanced configurations
  7. Confirm settings and click Create.

Step 4: Switch the MySQL Monitor

  1. On the Monitoring List page, click Switch Over in the row of a target monitor.
  2. Click OK. The active (primary) database changes from data center 1 to data center 2.
  3. After the database connection and read/write in data center 1 recover, click Switch Back in the row of the target monitor.
  4. Click OK. The active (primary) database changes back to data center 1.