Advertisement

Monday, November 30, 2015

Oracle Database 12c - Statistics Gather Reporting

 
Database 12c came up with a brilliant feature of reporting of stats, i.e, you can run stats gather in reporting mode, rather than just running it. 

This will tell you on what all tables statistics are going to be gathered when you run your stats gather procedure with specific arguments. 

6 new procedures introduced for this
dbms_stats.report_gather_?_stats
where ? can be any of - Table, schema, dictionary, database, fixed_obj, auto

All the arguments to gather_stats procedure are valid and 2 new arguments introduced which are - 

1. detail_level - basic, typical, and all; depending on the type of details. typical is the deafult value
2. format - xml, html, and text. Text is the default value (I personally prefer html)

Below is an example of getting details of getting schema stats gather.



SQL> variable report_out clob;
SQL> set long 10000000
SQL> exec :report_out:=DBMS_STATS.REPORT_GATHER_SCHEMA_STATS ( ownname => 'MY_SCHEMA', -
                                    estimate_percent => 30, -
                                    method_opt => 'FOR ALL COLUMNS SIZE AUTO', -
                                    granularity => 'ALL', -
                                    cascade => TRUE, -
   detail_level => 'ALL', -
   format => 'HTML');
SQL> spool /tmp/stats_report.html
SQL> print report_out
..

Below is a screenshot from the html file output.  I have truncated the output and kept screenshot of only relevant data to this discussion. 




As is clear from the screenshot, we get a picture on what all tables the stats gather will take place. 
This is a really good feature, helping in developing a good stats gather technique.. 



Tuesday, November 3, 2015

Exadata - ExaWatcher configuration

 
Exawatcher is the elder brother or say sibling to OSWatcher on Exadata. It has additional diagnostics options for RDS logs/diags which are specific to Exadata only.

In this blog we see how to change the destination and the total available size for Exawatcher Logs.

I can wrap it up in 3 steps
1. Change the config
2. Stop Exawatcher
3. Start Exawatcher

Pretty neat !!

Now let's do it 

You cd to opt/oracle.ExaWatcher/archive and edit the file ExaWatcher.conf

Look for the below section precisely (it is the first section generally)
.
.
.
<ResultDir> /opt/oracle.ExaWatcher/archive
<ZipOption> bzip2
<SpaceLimit> 6047
.
.
Parameters we are looking for are ResultDir and Space Limit. 

Above is the default configuration (for X5 ODA, generally is similar for all versions of Exa Hardware)

Next we edit this to our own mount point and custom size so that it looks something like 

[root@Myexadata01 oracle.ExaWatcher]# cat ExaWatcher.conf | grep -E 'Result|Space' | tail -2
<ResultDir>  /mymount/Myexadata01
<SpaceLimit> 40960

What I have done here is redirected the output to a NAS device and then increased the space available. With all defaults 40960 should be good for around 40-45 days and Exawatcher will not clean it

On a side note cleaning of the logs is done by exawatcher script only, on the logic that it wipes clean data if mount on which it is writing is 80% or more utilized.

Okay, coming back now all we need to do is stop and start. 
We are still in the /opt/oracle.ExaWatcher directory

[root@Myexadata01 oracle.ExaWatcher]# ./ExaWatcher.sh --stop
 41500 ?        SN     0:00 /bin/bash ./ExaWatcher.sh --fromconf
[INFO     ] ExaWatcher successfully terminated!

so --stop does the stop, but starting is bit different, Below is how to start


[root@Myexadata01 oracle.ExaWatcher]# /opt/oracle.cellos/validations/bin/vldrun.pl -script oswatcher
Logging started to /var/log/cellos/validations.log
Command line is /opt/oracle.cellos/validations/bin/vldrun.pl -script oswatcher
Run validation oswatcher - PASSED


Wait for a a minute or so and Exawatcher will come up, you can see check out the status using ps utility. I have taken out one line to highlight the difference.

ps -ef | grep -i exaw

sh -c /usr/bin/vmstat  5  2 >> /mymount/Myexadata01/Vmstat.ExaWatcher/2015_11_03_04_14_00_VmstatExaWatcher_Myexadata01.mydomain

Tuesday, October 27, 2015

Oracle Database - 12c - Real-Time Database Operation Monitoring

 
In the latest release of Oracle - 12c,  Oracle has come up with another brilliant feature for performance monitoring  which is Real-Time Database Operation Monitoring.

