Monday, April 26, 2010

Enterprise Manager Grid Control 11gR1

Enterprise Manager Grid Control is a system management software that delivers centralized monitoring, administration, and life cycle management functionality for the complete IT infrastructure, including systems running Oracle and non-Oracle technologies.
Enterprise Manager Grid Control Architecture
- Oracle Management Agent (Management Agent)
- Oracle Management Service (OMS)
- Oracle Management Repository (Management Repository)
- Enterprise Manager Grid Control Console

How to Install Grid Control 11g? We can review on OEM document -> Oracle® Enterprise Manager Grid Control Basic Installation Guide and Step by step Installation of 11.1 Grid control [ID 1059516.1] (oracle support).
Install Grid Control 11g (my test):
1. Install WLS 10.3.2
2. Install Oracle Database(Enterprise Edition) and Create Database (ID 412431.1)
3. Install Grid control 11g
$ emctl status oms
Oracle Enterprise Manager 11g Release 1 Grid Control
Copyright (c) 1996, 2010 Oracle Corporation. All rights reserved.
WebTier is Up
Oracle Management Server is Up
After Installed, We should be able to access webs.
- WebLogic Server Administrator Console https://hostname:7101/console/

- OEM Grid Control https://hostname:7799/em/

However we can review Features.
Reference:
OEM 11gR1 Documentation
OEM Downloads
Oracle Database 11gR2
Oracle WebLogic Server

Sunday, April 25, 2010

Oracle User Group in Thailand

The Oracle User Group in Thailand was founded in 2010. This group is for all Oracle users contribute, share and interest.(Website,Facebook)
I wish this group:
- Exchange of information in the Oracle community(Thailand)
- Create education opportunities related to Oracle's products
- Increase the effective use of Oracle products in the community
- Provide a channel for those interested in Oracle's products
- Encourage excellence in those using Oracle's products

Sunday, April 18, 2010

Oracle Coherence 3.5 Book

Coherence provides replicated and distributed (partitioned) data management and caching services on top of a reliable, highly scalable peer-to-peer clustering protocol. We can learn more at Oracle Coherence Knowledge Base.

I mention a book titles Oracle Coherence 3.5 written by Leading Oracle Coherence => Aleksandar Seovic, Mark Falco, Patrick Peralta (Blog)... this essential book will teach us how to use Oracle Coherence. This book will teach us from Good Samples.

This book provides best practice, idea and guide from simple to more advanced topic. When we need to learn/implement Oracle Coherence, this book is helpful.

What we will learn from this book:
- Best use distributed caching to reduce the load on the backend database
- Design and implement your domain objects to work most effectively with Coherence
- Apply Domain Driven Design (DDD) principles to Coherence applications
- Query and aggregate data efficiently within the Coherence grid
- Boost application performance by executing tasks in parallel within the grid
- Leverage Coherence events and continuous queries to provide real-time updates to client applications
- Integrate various persistence technologies, such as JDBC, Hibernate, or TopLink, with Coherence
- Access Coherence from .NET and C++ applications using Coherence*Extend
- Test and debug Coherence-related code

Thursday, April 15, 2010

Learn to install SQL*Plus(Instant Client) or Learn More...

Installation PHP + OCI8, we have to use Instant Client Package(Basic) and Instant Client Package(SDK). but If we need to use SQL*Plus to test something by connection to Oracle Database. We have to use Instant Client Package(Basic) and Instant Client Package(SQL*Plus).
$ unzip oracle-instantclient11.2-basic-11.2.0.1.0-1.x86_64.zip
Archive: oracle-instantclient11.2-basic-11.2.0.1.0-1.x86_64.zip
inflating: instantclient_11_2/BASIC_README
inflating: instantclient_11_2/adrci
inflating: instantclient_11_2/genezi
inflating: instantclient_11_2/libclntsh.so.11.1
inflating: instantclient_11_2/libnnz11.so
inflating: instantclient_11_2/libocci.so.11.1
inflating: instantclient_11_2/libociei.so
inflating: instantclient_11_2/libocijdbc11.so
inflating: instantclient_11_2/ojdbc5.jar
inflating: instantclient_11_2/ojdbc6.jar
inflating: instantclient_11_2/xstreams.jar

$ unzip oracle-instantclient11.2-sqlplus-11.2.0.1.0-1.x86_64.zip
Archive: oracle-instantclient11.2-sqlplus-11.2.0.1.0-1.x86_64.zip
inflating: instantclient_11_2/SQLPLUS_README
inflating: instantclient_11_2/glogin.sql
inflating: instantclient_11_2/libsqlplus.so
inflating: instantclient_11_2/libsqlplusic.so
inflating: instantclient_11_2/sqlplus

