Database cloning using RMAN and with existing full database backups taken by RMAN
Wednesday, December 15, 2021
Database cloning
Monday, November 15, 2021
Dataguard
We are using the below DOC for Database upgrade from 12.1,12.2 to 19c(19.12) and parallelly migrating it as PDB into a container,
The Below process is for RAC environment:-
Reusing the Source Standby Database Files When Plugging a non-CDB as a PDB into the Primary Database of a Data Guard Configuration ( Doc ID 2273304.1 )
1.Before Starting upgrade, Copy the PFILE and PASSWORD file from the existing 12.1/12.2 home to new home 19.12 at DR side
cp /u01/app/oracle/product/12.2.0.1/dbhome_1/dbs/inittestdbdr1.ora /u01/app/oracle/product/19.0.0.0/dbhome_1/dbs
cp /u01/app/oracle/product/12.2.0.1/dbhome_1/dbs/orapwtestdbdr1.ora /u01/app/oracle/product/19.0.0.0/dbhome_1/dbs
And the database is upgraded successfully but DR database is out-of-sync at the step:17 in the DOC 2273304.1
We started seeing the issue when we plugin the xml file to create PDB in primary db and started the MRP in standby.
Saturday, September 18, 2021
Jenkins in Oracle Database Task Automation
Jenkins in Oracle Database Task Automation
Now we’re ready to finish setting up the node via the Jenkins UI. In Jenkins, go to Manage Jenkins, then Manage Nodes, then click New Node. Here you can give your agent node a name, then select Permanent Agent and click OK. There are a variety of options you can use here to customize your node. All we care about right now is the Launch Method.

