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

Best Practices for Administering and Resetting Pluggable Databases on An Oracle RAC System

Best Practices for Administering and Resetting Pluggable Databases on An Oracle RAC System




Introduction

Oracle Real Application Clusters (RAC) is an Oracle database solution that allows multiple instances of a single Oracle database to run across different nodes in a cluster. This provides advantages such as high availability and scalability, allowing the system to remain available even if one node fails or becomes unavailable. A Pluggable Database (PDB) can be started, stopped, restarted or removed from the RAC environment without impacting other databases hosted on the same system. Restarting a PDB in RAC is necessary when changes have been made to its configuration settings and need to take effect, or if it has become corrupted due to errors or faults occurring during normal operations. It's important for administrators of an Oracle RAC system to understand best practices for administering and resetting pluggable databases in order for them to ensure optimal performance of their systems.

The Prerequisites for Restarting a PDB in RAC

Before restarting a PDB in RAC, administrators should make sure that all databases in the cluster are running. This is because any changes made to one database may affect other databases on the same system or cluster. It's also important for administrators to check if Oracle Clusterware is configured and started properly before initiating a restart of the PDB. The Clusterware provides services such as managing nodes, network connections, and shared storage across multiple systems; it must be correctly set up to ensure optimal performance of an Oracle RAC environment. Additionally, ensuring that any applicable patches have been applied prior to restarting a PDB can help prevent potential problems during startup or while accessing data from different nodes in the cluster.

Once these prerequisites have been completed, administrators can then prepare their environment by taking certain steps such as stopping applications connected to the database instance being restarted, disabling triggers and constraints associated with it, deleting temporary tablespaces created for testing purposes (if applicable), etc., before attempting a restart of the pluggable database itself. After performing these preliminary tasks, they can begin resetting their pluggable database by using either manual commands through SQL*Plus or graphical tools provided by Oracle Database Enterprise Manager (EM).

Setting the Environment Variable to Restart the PDB

To begin setting the environment variable to restart the pluggable database, administrators must first create an Oracle Restart configuration file. This is a text file that contains settings to be used by Oracle Database when restarting a PDB. It includes information regarding which diskgroup will contain the datafiles for the PDB, how many instances of Oracle should be started up and how much memory should be allocated for each instance. Additionally, it can also include details such as where log files should be stored and any user-defined parameters necessary for starting up an instance of Oracle.

Once this configuration file has been created, administrators then need to set an environment variable in order to enable automatic restarts of their pluggable databases. This is done by adding ORACLE_RESTART_ENABLE=TRUE into the target machine’s system environment variables list (in Windows OS). Once this step is complete, they can test if their setup was successful by running simple commands like ‘sqlplus / as sysdba’ or ‘startup pdbs’ from SQL*Plus prompt on the node hosting their database instance and checking if all nodes have successfully started up in clustered mode or not.

Finally, once these steps have been completed and verified correctly, administrators are now ready to start resetting their pluggable databases within RAC environments. They can do so manually using command line tools such as SQL*Plus or through graphical tools provided by Enterprise Manager (EM).

Steps to Restart the PDB in RAC

Once the configuration file has been created and the environment variable set, administrators can now begin resetting their pluggable databases within RAC environments. To do this, they must first execute a restart command for the PDB in question. This is done by entering ‘alter pluggable database open’ from an SQL*Plus prompt on the node hosting the instance of Oracle to be restarted. After executing this command, administrators should then check if all nodes have successfully started up in clustered mode or not (using commands such as ‘select * from v$ instance;’).

After verifying that all nodes are running correctly, administrators can then verify that their desired PDB has been successfully restarted by using either Enterprise Manager (EM) or SQL*Plus commands like ‘show pdbs;’ which will display information about all existing Pluggable Databases on a system. Additionally, they may also use other tools such as ASMCMD to monitor any changes made to cluster resources via Oracle Clusterware during startup operations of their PDBs.

Finally, once these steps have been completed and verified correctly, administrators should ensure that applications connected to their database instance are functioning properly before allowing users access it again after being resetted in RAC environment. This involves performing tests on user queries and checking whether data integrity is maintained across different nodes while accessing them simultaneously after restarting the PDBs in RAC systems.

Troubleshooting Failed PDB Restarts

The next step in troubleshooting failed PDB restarts is to check the Oracle Clusterware configuration. This involves verifying if all of the necessary services are running correctly, such as the Oracle Listener and any other associated components like ASM or RAC. Additionally, administrators should also ensure that they’ve configured their environment variables correctly so that Oracle can properly access its files from each node in the cluster.

Another important factor to consider when troubleshooting failed PDB restarts is checking for instance logs. These logs contain valuable information about errors which may have occurred during startup operations of a particular database instance and can provide valuable insights into what went wrong during restart attempts. The most common types of log files generated by Oracle are alert logs, trace files, SQL*Plus output files and core dumps; these should be checked carefully for any potential issues which could have caused a PDB restart failure.

Finally, it's also important for administrators to perform basic checks on databases hosted on different nodes within an Oracle RAC system after resetting a pluggable database in order to ensure that data integrity has been maintained across all instances within the cluster. This includes validating tablespaces (including temporary ones), ensuring proper backups have been taken before performing changes or upgrades, confirming user privileges and roles assigned to various users accessing databases from multiple nodes etc., all of which must be verified prior allowing application users access it again after being resetted in RAC environment.