Real time Sql monitoring was introduced in 11g and helped monitoring sql's in real time.
However, only individual sql's could be monitored. Suppose there is a batch operation or a pl/sql block having multiple calls inside it which might not trigger real-time monitoring by default though it takes a lot of DB and CPU time. 

This is where real time database operation monitoring comes in.

The concept and the way to do is straight forward, let me demonstrate. 

Execute Start of Operation
-- Do Action ----
End of Operation.


Below is my script which I will be using in this context. I have highlighted in green  start of operation and end of operation.

I will be using the infamous scott schema and a cartersian join on dba_objects to have a long running query. 

var db_opid number;

EXEC :db_opid  := dbms_sql_monitor.begin_operation ('Scott.Batch.Select', forced_tracking => 'Y');

select * from emp a, dept d;
selet * from emp;
select /*+ MONITOR */ * from dba_objects a, dba_objects  b;


EXEC dbms_sql_monitor.end_operation('Scott.Batch.Select', :db_opid );

Note - 
I have purposefully inserted the monitor hint because I wanted to monitor the sql separately in real time as well. 
If you skip the monitor hint then the db decides (on the 5 second and parallel rule) that if the sql has to be monitored or not.
I have used forced_tracking as well to force monitoring of the operation.
Scott.Batch.Select is the name given to the operation which we would see in the performance page.

I am using EM Express but you can find the same stuff in Cloud Control as well.

From the Image 1 below - you can see 2 elements being monitored
One is the sql because of the monitor hint and other is the database operation. 

From the Image 2 you can see new options added for filtering the type of operation in the Performance Page






Thursday, October 22, 2015

Oracle Database - 12c - Data Pump Error during ORA-1031 during export of SYS tables

 
Issue occurs when you do a full export of your 12c (mine is 12.1.0.2) database with export of few SYS tables. 
This is when you do a consistent export using flashback_time or flashback_scn parameter
Even if you have the role - DATAPUMP_EXP_FULL_DATABASE

when you scan your log file, you will see multiple errors similar to below -

ORA-31693: Table data object "SYS"."KU$_USER_MAPPING_VIEW" failed to load/unload and is being skipped due to error:
ORA-01031: insufficient privileges
ORA-31693: Table data object "SYS"."FGA_LOG$FOR_EXPORT" failed to load/unload and is being skipped due to error:
ORA-01031: insufficient privileges
ORA-31693: Table data object "SYS"."AUDTAB$TBS$FOR_EXPORT" failed to load/unload and is being skipped due to error:
ORA-01031: insufficient privileges
ORA-31693: Table data object "SYS"."DBA_SENSITIVE_DATA" failed to load/unload and is being skipped due to error:
ORA-01031: insufficient privileges
ORA-31693: Table data object "SYS"."DBA_TSDP_POLICY_PROTECTION" failed to load/unload and is being skipped due to error:
ORA-01031: insufficient privileges
ORA-31693: Table data object "SYS"."NACL$_ACE_EXP" failed to load/unload and is being skipped due to error:
ORA-01031: insufficient privileges
ORA-31693: Table data object "SYS"."NACL$_HOST_EXP" failed to load/unload and is being skipped due to error:
ORA-01031: insufficient privileges
ORA-31693: Table data object "SYS"."NACL$_WALLET_EXP" failed to load/unload and is being skipped due to error:

ORA-01031: insufficient privileges

The workaround is to grant flashback to the tables reporting errors 

SQL> grant flashback on "SYS"."KU$_USER_MAPPING_VIEW"  to system;
Grant succeeded.

SQL> grant flashback on "SYS"."FGA_LOG$FOR_EXPORT" to system;
Grant succeeded.

SQL> grant flashback on  "SYS"."AUDTAB$TBS$FOR_EXPORT" to system;
Grant succeeded.

SQL> grant flashback on "SYS"."DBA_SENSITIVE_DATA"  to system;
Grant succeeded.

SQL> grant flashback on  "SYS"."DBA_TSDP_POLICY_PROTECTION" to system;
Grant succeeded.

SQL> grant flashback on  "SYS"."NACL$_ACE_EXP" to system;
Grant succeeded.

SQL> grant flashback on  "SYS"."NACL$_HOST_EXP"to system;
Grant succeeded.

SQL> grant flashback on "SYS"."NACL$_WALLET_EXP"  to system;
Grant succeeded.


The issue and workaround is reported in Bug - 18844843 

Saturday, October 17, 2015

12c - Histogram-Buckets Increased in

 
Oracle significantly increased the number of histogram buckets in 12c to 2048, that is an increase by 8 folds.

