Monday, April 17, 2023

Migrating from Oracle 19c to Postgres



Migrating from Oracle 19c to Postgres involves a number of steps. Here's a rough outline of the process along with some commands you can use:

  1. Install Postgres on the target server.

  2. Create a new database in Postgres:

    createdb mynewdatabase
  3. Install the Ora2Pg tool on the source server:

    arduino
    sudo apt-get install ora2pg
  4. Generate the Ora2Pg configuration file:

    css
    ora2pg --init_project myproject
  5. Edit the configuration file to match your Oracle database:

    bash
    vi myproject/ora2pg.conf
  6. Convert the Oracle database schema to Postgres:

    bash
    ora2pg -t EXPORT_SCHEMA -c myproject/ora2pg.conf -o schema.sql
  7. Convert the Oracle database data to Postgres:

    bash
    ora2pg -t EXPORT -c myproject/ora2pg.conf -o data.sql
  8. Transfer the schema and data files to the target server.

  9. Load the schema and data into Postgres:

    graphql
    psql mynewdatabase < schema.sql psql mynewdatabase < data.sql
  10. Verify that the data has been migrated correctly.

  11. Update any application code that accesses the database to use Postgres instead of Oracle.

Note that this is a high-level overview and there may be additional steps or variations depending on the specific needs of your migration. It's also important to thoroughly test the new system before cutting over to it in production.



Looking forward for your suggestions.. please feel free to write to me.. Your help would definitely help to improve our blog. Chetan Yadav

Sunday, April 16, 2023

Restarting PDB in Oracle RAC Database: A Step-by-Step Guide


Restarting PDB in Oracle RAC Database: A Step-by-Step Guide




Introduction

Oracle Real Application Clusters (RAC) is a clustered version of Oracle Database that provides high availability and scalability capabilities for large-scale database systems. Restarting the Pluggable Database (PDB) in an Oracle RAC environment requires multiple steps, which can be time consuming and difficult to manage. This step-by-step guide will provide an overview of the restart PDB process and discuss how RAC can benefit large-scale database deployments. The guide will outline each step required for restarting the PDB, including closing, opening, and verifying its status. Additionally, troubleshooting techniques will be addressed if any issues arise during the restart process. By following this comprehensive guide users should have a better understanding of how to properly manage their PDBs in their Oracle RAC environment.

Step 1: Close the PDB

Step 1: Close the PDB

In order to restart a Pluggable Database (PDB) in an Oracle Real Application Clusters (RAC) environment, it must first be closed. This can be accomplished using the ALTER PLUGGABLE DATABASE command with the CLOSE option. This command will close all user sessions and terminate any active transactions on the PDB prior to closing it completely. It is important that users take note of any open transactions or processes running on their database before attempting this step as they may need to be manually terminated beforehand.

Once the ALTER PLUGGABLE DATABASE command has been executed, users should check the STATUS column of V$ DATABASE view to confirm that their PDB is now in MOUNTED state after being closed properly. Additionally, they can query V$ PDBS view and check OPEN_MODE column status for their particular PDB instance which should reflect ‘READ ONLY’ mode indicating successful closure of the PDB instance.

Step 2: Open the PDB

In order to open a Pluggable Database (PDB) that has been closed in an Oracle Real Application Clusters (RAC) environment, the ALTER PLUGGABLE DATABASE command with the OPEN option should be used. This will initiate the opening of all user sessions and any active transactions on the PDB prior to fully opening it up for normal operations. It is important that users take note of any open transactions or processes running on their database before attempting this step as they may need to be manually terminated beforehand.

After issuing the ALTER PLUGGABLE DATABASE command, users should check the STATUS column of V$ DATABASE view to confirm that their PDB is now in READ WRITE state after being opened properly. Additionally, they can query V$ PDBS view and check OPEN_MODE column status for their particular PDB instance which should reflect ‘READ WRITE’ mode indicating successful closure of the PDB instance.

Once both steps are complete, users must verify status by querying V$ DATABASE and checking STATUS field which should display ‘ACTIVE’ if everything went according to plan during restart process indicating proper closing and reopening of PDB from RAC environment

Step 3: Verifying the PDB is Open

Once the open process has been completed, users must verify that their Pluggable Database (PDB) is properly opened within the Oracle Real Application Clusters (RAC) environment. This can be accomplished by querying V$ DATABASE view and checking the STATUS column which should display ‘ACTIVE’ indicating proper closure and reopening of PDB from RAC environment. Additionally, they can query V$ PDBS view and check OPEN_MODE column status for their particular PDB instance to ensure it reflects ‘READ WRITE’ mode as expected.

