Thursday, February 12, 2015

Big Data - Real and Practical Use Cases(copied from oracle blog)

Big Data - Real and Practical Use Cases
By Jean-Pierre Dijcks on Nov 27, 2013
The goal of this post is to explain in a few succinct patterns how organizations can start to work with big data and identify credible and doable big data projects. This goal is achieved by describing a set of general patterns that can be seen in the market today.
Big Data Usage Patterns
The following usage patterns are derived from actual customer projects across a large number of industries and cross boundaries between commercial enterprises and public sector. These patterns are also geographically applicable and technically feasible with today’s technologies.
This paper will address the following four usage patterns:
·         Data Factory – a pattern that enable an organization to integrate and transform – in a batch method – large diverse data sets before moving this data into an upstream system like an RDBMS or a NoSQL system. Data in the data factory is possibly transient and the focus is on data processing.
·         Data Warehouse Expansion with a Data Reservoir – a pattern that expands the data warehouse with a large scale Hadoop system to capture data at lower grain and higher diversity, which is then fed into upstream systems. Data in the data reservoir is persistent and the focus is on data processing as well as data storage as well as the reuse of data.
·         Information Discovery with a Data Reservoir – a pattern that creates a data reservoir for discovery data marts or discovery systems like Oracle Endeca to tap into a wide range of data elements. The goal is to simplify data acquisition into discovery tools and to initiate discovery on raw data.
·         Closed Loop Recommendation and Analytics system – a pattern that is often considered the holy grail of data systems. This pattern combines both analytics on historical data, event processing or real time actions on current events and closes the loop between the two to continuously improve real time actions based on current and historical event correlation.
Pattern 1: Data Factory
The core business reason to build a Data Factory as it is presented here is to implement a cost savings strategy by placing long-running batch jobs on a cheaper system. The project is often funded by not spending money on the more expensive system – for example by switching Mainframe MIPS off  - and instead leveraging that cost savings to fund the Data Factory. The first figure shows a simplified implementation of the Data Factory.
As the image below shows, the data factory must be scalable, flexible and (more) cost effective for processing the data. The typical system used to build a data factory is Apache Hadoop or in the case of Oracle’s Big Data Appliance – Cloudera’s Distribution including Apache Hadoop (CDH).
data factory
Hadoop (and therefore Big Data Appliance and CDH) offers an extremely scalable environment to process large data volumes (or a large number of small data sets) and jobs. Most typical is the offload of large batch updates, matching and de-duplication jobs etc. Hadoop also offers a very flexible model, where data is interpreted on read, rather than on write. This idea enables a data factory to quickly accommodate all types of data, which can then be processed in programs written in Hive, Pig or MapReduce.
As shown in above the data factory is an integration platform, much like an ETL tool. Data sets land in the data factory, batch jobs process data and this processed data moves into the upstream systems. These upstream systems include RDBMS’s which are then used for various information needs. In the case of a Data Warehouse, this is very close to pattern 2 described below, with the difference that in the data factory data is often transient and removed after the processing is done.
This transient nature of data is not a required feature, but it is often implemented to keep the Hadoop cluster relatively small. The aim is generally to just transform data in a more cost effective manner.
In the case of an upstream system in NoSQL systems, data is often prepared in a specific key-value format to be served up to end applications like a website. NoSQL databases work really well for that purpose, but the batch processing is better left to Hadoop cluster.
It is very common for data to flow in the reverse order or for data from RDBMS or NoSQL databases to flow into the data factory. In most cases this is reference data, like customer master data. In order to process new customer data, this master data is required in the Data Factory.
Because of its low risk profile – the logic of these batch processes is well known and understood – and funding from savings in other systems, the Data Factory is typically an IT department’s first attempt at a big data project. The down side of a Data Factory project is that business users see very little benefits in that they do not get new insights out of big data.
Pattern 2: Data Warehouse Expansion
The common way to drive new insights out of big data is pattern two. Expanding the data warehouse with a data reservoir enables an organization to expand the raw data captured in a system that is able to add agility to the organization. The graphical pattern is shown in below.

