Prepare Oracle RAC

To prepare for the migration of a Oracle Real Application Cluster (Oracle RAC) database to an Oracle Cloud Infrastructure server, you must perform multiple preparatory tasks before migration can start.

Add Entries for the Database Instances

Update the /etc/oratab file on the Oracle RAC nodes and add an entry for your database instance as follows:

  1. Use SSH to sign in to the first node of the source database (the primary database) to be migrated.
  2. Update /etc/oratab to add the database instance ID to the database entry by doing the following:
    1. Edit /etc/oratab:
      sudo vi /etc/oratab
    2. Add an entry for your database in the following format:
      $ORACLE_SID:$ORACLE_HOME:N
      Example for node 1:
      orcl1:/u01/app/oracle/product/12.1.0.2/dbhome_1:N
      Example for node 2:
      orcl2:/u01/app/oracle/product/12.1.0.2/dbhome_1:N
  3. Run the oraenv script to set environment variables of the database such as $ORACLE_HOME:
    . oraenv
  4. Repeat the previous steps for the second Oracle RAC node.

Ensure That the Database to be Migrated Is Running

Before you begin the migration process, you must check that the source database (the primary database) to be migrated is running.

  1. Use SSH to sign in to the server where the source database (the primary database) to be migrated is located.
  2. Sign in as the database software owner oracle.
    sudo su - oracle
  3. Execute the oraenv script, which sets the $ORACLE_HOME environment variable.
    . oraenv
  4. Go to the $ORACLE_HOME location.
    cd $ORACLE_HOME

    If the $ORACLE_HOME location has not been set, then use the oraenv script (located in the /usr/local/bin directory) to set the environment, including $PATH, so the lsnrctl and sqlplus commands can resolve without using full path names.

  5. Check the listener status.
    srvctl status listener
  6. If the listener is not running (for example, the output has error TNS-12541: TNS:no listener), then switch to OS user grid and start the listener.
    sudo su - grid  
    srvctl start listener
  7. Check that the database is running.
    sqlplus / as sysdba
    This command should connect you to the database instance and the SQL> prompt should appear.
  8. Check if the database is running in Read Write Mode
    SELECT NAME, OPEN_MODE FROM V$DATABASE;

    Output similar to the following appears:

    NAME              OPEN_MODE
    --------------    ---------
    source_db_name    READ WRITE
  9. Exit the SQL*Plus
    EXIT

Ensure That All Database Components on the Source Database Are Installed on the Target Database

You can find the components that are installed on the source database (the primary database) by querying the DBA_REGISTRY data dictionary view.

  1. Use SSH to sign in to the source database server.
  2. Sign in to SQL*Plus as an administrator user.
    For example:
    sqlplus sys / as sysdba
    Password: password
  3. Make a note of the version of the software that is displayed in the opening banner.
  4. Exit SQL*Plus.
    EXIT
  5. Use the opatch inventory command to find the latest patch set that has been applied.
    For example:
    $ORACLE_HOME/OPatch/opatch lsinventory
  6. Repeat these steps on the second node of the source database and both nodes of the target database (the standby database).
  7. The second node of the source database and both nodes of the target database should have the same or later versions installed.

Create a Standby Database for the Oracle Cloud Infrastructure System

You must create a standby database (the target database) on the Oracle Cloud Infrastructure, in addition to the database that is currently on this system. The creation process for creating this database creates a starter database during provisioning. Create the database system with the host name, shape, and CPU count that your site requires.

Generate SSH Key Pair

To gain local access to the tools, utilities and other resources on Oracle Cloud Infrastructure Virtual Machine Database system, you use Secure Shell (SSH) client software to establish a secure connection and log in as the user oracle or the user opc. To access the standby Virtual Machine Database system, using SSH, you have to use SSH key pair instead of a password to authenticate a remote user. A key pair consists of a private key and public key. You keep the private key on your computer and provide the public key every time you launch an instance. To create key pairs, you can use a third-party tool such as OpenSSH on UNIX-style systems (including Linux, Solaris, BSD, and OS X) or PuTTY Key Generator on Windows.

Create Virtual Cloud Network

When you work with Oracle Cloud Infrastructure, one of the first steps is to set up a virtual cloud network (VCN) for your cloud resources. Ensure that you have set up a VCN before creating a standby database. You can refer to Oracle Cloud Infrastructure documentation for more information on how to create a VCN.

