Pages

Monday, August 26, 2013

Orakill similar to kill -9


C:\Users\mmeerha>orakill

Usage:  orakill sid thread

  where sid    = the Oracle instance to target  --- > (sid is not session id it is instance name)
        thread = the thread id of the thread to kill

  The thread id should be retrieved from the spid column of a query such as:

        select spid, osuser, s.program from
        v$process p, v$session s where p.addr=s.paddr

C:\Users\mmeerha>orakill 5 8824

Could not attach to Oracle instance 5: err = 203

C:\Users\mmeerha>sqlplus / as sysdba

SQL*Plus: Release 11.2.0.2.0 Production on Mon Aug 26 00:29:55 2013

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


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> select     s.username
  2  ,  s.sid
  3  ,  s.serial#
  4  ,  p.spid
  5  ,  last_call_et
  6  ,  status,to_char(logon_time, 'hh24:mi dd/mm/yy') login_time
  7  from       V$SESSION s
  8  ,  V$PROCESS p
  9  where      s.PADDR = p.ADDR
 10  and        s.sid=5
 11  /

USERNAME                              SID    SERIAL# SPID
------------------------------ ---------- ---------- ------------------------
LAST_CALL_ET STATUS   LOGIN_TIME
------------ -------- --------------
A                                       5          5 8824
        4549 ACTIVE   22:56 25/08/13


SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

C:\Users\mmeerha>orakill testdb 8824

Kill of thread id 8824 in instance testdb successfully signalled.

Sunday, August 25, 2013

Tail -f in windows

     We have inconvenience in looking alert log when it grows in windows machines as we do it in linux machines with tail -f. Oracle ADRCI utility provide this feature and is very useful. We can also use it via Notepad++ but what we have to switch window to see the last update.

Remember it is 11g feature.

Steps followed:

  1. Set proper environment variables
  2. login to adrci
  3. set sid with set home as below
  4. SHOW ALERT -TAIL -F

C:\Users\mmeerha>adrci

ADRCI: Release 11.2.0.2.0 - Production on Sun Aug 25 23:31:40 2013

Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.

ADR base = "D:\ORACLE_DB"
adrci> show homes
ADR Homes:
diag\clients\user_mmeerha\host_813904677_80
diag\clients\user_SYSTEM\host_813904677_80
diag\rdbms\clonedb\clonedb
diag\rdbms\orcl\orcl
diag\rdbms\testdb\testdb
diag\tnslsnr\MMEERHA-IN\listener
adrci> set home diag\rdbms\testdb\testdb
adrci> SHOW ALERT -TAIL -F
2013-08-25 23:31:37.488000 +05:30
Archived Log entry 3579 added for thread 1 sequence 3672 ID 0x9a702651 dest 1:
2013-08-25 23:31:42.026000 +05:30
Thread 1 cannot allocate new log, sequence 3675
Checkpoint not complete
  Current log# 1 seq# 3674 mem# 0: D:\ORACLE_DB\TESTDB\TESTDB\REDO01.LOG
2013-08-25 23:31:44.418000 +05:30
Thread 1 advanced to log sequence 3675 (LGWR switch)
  Current log# 2 seq# 3675 mem# 0: D:\ORACLE_DB\TESTDB\TESTDB\REDO02.LOG
Archived Log entry 3580 added for thread 1 sequence 3673 ID 0x9a702651 dest 1:
2013-08-25 23:31:51.635000 +05:30
Archived Log entry 3581 added for thread 1 sequence 3674 ID 0x9a702651 dest 1:
2013-08-25 23:31:58.339000 +05:30
Thread 1 cannot allocate new log, sequence 3676
Checkpoint not complete
  Current log# 2 seq# 3675 mem# 0: D:\ORACLE_DB\TESTDB\TESTDB\REDO02.LOG
2013-08-25 23:31:59.473000 +05:30
Thread 1 advanced to log sequence 3676 (LGWR switch)
  Current log# 3 seq# 3676 mem# 0: D:\ORACLE_DB\TESTDB\TESTDB\REDO03.LOG
2013-08-25 23:32:07.646000 +05:30
Thread 1 advanced to log sequence 3677 (LGWR switch)
  Current log# 1 seq# 3677 mem# 0: D:\ORACLE_DB\TESTDB\TESTDB\REDO01.LOG