In this blog, let's just prove that - 

I will use max_histogram table and insert 2048 rows into it

SQL> create table max_histograms (id number, v_number number);

Table created.

Let's now insert 2048 rows into it 

SQL>  begin
  for i in 1..2048
  loop
  insert into max_histograms values (1,i);
  end loop;
  commit;
  end;
/  

PL/SQL procedure successfully completed.

now let's gather stats with 2048 as the bucket size 

SQL> exec DBMS_STATS.GATHER_TABLE_STATS('SCOTT','MAX_HISTOGRAMS', method_opt => 'FOR COLUMNS v_number size 2048');

PL/SQL procedure successfully completed.

Wow!, it captured with bucket size 2048 (try it in 11g)
Now let's prove it

SQL> select count(*), max(endpoint_value), min(endpoint_value) 
from dba_histograms
where owner = 'SCOTT' and table_name = 'MAX_HISTOGRAMS';  

  COUNT(*) MAX(ENDPOINT_VALUE) MIN(ENDPOINT_VALUE)
---------- ------------------- -------------------
      2048  2048 1


if you want to see all the buckets individually and their values you can use the below query

select owner, table_name, column_name, column_name, endpoint_value, endpoint_repeat_count
from dba_histograms
where owner = 'SCOTT' and table_name = 'MAX_HISTOGRAMS'
order by 1,5;

Note - I have removed sql prompts at places so that it is easy in case you want to just copy/paste to see this in your machine.

Tuesday, October 13, 2015

12c - Enable Unified Auditing

 
Oracle introduced Unified Auditing in 12c
This however requires you to relink the binaries (oops downtime)..

So if you are planning to get 12c and are going to use Unified Auditing then, this is how you should enable it.

[oracle@OEL lib]$ sqlplus / as sysdbaSQL*Plus: Release 12.1.0.2.0 Production on Tue Oct 13 12:38:31 2015Copyright (c) 1982, 2014, Oracle.  All rights reserved.
Connected to:Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit ProductionWith the Partitioning, OLAP, Advanced Analytics and Real Application Testing options

I need not to come back to this output, once I relink the binaries and show you the difference. 

- Stop all the Oracle processes running from Oracle Home and relink
- Start again

This how you do it - 

[oracle@OEL lib]$ echo $ORACLE_HOME
/u01/app/oracle/product/12.1.0.2/dbhome_1
[oracle@OEL lib]$ cd $ORACLE_HOME/rdbms/lib
[oracle@OEL lib]$ make -f ins_rdbms.mk uniaud_on ioracle ORACLE_HOME=$ORACLE_HOME
/usr/bin/ar d /u01/app/oracle/product/12.1.0.2/dbhome_1/rdbms/lib/libknlopt.a kzanang.o
/usr/bin/ar cr /u01/app/oracle/product/12.1.0.2/dbhome_1/rdbms/lib/libknlopt.a /u01/app/oracle/product/12.1.0.2/dbhome_1/rdbms/lib/kzaiang.o 
chmod 755 /u01/app/oracle/product/12.1.0.2/dbhome_1/bin
.
.
.
/u01/app/oracle/product/12.1.0.2/dbhome_1/bin/oracle
chmod 6751 /u01/app/oracle/product/12.1.0.2/dbhome_1/bin/oracle

At this point unified Auditing is enabled. I have purposefully omitted some console outputs (scroll below to see the full message)
Now how do you see it, just logon to sqlplus (after staring the db_instance)

[oracle@OEL lib]$ sqlplus / as sysdba

SQL*Plus: Release 12.1.0.2.0 Production on Tue Oct 13 12:45:00 2015

Copyright (c) 1982, 2014, Oracle.  All rights reserved.


Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics, Real Application Testing
and Unified Auditing options

Now Unified Auditing is turned on - It provides quite a lot of good features in auditing and security arena.

Execute the below query now -

SQL> /select value from V$option where parameter = 'Unified Auditing'

VALUE
----------------------------------------------------------------
TRUE


Unified Auditing is available for PDB architecture as well,.

Full output - re-linking binaries - 

