Skip to main content
MySQL is one of the database vendors supported on NexusOne. In this guide, you’ll deploy a MySQL database instance in a public cloud using Terraform, add datasets into the database, and ingest the database into NexusOne.

Prerequisites

Before starting this tutorial, ensure you have the following:
  • An existing AWS, Azure, or Google Cloud account
  • Required roles: nx1_ingest and superset_user.
  • While configuring variables to deploy NexusOne, your ranger_repo_mode variable has the value shared. This ensures you have the nx1-unifiedsql service name. NexusOne supports other values too, but this tutorial uses shared.
  • A policy that your platform administrator creates for you. It should be on the mysql_schema schema in the iceberg catalog, and grant the alter, create, drop, insert, select, and update permissions. It’s created with one of the following options:
  • When you create the policy, assign it to the nx1_ingest or superset_user role.
  • Command line tools from AWS, Azure, or Google Cloud installed
  • mysql command line tool installed
  • Terraform installed

Authenticate to your public cloud

Use your public cloud’s command line tool to authenticate to your cloud account. This allows Terraform to interact with your cloud account.
The following AWS command requests that you enter the following AWS credentials:
  • Access key ID
  • Secret access key
  • Default region
To create an access key ID and secret access key, refer to How IAM users can manage their own access keys in the AWS documentation.

Define a Terraform and cloud provider

After authenticating to your cloud account using the command line tool, create the following Terraform file.
The defined cloud provider automatically uses the credentials you defined when interacting with the cloud provider’s command line tool.

Define a MySQL instance

This step defines Terraform resources required in this tutorial for deploying the MySQL database. Create the following Terraform file.
  • Azure expects a globally unique MySQL Flexible Server name. If you experience a ServerNameAlreadyExists error when creating the resource, then use a unique name.
  • Public access to the database is for demonstration purposes only.

Deploy the MySQL instance

After defining the MySQL Terraform resource specific to your cloud provider, take the following steps to deploy the Terraform resources.
  1. Initialize the Terraform configuration.
  2. Create the MySQL instance.
Once the resources are successfully created, Terraform outputs the database address.

Add datasets to the database

To ingest datasets from the database into NexusOne, these datasets need to exist first. Take the following steps to add datasets to the database:
  1. Authenticate to the database using the mysql command line tool.
  2. Create a schema.
  3. Create a table inside the tutorial schema.
  4. Insert data into the table.
  5. View all rows in the test table.

Ingest the database into NexusOne

Now that a dataset is available on the MySQL database, you can ingest the database into NexusOne using the following steps:
  1. Log in to NexusOne.
  2. On the top navigation bar, hover your mouse over Data, and then select Ingest.
  3. Click New pipeline.
  4. In the Source step, select Database.
  5. Enter the connection details:
    • Engine: MySQL
    • Host: <database_address>, or <database_public_ip> on Google Cloud
    • Port: 3306
    • Database: tutorial
    • Username: mysqladmin
    • Password: NexusMySQL!
    • Port 3306 is MySQL’s default port number.
    • In MySQL, a database name is also a schema name.
  6. Click A table, and then enter tutorial.test in the Table field.
  7. Click Next.
  8. In the Preview and schema step, don’t add any column changes, click Next.
  9. In the Destination step, enter the following information in the fields:
    • Schema: mysql_schema
    • Table: mysql_table
    • Mode: Append
    • Pipeline name: ingest_database
    • Schedule: Once
  10. Click Next.
  11. In the Governance step, don’t add any tags or domain, click Next.
  12. In the Review step, click Create pipeline.

Monitor the pipeline

When you create the pipeline, NexusOne creates an Airflow job and opens the Ingest page, which lists your pipelines in a table. Since you set the pipeline to run once, as soon as it’s created, you can monitor the run using the following steps:
  1. On the Ingest page, click the All tab to show pipelines with any status.
  2. Select Mine to show only your pipelines.
  3. In the table, find your pipeline, ingest_database, and click it.
  4. On the pipeline’s page, click the Runs tab.
  5. Find the latest run in the list, and watch its status in the Result column.
  6. Wait for a few minutes and refresh your browser until the status in the Result column changes to Succeeded.

Visualize your dataset

Use the following steps to visualize your dataset:
  1. On the top navigation bar, hover your mouse over Platform, and then select Tools.
  2. On the Superset card, click SQL Lab to launch Superset’s SQL Lab.
  3. Enter the following command in the query box:
visualize-mysql-v4-1-2
Visualize your dataset

Delete the schema and Terraform resources

After completing the tutorial, delete the created schema and MySQL instance using the following steps:
  1. Delete the schema.
  2. Destroy the Terraform resources.

Additional resources

  • To get an overview of what database ingestion is, refer to Data ingestion overview.
  • For general instructions about how to ingest a database in NexusOne, refer to Ingest a database.
  • For more information about roles or permissions, refer to IAM.