2013-08-25 23:32:16.794000 +05:30
Thread 1 cannot allocate new log, sequence 3678
Checkpoint not complete
  Current log# 1 seq# 3677 mem# 0: D:\ORACLE_DB\TESTDB\TESTDB\REDO01.LOG
2013-08-25 23:32:18.185000 +05:30
Archived Log entry 3582 added for thread 1 sequence 3675 ID 0x9a702651 dest 1:
2013-08-25 23:32:19.720000 +05:30
Thread 1 advanced to log sequence 3678 (LGWR switch)
  Current log# 2 seq# 3678 mem# 0: D:\ORACLE_DB\TESTDB\TESTDB\REDO02.LOG
^C
C:\Users\mmeerha>

Happy reading, leave your comments/suggestion.

Reference:

Sunday, August 11, 2013

Why CBD_DATA_FILES and V$DATAFILE differs?

Though it is well documented in the Oracle 12c documentation, just to demo I wrote this post.

http://docs.oracle.com/cd/E16655_01/server.121/e17615/refrn009.htm#REFRN009

CDB_* Views

For every DBA_* view, a CDB_* view is defined. In the root of a multitenant container database (CDB), CDB_* views can be used to obtain information about tables, tablespaces, users, privileges, parameters, and so on contained in the root and in pluggable databases (PDBs).
CDB_* views are container data objects. When a user connected to the root queries a CDB_* view, the query results will depend on the CONTAINER_DATA attribute for users for the view. The CONTAINER_DATA clause of the SQL ALTER USER statement is used to set and modify users' CONTAINER_DATA attribute.
The CDB_* views are owned by SYS, regardless of who owns the underlying DBA_* view.
By default, a user connected to the root will only see data pertaining to the root.

In a PDB, the CDB_* views only show objects visible through a corresponding DBA_* view.
In addition to all the columns found in a given DBA_* view, the corresponding CDB_* view also contains the CON_ID column, which identifies a container whose data a given CDB_* row represents. In a non-CDB, the value of a CON_ID column will be 0.
Data returned by these views depends on whether a given PDB is open at the time the query is issued.

In particular, in an Oracle RAC environment, data returned by these view may vary according to the instance to which a session is connected.

List of action performed

  1. Logged into CDB
  2. Queried  both cbd_data_files and v$datafile , CDB_ view has only 7 rows
  3. Queried V$PDBS to know status off PDBs
  4. One PDB is in Mount state
  5. Opened that PDB in read write mode.
  6. Then we could see all the files.

SQL> set time on echo on
22:27:54 SQL> select name,cdb from v$database;

NAME      CDB                                                                  
--------- ---                                                                  
ORCL12C   YES                                                                  

22:28:14 SQL> sho con_name

CON_NAME                                                                       
------------------------------                                                 
CDB$ROOT                                                                       
22:28:20 SQL> set pages 20
22:28:54 SQL> select name from v$datafile;

NAME                                                                           
--------------------------------------------------------------------------------
D:\APP\TWELVEC\ORADATA\ORCL12C\SYSTEM01.DBF                                    
D:\APP\TWELVEC\ORADATA\ORCL12C\PDBSEED\SYSTEM01.DBF                            
D:\APP\TWELVEC\ORADATA\ORCL12C\SYSAUX01.DBF                                    
D:\APP\TWELVEC\ORADATA\ORCL12C\PDBSEED\SYSAUX01.DBF                            
D:\APP\TWELVEC\ORADATA\ORCL12C\UNDOTBS01.DBF                                   
D:\APP\TWELVEC\ORADATA\ORCL12C\USERS01.DBF                                     
D:\APP\TWELVEC\ORADATA\ORCL12C\PDBORCL\SYSTEM01.DBF                            
D:\APP\TWELVEC\ORADATA\ORCL12C\PDBORCL\SYSAUX01.DBF                            
D:\APP\TWELVEC\ORADATA\ORCL12C\PDBORCL\SAMPLE_SCHEMA_USERS01.DBF               
D:\APP\TWELVEC\ORADATA\ORCL12C\PDBORCL\EXAMPLE01.DBF                           

10 rows selected.