[oracle@OEL lib]$ echo $ORACLE_HOME
/u01/app/oracle/product/12.1.0.2/dbhome_1
[oracle@OEL lib]$ cd $ORACLE_HOME/rdbms/lib
[oracle@OEL lib]$ make -f ins_rdbms.mk uniaud_on ioracle ORACLE_HOME=$ORACLE_HOME
/usr/bin/ar d /u01/app/oracle/product/12.1.0.2/dbhome_1/rdbms/lib/libknlopt.a kzanang.o
/usr/bin/ar cr /u01/app/oracle/product/12.1.0.2/dbhome_1/rdbms/lib/libknlopt.a /u01/app/oracle/product/12.1.0.2/dbhome_1/rdbms/lib/kzaiang.o 
chmod 755 /u01/app/oracle/product/12.1.0.2/dbhome_1/bin

 - Linking Oracle 
rm -f /u01/app/oracle/product/12.1.0.2/dbhome_1/rdbms/lib/oracle
/u01/app/oracle/product/12.1.0.2/dbhome_1/bin/orald  -o /u01/app/oracle/product/12.1.0.2/dbhome_1/rdbms/lib/oracle -m64 -z noexecstack -Wl,--disable-new-dtags -L/u01/app/oracle/product/12.1.0.2/dbhome_1/rdbms/lib/ -L/u01/app/oracle/product/12.1.0.2/dbhome_1/lib/ -L/u01/app/oracle/product/12.1.0.2/dbhome_1/lib/stubs/   -Wl,-E /u01/app/oracle/product/12.1.0.2/dbhome_1/rdbms/lib/opimai.o /u01/app/oracle/product/12.1.0.2/dbhome_1/rdbms/lib/ssoraed.o /u01/app/oracle/product/12.1.0.2/dbhome_1/rdbms/lib/ttcsoi.o -Wl,--whole-archive -lperfsrv12 -Wl,--no-whole-archive /u01/app/oracle/product/12.1.0.2/dbhome_1/lib/nautab.o /u01/app/oracle/product/12.1.0.2/dbhome_1/lib/naeet.o /u01/app/oracle/product/12.1.0.2/dbhome_1/lib/naect.o /u01/app/oracle/product/12.1.0.2/dbhome_1/lib/naedhs.o /u01/app/oracle/product/12.1.0.2/dbhome_1/rdbms/lib/config.o  -lserver12 -lodm12 -lcell12 -lnnet12 -lskgxp12 -lsnls12 -lnls12  -lcore12 -lsnls12 -lnls12 -lcore12 -lsnls12 -lnls12 -lxml12 -lcore12 -lunls12 -lsnls12 -lnls12 -lcore12 -lnls12 -lclient12  -lvsn12 -lcommon12 -lgeneric12 -lknlopt `if /usr/bin/ar tv /u01/app/oracle/product/12.1.0.2/dbhome_1/rdbms/lib/libknlopt.a | grep xsyeolap.o > /dev/null 2>&1 ; then echo "-loraolap12" ; fi` -lskjcx12 -lslax12 -lpls12  -lrt -lplp12 -lserver12 -lclient12  -lvsn12 -lcommon12 -lgeneric12 `if [ -f /u01/app/oracle/product/12.1.0.2/dbhome_1/lib/libavserver12.a ] ; then echo "-lavserver12" ; else echo "-lavstub12"; fi` `if [ -f /u01/app/oracle/product/12.1.0.2/dbhome_1/lib/libavclient12.a ] ; then echo "-lavclient12" ; fi` -lknlopt -lslax12 -lpls12  -lrt -lplp12 -ljavavm12 -lserver12  -lwwg  `cat /u01/app/oracle/product/12.1.0.2/dbhome_1/lib/ldflags`    -lncrypt12 -lnsgr12 -lnzjs12 -ln12 -lnl12 -lnro12 `cat /u01/app/oracle/product/12.1.0.2/dbhome_1/lib/ldflags`    -lncrypt12 -lnsgr12 -lnzjs12 -ln12 -lnl12 -lnnzst12 -lzt12 -lztkg12 -lmm -lsnls12 -lnls12  -lcore12 -lsnls12 -lnls12 -lcore12 -lsnls12 -lnls12 -lxml12 -lcore12 -lunls12 -lsnls12 -lnls12 -lcore12 -lnls12 -lztkg12 `cat /u01/app/oracle/product/12.1.0.2/dbhome_1/lib/ldflags`    -lncrypt12 -lnsgr12 -lnzjs12 -ln12 -lnl12 -lnro12 `cat /u01/app/oracle/product/12.1.0.2/dbhome_1/lib/ldflags`    -lncrypt12 -lnsgr12 -lnzjs12 -ln12 -lnl12 -lnnzst12 -lzt12 -lztkg12   -lsnls12 -lnls12  -lcore12 -lsnls12 -lnls12 -lcore12 -lsnls12 -lnls12 -lxml12 -lcore12 -lunls12 -lsnls12 -lnls12 -lcore12 -lnls12 `if /usr/bin/ar tv /u01/app/oracle/product/12.1.0.2/dbhome_1/rdbms/lib/libknlopt.a | grep "kxmnsd.o" > /dev/null 2>&1 ; then echo " " ; else echo "-lordsdo12 -lserver12"; fi` -L/u01/app/oracle/product/12.1.0.2/dbhome_1/ctx/lib/ -lctxc12 -lctx12 -lzx12 -lgx12 -lctx12 -lzx12 -lgx12 -lordimt12 -lclsra12 -ldbcfg12 -lhasgen12 -lskgxn2 -lnnzst12 -lzt12 -lxml12 -locr12 -locrb12 -locrutl12 -lhasgen12 -lskgxn2 -lnnzst12 -lzt12 -lxml12  -lgeneric12 -loraz -llzopro -lorabz2 -lipp_z -lipp_bz2 -lippdcemerged -lippsemerged -lippdcmerged  -lippsmerged -lippcore  -lippcpemerged -lippcpmerged  -lsnls12 -lnls12  -lcore12 -lsnls12 -lnls12 -lcore12 -lsnls12 -lnls12 -lxml12 -lcore12 -lunls12 -lsnls12 -lnls12 -lcore12 -lnls12 -lsnls12 -lunls12  -lsnls12 -lnls12  -lcore12 -lsnls12 -lnls12 -lcore12 -lsnls12 -lnls12 -lxml12 -lcore12 -lunls12 -lsnls12 -lnls12 -lcore12 -lnls12 -lasmclnt12 -lcommon12 -lcore12  -laio -lons    `cat /u01/app/oracle/product/12.1.0.2/dbhome_1/lib/sysliblist` -Wl,-rpath,/u01/app/oracle/product/12.1.0.2/dbhome_1/lib -lm    `cat /u01/app/oracle/product/12.1.0.2/dbhome_1/lib/sysliblist` -ldl -lm   -L/u01/app/oracle/product/12.1.0.2/dbhome_1/lib
test ! -f /u01/app/oracle/product/12.1.0.2/dbhome_1/bin/oracle ||\
   mv -f /u01/app/oracle/product/12.1.0.2/dbhome_1/bin/oracle /u01/app/oracle/product/12.1.0.2/dbhome_1/bin/oracleO