$ cd instantclient_11_2
$ ./sqlplus
./sqlplus: error while loading shared libraries: libsqlplus.so: cannot open shared object file: No such file or directory
We learned to install SQL*Plus(Instant Client) and we were learning to make it work, then checked "libsqlplus.so" shared library file.
$ ls -l libsqlplus.so
-r-xr-xr-x 1 oracle oinstall 1470768 Aug 15 2009 libsqlplus.so
then used "ldd" to help.
ldd prints the shared libraries required by each program or shared library specified on the command line.
$ ldd sqlplus
libsqlplus.so => not found
libclntsh.so.11.1 => not found
libnnz11.so => not found
libdl.so.2 => /lib64/libdl.so.2 (0x0000003fc1f00000)
libm.so.6 => /lib64/tls/libm.so.6 (0x0000003fc1d00000)
libpthread.so.0 => /lib64/tls/libpthread.so.0 (0x0000003fc2100000)
libnsl.so.1 => /lib64/libnsl.so.1 (0x0000003fc9400000)
libc.so.6 => /lib64/tls/libc.so.6 (0x0000003fc1a00000)
/lib64/ld-linux-x86-64.so.2 (0x0000003fc1600000)
"sqlplus" command could not load shared libraries. checked all shared libraries = "not found"
$ ls -l libsqlplus.so libclntsh.so.11.1 libnnz11.so
-rwxrwxr-x 1 oracle oinstall 48797739 Aug 15 2009 libclntsh.so.11.1
-r-xr-xr-x 1 oracle oinstall 7899997 Aug 15 2009 libnnz11.so
-r-xr-xr-x 1 oracle oinstall 1470768 Aug 15 2009 libsqlplus.so

$ pwd
/opt/instantclient_11_2
then used LD_LIBRARY_PATH environment variable.
The environment variable LD_LIBRARY_PATH is a colon-separated set of directories where libraries should be searched for first, before the standard set of directories.
$ export LD_LIBRARY_PATH=/opt/instantclient_11_2:$LD_LIBRARY_PATH

$ ldd sqlplus
libsqlplus.so => /opt/instantclient_11_2/libsqlplus.so (0x0000002a95557000)
libclntsh.so.11.1 => /opt/instantclient_11_2/libclntsh.so.11.1 (0x0000002a9573f000)
libnnz11.so => /opt/instantclient_11_2/libnnz11.so (0x0000002a97c6f000)
libdl.so.2 => /lib64/libdl.so.2 (0x0000003fc1f00000)
libm.so.6 => /lib64/tls/libm.so.6 (0x0000003fc1d00000)
libpthread.so.0 => /lib64/tls/libpthread.so.0 (0x0000003fc2100000)
libnsl.so.1 => /lib64/libnsl.so.1 (0x0000003fc9400000)
libc.so.6 => /lib64/tls/libc.so.6 (0x0000003fc1a00000)
libaio.so.1 => /usr/lib64/libaio.so.1 (0x0000003fc1800000)
/lib64/ld-linux-x86-64.so.2 (0x0000003fc1600000)
"sqlplus" command could load all shares libraries.
$ ./sqlplus

SQL*Plus: Release 11.2.0.1.0 Production on Thu Apr 15 20:58:18 2010

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

Enter user-name:
We can use SQL*Plus(Instant Client), we learned to make it work (learned to fix and use shell command). so We learned more...

However, If we need to make it work faster... and don't necessary to learn more... (just need it work). After unzip file:
$ pwd
/opt/instantclient_11_2
$ export TNS_ADMIN=/opt/instantclient_11_2
$ export LD_LIBRARY_PATH=/opt/instantclient_11_2:$LD_LIBRARY_PATH
$ export PATH=$PATH:/opt/instantclient_11_2
$ sqlplus user/pwd@DB

SQL*Plus: Release 11.2.0.1.0 Production on Thu Apr 15 21:50:53 2010

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

Connected to:
Oracle Database 11g Enterprise Edition Release
With the Partitioning, Real Application Clusters, OLAP, Data Mining
and Real Application Testing options

SQL>
TNS_ADMIN environment is the directory containing the tnsnames.ora file.

Reference(To Learn More):
Oracle Database Instant Client
SQL*Plus Instant Client
Linux Shared Libraries
Filesystem Hierarchy Standard

/lib : Essential shared libraries and kernel modules
Purpose:
The /lib directory contains those shared library images needed to boot the system and run the commands in the root filesystem, ie. by binaries in /bin and /sbin.

