Generic MySQL

MySQL is the most popular Open Source Relational SQL Database Management System used by small and large businesses. It has a customizable software and works well even with large data sets.

You can ingest data from your MySQL database using Hevo Pipelines and replicate it to a warehouse of your choice.

Prerequisites


Perform the following steps to configure your Generic MySQL Source:

Set up MySQL Binary Logs for Replication

A binary log is a collection of log files that records information about data modifications and data object modifications made on a MySQL server instance. Typically binary logs are used for data replication and data recovery.

Hevo supports data ingestion for replication from MySQL servers via binary logs (BinLog). For this, binary logging must be enabled on your MySQL server. You can do this via the MySQL server configuration file or via server startup options to mysqld.

Follow these steps to set up BinLog replication:

1. Check if BinLog replication is already enabled

  1. Access the MySQL database you want to check for BinLog activity:

     mysql -h hostname -u user -p database
    
  2. Open a secure shell:

     ssh user@localhost
    
  3. Enter the command:

    select @@log_bin;
    

    If this statement returns a value of 1, BinLog is active. If value returned is 0, this means that BinLog is disabled. To enable it, follow the steps below.

2. Enable BinLog replication

  1. Log in to your MySQL server instance.

  2. Check your MySQL Server configuration:

    sudo nano /etc/mysql/my.cnf
    

    This may be sudo nano /etc/my.cnf in some cases.

  3. In the config file, ensure the following configurations are specified. If not specified, add them now.

     [mysqld]
    
     binlog_format=ROW
    
     binlog_row_image=FULL
    
     expire_logs_days=3  -- The retention period (`expire_log_days`) can also be set in seconds by using the command: `binlog_expire_logs_seconds=259200`
    
     log_bin=mysql-binlog  -- For ubuntu, use: `/var/log/mysql/mysql-bin.log` 
    
     server-id=1 -- (only in the case of ubuntu) 
    
     log_slave_updates=1
    
  4. Restart the MySQL server using the command service mysql restart on your instance.

  5. After restart, log in to the MySQL server to check BinLog again:

     SELECT @@log_bin;
    

    The value returned is now 1, indicating that BinLog is active.

    Note: The retention period should ideally be at least 72 hours (3 days). This helps Hevo ensure that no log-file is missed from being read, specially when Historical Data loading is enabled. Read BinLog Alerts.

Read BinLog Replication and BinLog Alerts.

The replication reference guide on MySQL’s documentation portal provides a complete reference of the options available for replication and binary logging.


Whitelist Hevo’s IP Addresses

You need to whitelist the Hevo IP address for your region to enable Hevo to connect to your MySQL database. To do this:

  1. Edit the MySQL server configuration:

     sudo nano /etc/mysql/mysql.conf.d/mysqld.cnf
    
  2. Scroll to [mysqld] and add:

     bind-address = 0.0.0.0
    

    Or

     bind-address = 10.2.7.152
    

    (Check the Hevo IP address for your region).

  3. Save the file.


Grant Privileges to the User

The database user specified in the Hevo Pipeline must have the following global privileges:

  • SELECT

  • SUPER or (REPLICATION_CLIENT and REPLICATION_SLAVE)

To set up these privileges:

  1. Go to your mysql server. For example: mysql -u root -p.

  2. Grant SELECT privileges to the user using following command:

    GRANT SELECT ON *.* to jacob@localhost;
    
  3. (Optional) View the grants for the user with the following command:

    show grants for jacob@localhost;
    

Limitations

  • Hevo does not fetch Views from the MySQL database automatically.

    As a workaround, you can create individual Pipelines in Custom SQL mode to fetch each View. However, some limitations may arise based on the type of data synchronization, the query mode, or the number of Events. Contact Hevo Support for more details.

Last updated on 06 Mar 2021