Moreover, verifying database access is recommended after restarting a PDB in order to ensure all user sessions have been successfully reopened with no errors or unexpected issues. Users may use an SQL script or other tool such as TOAD to check database connections after restarting the PDB in RAC environment; if necessary, any inactive sessions should then be terminated manually before proceeding with further operations on database system.

STEPS :

  1. Connect to the CDB (Container Database) as a privileged user: sqlplus / as sysdba

  2. Determine the name of the PDB that you want to restart: SELECT name FROM v$pdbs;

  3. Switch to the PDB that you want to restart: ALTER SESSION SET CONTAINER=<PDB_NAME>;

  4. Check the current status of the PDB: SELECT name, open_mode FROM v$pdbs WHERE name='<PDB_NAME>';

  5. If the PDB is currently open, close it: ALTER PLUGGABLE DATABASE <PDB_NAME> CLOSE;

  6. Wait for the PDB to close: SELECT name, open_mode FROM v$pdbs WHERE name='<PDB_NAME>';

  7. Once the PDB is closed, restart it: ALTER PLUGGABLE DATABASE <PDB_NAME> OPEN;

  8. Check the status of the PDB to confirm that it has been restarted: SELECT name, open_mode FROM v$pdbs WHERE name='<PDB_NAME>';

Troubleshooting

Troubleshooting PDB Opening Errors

If users encounter errors when attempting to open a Pluggable Database (PDB) in an Oracle Real Application Clusters (RAC) environment, they should first investigate the cause of the issue. This can be accomplished by querying V$ DATABASE view and checking STATUS field for their particular PDB instance which will help identify any issues related to database state prior to restarting process. If necessary, users may also need to query V$ SESSION or other dynamic views such as GV$ SESSION and check CURRENT_USER column status which would indicate if there are any user sessions still connected or active in their PDB instance that needs to be manually terminated before proceeding with opening process again.

Options to Resolve PDB Opening Issues

Once the root cause of any potential issue has been identified, users must then determine how best to resolve it so that they can successfully open their Pluggable Database (PDB) in Oracle Real Application Clusters (RAC) environment. Some common solutions include manually terminating any inactive user sessions through SQL commands or tools like Toad; performing a recovery operation on failed transactions due to abnormal termination; and restarting RAC nodes hosting affected databases if applicable. It is important that these steps are taken carefully as incorrect configurations may lead further complications during restart process; thus, consulting with an experienced DBA professional beforehand is highly recommended for large-scale database systems.

Conclusion

In conclusion, the restart PDB process in an Oracle Real Application Clusters (RAC) environment is a complex and time-consuming task. However, with careful planning and execution it can provide numerous benefits to large-scale database deployments such as high availability and scalability. By following this comprehensive guide, users will have a better understanding of how to properly manage their PDBs in their RAC environment. Troubleshooting techniques were also discussed in the event any issues arise during the restart process so that they can be resolved quickly and efficiently. With the right knowledge, users should be able to confidently use these steps to effectively restart their Pluggable Databases in an Oracle RAC environment.


Looking forward for your suggestions.. please feel free to write to me.. Your help would definitely help to improve our blog. Chetan Yadav

To restart a PDB (Pluggable Database) in an Oracle RAC (Real Application Clusters) environment, you can use the following commands:


To restart a PDB (Pluggable Database) in an Oracle RAC (Real Application Clusters) environment, you can use the following commands:



  1. Connect to the CDB (Container Database) as a privileged user:


    sqlplus / as sysdba
  2. Determine the name of the PDB that you want to restart:


    SELECT name FROM v$pdbs;
  3. Switch to the PDB that you want to restart:


    ALTER SESSION SET CONTAINER=<PDB_NAME>;
  4. Check the current status of the PDB:


    SELECT name, open_mode FROM v$pdbs WHERE name='<PDB_NAME>';
  5. If the PDB is currently open, close it:


    ALTER PLUGGABLE DATABASE <PDB_NAMECLOSE;
  6. Wait for the PDB to close:


    SELECT name, open_mode FROM v$pdbs WHERE name='<PDB_NAME>';
  7. Once the PDB is closed, restart it:


    ALTER PLUGGABLE DATABASE <PDB_NAMEOPEN;
  8. Check the status of the PDB to confirm that it has been restarted:


    SELECT name, open_mode FROM v$pdbs WHERE name='<PDB_NAME>';

That's it! You have successfully restarted a PDB in an Oracle RAC environment using commands.

 



Looking forward for your suggestions.. please feel free to write to me.. Your help would definitely help to improve our blog. Chetan Yadav