/usr/lib : Libraries for programming and packages
Purpose:
/usr/lib includes object files, libraries, and internal binaries that are not intended to be executed directly by users or shell scripts.
Applications may use a single subdirectory under /usr/lib. If an application uses a subdirectory, all architecture-dependent data exclusively used by the application must be placed within that subdirectory.

Wednesday, April 14, 2010

FIXING BLOCK CORRUPTION (RMAN 11G)

How do you fix block corruption? I just tested to fix block corruption on 11g. FIXING BLOCK CORRUPTION (RMAN 11G)

Tuesday, April 06, 2010

Change! When Oracle Version Change

ERROR at line 1:
ORA-01722: invalid number
My friend told me, He found error on script/program after he used with 10gR2, But no problem on 10gR1.
SQL> select * from v$version;

BANNER
----------------------------------------------------------------
Oracle Database 10g Enterprise Edition Release 10.1.0.3.0
PL/SQL Release 10.1.0.3.0
CORE 10.1.0.3.0
TNS for Linux: Version 10.1.0.3.0
NLSRTL Version 10.1.0.3.0

SQL> SELECT a.Current_proc, b.Max_proc, ROUND(((b.Max_proc-a.Current_proc)/b.Max_proc)*100, 0) Alert_proc FROM (SELECT COUNT(*)Current_proc FROM sys.v_$process) a,(SELECT value Max_proc FROM sys.v_$parameter WHERE name = 'processes') b WHERE ROUND(((b.Max_proc-a.Current_proc)/b.Max_proc)*100,0) < 15;

no rows selected

SQL> select * from v$version;

BANNER
----------------------------------------------------------------
Oracle Database 10g Enterprise Edition Release 10.2.0.3.0
PL/SQL Release 10.2.0.3.0
CORE 10.2.0.3.0
TNS for Linux: Version 10.2.0.3.0
NLSRTL Version 10.2.0.3.0

SQL> SELECT a.Current_proc, b.Max_proc, ROUND(((b.Max_proc-a.Current_proc)/b.Max_proc)*100, 0) Alert_proc FROM (SELECT COUNT(*)Current_proc FROM sys.v_$process) a,(SELECT value Max_proc FROM sys.v_$parameter WHERE name = 'processes') b WHERE ROUND(((b.Max_proc-a.Current_proc)/b.Max_proc)*100,0) < 15;

SELECT a.Current_proc, b.Max_proc, ROUND(((b.Max_proc-a.Current_proc)/b.Max_proc)*100, 0) Alert_proc FROM (SELECT COUNT(*)Current_proc FROM sys.v_$process) a,(SELECT value Max_proc FROM sys.v_$parameter WHERE name = 'processes') b WHERE ROUND(((b.Max_proc-a.Current_proc)/b.Max_proc)*100,0) < 15
*
ERROR at line 1:
ORA-01722: invalid number
Query is multiplying a column with varchar2 data type with a number column. This may or may not succeed depending on the query plan. Oracle cannot guarantee plans to remain same across database versions. With new features in a new release query plans can always change.

On 10gR1:
----------------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
----------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 358 | 72 (0)| 00:00:01 |
| 1 | NESTED LOOPS | | 1 | 358 | 72 (0)| 00:00:01 |
| 2 | NESTED LOOPS | | 1 | 345 | 48 (0)| 00:00:01 |
|* 3 | FIXED TABLE FULL | X$KSPPI | 1 | 68 | 24 (0)| 00:00:01 |
|* 4 | FIXED TABLE FIXED INDEX| X$KSPPCV (ind:2) | 1 | 277 | 24 (0)| 00:00:01 |
|* 5 | VIEW | | 1 | 13 | 24 (0)| 00:00:01 |
| 6 | SORT AGGREGATE | | 1 | 26 | | |
|* 7 | FIXED TABLE FULL | X$KSUPR | 1 | 26 | 24 (0)| 00:00:01 |
----------------------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
3 - filter("KSPPINM"='processes' AND "X"."INST_ID"=:B1)
4 - filter("X"."INDX"="Y"."INDX" AND (TRANSLATE("KSPPINM",'_','#') NOT LIKE '#%'
OR "KSPPSTDF"='FALSE'))
5 - filter(ROUND((TO_NUMBER("KSPPSTVL")-"A"."CURRENT_PROC")/TO_NUMBER("KSPPSTVL")*1
00,0)<15)>0)