DW Expansion
A Data Reservoir – like the Data Factory from Pattern 1 – is based on Hadoop and Oracle Big Data Appliance, but rather then have transient data and just process data and then hand the data off, a Data Reservoir aims to store data at a lower than previously stored grain for a period much longer than previous periods.
The Data Reservoir is initially used to capture data, aggregate new metrics and augment (not replace) the data warehouse with new and expansive KPIs or context information. A very typical addition is the sentiment of a customer towards a product or brand which is added to a customer table in the data warehouse.
The addition of new KPIs or new context information is a continuous process. That is, new analytics on raw and correlated data should find their way into the upstream Data Warehouse on a very, very regular basis.
As the Data Reservoir grows and starts to become known to exist because of the new KPIs or context, users should start to look at the Data Reservoir as an environment to “experiment” and “play” with data. With some rudimentary programming skills power users can start to combine various data elements in the Data Reservoir, using for example Hive. This enables the users to verify a hypotheses without the need to build a new data mart. Hadoop and the Data Reservoir now becomes an economically viable sandbox for power users driving innovation, agility and possibly revenue from hitherto unused data.
Pattern 3: Information Discovery
Agility for power users and expert programmers is one thing, but eventually the goal is to enable business users to discover new and exciting things in the data. Pattern 3 combines the data reservoir with a special information discovery system to provide a Graphical User Interface specifically for data discovery. This GUI emulates in many ways how an end user today searches for information on the internet.
To empower a set of business users to truly discover information, they first and foremost require a Discovery tool. A project should therefore always start with that asset.
https://blogs.oracle.com/datawarehousing/resource/BigDataPosts/scaleout_discovery.jpg
Once the Discovery tool (like Oracle Endeca) is in place, it pays to start to leverage the Data Reservoir to feed the Discovery tool. As is shown above, the Data Reservoir is continuously fed with new data. The Discovery tool is a business user’s tool to create ad-hoc data marts in the discovery tool. Having the Data Reservoir simplifies the acquisition by end users because they only need to look in one place for data.
In essence, the Data Reservoir now is used to drive two different systems; the Data Warehouse and the Information Discovery environment and in practice users will very quickly gravitate to the appropriate system. But no matter which system they use, they now have the ability to drive value from data into the organization.
Pattern 4: Closed Loop Recommendation and Analytics System
So far, most of what was discussed was analytics and batch based. But a lot of organizations want to come to some real time interaction model with their end customers (or in the world of the Internet of Things – with other machines and sensors).
Closed Loop System
Hadoop is very good at providing the Data Factory and the Data Reservoir, at providing a sandbox, at providing massive storage and processing capabilities, but it is less good at doing things in real time. Therefore, to build a closed loop recommendation system – which should react in real time – Hadoop is only one of the components .
Typically the bottom half of the last figure is akin to pattern 2 and is used to catch all data, analyze the correlations between recorded events (detected fraud for example) and generate a set of predictive models describing something like “if a, b and c during a transaction – mark as suspect and hand off to an agent”. This model would for example block a credit card transaction.
To make such a system work it is important to use the right technology at both levels. Real time technologies like Oracle NoSQL Database, Oracle Real Time Decisions and Oracle Event Processing work on the data stream in flight. Oracle Big Data Appliance, Oracle Exadata/Database and Oracle Advanced Analytics provide the infrastructure to create, refine and expose the models.
Summary
Today’s big data technologies offer a wide variety of capabilities. Leveraging these capabilities with the existing environment and skills already in place according to the four patterns described does enable an organization to benefit from big data today. It is a matter of identifying the applicable pattern for your organization and then to start on the implementation.
The technology is ready. Are you?


Wednesday, November 12, 2014

_optimizer_use_feedback

There is a bug in 11.2.0.2 and 11.2.0.3 that causes worse plan. need to add hint /*+OPT_PARAM('_optimizer_use_feedback','false') */ to resolve the issue.

 symptom:
first run --fast
second and onward runs --very slow
do 10046, you will see a lot of physical reads query on v$sql, you will see the plan_hash_values are different.

Friday, October 31, 2014

How to fix ORA-01103 during DB clone

Option 1: CREATE CONTROLFILE REUSE SET DATABASE dbname LOGFILE GROUP 1 ('FILENAME','FILENAME2') SIZE 50K, GROUP 2 ('FILENAME','FILENAME2') SIZE 50K RESETLOGS DATAFILE 'FILENAME' SIZE 2M Option 2: use backup controlfile to trace Option 3: Use NID to reset DBname

Monday, November 15, 2010

scp, ssh, and rsync no prompting solution

Source host: oratest-sg29
Destination host: oradev01

1. On oratest-sg29, run this command as scpuser or whoever runs the scp in shell script.
$ ssh-keygen -t rsa
Press enter, then it will generate a public key and a private key.
Don’t share the private key.
The public key should have been saved on
/.ssh/id_rsa.pub
=====sample output=======
[oradev03 2] [portald] ~ > ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/export/home/oracle/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /export/home/oracle/.ssh/id_rsa.
Your public key has been saved in /export/home/oracle/.ssh/id_rsa.pub.
The key fingerprint is:
58:07:9d:ae:69:48:b3:8b:2a:65:2b:3a:8f:ff:ea:80 oracle@oradev03
[15:18:57]
[oradev03 3] [portald] ~ >


2. Scp id_rsa.pub from source/oratest-sg29 to destination/oradev01.


3. On destination server, login as the remote user which you plan to use scp.


4. Copy the contents of id_rsa.pub to ~/.ssh/authorized_keys
===========sample============
$ cat id_rsa.pub >>~/.ssh/authorized_keys
$ chmod 700 ~/.ssh/authorized_keys


5. Done. Enjoy the no prompt scp!

Monday, November 8, 2010

How External Table Works in StandBy Database

Standby database/Data Guard is highly used for reporting purposes. However, when you want to write some log data for your reporting purpose, you might encounter an issue that you are not allowed to do so on the standby instance.

In this case, using External Table is an option. You can create a stored procedure and use it to write os file for the external table.

Here is a sample code.

