Thursday, February 18, 2016

Another Corrupt Block in Oracle 11g - fixed

2016_06_13 update
Another bad block located:
SQL Error: ORA-01578: ORACLE data block corrupted (file # 8, block # 61663)ORA-01110: data file 8: '/home/oracle/app/oracle/oradata/orcl/HYP_DM_TBL_3.DBF'

Then to fix this one I had to find the problem using:
select owner, segment_type, segment_namefrom dba_extentswhere file_id=8  and 61663  between block_id and block_id+blocks-1;
Located the ROWS that were good with this command:

select * from entity_Hour_fact where ROWNUM <2127000 order by 2;
Anything more would error with this:
SQL Error: ORA-01578: ORACLE data block corrupted (file # 8, block # 61663)ORA-01110: data file 8: '/home/oracle/app/oracle/oradata/orcl/HYP_DM_TBL_3.DBF'01578. 00000 -  "ORACLE data block corrupted (file # %s, block # %s)" *Cause:    The data block indicated was corrupt. This was a physical           corruption, also called a media corruption. The cause is unknown           but is most likely external to the database. If ORA-26040 is also           signaled, the corruption is due to NOLOGGING or UNRECOVERABLE           operations.
Will copy the old file to a new filename:
with a CTAS command:

Create Table As Select...

scroll down to see older examples.

------------------------------------------------
2016_02_18

After more bad blocks...I replaced the SSD drive.

Error in Enterprise Manager:
ORA-1578 [ORA-01578: ORACLE data block corrupted (file # 2, block # 35170)]

Error in CCC.LOG file was this:
----
### The error may exist in com/hyperformix/pb/server/mapper/IAnalyzeMapper.java (best guess)
### The error may involve defaultParameterMap
### The error occurred while setting parameters
### SQL: call DATAMART_LIB.Analyze_pb_objects()
### Cause: java.sql.SQLException:
ORA-01578: ORACLE data block corrupted (file # 2, block # 35170)
ORA-01110: data file 2: '/home/oracle/app/oracle/oradata/orcl/sysaux01.dbf'
ORA-06512: at "SYS.DBMS_STATS", line 20337
ORA-06512: at "SYS.DBMS_STATS", line 20360
ORA-06512: at "HYP_CCC9.DATAMART_LIB", line 2472
----

Then to fix this one I had to find the problem using:

select owner, segment_type, segment_name
from dba_extents
where file_id=2  and 35170  between block_id and block_id+blocks-1;
This returns:
OWNER                          SEGMENT_TYPE   SEGMENT_NAME                                               
------------------------------ ------------------       -------------------------------------------------------
SYS                                  TABLE                   WRI$_OPTSTAT_HISTGRM_HSTRY_BAD         
Using this I found that it was in the SYSAUX tablespace.

So I moved it to the SYSAUX1 tablespace, which was empty.

So I renamed the table to have a _ on the end and copied the Index definitions.

Then I use a CTAS method to copy the table.
SELECT * FROM TABLENAME WHERE ROWNUM < 410000
This allows me to get most of the table and stop pulling data before I hit the Corrupted Block.

select * from SYS.WRI$_OPTSTAT_HISTGRM_HISTORY_ where rownum < 410000 order by 3;

It was trial and error using first ROWNUM of 1000, 5000, 100000, 1000000 till I hit the error and then backed down until I got no error.

This was the CTAS command I used:

CREATE    TABLE SYS.WRI$_OPTSTAT_HISTGRM_HISTORY TABLESPACE SYSAUX1 STORAGE    (      INITIAL 500m NEXT 50m maxextents unlimited    )    parallel    (      degree 4    ) ASSELECT    *  FROM    SYS.WRI$_OPTSTAT_HISTGRM_HISTORY_  WHERE    rownum < 410000  ORDER BY    3;
These are the indexes:

  CREATE INDEX "SYS"."I_WRI$_OPTSTAT_H_OBJ#_ICOL#_ST" ON "SYS"."WRI$_OPTSTAT_HISTGRM_HISTORY" ("OBJ#", "INTCOL#", SYS_EXTRACT_UTC("SAVTIME"), "COLNAME")   PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS   STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645  PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)  TABLESPACE "SYSAUX1" ; 
  CREATE INDEX "SYS"."I_WRI$_OPTSTAT_H_ST" ON "SYS"."WRI$_OPTSTAT_HISTGRM_HISTORY" (SYS_EXTRACT_UTC("SAVTIME"))   PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS   STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645  PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)  TABLESPACE "SYSAUX1" ;
I did NOT delete the original table space I just kept it and renamed it to:

alter table "SYS"."WRI$_OPTSTAT_HISTGRM_HISTORY_" rename to WRI$_OPTSTAT_HISTGRM_HSTRY_BAD;
If I delete the bad table then the Corrupt block may get used again...

Thursday, February 11, 2016

LOADER -- overcoming problems when bringing in staging data from other Data Manager instances.

Problems with bringing in Staging data from customer site.

1.  Transaction ID
2.  Data Source Types ID's
3.  Data Source Definitions
4.  Data Type Tables
5.  Migration status tables


6. Sequence numbers.

a. Get a list from both systems with this query:

-- Find last value for all Sequences in the Schema.
-- Be sure you have all the Sequences in the sequence_name list.

SELECT  * FROM  user_sequences WHERE  sequence_name IN ('APPLICATION_DIM_ID_SEQ','BASELINES_SEQ','CLUSTER_DIM_ID_SEQ',  'CLUSTER_ENTITY_MOTION_ID_SEQ','CONFIG_ID_SEQ','CONFIG_METRIC_DIM_ID_SEQ','DIVERSE_METRIC_SEQ',  'ENTITY_ID_SEQ','ENTITY_TYPE_ID_SEQ','GLOBAL_ID_SEQ','GROUP_ENTITY_CONFIG_ID_SEQ',  'GROUP_ENTITY_TMP_CONFIG_ID_SEQ','GROUP_XML_DOCUMENT_ID','HYFY_TPP_CONFIG_ID_SEQ',  'JOB_ACTIVITY_ERROR_SEQ','JOB_ACTIVITY_MIGRATE_SEQ','JOB_DGE_DETAIL_SEQ','JOB_ID_SEQ',  'METRIC_DIM_ID_SEQ','METRIC_RANGE_ID_SEQ','MIGRATION_SESSION_ID_SEQ','PROCESS_DIM_ID_SEQ',  'PROCESS_LOG_ID_SEQ','PURGE_LOG_CONFIG_SEQ','RESOURCE_POOL_ID_SEQ','ROLLUP_ID_SEQ',  'ROLLUP_TRANS_ID_SEQ','SERVER_DIM_ID_SEQ','SERVER_VIRTUAL_DIM_ID_SEQ','SOURCE_PARAMS_CONFIG_SEQ',  'SOURCE_TYPE_CONFIG_SEQ','STANDARD_METRICS_SEQ','SUBSYSTEM_DIM_ID_SEQ','WORKLOAD_LOG_DIM_ID_SEQ',  'WORKLOAD_LOG_ID_SEQ','WORKLOAD_TRANS_DIM_ID_SEQ','WORKLOAD_TRANS_ID_SEQ','PRECALC_TYPE_SEQ'); 

b. Compare them and adjust your Data Manager with the values that are LARGER from the customers system.  Only adjust the ones that need be moved up to match the customer's system.

c.  Use this to drop a list of sequences.  This only creates the commands to run in another database session, it does not execute the changes.

--- Drop Sequence numbers

SELECT
 -- Drop SEQUENCE
'drop sequence "HYP_CCC9"."'||column_value||'";' as p
FROM
  TABLE(sys.dbms_debug_vc2coll('GROUP_XML_DOCUMENT_ID','JOB_ACTIVITY_ERROR_SEQ',
  'JOB_ACTIVITY_MIGRATE_SEQ','METRIC_DIM_ID_SEQ','MIGRATION_SESSION_ID_SEQ','PROCESS_DIM_ID_SEQ',
  'PROCESS_LOG_ID_SEQ','PURGE_LOG_CONFIG_SEQ','ROLLUP_TRANS_ID_SEQ','SERVER_DIM_ID_SEQ',
  'SERVER_VIRTUAL_DIM_ID_SEQ','SOURCE_PARAMS_CONFIG_SEQ','SOURCE_TYPE_CONFIG_SEQ',
  'CLUSTER_ENTITY_MOTION_ID_SEQ','CONFIG_ID_SEQ','DIVERSE_METRIC_SEQ','ENTITY_ID_SEQ',
  'ENTITY_TYPE_ID_SEQ','GROUP_ENTITY_CONFIG_ID_SEQ'));
  
  
d. Use this to recreate a list of sequences. This only creates the commands to run in another database session, it does not execute the changes.

-- Create Sequence number
-- Create SEQUENCE
with
part1 as
(
Select
   'CREATE SEQUENCE  "HYP_CCC9"."'||column_value||'" MINVALUE 1 MAXVALUE 9999999999999999999999999999 INCREMENT BY 1 START WITH ' as p,
   ROWNUM  rn
FROM
  TABLE(sys.dbms_debug_vc2coll('GROUP_XML_DOCUMENT_ID','JOB_ACTIVITY_ERROR_SEQ',
  'JOB_ACTIVITY_MIGRATE_SEQ','METRIC_DIM_ID_SEQ','MIGRATION_SESSION_ID_SEQ','PROCESS_DIM_ID_SEQ',
  'PROCESS_LOG_ID_SEQ','PURGE_LOG_CONFIG_SEQ','ROLLUP_TRANS_ID_SEQ','SERVER_DIM_ID_SEQ',
  'SERVER_VIRTUAL_DIM_ID_SEQ','SOURCE_PARAMS_CONFIG_SEQ','SOURCE_TYPE_CONFIG_SEQ',
  'CLUSTER_ENTITY_MOTION_ID_SEQ','CONFIG_ID_SEQ','DIVERSE_METRIC_SEQ','ENTITY_ID_SEQ',
  'ENTITY_TYPE_ID_SEQ','GROUP_ENTITY_CONFIG_ID_SEQ'))
  ),
  part2 as
  (
  select column_value||' CACHE 20 NOORDER  NOCYCLE ;' p,
  ROWNUM  rn
  from table( sys.odcinumberlist(1233,377498,1200,100751,334,201,8282,5692,258,167141,20089,100320,100140,2989,195842,153293,36641,10025,2812438))
  
  )
  select distinct p1.p||p2.p
  from part1 p1,part2 p2
  where p1.rn=p2.rn
  order by p1.p||p2.p;
  
The values are in the second part of the query and the sequence names are in the first part.
The join is matched on rownumbers.

LOADER - sqlldr - error File missing oranfsodm12.dll

This was originally from:
http://blogs.developpeur.org/jeremyjeanson/archive/2014/11/10/oracle-fichier-oranfsodm12-dll-absent-du-package-client.aspx

[Oracle] File missing oranfsodm12.dll client package

A small bug exists in the Oracle Database Client Package (12.1.0.2.0) for Microsoft Windows (32-bit) that is on the following download page :

http://www.oracle.com/technetwork/database/enterprise-edition/downloads/database12c-win64-download-2297732.html

Oranfsodm12.dll the file is missing, preventing the use of SQL * Loader.
When checking the documentation, we discover that this is a modified version of the oraodm library.

https://docs.oracle.com/database/121/NTDBI/postcfg.htm

Oraodm12.dll by copying and renaming the oranfsodm12.dll we get a usable replacement dll without NFS. It can therefore be used on a client machine, but will not benefit from features of Direct NFS Client documented here (in version 11):

http://www.oracle.com/technetwork/articles/directnfsclient-11gr1-twp-129785.pdf
If the solution is acceptable in an environment of development to a production environment, it is best to get this DLL in the package DataBase.Only problem, this package does not exist in 32-bit.