Verify the Virtual Machine Database Shapes Supported by your Tenancy

When you sign up for Oracle Cloud Infrastructure, a set of service limits are configured for your tenancy. The service limit is the quota or allowance set on a resource. For example, your tenancy is allowed a maximum number of compute instances per availability domain. These limits are generally established with your Oracle account representative when you purchase Oracle Cloud Infrastructure.

When you create a standby Virtual Machine Database system, you have to ensure that the Virtual Machine database shape that you select, should closely map to the primary(source) instance. You also MUST ensure that the selected shape is supported by your tenancy.

Verify your tenancy limits and usage (by region):

Note:

If a given resource type has limits per availability domain, the limit and usage for each availability domain is displayed.
  1. Open the Oracle Cloud Services Dashboard. Open the User menu and click Tenancy: <your_tenancy_name>.
  2. Click Service Limits on the left side of the page.

    Your resource limits and usage for the specific region are displayed, broken out by service.

  3. Click on Database, and verify the Virtual Machine database shapes supported by your tenancy.

Your selection of the standby database shape should be a combination of shape that closely maps to primary(source) instance shape along with supported database shapes in your tenancy. Virtual Machine Database system is available in fixed data sizing shapes. Ensure that the shape chosen for creating database should be able to accommodate the source database plus any future sizing requirements. A thumb rule is to use a shape similar or higher in size than source database.

Create Standby Virtual Machine Database System

Note:

Ensure the database is created with the same parameters, such as character set, as the primary database (the source database).
  1. Login to your Oracle Cloud Services Dashboard
  2. Open the navigation menu. Under Services, click Database (NOT Database Classic).
  3. Under Database, click Bare Metal, VM, and Exadata.
  4. Select the compartment in which you want to work.
  5. Click Launch DB System.
  6. In the Launch DB System wizard, enter the following:
    1. DB System Information
      • Compartment: By default, the DB system launches in your current compartment and you can use the network resources in that compartment. Click the click here link in the dialog box if you want to enable compartment selection for the DB system, network, and subnet resources.
      • Display Name: A friendly, display name for the DB system. The name doesn't need to be unique. An Oracle Cloud Identifier (OCID) will uniquely identify the DB system.
      • Availability Domain: The availability domain in which the DB system resides.
      • Shape Type: Select Virtual Machine
      • Shape: The shape to use to launch the DB system. The shape determines the type of DB system and the resources allocated to the system. Choose the Virtual Machine Database Shape that you identified from the previous section.

      • Total Node Count: The number of nodes in the DB system. The number depends on the shape you select. You must specify 2.
      • Oracle Database Software Edition: The database edition supported by the DB system. Choose a database edition which is same or higher than the primary database.

      • Available Storage Size (GB): Enter a size with at least the same size as your primary (source) server.
      • License Type: The type of license you want to use for the DB system. Your choice affects metering for billing.

        • License included means the cost of the cloud service includes a license for the Database service.
        • Bring Your Own License (BYOL) means you are an Oracle Database customer with an Unlimited License Agreement or Non-Unlimited License Agreement and want to use your license with Oracle Cloud Infrastructure. This removes the need for separate on-premises licenses and cloud licenses.
      • SSH Public Key: The public key portion of the key pair you want to use for SSH access to the DB system. Use the public key that you generated in the previous section.
    2. Network Information
      • Virtual Cloud Network: The VCN in which to launch the DB system. Select the VCN that you created in the previous section.
      • Subnet Compartment: The compartment containing a subnet within the cloud network to attach the DB system to.
      • Client Subnet: The subnet to which the DB system should attach.

      • Hostname Prefix: Your choice of host name for the DB system. The host name must begin with an alphabetic character, and can contain only alphanumeric characters and hyphens (-).

        • The maximum number of characters allowed is 30. The host name must be unique within the subnet. If it is not unique, the DB system will fail to provision.

      • Host Domain Name: The domain name for the DB system. If the selected subnet uses the Oracle-provided Internet and VCN Resolver for DNS name resolution, this field displays the domain name for the subnet and it can't be changed. Otherwise, you can provide your choice of a domain name. Hyphens (-) are not permitted.

      • Host and Domain URL: Combines the host and domain names to display the fully qualified domain name (FQDN) for the database. The maximum length is 64 characters.
    3. Database Information
      • Database Name: The name for the database. The database name must begin with an alphabetic character and can contain a maximum of eight alphanumeric characters. Special characters are not permitted. Specify a name that is different from the primary database (the source database) name.
      • Database Version: The version of the initial database created on the DB system when it is launched. After the DB system is active, you can create additional databases on it. You can mix database versions on the DB system, but not editions.
      • PDB Name: Omit this setting because the pluggable database (PDB) will be created later on, when you perform the Oracle RMAN duplicate step.
      • Database Admin Password: Enter the same SYS password that is used for the primary database (the source database). It should be a strong password for SYS, SYSTEM, TDE wallet, and PDB Admin. The password must be 9 to 30 characters and contain at least 2 uppercase, 2 lowercase, 2 numeric, and 2 special characters. The special characters must be _, #, or -. The password must not contain the username (SYS, SYSTEM, and so on) or the word "oracle" either in forward or reversed order and regardless of casing. (If the primary database SYS password does not fit this requirement, then you can change it after you complete these settings.)

      • Confirm Database Admin Password: Re-enter the Database Admin Password you specified.
      • Automatic Backup: Check the check box to enable automatic incremental backups for this database.
      • Database Workload: Select the workload type that best suits your application.

        • Online Transactional Processing (OLTP) configures the database for a transactional workload, with a bias towards high volumes of random data access.
        • Decision Support System (DSS) configures the database for a decision support or data warehouse workload, with a bias towards large data scanning operations.
      • Character Set: The character set for the database. The default is AL32UTF8.
      • National Character Set: The national character set for the database. The default is AL16UTF16.
      • Tags: Optionally, you can apply tags. If you have permissions to create a resource, you also have permissions to apply free-form tags to that resource. To apply a defined tag, you must have permissions to use the tag namespace. For more information about tagging, see Resource Tags. If you are not sure if you should apply tags, skip this option (you can apply tags later) or ask your administrator.
  7. Click Launch DB System. The DB system appears in the list with a status of Provisioning. The DB system's icon changes from yellow to green (or red to indicate errors).
  8. Wait for the DB system's icon to turn green, with a status of Available, and then click the highlighted DB system name. Details about the DB system are displayed.
  9. Note the IP addresses; you'll need the private or public IP address, depending on network configuration, to connect to the DB system.
  10. Check the SYS password on the primary (source) database. If it does not meet the Oracle Cloud Infrastructure password requirements, then change it to match the password that you created for the standby database (the target database).

