Skip to content

Import data#

There are at least four methods to import data into RonDB. A very efficient method exists by using CSV files as input. CSV files can be produced by most DBMS and in particular MySQL can produce it either using mysqldump or using SELECT .... INTO OUTFILE ’file.name’.

Backup files produced by RonDB is a second method to import data into RonDB, this is often used in conjunction with replication between clusters. Of course also when restoring a backup that will be covered in more detail in a later chapter.

A third method is to use a dump produced by mysqldump or mysqlpump. mysqldump and mysqlpump produces a file full of SQL statements (mysqldump can dump data both in SQL format and in CSV format).

Next one can alter a table to become an RonDB table if the data is moved from e.g. InnoDB in a MySQL Server already connected to the cluster.

Importing metadata#

If the data is imported from another DBMS then the tables and databases must be manually created in RonDB before starting the import.

If we import the data from another MySQL database using InnoDB or other storage engine we can use the following commands to create the RonDB table for the import.

CREATE DATABASE rondb_db;
USE rondb_db;
CREATE TABLE ndb_table LIKE mysql_db.mysql_table;
ALTER TABLE ndb_table ENGINE=NDB;

First ensure that the database to be used by the new RonDB tables are created. Next create an empty table with the same table definition as the table we are importing in this database. Finally convert this table into an RonDB table. We should make any necessary changes to the table definition in the ALTER TABLE command to suite your RonDB installation.

If data is to be transported from one MySQL installation to another the most natural program to use for importing the MySQL tables and databases is the mysqldump command.

mysqldump --no-data --databases db_name > db_name.sql

The above command will write all table definitions and the database definition into a dump file. The --no-data option means that no rows from the table will be dumped, only the CREATE TABLE and CREATE DATABASE commands.

To install these tables into the RonDB installation simply use the MySQL client like this:

mysql < db_name.sql

After executing this command it is still necessary to perform an ALTER TABLE command on each table to convert them into RonDB tables.

ndb_restore using Backups#

ndb_restore is a tool that have existed since version 2.1 of NDB Cluster. It is the complement of the feature in RonDB to backup its data. It takes the backup files as input and uses the data files and log files to restore the database content using an API program. Several ndb_restore instances can operate in parallel to restore the data. There is one backup file per node per LDM. With 4 nodes and 4 LDMs per node there will be 16 backup files. More information on how to use this tool in the chapter on restore.

Importing from mysqldump files#

The dump produced by mysqldump contains files full of SQL statements. To import the data from a dump one simply pipes the dump file to the mysql client program that will then execute one SQL statement at a time.

This will become a single-threaded approach to importing and is thus likely to take a very long time. One approach to this is to split the data file into multiple files. This can be accomplished with a fairly simple shell script. After that one restores using those files in parallel.

Alter Table#

If the export is from the same MySQL Server as the import is done into we can use ALTER TABLE to convert from one storage engine to another. It is one command per table.

mysqlimport#

mysqlimport is another tool that can be used for importing data into RonDB.