22:29:03 SQL> select file_name from cdb_data_files;

FILE_NAME                                                                      
--------------------------------------------------------------------------------
D:\APP\TWELVEC\ORADATA\ORCL12C\USERS01.DBF                                     
D:\APP\TWELVEC\ORADATA\ORCL12C\UNDOTBS01.DBF                                   
D:\APP\TWELVEC\ORADATA\ORCL12C\SYSAUX01.DBF                                    
D:\APP\TWELVEC\ORADATA\ORCL12C\SYSTEM01.DBF                                    
D:\APP\TWELVEC\ORADATA\ORCL12C\PDBSEED\SYSTEM01.DBF                            
D:\APP\TWELVEC\ORADATA\ORCL12C\PDBSEED\SYSAUX01.DBF                            

6 rows selected.

22:29:24 SQL> select con_id,name,open_mode from v$pdbs order by 1;

    CON_ID NAME                           OPEN_MODE                            
---------- ------------------------------ ----------                           
         2 PDB$SEED                       READ ONLY                            
         3 PDBORCL                        MOUNTED                              


22:31:08 SQL> alter pluggable database PDBORCL open read write;

Pluggable database altered.

22:31:25 SQL> select con_id,name,open_mode from v$pdbs order by 1;

    CON_ID NAME                           OPEN_MODE                            
---------- ------------------------------ ----------                           
         2 PDB$SEED                       READ ONLY                            
         3 PDBORCL                        READ WRITE                           

22:31:32 SQL> select file_name from cdb_data_files;

FILE_NAME                                                                      
--------------------------------------------------------------------------------
D:\APP\TWELVEC\ORADATA\ORCL12C\PDBSEED\SYSTEM01.DBF                            
D:\APP\TWELVEC\ORADATA\ORCL12C\PDBSEED\SYSAUX01.DBF                            
D:\APP\TWELVEC\ORADATA\ORCL12C\USERS01.DBF                                     
D:\APP\TWELVEC\ORADATA\ORCL12C\UNDOTBS01.DBF                                   
D:\APP\TWELVEC\ORADATA\ORCL12C\SYSAUX01.DBF                                    
D:\APP\TWELVEC\ORADATA\ORCL12C\SYSTEM01.DBF                                    
D:\APP\TWELVEC\ORADATA\ORCL12C\PDBORCL\SYSTEM01.DBF                            
D:\APP\TWELVEC\ORADATA\ORCL12C\PDBORCL\SYSAUX01.DBF                            
D:\APP\TWELVEC\ORADATA\ORCL12C\PDBORCL\SAMPLE_SCHEMA_USERS01.DBF               
D:\APP\TWELVEC\ORADATA\ORCL12C\PDBORCL\EXAMPLE01.DBF                           

10 rows selected.

22:31:45 SQL> spool off

Please provide your valuable suggestion/ corrections to improve
Thanks , Happy reading...

Sunday, August 4, 2013

Oracle 12c Database install on Windows 7

Today I have installed 12c database on my laptop to test one issue, just thought to share the steps. Will post all my experiments in this blog soon. Happy learning. :)

1. Configure Security updates.

2. Mention whether software updates needed
3. Install options, select 

4. Install class Desktop or server class

5. Grid installation option
6. Install type
7. Specify Oracle Home user
8. Select home path, provide OS admin user password, whether container/ pluggable DB need to be created
9 & 10 Pre requisite check and Summary Screen ( Forgot to take Snap) sorry

11. Installing database, will invoke DBCA and will create CDB and PDB
12. Finish
Test login


Windows x64 Hardware Requirements
RequirementValue
System Architecture
Processor: AMD64 and Intel EM64T
Physical memory (RAM)
2 GB minimum
Virtual memory (swap)
  • If physical memory is between 2 GB and 16 GB, then set virtual memory to 1 times the size of the RAM
  • If physical memory is more than 16 GB, then set virtual memory to 16 GB
Disk space
  • Typical Install Type total: 10 GB
  • Advanced Install Types total: 10 GB
See Table 2-2 for details.
Video adapter
256 colors
Screen Resolution
1024 X 768 minimum


Reference:

Oracle® Database Installation Guide 12c Release 1 (12.1) for Microsoft Windows
Oracle 12c Download