mv /u01/app/oracle/product/12.1.0.2/dbhome_1/rdbms/lib/oracle /u01/app/oracle/product/12.1.0.2/dbhome_1/bin/oracle
chmod 6751 /u01/app/oracle/product/12.1.0.2/dbhome_1/bin/oracle

Friday, October 9, 2015

RMAN vs ZFS Compression

 
Continuing from my Last blog on ZFS compression, this is the RMAN day.

I wanted to bring about few statistics in performance (time and space) but this time -
RMAN versus ZFS compression.

RMAN does compresses on the fly (cliche is it??)

I did a test of backing up 2 datafiles size 2*30GB using RMAN basic compression on ZFS with no compression enabled and then RMAN no compression with ZFS compression enabled to LZJB.

I have already shown that compressing above lzjb certainly requires you to monitor controller's cpu utilization carefully.

(My Setup is same as last time ZFS - 7330, exadata - quarter rack, with both connected using infiniband network)

Here are few statistics for your for 2 datafiles to get the maths running in the head  -
I will give for the full database next.


Raw DF size
Backup Type
Time Taken
Ratio  
Size (raw)
Size (ZFS)
Ratio (Size, appx)
(Time, appx)
61440 GB -2 Datafiles  
Normal
55 secs
1
15GB
4.0GB
1
61440 GB -2 Datafiles  
Compressed backupset
5:45 minutes
6
2.2GB
2.2GB
0.5


So now you can start doing the math in your head. Pretty neat isn't it.
Remember the compression was LZJB in the first case.  ZFS compressed it nicely.
Now here are the stats for the full databases, I have rounded out few figures for better calculation, the key idea is that you should get the broader picture..


Database
Backup Type
Time Taken
Ratio  
Size (raw)
Size (ZFS)
Ratio (Size, appx)
(Time, appx)
6.0TB
Normal
2 hours
1
2.8T
1.8T
1.5
6.0TB
Compressed backupset
10 hours
5
1.2T
1.2T
1

Note - Am not really good in formatting, so you see some stuff moving out of the ruler lines, pardon me for that :).