Exporting and Importing a Database

The TimesTen Scaleout export and import functionality enables you to migrate data between two grid databases.

In these circumstances you must export a database:

  • The source database is from a version of TimesTen Scaleout that patch incompatible, such as from a different major release. See Upgrading a Grid for more information on both types of upgrades (patch-compatible or otherwise).

  • The destination database is in a grid topology that has fewer replica sets than the grid topology where the database is exported.

When you export a database, TimesTen Scaleout performs the export asynchronously of each replica set and creates a sub-collection for each replica set that is exported.

See Determining the Size of a Backup or Export for information on the file system space each export operation requires.

TimesTen Scaleout enables you to perform the following procedures with database exports:

Export a Database

Before attempting to export a database, ensure that you have configured a repository for your grid. See Working with Repositories.

Ensure that you disconnect all application connections to the database before performing a database export to ensure that no applications are modifying data during the database export operation. Also, ensure that you close the database to prevent any new connections to the database. Any transaction committed during an export operation may result in an inconsistent database.

This example creates a database export of the database database1 and stores that export in the repository repo1. By default, TimesTen Scaleout names your database export with the current date and time, Myyyymmddhhss. Ensure that you run the ttGridAdmin dbExport command on a management instance.

Note:

You can add the -name parameter to specify a database export name. For example, ttGridAdmin dbExport database1 -repository repo1 -name myexport creates a database export named myexport.

% ttGridAdmin dbExport database1 -repository repo1
dbExport M20170302144218 started

Depending on the size of your database, the number of replica sets that your database uses, the performance of your secondary storage device, and the performance of your network the database export time varies. Use the ttGridAdmin dbExportStatus command to see the status of your database export. See Check the Status of a Database Export.

For more information about the ttGridAdmin dbExport command, see Export a Database (dbExport) in Oracle TimesTen In-Memory Database Reference.

Check the Status of a Database Export

The ttGridAdmin dbExportStatus command enables you to view the progress of all database export processes for a specific database.

This example displays the status of all database export processes for the database database1.

% ttGridAdmin dbExportStatus database1
Database  Export          Repository Host  Instance  Elem State     Started
--------- --------------- ---------- ----- --------- ---- --------- ------------------------
database1 M20170321073022 repo1                           Completed 2017-03-21T07:30:27.000Z
                                     host3 instance1      Complete
                                     host6 instance1      Complete

Ensure that the ttGridAdmin dbExportStatus output shows that a database export has been completed for every replica set of your grid. In case that you see a state value of Failed for an element, perform these tasks:

  • Use the ttGridAdmin dbStatus database1 -details command to ensure that the host and instance of that element are up and running. See Monitor the Status of a Database (dbStatus) in Oracle TimesTen In-Memory Database Reference.

  • Ensure that the repository where you are attempting to create the backup has enough free file system space to create a backup of your database.

After you have resolved the issues that caused the export to fail, use the ttGridAdmin dbExportDelete to delete the failed database export. TimesTen Scaleout does not automatically delete a failed database export. Then, use the ttGridAdmin dbExport command to start a new database export. See Delete a Database Export and Export a Database.

For more information about the ttGridAdmin dbExportStatus command, see Display the Status of a Database Export (dbExportStatus) in Oracle TimesTen In-Memory Database Reference.

Delete a Database Export

TimesTen Scaleout does not automatically delete database exports. In some cases, you may want to delete database exports that have failed or old database exports to free up file system space.

Use the ttGridAdmin repositoryList -contents command to view all of your available database exports and their respective repositories. See List Repositories and Collections.

This example deletes the database export named M20170321073022 from repository repo1.

% ttGridAdmin dbExportDelete -repository repo1 -name M20170321073022
Export M20170321073022 deleted

TimesTen Scaleout deletes all of the sub-collections that are part of the database export.

For more information about the ttGridAdmin dbExportDelete command, see Delete a Database Export (dbExportDelete) in Oracle TimesTen In-Memory Database Reference.

Import a Database Export

Before attempting to import a database export, consider the following:

  • The database to which you import must exist when you attempt to perform a database import. The database can either contain data or be empty. It is not necessary to create the users or tables of the original database. If the database contains data, create a database backup before performing a database import.

  • The database name of the database that you exported does not need to match the database name of the database where you are importing the database export. For example, you can import a database export of the payroll database in the new_payroll database.

  • The K-safety value of the database that you exported does not need to match the K-safety value of the grid where you are importing the database export.

  • Ensure that you disconnect all application connections to the database before performing a database import to ensure that no applications are modifying data during the database import operation. Also, ensure that you close the database to prevent any new connections to the database. Any transaction committed during an import operation may result in an inconsistent database. See Close a Database (dbClose) in Oracle TimesTen In-Memory Database Reference.

This example imports the database import_db from the database export M20170321073022 from repository repo1. Ensure that you run the ttGridAdmin dbImport command on a management instance.

% ttGridAdmin dbImport import_db -repository repo1 -name M20170321073022 -numThreads 8
dbImport M20170321073022 started

Note:

Ensure that the import_db database exists before attempting to perform a restore. See Create a Database Definition.

Depending on the size of your database export, the number of replica sets that your database uses, the performance of your secondary storage device, and the performance of your network the import time varies. To increase the performance of the import operation, use the -numThreads option to specify the number threads that concurrently read rows from the export database and insert them into the import database. Use the ttGridAdmin dbExportStatus command to see the status of your database export. See Check the Status of a Database Import.

For more information about the ttGridAdmin dbImport command, see Import a Database (dbImport) in Oracle TimesTen In-Memory Database Reference.

Check the Status of a Database Import

The ttGridAdmin dbImportStatus command enables you to view the progress of the import process for a specific database.

This example displays the status of all import processes for the database import_db.

% ttGridAdmin dbImportStatus import_db
Database  Import          Repository Host  Instance  Elem State                  Started
--------- --------------- ---------- ----- --------- ---- ---------------------- -------------
import_db M20170321073022 repo1                           Import_Finale_Complete 2017-03-21...
                                     host3 instance1 1    Import_Rows_Complete
                                     host6 instance1 4    Import_Rows_Complete

Ensure that the ttGridAdmin dbImportStatus output shows that the import operation has been completed for every element of your grid. The import operation is fully completed when the State column of the row with the database name is marked as Import_Finale_Complete.

By default, if the import operation encounters an error, the operation terminates and gets a Import_Phase_Failed state. To retry the import, first you need to either drop all the SQL objects created by the failed import operation or destroy and recreate the database. Then, attempt the import operation again.

However, for import operations where errors are expected (like importing a database export from a newer TimesTen release with unsupported SQL objects), the -errorTolerance option of the ttGridAdmin dbImport command can be set to complete the import operation while ignoring all errors. If an error is encountered, the operation completes and gets a Import_Complete_With_Errors state. The errors encountered are listed in the daemon logs of the data instances. See Import a Database (dbImport) in Oracle TimesTen In-Memory Database Reference.

For more information on the ttGridAdmin dbImportStatus command, see Display the Status of a Database Import (dbImportStatus) in Oracle TimesTen In-Memory Database Reference.