Ensure That Port 1522 and 1521 Is Open Between the Primary Database and the Standby Database

You must ensure that port 1522 is open on the primary database (the source database) and port 1521 on the standby database (the target database) to allow the databases to connect.

Enable Communication from the Oracle Cloud Infrastructure System to the Oracle Cloud Infrastructure Classic System

On the Oracle Cloud Infrastructure Classic system, you must open port 22 and 1522 for ingress traffic from the Oracle Cloud Infrastructure virtual machine system.

Configure the Standby Database to Primary Database Communication Settings in the Oracle Cloud My Services Console

You can use the Oracle Cloud My Services console to configure the first part of the communication settings.

  1. Sign in to My Services console.
  2. From the Dashboard, click Database Classic.
  3. On Service: Oracle Database Cloud Service, click Open Service Console, in the right-hand side of the page.
  4. From the img/action_menu.png menu for your database deployment, select Access Rules.
    The Access Rules page is displayed.
  5. Locate the ora_p2_dblistener rule to enable ingress traffic on port 1522 from the public internet.
  6. From the img/action_menu.png menu for the located rule, select Enable.
    The Enable Access Rule window is displayed.
  7. Click Enable.
    The Enable Access Rule window closes and the rule is displayed as enabled in the list of rules. The given port on the compute node is opened to the public internet.
  8. Create the source-db-ssh rule to open ingress traffic on port 22 from the public internet.
    if port 22 is not already open add this access rule.
    In the "Create Access Rule" wizard enter the following information:
    1. Rule Name: source-db-ssh
    2. Source: PUBLIC-INTERNET (select from drop down menu)
    3. Destination: The database name from the drop down menu
    4. Destination Port(s): 22
    5. Protocol: TCP (select from drop down menu)
  9. Click Create.
  10. Set Status to Enabled.
  11. Use SSH to sign in to the server where the standby database (the target database) is located.
  12. Test SSH on port 22 from the Oracle Cloud Infrastructure system to the Oracle Database Cloud Service system.
    Port 22 on the Oracle Database Cloud Service system is open by default from the public internet.
    1. Transfer the SSH private key to the /home/opc/.ssh directory by using a secure file transfer utility such as SCP.
    2. As the Oracle Cloud Infrastructure opc user, test SSH by running the following command. In this example, the private key is named privateKey:
      ssh -i /home/opc/.ssh/privateKey opc@source_ip