Sunday, September 12, 2021
Important Points
Important points to be noted from daily activities:-
While performing Re-org/oracle home movement on a production database:-
i)While performing oracle-home movement of a production database, please add the TNS of both primary and standby databases to the new homes on both the PRIMARY and STANDBY side.
ii)While performing re-org/table/index/lob/table partitions movement , monitor the RECO disk group closely , flashback log also accumulated. If DR-sync-up is not happening, RECO disk group may get full.
------------------------------------------------------------------------------------------------------
If you are unable to drop the tablespace due to BIN$ objects in dba_indexes, then try to drop those indexes, if you are unable to drop them, then drop the BIN$ constraints of that table first from dba_constraints then drop the BIN$ indexes.
select sum(bytes) from v$sgastat where pool = 'shared pool';
The sharedpool holds many other structures that are outside the scope of the corresponding parameter. The SHARED_POOL_SIZE is typically the largest contributor to the shared pool as reported by the SUM(BYTES), but it is not the only contributor.
In Oracle 10g, the SHARED_POOL_SIZE parameter controls the size of the shared pool, whereas in Oracle9i and before, it was just the largest contributor to the shared pool. You should review your 9i and before actual shared pool size (based on V$SGASTAT) and use that figure to set your SHARED_POOL_SIZE parameter in Oracle 10g and above.
SELECT DBTIMEZONE AS "Database Time Zone", SESSIONTIMEZONE AS "Session Time Zone"
FROM dual;
Wednesday, September 1, 2021
SQL_TUNING
SQL_TUNING
Turning on 10046 tracing for the sql:
ALTER SESSION SET EVENTS '10046 TRACE NAME CONTEXT FOREVER, LEVEL 12';
Or if the sql is already running you can turn the trace on for this sql_id:
How to trace sql id:
1. ALTER SYSTEM SET EVENTS sql_trace [sql: sql_id=3s1yukp05bzg7] bind=true, wait=true';
2. execute the query
3. alter system set events 'sql_trace off';
4. Find the trace
You do not need to leave the trace on, just collect for 10 minutes.
Explain plan of a sql query:
Monday, August 30, 2021
Table Fragmentation
Checking the deleted space from table:
SELECT BLOCKS, BLOCKS*8192/1024 TOTAL_SIZE_KB, AVG_SPACE, round(BLOCKS*AVG_SPACE/1024,2) FREE_SPACE_KB FROM USER_TABLES WHERE TABLE_NAME='EMPLOYEE';
Monday, August 23, 2021
Shell Scripting
Shell Scripting Handy
User creation at OS level (usercreate_os.sh)
#!/bin/bash
#this script creates an account on the local system.
#you will be prompter for the account name and password
#Ask for username
read -p 'Enter the username: ' USER_NAME
#Ask for the real name
read -p 'Enter the name of the person who is this account for: ' COMMENT
#ask for the password
read -p 'Enter the password to use for the account: ' PASSWORD
#create the username
useradd -c "${COMMENT}" -m ${USER_NAME}
#set the password for the username
echo ${PASSWORD} | passwd --stdin ${USER_NAME}
#force password change on first login
passwd -e ${USER_NAME}
######################################################################
Script2:
RANDOM Each time this parameter is referenced, a random integer between 0 and 32767
is generated. The sequence of random numbers may be initialized by assign‐
ing a value to RANDOM. If RANDOM is unset, it loses its special properties,
even if it is subsequently reset.
[oracle@kolkata02 ~]$ echo ${RANDOM}
24092
[oracle@kolkata02 ~]$ echo ${RANDOM}
1748
[oracle@kolkata02 ~]$ echo ${RANDOM}
2398
[oracle@kolkata02 ~]$ !v ----> this will opens the last closed file
#!/bin/bash
#This scripts generates a list of random passwords
#A random number as a password
PASSWORD=${RANDOM}
echo "${PASSWORD}"
#Three random numbers together
PASSWORD="${RANDOM}${RANDOM}${RANDOM}"
echo "${PASSWORD}"
#use the current date/time as the basis for the password
PASSWORD=$(date +%s) ---->'+' is for format and %s is for seconds since 1970 UTC
echo "${PASSWORD}"
#use nano seconds to act as randomization
PASSWORD=$(date +%s%N) --->%N is the nano seconds
echo "${PASSWORD}"
# A better password
PASSWORD=$(date +s%N | sha256sum | head -c32)
echo "${PASSWORD}"
# An even better passsword
PASSWORD=$(date +s%N${RANDOME}${RANDOM} | sha256sum | head -c32)
echo "${PASSWORD}"
# An even better passsword
Special_character=$(echo '!@#$%^&*()_+' | fold -w1 | shuf | head -c1)
echo "${PASSWORD}${Special_character}" --->here special character will be appended
QFSDP Patching
Step1: Cell patching in rolling mode
step2: Downtime patching for below:
First have IB Switches patching
then GI home patch
then ORACLE homes patching
then yum upgrade
then apply datapatch for all databases, if you face issue with automation script of oracle for CDB databases, so please ran datapatch manually on all databases.
Sunday, August 22, 2021
DataPump - expdp/impdp
Expdp with Query option: (parfile)
directory=DATA_PUMP
dumpfile=expdp_zamdbtdb_tblbkup_new_%U.dmp
logfile=expdp_zamdbtdb_tblbkup_new.log
tables=schema.table1
parallel=10
query=schema1.table1:"where column1 NOT IN (SELECT column2 FROM schema1.table2 where column3= 'value')"
cluster=N
Impdp: (parfile)
directory=DATA_PUMP
dumpfile=expdp_zamdbtdb_tblbkup_new_%U.dmp
logfile=imdp_zamdbtdb_tblbkup_new.log
tables=schema.table1
table_exists_action=replace
parallel=10
cluster=N
Regular Commands:
select directory_name,directory_path from dba_directories where directory_name='DATA_PUMP';
select sum(bytes)/1024/1024/1024 from dba_segments;
create directory DATA_PUMP as '/opt/backups';
grant read,write on directory DATA_PUMP to system;
grant all on directory DATA_PUMP to public;
expdp system directory=DATA_PUMP dumpfile=expdp_test_tblbkp_%U.dmp logfile=expdp_test_tblbkp.log tables=schema1.table1 parallel=16 exclude=statistics
expdp system directory=DATA_PUMP dumpfile=expdp_test_tblbkp_%U.dmp logfile=expdp_test_tblbkp.log schemas=schema1 parallel=12 exclude=statistics
nohup expdp system/'password' directory=DATA_PUMP dumpfile=expdp_test_tblbkp_%U.dmp logfile=expdp_test_tblbkp.log schemas=schema1 parallel=12 exclude=statistics &
nohup impdp system/'password' directory=DATA_PUMP dumpfile=expdp_test_tblbkp_%U.dmp logfile=impdp_test_tblbkp.log schemas=schema1 TABLE_EXISTS_ACTION=REPLACE parallel=16 exclude=statistics &
Cluster=N -->use this for RAC environment where export/import is doing in/from local mount point
nohup impdp system/'password' directory=DATA_PUMP dumpfile=expdp_test_tblbkp_%U.dmp logfile=expdp_test_tblbkp.log remap_schema=schema_old_name:schema_new_name remap_tablespace=OLD_TABLESPACE_NAME:NEW_TABLESPACE_NAME parallel=5 Cluster=N &
impdp system/'password' directory=DATA_PUMP dumpfile=expdp_test_tblbkp_%U.dmp logfile=expdp_test_tblbkp.log remap_table=OLD_TABLE_NAME:NEW_TABLE_NAME remap_schema=schema_old_name:schema_new_name parallel=5
Connecting using database service:
nohup expdp system/'password'@kol-scan:1521/zamdbtdb.localdomain parfile=expdp_tablebkup_01.par &
Database Upgrade (autoupgrade.jar)
The most recent version of AutoUpgrade can be downloaded via myoracle support - 2485457.1
Copy autoupgrade.jar to any location as per your convenience
[oracle@kolkata02 auto_upgrade]$ cp /u01/app/oracle/product/19.0.0.0/dbhome_1/rdbms/admin/autoupgrade.jar /home/oracle/auto_upgrade
Create a sample config file using :
[oracle@kolkata02 auto_upgrade]$ java -jar /home/oracle/auto_upgrade/autoupgrade.jar -create_sample_file config
Created sample configuration file /home/oracle/auto_upgrade/sample_config.cfg
Now create your own config file using sample_config.cfg
[oracle@kolkata02 ~]$ vi /home/oracle/config_zamdbtdb.cfg
global.autoupg_log_dir=/u01/app/oracle/cfgtoollogs/autoupgrade/zamdbtdb1
upg1.log_dir=/home/oracle/auto_upgrade/logs/zamdbtdb1
upg1.sid=zamdbtdb1
upg1.source_home=/u01/app/oracle/product/12.2.0.1/dbhome_1
upg1.target_cdb=CNTESTDB1
upg1.target_pdb_name=zamdbtdbx -->for prechecks remove this target_pdb_name
upg1.target_pdb_copy_option=file_name_convert=('+DATA1/ZAMDBTDB','+DATA1','+RECO1/ZAMDBTDB','+RECO1','+FRA/ZAMDBTDB','+FRA') -->If you want to upgrade with copy use this option, otherwise remove this option
upg1.target_home=/u01/app/oracle/product/19.0.0.0/dbhome_1
upg1.start_time=now
upg1.upgrade_node=kolkata02.localdomain
upg1.run_utlrp=yes
upg1.timezone_upg=yes
And save it, now run the prechecks
nohup java -jar /home/oracle/auto_upgrade/autoupgrade.jar -config /home/oracle/config_zamdbtdb.cfg -mode analyze -noconsole >> /home/oracle/zamdbtdb_upg.log 2>&1 &
Otherwise you can run it in console mode as below: (PRECHECKS)
java -jar /home/oracle/auto_upgrade/autoupgrade.jar -config /home/oracle/config_zamdbtdb.cfg -mode analyze
[oracle@kolkata02 prechecks]$ pwd
/home/oracle/auto_upgrade/logs/zamdbtdb1/zamdbtdb1/102/prechecks
[oracle@kolkata02 prechecks]$ firefox zamdbtdb_preupgrade.html
java -jar /home/oracle/auto_upgrade/autoupgrade.jar -config /home/oracle/config_zamdbtdb.cfg -mode deploy -->This is console mode
FIG project queries
##### Service add & LOad Baclancing on Add Service ####### srvctl add service -s wcccdmt.farmersinsurance.com -r wcccdmtx1,wcccdmtx2,wcc...
-
ORA-00742: Log read detects lost write in thread 1 sequence 104 block 30681 You can encounter this error if your Oracle Database machine wa...
-
set linesize 180 select b.db_unique_name, a.tablespace_name ,sum(a.tots)/1024/1024/1024 "Total Size(GB)" ...