PROCEDURE wrt_transaction_log (p_job_id IN NUMBER,
p_programname IN VARCHAR2,
p_filename IN VARCHAR2,
p_full IN VARCHAR2,
p_feedstartts IN DATE,
p_feedendts IN DATE,
p_status IN VARCHAR2,
p_message IN VARCHAR2)
IS
v_output_file UTL_FILE.file_type;
filename VARCHAR2 (100);
v_string VARCHAR2 (2000);
nodata EXCEPTION;
BEGIN
EXECUTE IMMEDIATE ('ALTER SESSION SET NLS_DATE_FORMAT = ''YYYY-MM-DD HH24:MI:SS''');

filename := 'at_genpdfile_pkg_log_ext.txt';
v_output_file := UTL_FILE.fopen ('XTABLES', filename, 'A');

v_string :=
at_genpdfile_pkg_log_seq.NEXTVAL
|| '|'
|| p_job_id
|| '|'
|| USER
|| '|'
|| p_programname
|| '|'
|| p_filename
|| '|'
|| p_full
|| '|'
|| p_feedstartts
|| '|'
|| p_feedendts
|| '|'
|| p_status
|| '|'
|| p_message
|| '|'
|| SYSDATE;
UTL_FILE.put_line (v_output_file, v_string);
UTL_FILE.fclose_all;
END;

Thursday, November 4, 2010

How To Configure APEX Not To Prompt For User/Password

When I installed APEX for our clinical research using EPG, we got prompted to enter anonymous username password everytime. Try google...no luck. Oracle support just refuse my ticket because they just don't support 10gR2 using EPG....so I have to figure it out by my own in meta link.

Here is the solution:

If anonymous access to XML DB repository data via HTTP is not required, then you do not have to perform this step.

If anonymous access to XML DB repository data via HTTP is required, then you must provide correct configuration information, as described in this section. The administrator must carefully consider whether anonymous access is to be allowed, given the inherent security risks.

If you wish to have anonymous access to XML DB repository data via HTTP, you must change the XML DB configuration file (located at /xdbconfig.xml in the repository) by adding an additional element "allow-repository-anonymous-access" and set this new element to true, in addition to unlocking the ANONYMOUS user account.



connect sys/password@tns_alias AS SYSDBA

-- enable anonymous access to XDB repository

SET SERVEROUTPUT ON
DECLARE
l_cfgxml XMLTYPE;
l_value VARCHAR2(5) := 'true'; -- (true/false)
BEGIN
l_cfgxml := DBMS_XDB.cfg_get();

IF l_cfgxml.existsNode('/xdbconfig/sysconfig/protocolconfig/httpconfig/allow-repository-anonymous-access') = 0 THEN
-- Add missing element.
SELECT insertChildXML
(
l_cfgxml,
'/xdbconfig/sysconfig/protocolconfig/httpconfig',
'allow-repository-anonymous-access',
XMLType('' ||
l_value ||
'
'),
'xmlns="http://xmlns.oracle.com/xdb/xdbconfig.xsd"'
)
INTO l_cfgxml
FROM dual;

DBMS_OUTPUT.put_line('Element inserted.');
ELSE
-- Update existing element.
SELECT updateXML
(
DBMS_XDB.cfg_get(),
'/xdbconfig/sysconfig/protocolconfig/httpconfig/allow-repository-anonymous-access/text()',
l_value,
'xmlns="http://xmlns.oracle.com/xdb/xdbconfig.xsd"'
)
INTO l_cfgxml
FROM dual;

DBMS_OUTPUT.put_line('Element updated.');
END IF;

DBMS_XDB.cfg_update(l_cfgxml);
DBMS_XDB.cfg_refresh;
END;
/




Once the "" element is set to "true", anonymous access to the XML DB repository, but not web services, is enabled by unlocking the anonymous database account.



connect sys/password@tns_alias AS SYSDBA

ALTER USER anonymous ACCOUNT UNLOCK;
Removing anonymous access to the XML DB repository, not web services, can be accomplished by locking the anonymous database account, or setting the "" element back to "false".

If you need to remove the "" element entirely, it can be accomplished using the following code:

connect sys/password@tns_alias AS SYSDBA

SET SERVEROUTPUT ON
DECLARE
l_cfgxml XMLTYPE;
BEGIN
l_cfgxml := DBMS_XDB.cfg_get();

IF l_cfgxml.existsNode('/xdbconfig/sysconfig/protocolconfig/httpconfig/allow-repository-anonymous-access') != 0 THEN
SELECT deleteXML
(
l_cfgxml,
'/xdbconfig/sysconfig/protocolconfig/httpconfig/allow-repository-anonymous-access',
'xmlns="http://xmlns.oracle.com/xdb/xdbconfig.xsd"'
)
INTO l_cfgxml
FROM dual;

DBMS_XDB.cfg_update(l_cfgxml);
DBMS_XDB.cfg_refresh;

DBMS_OUTPUT.put_line('Element deleted.');
END IF;
END;
/

Added more to my mindmap tool

 This essay version allows you to add long essays to each topic. https://www.free-mindmap.com/Mindmap4LawSchoolEssay.html As I promised, the...