This topic describes how to periodically collect SQL information in an Oracle database and analyze the collected SQL information.

Prerequisites

The engine version of the Oracle database is 10g, 11g, or 12c.

Background information

Periodic SQL collection allows you to specify a custom collection period for an Oracle database and merge the collected SQL information.
Note You can perform periodic SQL collection only by using an offline collector. Therefore, you must collect the SQL information of your Oracle database by yourself first. For more information, see the "Collect SQL information" section of this topic.

Workflow

  1. Collect SQL information.
    Note You can perform periodic SQL collection only by using an offline collector.
  2. Analyze the collected SQL information.
    Note You can create a periodic collection project and upload the collected data file. Then, the system automatically merges and analyzes the collected SQL information. For more information, see the "Analyze the collected SQL information" section of this topic.

Collect SQL information

  1. Download a database collector.
    1. Log on to the Data Management (DMS) console V5.0.
    2. In the top navigation bar, move the pointer over DTS. Choose Heterogeneous Database Migration(ADAM) > Migration Lab.
    3. In the Periodic SQL Collection section, click Download.
    4. On the Download Database Collector page, click Download in the Download Database Collector section.
    5. Select a database collector version. In the dialog box that appears, read the agreement and click Agree.
      Note
      • The database collector must meet the following runtime environment requirements:
        • The host of the database collector is accessible to the source Oracle database. The database collector is not necessarily installed on the host of the source Oracle database.
        • The memory is larger than 6 GB and the disk space is larger than 50 GB.
      • When the source database schema is collected, the database collector automatically masks the sensitive data.
      • When the source database schema is collected, the database collector automatically monitors the load of the destination database. If the load exceeds a specific limit, the collection is automatically suspended. After the load decreases below the limit, the collection resumes.
  2. Log on to the source Oracle database. Use an account with SYSDBA permissions to create a temporary account and grant permissions to the temporary account.
    Note
    • If you already have an account with the following permissions, skip this step.
    • The following permissions are used to connect to the Oracle database. If you have these permissions, you can collect, mask, and export database information.
    • If the engine version of the source Oracle database is 10g, 11g, or 12c, create a local user in a non-CDB architecture.
      -- Create an account named eoa_user and set the password to eoaPASSW0RD.
      create user eoa_user identified by "eoaPASSW0RD" default tablespace users;
      -- Grant query permissions.
      grant connect,resource,select_catalog_role,select any dictionary to eoa_user;
      -- Grant the DBMS_LOGMNR permission. 
      -- If the engine version of the source Oracle database is 10g, execute the following statement first:
      CREATE OR REPLACE PUBLIC SYNONYM dbms_logmnr FOR sys.dbms_logmnr;
      grant execute on DBMS_LOGMNR to eoa_user;
      -- Grant the DBMS_METADATA permission.
      grant execute on dbms_metadata to eoa_user;
      -- Grant permissions to query transactions.
      grant select any transaction to eoa_user;
      -- Grant permissions to analyze tables.
      grant analyze any to eoa_user;
      -- Grant permissions to generate random numbers.
      grant execute on dbms_random to eoa_user;
    • If the engine version of the source Oracle database is 12c, connect to an Oracle 12c container database (CDB) to create a common user.
      create user c##eoa_user identified by "eoaPASSW0RD" default tablespace users;
      grant connect,resource,select_catalog_role,select any dictionary to c##eoa_user container=all;
      grant execute on DBMS_LOGMNR to c##eoa_user container=all;
      grant execute on dbms_metadata to c##eoa_user container=all;
      grant select any table to c##eoa_user container=all;
      grant select any transaction to c##eoa_user container=all;
      grant analyze any to c##eoa_user container=all;
      grant execute on dbms_random to c##eoa_user container=all;
      alter user c##eoa_user set container_data=all container=current;
  3. Start collection. In the Windows environment, run a .bat file. In the Linux environment, run an .sh file. In this example, the Linux environment is used.
    • If the engine version of the source Oracle database is 10g or 11g, run one of the following commands:
      sh collect_10g_cycle.sh -h <ip> -u <username> -p <password> -d <service_name> -c <cron>
      sh collect_11g_cycle.sh -h <ip> -u <username> -p <password> -d <service_name> -c <cron>
      ouput
    • If the engine version of the source Oracle database is 12c, run the following command:
      sh collect_12c_cycle.sh -h <ip> -u <username> -p <password> -d <service_name> -s <sid> -c <cron>
      output1
    Note Parameter description:
    • -h: required. The IP address of the source database.
    • -u: required. The database account that performs the collection.
    • -p: required. The password of the database account.
    • -d: required. The service name of the source database.
    • -s: required only for Oracle 12c databases. The ID of the instance in which the source database is created.
    • -c: required. A cron expression that is used to specify the period of collection. Format: second minute hour day month week [year].

    Periodic collection works at an interval specified by a cron expression. The following table describes some examples of common cron expressions. You can stop collection by terminating the collection process at any time.

    Expression Description
    0 */1 * * * ? Collects data every 1 minute.
    0 0 5-15 * * ? Collects data between 5:00 and 15:00 on the hour every day.
    0 0/3 * * * ? Collects data every 3 minutes.
    0 0-5 14 * * ? Collects data every 1 minute between 14:00 and 14:05 every day.
    0 0/5 14 * * ? Collects data every 5 minutes between 14:00 and 14:55 every day.
    0 0/5 14,18 * * ? Collects data every 5 minutes from 14:00 to 14:55 and from 18:00 to 18:55 every day.
    0 0/30 9-17 * * ? Collects data every 30 minutes between 9:00 and 17:00 every day.
    0 0 10,14,16 * * ? Collects data at 10:00, 14:00, and 16:00 every day.
    0 0 12 ? * WED Collects data at 12:00 every Wednesday.
    0 0 17 ? * TUES,THUR,SAT Collects data at 17:00 every Tuesday, Thursday, and Saturday.
    0 10,44 14 ? 3 WED Collects data at 14:10 and 14:44 every Wednesday in March every year.
    0 15 10 ? * MON-FRI Collects data at 10:15 from Monday to Friday.
    0 0 23 L * ? Collects data at 23:00 on the last day of every month.
    0 15 10 L * ? Collects data at 10:15 on the last day of every month.
    0 15 10 ? * 6L Collects data at 10:15 on the last Friday of every month.
    0 15 10 * * ? 2021 Collects data at 10:15 every day in 2021.
    0 15 10 ? * 6L 2021-2025 Collects data at 10:15 on the last Friday of every month from 2021 to 2025.
    0 15 10 ? * 6#3 Collects data at 10:15 on the third Friday of every month.
  4. Export the collection results.
    After the collection is complete, you are prompted that a compressed file is generated. Sample log file:
    [***] ******************************************************************
    [***] *     Collect Successfully!
    [***] *
    [***] * Complete the file packaging, the package result path is: 
    [***] *        ~rainmeter/out/data.zip ******************************************************************

Analyze the collected SQL information

  1. Log on to the Data Management (DMS) console V5.0.
  2. In the top navigation bar, move the pointer over DTS. Choose Heterogeneous Database Migration(ADAM) > Migration Lab.
  3. On the Migration Lab page, click Details in the Periodic SQL Collection section.
  4. Click Create Project.
  5. In the Create Project panel, specify Project Name and set Type to Oracle. Then, Click Upload and select the generated out/data.zip file.
  6. Click Create.
  7. Find the project and click Details in the Actions column to view the collection results.
    Note You can click View in the Destination SQL column to view the error analysis of a specific SQL information.