On 10gR2:
---------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
---------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 371 | 1 (100)| 00:00:01 |
|* 1 | HASH JOIN | | 1 | 371 | 1 (100)| 00:00:01 |
| 2 | NESTED LOOPS | | 5 | 1515 | 0 (0)| 00:00:01 |
| 3 | VIEW | | 1 | 13 | 0 (0)| 00:00:01 |
| 4 | SORT AGGREGATE | | 1 | 26 | | |
|* 5 | FIXED TABLE FULL| X$KSUPR | 1 | 26 | 0 (0)| 00:00:01 |
|* 6 | FIXED TABLE FULL | X$KSPPCV | 5 | 1450 | 0 (0)| 00:00:01 |
|* 7 | FIXED TABLE FULL | X$KSPPI | 1 | 68 | 0 (0)| 00:00:01 |
---------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
1 - access("X"."INDX"="Y"."INDX")
filter(TRANSLATE("KSPPINM",'_','#') NOT LIKE '#%' OR
"KSPPSTDF"='FALSE' OR BITAND("KSPPSTVF",5)>0)
5 - filter("INST_ID"=USERENV('INSTANCE') AND BITAND("KSSPAFLG",1)<>0)
6 - filter(ROUND((TO_NUMBER("KSPPSTVL")-"A"."CURRENT_PROC")/TO_NUMBER(
"KSPPSTVL")*100,0)<15)
7 - filter("KSPPINM"='processes' AND
"X"."INST_ID"=USERENV('INSTANCE') AND TRANSLATE("KSPPINM",'_','#') NOT
LIKE '##%')

That show, SQL PLAN was changed.
we might change SQL or something to make script/program work and (show old result)
SQL>select CURRENT_UTILIZATION Current_proc, INITIAL_ALLOCATION Max_proc, ROUND(((INITIAL_ALLOCATION-CURRENT_UTILIZATION)/INITIAL_ALLOCATION)*100, 0) Alert_proc from v$resource_limit where RESOURCE_NAME='processes' and ROUND(((INITIAL_ALLOCATION-CURRENT_UTILIZATION)/INITIAL_ALLOCATION)*100, 0) < 15;

no rows selected
That worked... Perhaps we can use other Ideas, But My point ... When we change Oracle version, we might necessary to change SQL Statement or something.
:(

Friday, April 02, 2010

Objects Invalid when Enable Row Movement

On Oracle 10g, The command "ALTER TABLE TABLE_NAME ENABLE ROW MOVEMENT" make the dependent objects be INVALID status. So, we need to recompile the dependent objects or wait for compilation automatic when objects are called.
SQL> select * from v$version;

BANNER
----------------------------------------------------------------
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0
PL/SQL Release 10.2.0.4.0
CORE 10.2.0.4.0
TNS for Linux: Version 10.2.0.4.0
NLSRTL Version 10.2.0.4.0

SQL> select object_name, object_type, status from dba_objects where object_name like '%TB01';

OBJECT_NAME OBJECT_TYPE STATUS
------------------------------ ------------------- -------
V_TB01 VIEW VALID
TB01 TABLE VALID
PRC_TB01 PROCEDURE VALID

SQL> alter table tb01 enable row movement;

Table altered.

SQL> select object_name, object_type, status from dba_objects where object_name like '%TB01';

OBJECT_NAME OBJECT_TYPE STATUS
------------------------------ ------------------- -------
V_TB01 VIEW INVALID
TB01 TABLE VALID
PRC_TB01 PROCEDURE INVALID

SQL> select * from v_tb01;

SQL> exec PRC_TB01;

SQL> select object_name, object_type, status from dba_objects where object_name like '%TB01';

OBJECT_NAME OBJECT_TYPE STATUS
------------------------------ ------------------- -------
V_TB01 VIEW VALID
TB01 TABLE VALID
PRC_TB01 PROCEDURE VALID
This is the issue, when we need to use "enable row movement" command, But on Oracle 11g has changed.
SQL> select * from v$version;

BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.1.0.6.0
PL/SQL Release 11.1.0.6.0
CORE 11.1.0.6.0 Production
TNS for Linux: Version 11.1.0.6.0
NLSRTL Version 11.1.0.6.0

SQL> select object_name, object_type, status from dba_objects where object_name like '%TB01';

OBJECT_NAME OBJECT_TYPE STATUS
------------------------------ ------------------- -------
V_TB01 VIEW VALID
TB01 TABLE VALID
PRC_TB01 PROCEDURE VALID

SQL> alter table tb01 enable row movement;

Table altered.

SQL> select object_name, object_type, status from dba_objects where object_name like '%TB01';

OBJECT_NAME OBJECT_TYPE STATUS
------------------------------ ------------------- -------
V_TB01 VIEW VALID
TB01 TABLE VALID
PRC_TB01 PROCEDURE VALID