Conclusion

In conclusion, restarting Pluggable Databases (PDBs) in an Oracle Real Application Clusters (RAC) environment can be a complex task that requires careful planning and preparation. However, the advantages of performing this procedure are numerous – from improved database performance to increased availability for applications using PDBs as their data source. By following best practices such as ensuring all prerequisite steps are taken before attempting a reset, verifying that Clusterware is configured and started properly, setting up environment variables correctly and checking logs for any potential issues; administrators can ensure successful restarts of their pluggable databases within RAC environments with minimal downtime or disruption. Additionally, it's also important to remember to perform basic checks on databases hosted on different nodes after resetting a PDB in order to maintain data integrity across all instances within the cluster.




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

Thursday, March 16, 2023

Recovery Manager (RMAN)






An application used for backing up, restoring, and recovering Oracle databases is called Oracle Recovery Manager (RMAN). For Oracle databases, RMAN offers a complete backup and recovery solution, including full backups, incremental backups, and backups of particular database components.

You must connect to the target database and set aside a channel before you can run an RMAN backup. The channel can be assigned manually or automatically by RMAN, and it can be a disc or tape device. Once the channel has been assigned, you can start the backup procedure using the backup command.


You can specify different parameters with the backup command, including the backup type, backupset size, and compression level. For instance, you can use the following command to backup the database completely:

shell
RMAN>  backup database;
You can use the following command to carry out an incremental backup:

 
 
RMAN> backup incremental level 1 database;

  The backup is examined for consistency and restoreability using the validate command.

You must connect to the target database and set aside a channel before you can restore a backup. The database can then be restored using the restore command. You can specify other options with the restore command, including the restoration type and backupset location. For instance, you may use the following command to restore a database backup in its entirety:

shell
 
RMAN> restore database; 
After a restore, you can use the recover command to restore the database. To bring the database up to date, the recover command applies any necessary redo logs to the restored backup. For instance, you can use the following command to restore the database after a restoration:

 
 
RMAN> recover database;
For Oracle databases, RMAN offers a strong backup and recovery solution that enables you to execute full backups, incremental backups, and backups of particular database components. The validate and recover commands make sure that the backup is valid and the database is current while the backup and restore commands let you personalise the backup and restore procedure.


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

Monday, March 6, 2023

Migration Oracle Database 11g to 19c (CDB)


    Moving from Oracle Database 11g to 19c (CDB) might be challenging, but with the appropriate knowledge and direction, it can be a straightforward procedure. This article offers a thorough tutorial to assist you in upgrading your Oracle Database 11g to 19c (CDB).

Are you considering upgrading from Oracle Database 11g to 19c (CDB)? If so, a thorough understanding of the procedure is required to guarantee a smooth upgrading. This article offers a thorough tutorial on how to smoothly upgrade your Oracle Database 11g to 19c (CDB).


 


  A Complete Guide on Upgrading from Oracle Database 11g to 19c

                                                Are you still using Oracle Database 11g for your database? It's time to update it to Oracle Database 19c (CDB), the most recent version, in order to benefit from new features, improved security, and improved speed. The transition from Oracle Database 11g to Oracle Database 19c (CDB) might be challenging, but with the correct information and direction, it can be a straightforward procedure. This article offers a thorough tutorial to assist you in upgrading your Oracle Database 11g to 19c (CDB).

There are a few things you should take into account before you start the update process:

Make sure your system and software fit Oracle Database 19c's hardware and software requirements (CDB).

Verify your existing Oracle Database 11g's compatibility with Oracle Database 19c (CDB). Verify that the new version is compatible with all the applications that use the database.

Backup: Create a copy of your current database before you start the upgrade procedure. In the event that the upgrade procedure fails, this will assist you in restoring the database.

Testing: Prior to upgrading the production system, it is generally desirable to carry out a test upgrade on a test system. This will assist you in locating any problems that might occur throughout the update procedure.

After giving these things some thought, let's go on to the upgrade procedure.

Upgrade Oracle Database 11g to 12c as the first step

Upgrade your Oracle Database from 11g to 12c is the first step in moving to Oracle Database 19c (CDB). Because Oracle Database 19c (CDB) requires Oracle Database 12c Release 2 (12.2.0.1) or later versions, this step is crucial. The following stages are involved in upgrading Oracle Database 11g to Oracle Database 12c:

Install Oracle Database 12c Release 2 (12.2.0.1) or a later version by downloading it.

Make a backup of the database.

Using the command-line interface or the Database Upgrade Assistant (DBUA), upgrade the database (CLI).

Do post-upgrade duties, such as recompiling broken objects using the utlrp.sql script.

Upgrade Oracle Database 12c to 19c in step two (CDB)

The next stage is to upgrade to Oracle Database 19c after you have upgraded your Oracle Database 11g to 12c (CDB). The following steps are part of the upgrade process:

Install Oracle Database 19c by downloading it (CDB).

Make an Oracle Database 12c backup.

Use the DBUA or CLI to upgrade the database.

run the utlrp.sql script and other post-upgrade actions.



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