Complete the Oracle Cloud Infrastructure to Oracle Cloud Infrastructure Classic Communication Settings on the Command Line

You must set a TCP socket size, edit the etc/host file, and update the tnsnames.ora file on the primary database (the source database).

  1. SSH to the first node of the primary database (the source database)
  2. Connect as root.
    sudo su -
  3. (Optional) Set the TCP socket size. For example:
    sysctl -w net.core.rmem_max=10485760 
    sysctl -w net.core.wmem_max=10485760

    Note:

    The TCP socket size is set to increase performance during the migration. This setting may not be ideal for production databases.
  4. Connect as the oracle user.
    su - oracle
  5. Execute the oraenv script, which sets the $ORACLE_HOME environment variable.
    . oraenv
  6. On both Oracle RAC nodes, in the $ORACLE_HOME/network/admin/tnsnames.ora file on the primary database (the source database) on Oracle Cloud Infrastructure Classic, add a TNS entry similar to the following:

    Note:

    Replace source_node1_ip, source_node2_ip, source_server_name with the parameters of the primary database (the source database). Replace target_node1_ip,target_node2_ip, target_server_name with the parameters of the standby database (the target database).
    MIGRAC_OCIC_s1 =
      (DESCRIPTION =
        (ADDRESS_LIST=
          (ADDRESS = (PROTOCOL = TCP)(HOST = source_node1_ip)(PORT = 1522))
          (ADDRESS = (PROTOCOL = TCP)(HOST = source_node2_ip)(PORT = 1522))
        )
        (CONNECT_DATA =
          (UR=A)
          (SERVER = DEDICATED)
          (SERVICE_NAME = source_service_name)
        )
      )
      
    MIGRAC_OCI_s2 =
      (DESCRIPTION =
        (ADDRESS_LIST=
          (ADDRESS = (PROTOCOL = TCP)(HOST = target_node1_ip)(PORT = 1521))
          (ADDRESS = (PROTOCOL = TCP)(HOST = target_node2_ip)(PORT = 1521))
        )
        (CONNECT_DATA =
          (UR=A)
          (SERVER = DEDICATED)
          (SERVICE_NAME = target_service_name)
        )
      )
    

    Note:

    (UR=A) is optional for RAC.
  7. Test the SQL*Plus connect from the standby database (the target database) system to the primary database (target database) on port 1521.
    sqlplus sys@migrac_oci_s2 as sysdba
    Enter password: password
    
    SQL> SELECT NAME FROM V$DATABASE;
  8. Exit SQL*Plus.
    exit
  9. Repeat these steps on the second node of the primary database (source database).

Enable Communication from the Oracle Cloud Infrastructure Classic System to the Oracle Cloud Infrastructure System

On the Oracle Cloud Infrastructure Database system, you must open ports 22 and 1521 for ingress traffic from the Oracle Cloud Infrastructure Classic system.

Configure the Oracle Cloud Infrastructure Classic to Oracle Cloud Infrastructure Communication Settings in the Oracle Cloud Infrastructure Console

You can use the Oracle Cloud Infrastructure console to configure the first part of the communication settings.

  1. Make a note of the public IP address of the Oracle Cloud Infrastructure Classic server.
  2. Sign in to the Oracle Cloud Infrastructure console.
  3. On the left side of the page, select your compartment, and then select the Networking tab at the top of the page.
  4. On the Virtual Cloud Networks in the Compartment page, select the name of your network.
  5. On the page that is labeled with the network name, select Security Lists from the left navigation pane.
  6. On the Security Lists page, select the list that you want to view.
  7. On the Security_list_name Security List for network_name page, click Edit all rules.
  8. Scroll to find the rule that you want to change, or click Add Rule for either the Ingress or Engress rule.
  9. Update the database system security list to the Oracle Cloud Infrastructure Classic server public IP that you obtained in the first step.
    By default, port 22 for SSH is enabled on Oracle Cloud Infrastructure systems for traffic from the public internet.
    1. Set SOURCE CIDR to the IP address on the Oracle Cloud Infrastructure Compute Classic server.
    2. Set IP PROTOCOL to TCP.
    3. Set SOURCE PORT RANGE to ALL.
    4. Set DESTINATION PORT RANGE to 1521.
