Announcements

Oracle training based on real-time expertise as per industry standards. Upcoming batch details are here.

View batch schedule

Free Oracle mock interview. Register using the link.

Register

#DBAchallenge: submit your questions.

Ask questions
Swipe for more →
Browse by Topic
Latest Posts

    Thursday, March 17, 2022

    Create Passwordfile inside DiskGroup for RAC database and add to srvctl

    Create Passwordfile inside DiskGroup for RAC database and add to srvctl:


    Steps:
    1. Check database status:
    2. Check database configuration:
    3. Create passwordfile inside diskgroup 
    4. Add passwordfile into srvctl config:

    1. Check database status:
    [oracle@oraclenode1 dbs]$ srvctl status database -d TESTDB
    Instance TESTDB1 is running on node oraclenode1
    Instance TESTDB2 is running on node oraclenode2
    [oracle@oraclenode1 dbs]$

    2. Check database configuration:
    [oracle@oraclenode1 dbhome_1]$ srvctl config database -d TESTDB
    Database unique name: TESTDB
    Database name: TESTDB
    Oracle home: /u01/app/oracle/product/19.0.0.0/dbhome_1
    Oracle user: oracle
    Spfile: +DATA/TESTDB/PARAMETERFILE/spfileTESTDB.ora
    Password file:
    Domain:
    Start options: open
    Stop options: immediate
    Database role: PRIMARY
    Management policy: AUTOMATIC
    Server pools:
    Disk Groups: DATA,RECO
    Mount point paths:
    Services:
    Type: RAC
    Start concurrency:
    Stop concurrency:
    OSDBA group: oinstall
    OSOPER group: oinstall
    Database instances: TESTDB1,TESTDB2
    Configured nodes: oraclenode1,oraclenode2
    CSS critical: no
    CPU count: 0
    Memory target: 0
    Maximum memory: 0
    Default network number for database services:
    Database is administrator managed
    [oracle@oraclenode1 dbhome_1]$

    3. Create passwordfile inside diskgroup 
    [oracle@oraclenode1 dbs]$ orapwd file='+DATA/TESTDB/PASSWORD/orapwTESTDB' dbuniquename='TESTDB'
    Enter password for SYS:
    [oracle@oraclenode1 dbs]$

    [oracle@oraclenode1 ~]$ asmcmd -p
    ASMCMD [+] > cd +DATA/TESTDB/PASSWORD
    ASMCMD [+DATA/TESTDB/PASSWORD] > ls -l
    Type      Redund  Striped  Time             Sys  Name
    PASSWORD  UNPROT  COARSE   MAR 16 17:00:00  N    orapwtestdb => +DATA/TESTDB/PASSWORD/pwdtestdb.349.1099502001
    PASSWORD  UNPROT  COARSE   MAR 16 17:00:00  Y    pwdtestdb.349.1099502001
    ASMCMD [+DATA/TESTDB/PASSWORD] >

    4. Add passwordfile into srvctl config:
    [oracle@oraclenode1 dbs]$ srvctl modify database -d TESTDB -pwfile '+DATA/TESTDB/PASSWORD/orapwTESTDB'
    [oracle@oraclenode1 dbs]$ srvctl config database -d TESTDB
    Database unique name: TESTDB
    Database name: TESTDB
    Oracle home: /u01/app/oracle/product/19.0.0.0/dbhome_1
    Oracle user: oracle
    Spfile: +DATA/TESTDB/PARAMETERFILE/spfileTESTDB.ora
    Password file: +DATA/TESTDB/PASSWORD/orapwTESTDB
    Domain:
    Start options: open
    Stop options: immediate
    Database role: PRIMARY
    Management policy: AUTOMATIC
    Server pools:
    Disk Groups: DATA,RECO
    Mount point paths:
    Services:
    Type: RAC
    Start concurrency:
    Stop concurrency:
    OSDBA group: oinstall
    OSOPER group: oinstall
    Database instances: TESTDB1,TESTDB2
    Configured nodes: oraclenode1,oraclenode2
    CSS critical: no
    CPU count: 0
    Memory target: 0
    Maximum memory: 0
    Default network number for database services:
    Database is administrator managed
    [oracle@oraclenode1 dbs]$

    Regards,
    Mallik

    Cluster Commands

    Cluster Commands:

    How to get a master node:
    [root@oraclenode1 ~]# oclumon manage -get master
    Master = oraclenode1

    How to get a cluster name:
    [oracle@oraclenode1 admin]$ cemutlo -n
    orcl-clu

    [oracle@oraclenode1 admin]$ olsnodes -c
    orcl-clu

    How to get scan details:
    [oracle@oraclenode1 admin]$  srvctl config scan
    SCAN name: orclscan, Network: 1
    Subnet IPv4: 10.38.4.0/255.255.252.0/ens192, static
    Subnet IPv6:
    SCAN 1 IPv4 VIP: 10.38.4.126
    SCAN VIP is enabled.
    SCAN 2 IPv4 VIP: 10.38.4.154
    SCAN VIP is enabled.
    SCAN 3 IPv4 VIP: 10.38.4.162
    SCAN VIP is enabled.

    Create Password file inside DISK Group:
    orapwd file='+DATA/TESTDB/PASSWORD/orapwTESTDB' dbuniquename='TESTDB'

    Add password details to cluster database:
    srvctl modify database -d TESTDB -pwfile '+DATA/TESTDB/PASSWORD/orapwTESTDB'

    Regards,
    Mallik

    Saturday, March 12, 2022

    #DBAchallenge -3 || Interview Questions on RMAN, SGA, PGA, Patching, Password fIle and Query Running Slow

    #DBAchallenge -3

    Interesting Question 1...

    How many RMAN channels you will allocate for a database backup?

    What all resource you are going to check before allocating the RMAN channels?

    To Make it simple...

    If I have DB with 4 CPU assigned each CPU has single thread then how many RMAN channel you will allocate? Do you consider PGA and SGA before allocating channels?

    Answer 1…

    --- RMAN channels should be allocated purely based on number of CPUs, No need to consider SGA/PGA sizing while allocating the channel because automatic memory management will take care of assigning the adequate large pool memory during the RMAN backups.

    --- In case if you have 4 CPUs assigned for your database then allocate 2 channels for RMAN and leave the other 2 channels for other your database and ASM operations.

    --- Remember in case if you undersize your SGA and PGA which is not only impacting on your RMAN backups but also your database performance, make sure assign the adequate memory (SGA/PGA) allocation for your database.


    Case1:

    --- I have 16 CPUs on my server and out of 16 CPUs I have assigned 8CPUs (Using CPU_Caging) for my database in that case I can assign max 6 channels to RMAN backup and I will leave 1 or 2 buffer CPUs for my database operation.

    Case2:

    --- I have 16 CPUs on my server and default my database will take all 16 CPUs in my database if you don’t use CPU caging in that case I can allocate 12 channels to RMAN backup and I will remaining 4 channels for my database, ASM and OS operations.

    Case3:

    --- I have 16 CPUs on my server and in case if you are running multiple databases then its little challenging since you have to consider when the backups are running for all these DBs, how many CPUs are assigning inside my database and I need to assign some buffer CPUs for my database, ASM and OS operations.

    SQL>show parameter cpu_count

    [root@oraclelab1]# lscpu |grep "CPU(s):"

    https://www.oracle.com/technetwork/database/performance/instance-caging-wp-166854.pdf


    Interesting Question 2...

    I got a downtime

    Today for DB1,

    Tomorrow for DB2.

    I want to patch these both the databases,

    Remember both the DBs are running on a same server.

    How to accomplish this task?

    Answer 2…

    --- We can deal this situation in different scenarios

    Case1:

    --- In case both the DBs are running from different Oracle Home then no need to worry, you can patch these databases independently irrespective of whether these are RAC database or standalone databases.

    Case2:

    --- In case both the DBs are running from same Oracle Home and in case both are RAC databases then you no need to worry about downtime you can do rolling patching today or tomorrow anytime which does not need a downtime.

    Case3:

    --- In case both the DBs are running from same Oracle Home and in this situation, we can clone Oracle Home and patch that cloned oracle Home and move 1 database on cloned Oracle Home and run that database with datapatch and we can patch the other Oracle Home & respective database on tomorrow’s downtime

    Note:

    Point to considering during this clone process is In case both the DBs are using the same listener then you have to create a new listener for that cloned Oracle Home and you need to register that database with that new listener.

     

    Interesting Question 3...

    I have a server with 10GB RAM 4 CPU/cores with single thread for each core.

    I want to create a new database in it,

    How much SGA, I can allocate?

    How much PGA, I can allocate?

    How much CPU/Core I can allocate for the new DB?

    Answer 3…

    --- Default 40% of RAM will be allocated to SGA

         Cal: 40* Total RAM = SGA 

    --- PGA allocation depends on number of process you defined on database

         Cal: 3MB * Number of Process = PGA

    --- We no need to assign any CPUs for my database default it will take all the CPUs available on my server. We can limit the number of CPUs for my database using parameter called cpu_count inside my database.

    --- This CPUs allocation inside my database depends on How many DBs you are running and how critical are these DBs.

    [oracle@oraclelab1]$ grep -i SGA $ORACLE_HOME/assistants/dbca/templates/General_Purpose.dbc

             <percentageMemTOSGA>40</percentageMemTOSGA>

    SGA:

    https://asktom.oracle.com/pls/apex/f?p=100:11:0::::P11_QUESTION_ID:30011178429375

    PGA:

    https://oracle-base.com/articles/12c/pga_aggregate_limit_12cR1


    Interesting Question 4...

    Seems this is commonly asked question in most of the interview...

    My query is running fine till yesterday but all of sudden today it is taking more time?

    How will you troubleshoot this situation?

    Answer 5…

    We should ask cross question:

    --- Is only this query is running slow or all other queries running slow?

         --- all queries are having issue then its DB related issue if not then its only this query has issue

    --- Only this user facing this issue or all other facing this issue.

         --- In case only this user having issue then it might be this user level permission or access issue otherwise this is query issue

    --- We drilled down the issue whether it is at DB level issue or this query level issue

         --- In case of if its DB level issue then we can check load on DB, check any backups or expdp/impdp running on server, load on Server, IO stats, memory stats, vmstats, AWR report and other OS analysis.

         --- In case of its query level issue then we can troubleshoot further like

         --- table_stats on tables involved in this query (Gather stats)

         --- Index status on these tables (Rebuild Index)

         --- Fragmentation on these tables (Table Move or Table shrink)

         --- Check for execution plan and verify any change in the execution plan

         --- In case change in plan then use SQL profile to peg the best execution plan.


    Interesting Question 5...

    Password file... 📂

    What is the use of password file in database?

    What are the use cases of password file?

    What is the impact in case if I lost or corrupt password file?

    Answer 5…

    --- Password file is needed for remote administration activities from your sysdba user.

    --- If the DBA wants to start up an Oracle or ASM instance there must be a way for Oracle to authenticate the DBA. Obviously, DBA password cannot be stored in the database, because Oracle cannot access the database before the instance is started up. Therefore, the authentication of the DBA must happen outside of the database.

    User Cases:

    --- Remote administration activities

    --- DR or Standby sync

    --- In case passwordfile corrupt or lost then there is no impact on running database, you can recreate the passwordfile online using orapdw utility

    --- In case of DR database if passwordfile corrupt or lost then DR will goes out of sync.

    SQL> desc v$pwfile_users;

    [oracle@oraclelab1 dbs]$ ls -ltr $ORACLE_HOME/dbs/orapw*

     

    Regards,

    Mallik

    Tuesday, March 1, 2022

    RAC to RAC Database Clone scenario - RMAN Duplicate Database - RMAN clone for RAC DB

    RAC Database Clone or RMAN Duplicate Database:

    ==============================================
    RAC to RAC Database Clone scenario - RMAN Duplicate Database - RMAN clone for RAC DB

    1. Prestep take source DB backups and transfer it to target:
    2. Database Clone or RMAN Duplicate Database on target:
    3. Post Restore/Clone Steps:


    1. Prestep take source DB backups and tranfer it to target
    ==========================================================
    rman target /
    run {
    allocate channel ch1 device type disk;
    backup as backupset database format '/u01/backup/Fullback_%T_%U'
    plus archivelog format '/u01/backup/Archive_%T_%U';
    backup current controlfile format '/u01/backup/Controlback_%T_%U';
    backup spfile format '/u01/backup/spfile_%T_%U';
    release channel ch1;
    }

    scp /u01/backup/* oracle@10.38.4.110:/u01/backup/.

    2. Database Clone or RMAN Duplicate Database on target:
    =======================================================
    sqlplus / as sysdba
    startup nomount pfile='/u01/app/oracle/product/19.0.0.0/dbhome_1/dbs/initTESTDB.ora';

    rman auxiliary /
    duplicate target database to TESTDB backup location '/u01/backup' nofilenamecheck;

    sqlplus / as sysdba
    select name, open_mode from v$database;

    3. Post Restore/Clone Steps:
    ============================
    1. Get a pfiles from source and modify according to target environemtn
    2. Start target instance using pfiles

    sqlplus / as sysdba
    shut immediate

    cp initTESTDB.ora initTESTDB.ora_for_clone

    vi /u01/app/oracle/product/19.0.0.0/dbhome_1/dbs/initTESTDB1.ora

    . oraenv
    >>> TESTDB1

    sqlplus / as sysdba
    startup mount pfile='/u01/app/oracle/product/19.0.0.0/dbhome_1/dbs/initTESTDB1.ora';

    create spfile='+DATA/TESTDB/PARAMETERFILE/spfileTESTDB.ora' from pfile='/u01/app/oracle/product/19.0.0.0/dbhome_1/dbs/initTESTDB1.ora';
    shut immediate;

    cp initTESTDB1.ora initTESTDB1.ora_After_RAC_Parameter_Added

    Create local pfile initTESTDB1.ora point to SPFILE '+DATA/TESTDB/PARAMETERFILE/spfileTESTDB.ora'

    Node1>>>
    cd $ORACLE_HOME/dbs
    cat > initTESTDB1.ora 
    spfile='+DATA/TESTDB/PARAMETERFILE/spfileTESTDB.ora'

    Node2 >>>
    cat > initTESTDB2.ora 
    spfile='+DATA/RACSB/PARAMETERFILE/spfileRACSB.ora'

    sqlplus / as sysdba
    startup mount;
    show parameter spfile
    shut immediate

    Convert TESTDB database to RAC
    ==========================
    srvctl add database -d TESTDB -n TESTDB -o '/u01/app/oracle/product/19.0.0.0/dbhome_1' -p '+DATA/TESTDB/PARAMETERFILE/spfileTESTDB.ora' -t IMMEDIATE -a 'DATA,RECO'

    Add the NODE instances
    srvctl add instance -d TESTDB -i TESTDB1 -n oraclenode1
    srvctl add instance -d TESTDB -i TESTDB2 -n oraclenode2

    srvctl config database -d TESTDB
    srvctl status database -d TESTDB
    srvctl start database -d TESTDB
    srvctl status database -d TESTDB
    srvctl stop database -d TESTDB

    cp initTESTDB1.ora initTESTDB1.ora_Pointing_To_spfile

    Regards,
    Mallik

    RAC Database Restore and Recover scenario - RAC to RAC Restore and Recover

    RAC Database Restore & Recover:

    ==============================
    RAC Database Restore and Recover scenario - RAC to RAC Restore and Recover

    1. Prestep take source DB backups and transfer it to target:
    2. Restore and Recover Database on target:
    3. Post Restore/Clone Steps:



    1. Prestep take source DB backups and tranfer it to target
    ==========================================================
    rman target /
    run {
    allocate channel ch1 device type disk;
    backup as backupset database format '/u01/backup/Fullback_%T_%U'
    plus archivelog format '/u01/backup/Archive_%T_%U';
    backup current controlfile format '/u01/backup/Controlback_%T_%U';
    backup spfile format '/u01/backup/spfile_%T_%U';
    release channel ch1;
    }

    scp /u01/backup/* oracle@10.38.4.110:/u01/backup/.


    2. Restore and Recover on target server:
    ========================================
    sqlplus / as sysdba
    startup nomount pfile='/u01/app/oracle/product/19.0.0.0/dbhome_1/dbs/initDEVDB.ora';

    rman target /
    restore spfile from '/u01/backup/spfile_20220301_1f0napte_1_1';
    restore controlfile from '/u01/backup/Controlback_20220301_1e0naptc_1_1';
    alter database mount;
    catalog start with '/u01/backup/';
    run {
    restore database;
    recover database;
    }
    alter database open resetlogs;

    sqlplus / as sysdba
    select name, open_mode from v$database;


    3. Post Restore/Clone Steps:
    ============================
    1. Get a pfiles from source and modify according to target environemtn
    2. Start target instance using pfiles

    sqlplus / as sysdba
    shut immediate

    cp initDEVDB.ora initDEVDB.ora_for_clone

    vi /u01/app/oracle/product/19.0.0.0/dbhome_1/dbs/initDEVDB1.ora

    . oraenv
    >>> DEVDB1

    sqlplus / as sysdba
    startup mount pfile='/u01/app/oracle/product/19.0.0.0/dbhome_1/dbs/initDEVDB1.ora';

    create spfile='+DATA/DEVDB/PARAMETERFILE/spfileDEVDB.ora' from pfile='/u01/app/oracle/product/19.0.0.0/dbhome_1/dbs/initDEVDB1.ora';
    shut immediate;

    cp initDEVDB1.ora initDEVDB1.ora_After_RAC_Parameter_Added

    Create local pfile initDEVDB1.ora point to SPFILE '+DATA/DEVDB/PARAMETERFILE/spfileDEVDB.ora'

    Node1>>>
    cd $ORACLE_HOME/dbs
    cat > initDEVDB1.ora 
    spfile='+DATA/DEVDB/PARAMETERFILE/spfileDEVDB.ora'

    Node2 >>>
    cat > initDEVDB2.ora 
    spfile='+DATA/RACSB/PARAMETERFILE/spfileRACSB.ora'

    sqlplus / as sysdba
    startup mount;
    show parameter spfile
    shut immediate

    Convert DEVDB database to RAC
    =========================
    srvctl add database -d DEVDB -n DEVDB -o '/u01/app/oracle/product/19.0.0.0/dbhome_1' -p '+DATA/DEVDB/PARAMETERFILE/spfileDEVDB.ora' -t IMMEDIATE -a 'DATA,RECO'

    Add the NODE instances
    srvctl add instance -d DEVDB -i DEVDB1 -n oraclenode1
    srvctl add instance -d DEVDB -i DEVDB2 -n oraclenode2

    srvctl config database -d DEVDB
    srvctl status database -d DEVDB
    srvctl start database -d DEVDB
    srvctl status database -d DEVDB
    srvctl stop database -d DEVDB

    cp initDEVDB1.ora initDEVDB1.ora_Pointing_To_spfile

    Regards,
    Mallik

    🌟 Proud to be an Oracle ACE Pro! 🚀

    🌟 Proud to be an Oracle ACE Pro! 🚀 I’m excited to share my official Oracle ACE Profile with the Oracle community. 👨‍💻 Mallikarjun ...