Complete the Oracle Cloud Infrastructure Classic to Oracle Cloud Infrastructure Communication Settings on the Command Line

You must edit the $ORACLE_HOME/network/admin/tnsnames.ora file, set the TCP socket size on the standby database (the target database).

  1. SSH to the first node of the standby database (the target database).
  2. On the standby database (the target database), connect as the database software owner oracle.
    sudo su - oracle
  3. Execute the oraenv script, which sets the $ORACLE_HOME environment variable.
    . oraenv
  4. On both nodes, in the $ORACLE_HOME/network/admin/tnsnames.ora file on the Oracle Cloud Infrastructurevirtual machine system, add a TNS entry for each of the two databases:
    In this example, the primary database TNS name is OCIC-ORCL and the standby database TNS name is OCI-ORCL.

    Note:

    Replace source_node1_ip, source_node2_ip, source_server_name with the parameters of the primary database (the source database).

    Replace target_node1_ip, target_node2_ip, target_server_name with the parameters of the standby database (the target database)

    MIGRAC_OCIC_s1 =
      (DESCRIPTION =
        (ADDRESS_LIST=
          (ADDRESS = (PROTOCOL = TCP)(HOST = source_node1_ip)(PORT = 1522))
          (ADDRESS = (PROTOCOL = TCP)(HOST = source_node2_ip)(PORT = 1522))
        )
        (CONNECT_DATA =
          (UR=A)
          (SERVER = DEDICATED)
          (SERVICE_NAME = source_service_name)
        )
      )
      
    MIGRAC_OCI_s2 =
      (DESCRIPTION =
        (ADDRESS_LIST=
          (ADDRESS = (PROTOCOL = TCP)(HOST = target_node1_ip)(PORT = 1521))
          (ADDRESS = (PROTOCOL = TCP)(HOST = target_node2_ip)(PORT = 1521))
        )
        (CONNECT_DATA =
          (UR=A)
          (SERVER = DEDICATED)
          (SERVICE_NAME = target_service_name)
        )
      )
  5. Use SQL*Plus to test connection from the Oracle Cloud Infrastructure system to the Oracle Cloud Infrastructure Classic database on port 1521.
    sqlplus sys@migrac_orcl_s2 as sysdba
    Enter password: password
    (At this stage, any SQL statements you execute will fail because the standby database has not been fully configured yet.)
  6. At the command line, connect as root.
    sudo su -
  7. (Optional) On both nodes, set the TCP socket size.For example:
    sysctl -w net.core.rmem_max=10485760 
    sysctl -w net.core.wmem_max=10485760

    Note:

    The TCP socket size is set to increase performance during the migration. This setting may not be ideal for production databases.
  8. Repeat these steps on the second node of the standby database (target database).

Ensure That Bundle Patches Have Been Applied and Are in Sync

Ensure that the patch level on the primary database (the source database) Oracle Cloud Infrastructure Classic system is earlier or the same as the patch level on the standby database (the target database) Oracle Cloud Infrastructure system.

  1. Use SSH to sign in to the first node of the primary database (the source database).
  2. Check the patch level on the primary database as follows:
    1. To find a brief listing of patches:
      $ORACLE_HOME/OPatch/opatch lspatches
    2. To find a detailed listing of patches:
      $ORACLE_HOME/OPatch/opatch lsinventory
  3. Make a note of the patch level.
  4. Repeat steps 1 to 3 for the second node of the primary database (the source database).
  5. Use SSH to sign in to the nodes of the standby database (the target database).
  6. Check the patch level on the nodes of the standby database by running the opatch lsinventory command.
  7. Compare the patch levels of the nodes of the databases. Ensure that the standby system has a bundle patch that is either equal to or later than the bundle patch that is on the primary database.
  8. If you must install a later patch on the standby database (the target database), then access My Oracle Support: https://support.oracle.com/
  9. Download the correct version of the patch to the standby database (the target database).
  10. Extract the bundle patch.
  11. List the available patches.
    $ORACLE_HOME/OPatch/opatch lspatches
  12. Apply the patch.
    $ORACLE_HOME/OPatch/opatch apply patch_number