Saturday, July 27, 2013

EM - Express 12c

EM Express – 12c Edition

Oracle Enterprise Manager Database Express, also referred to as EM Express, is a web-based tool for managing Oracle Database 12c



About license: This tool is free tool with oracle 12c standard or 12c Enterprise edition

To access EM express you need local listener configuration and this will get installed by default when u use DBCA to create database.


In my case I don't have listener so I am creating it from scratch

I registered my database with the newly created listener as follows

in sqlplus
 alter system register;


to know the port of your em please run the following query

 select dbms_xdb.getHttpPort() from dual;

DBMS_XDB.GETHTTPPORT()
----------------------
    0

SQL> select dbms_xdb_config.getHttpsPort() from dual;

DBMS_XDB_CONFIG.GETHTTPSPORT()
------------------------------
 5500

okay to invoke the em express the following is the formart

in web browser  https://hostname:portnumber://em/

in my case the following is the example

Note: This em plugin requires flash player. I tried more tough to update my firefox to install flash player.

finally I managed to install through following command

yum install flash-plugin nspluginwrapper.x86_64 nspluginwrapper.i686 

here you go first screen





























==================================================================================
please post your questions

Saturday, June 29, 2013

12c New Features - Data file move without taking tablespace read only or offline.

12c New Features - Data file move without taking tablespace read only or offline.

one of the features of 12.1.0 is datafile rename online. so from 12.1.0 no longer we need to take tablespace offline or readonly. It can be done online.

I have tested this in normal database to understand the behaviour easily.

database version: 12.1.0
file management: file system




SQL> 1
  1* select file_name,tablespace_name,status from dba_data_files where tablespace_name='USERS'
SQL> /

FILE_NAME                             TABLESPACE_NAME            STATUS
------------------------------------------------------------ ------------------------------ ---------
/media/12c_db/oradata/ora12cdb/loc2/users02.dbf          USERS                AVAILABLE
/media/12c_db/oradata/ora12cdb/users01.dbf             USERS                AVAILABLE
/media/12c_db/oradata/ora12cdb/loc2/users03.dbf          USERS                AVAILABLE

SQL> select tablespace_name,status from dba_tablespaces where tablespace_name='USERS';

TABLESPACE_NAME            STATUS
------------------------------ ---------
USERS                   ONLINE

SQL>
SQL> select * from v$version;

BANNER                               CON_ID
-------------------------------------------------- ----------
Oracle Database 12c Enterprise Edition Release 12.        0
1.0.1.0 - 64bit Production

PL/SQL Release 12.1.0.1.0 - Production                0
CORE    12.1.0.1.0    Production                    0
TNS for Linux: Version 12.1.0.1.0 - Production            0
NLSRTL Version 12.1.0.1.0 - Production                0

SQL> alter database move datafile '/media/12c_db/oradata/ora12cdb/loc2/users02.dbf' to '/media/12c_db/oradata/ora12cdb/users02.dbf';  

Database altered.

SQL> select tablespace_name,status from dba_tablespaces where tablespace_name='USERS';

TABLESPACE_NAME            STATUS
------------------------------ ---------
USERS                   ONLINE

SQL> select file_name,tablespace_name,status from dba_data_files where tablespace_name='USERS';

FILE_NAME                             TABLESPACE_NAME            STATUS
------------------------------------------------------------ ------------------------------ ---------
/media/12c_db/oradata/ora12cdb/users01.dbf             USERS                AVAILABLE
/media/12c_db/oradata/ora12cdb/loc2/users03.dbf          USERS                AVAILABLE
/media/12c_db/oradata/ora12cdb/users02.dbf             USERS                AVAILABLE

 

 
 

alert log

alter database move datafile '/media/12c_db/oradata/ora12cdb/loc2/users02.dbf' to '/media/12c_db/oradata/ora12cdb/users02.dbf' Sat Jun 29 20:58:00 2013 Moving datafile /media/12c_db/oradata/ora12cdb/loc2/users02.dbf (5) to /media/12c_db/oradata/ora12cdb/users02.dbf Move operation committed for file /media/12c_db/oradata/ora12cdb/users02.dbf Completed: alter database move datafile '/media/12c_db/oradata/ora12cdb/loc2/users02.dbf' to '/media/12c_db/oradata/ora12cdb/users02.dbf' $

12c feature: Pluggable Databases

The below demo is created on the basis of the following reference link

Oracle Database 12c: New Features - Pluggable Databases- by mikerajendran

details provided by mikerajendran in his blog

CDB vs. PDB

CDB is an acronym for “Container Database” and PDB is an acronym for “Pluggable Database”. I think it will be easier to explain with a metaphor for DBAs. Think of a freight train with many cars up to 250. Each container could be having different contents, with delivery target for different customers and completely packed/sealed independently with customer options but the entire freight is carried by a single engine or carrier at the front. It will be stupid enough to run 250 freight trucks but rather it is efficient to consolidate them into a single freight train. When running independently we will spend on gas, drivers’ expenses and much more complicated to manage them. The freight train is basically the CDB and each car is the PDB.
PDB is fully backward compatible to pre-12.1 database releases. There is nothing different from a developer or application connectivity perspective. Everything stays the same but the PDB will belong to a single CDB. When application connects to the PDB, it will specify the destination PDB via a database service. All home-grown or third party applications typically will have connectivity defined out of the application so it is easier to just change the service name outside of the application code. So all database connectivity should use “database service” rather than using the legacy approach of ORACLE_SID based connectivity. ORACLE_SID ties the application connectivity to a specific database instance and does not give the scalability or high availability. You can have many pluggable databases in 12.1.
So now we will see the creation of pluggabble database
I am using dbca to create the pluggable database as it is first time.
I got to see the process and it creating normal database then it converting the database as plugabble database

create pluggable database PDB$SEED as clone  using '/media/12c_db/product/12.1.0/dbhome_1/assistants/dbca/templates//pdbseed.xml'  source_file_nam
e_convert = ('/ade/b/3593327372/oracle/oradata/seeddata/pdbseed/temp01.dbf','/media/12c_db/oradata/ORA12CC1/datafile/pdbseed_temp01.dbf',
'/ade/b/3593327372/oracle/oradata/seeddata/pdbseed/system01.dbf','/media/12c_db/oradata/ORA12CC1/datafile/o1_mf_system_8wz2hq6d_.dbf',
'/ade/b/3593327372/oracle/oradata/seeddata/pdbseed/sysaux01.dbf','/media/12c_db/oradata/ORA12CC1/datafile/o1_mf_sysaux_8wz2hq68_.dbf') file_name_c
onvert=NONE  NOCOPY
Sat Jun 29 18:30:39 2013
****************************************************************
Pluggable Database PDB$SEED with pdb id - 2 is created as UNUSABLE.
If any errors are encountered before the pdb is marked as NEW,
then the pdb must be dropped
****************************************************************
Database Characterset is US7ASCII
Deleting old file#2 from file$ 
Deleting old file#4 from file$ 
Adding new file#5 to file$(old file#2) 
Adding new file#7 to file$(old file#4) 
ALTER SYSTEM: Flushing buffer cache inst=0 container=2 local
****************************************************************
Post plug operations are now complete.
Pluggable database PDB$SEED with pdb id - 2 is now marked as NEW.
****************************************************************
Completed: create pluggable database PDB$SEED as clone  using '/media/12c_db/product/12.1.0/dbhome_1/assistants/dbca/templates//pdbseed.xml'  sour
ce_file_name_convert = ('/ade/b/3593327372/oracle/oradata/seeddata/pdbseed/temp01.dbf','/media/12c_db/oradata/ORA12CC1/datafile/pdbseed_temp01.dbf
',
'/ade/b/3593327372/oracle/oradata/seeddata/pdbseed/system01.dbf','/media/12c_db/oradata/ORA12CC1/datafile/o1_mf_system_8wz2hq6d_.dbf',
'/ade/b/3593327372/oracle/oradata/seeddata/pdbseed/sysaux01.dbf','/media/12c_db/oradata/ORA12CC1/datafile/o1_mf_sysaux_8wz2hq68_.dbf') file_name_c
onvert=NONE  NOCOPY
alter pluggable database PDB$SEED open restricted


once created you can see this parameter is enabled
  enable_pluggable_database= TRUE

SQL> set pages 1000
SQL> select * from v$instance;

INSTANCE_NUMBER INSTANCE_NAME
--------------- ----------------
HOST_NAME
----------------------------------------------------------------
VERSION  STARTUP_T STATUS PAR THREAD# ARCHIVE LOG_SWITCH_WAIT
----------------- --------- ------------ --- ---------- ------- ---------------
LOGINS   SHU DATABASE_STATUS INSTANCE_ROLE    ACTIVE_ST BLO     CON_ID
---------- --- ----------------- ------------------ --------- --- ----------
INSTANCE_MO EDITION
----------- -------
FAMILY
--------------------------------------------------------------------------------
     1 ora12cc1
ovs1.co.nz
12.1.0.1.0  29-JUN-13 OPEN NO      1 STOPPED
ALLOWED    NO  ACTIVE PRIMARY_INSTANCE   NORMAL    NO   0
REGULAR     EE


$ cat initora12cc1.ora
ora12cc1.__data_transfer_cache_size=0
ora12cc1.__db_cache_size=402653184
ora12cc1.__java_pool_size=16777216
ora12cc1.__large_pool_size=50331648
ora12cc1.__oracle_base='/media/12c_db'#ORACLE_BASE set from environment
ora12cc1.__pga_aggregate_target=503316480
ora12cc1.__sga_target=738197504
ora12cc1.__shared_io_pool_size=0
ora12cc1.__shared_pool_size=251658240
ora12cc1.__streams_pool_size=0
*.audit_file_dest='/media/12c_db/admin/ora12cc1/adump'
*.audit_trail='db'
*.compatible='12.1.0.0.0'
*.control_files='/media/12c_db/oradata/ORA12CC1/controlfile/o1_mf_8wz2gv8x_.ctl','/media/12c_db/fast_recovery_area/ORA12CC1/controlfile/o1_mf_8wz2gvog_.ctl'
*.db_block_size=8192
*.db_create_file_dest='/media/12c_db/oradata'
*.db_domain=''
*.db_name='ora12cc1'
*.db_recovery_file_dest='/media/12c_db/fast_recovery_area'
*.db_recovery_file_dest_size=4800m
*.diagnostic_dest='/media/12c_db'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=ora12cc1XDB)'
*.enable_pluggable_database=true
*.memory_target=1177m
*.open_cursors=300
*.processes=300
*.remote_login_passwordfile='EXCLUSIVE'
*.undo_tablespace='UNDOTBS1'












SQL> COLUMN "RESTRICTED" FORMAT A10
SQL> select v.name, v.open_mode, nvl(v.restricted, 'n/a') "RESTRICTED", d.status
  2  from v$PDBs v inner join dba_pdbs d
  3   using (GUID)
  4  order by v.create_scn
  5  /

NAME                   OPEN_MODE  RESTRICTED STATUS
------------------------------ ---------- ---------- -------------
PDB$SEED               READ ONLY  NO         NORMAL
ORA12CP1               MOUNTED      n/a         NORMAL



SQL> select name,TS#,STATUS from v$datafile;

NAME
--------------------------------------------------------------------------------
       TS# STATUS
---------- -------
/media/12c_db/oradata/ORA12CC1/datafile/o1_mf_system_8wz29n4m_.dbf
     0 SYSTEM

/media/12c_db/oradata/ORA12CC1/datafile/o1_mf_sysaux_8wz26nvn_.dbf
     1 ONLINE

/media/12c_db/oradata/ORA12CC1/datafile/o1_mf_undotbs1_8wz2dnof_.dbf
     2 ONLINE


NAME
--------------------------------------------------------------------------------
       TS# STATUS
---------- -------
/media/12c_db/oradata/ORA12CC1/datafile/o1_mf_system_8wz2hq6d_.dbf
     0 SYSTEM

/media/12c_db/oradata/ORA12CC1/datafile/o1_mf_users_8wz2dmgk_.dbf
     4 ONLINE

/media/12c_db/oradata/ORA12CC1/datafile/o1_mf_sysaux_8wz2hq68_.dbf
     1 ONLINE


NAME
--------------------------------------------------------------------------------
       TS# STATUS
---------- -------
/media/12c_db/oradata/ORA12CC1/E05626A829151520E0430F02000A6A84/datafile/o1_mf_s
ystem_8wz2y8z4_.dbf

     0 SYSTEM

/media/12c_db/oradata/ORA12CC1/E05626A829151520E0430F02000A6A84/datafile/o1_mf_s
ysaux_8wz2y92h_.dbf
     1 ONLINE

/media/12c_db/oradata/ORA12CC1/E05626A829151520E0430F02000A6A84/datafile/o1_mf_u

NAME
--------------------------------------------------------------------------------
       TS# STATUS
---------- -------
sers_8wz30lod_.dbf
     3 ONLINE

/media/12c_db/oradata/ORA12CC1/datafile/o1_mf_users_8wz81r9g_.dbf
     4 ONLINE


10 rows selected.



I will post little more examples on pluggable database. This above is just creation of pluggable database.








Friday, June 28, 2013

ORACLE-BASE - Oracle Database 12c Release 1 (12.1) Installation On Oracle Linux 6

ORACLE-BASE - Oracle Database 12c Release 1 (12.1) Installation On Oracle Linux 6

Please click the above link. I used the above link as reference and I have did the following installation in oracle linux 6

I have unziped the linuxamd64_12c_database* to database.

for pre-requiste I simply did 11G pre-requiste and the prequiste completed sucessfully for 12c database install.

so you can go for 


yum install
or
yum install oracle-rdbms-server-11gR2-preinstall -y

















































running root scripts 

$ su - root
Password: 
[root@ovs1 ~]# /media/12c_db/product/12.1.0/dbhome_1/root.sh
Performing root user operation for Oracle 12c 

The following environment variables are set as:
    ORACLE_OWNER= oracle
    ORACLE_HOME=  /media/12c_db/product/12.1.0/dbhome_1

Enter the full pathname of the local bin directory: [/usr/local/bin]: 
The file "dbhome" already exists in /usr/local/bin.  Overwrite it? (y/n) 
[n]: y
   Copying dbhome to /usr/local/bin ...
The file "oraenv" already exists in /usr/local/bin.  Overwrite it? (y/n) 
[n]: y
   Copying oraenv to /usr/local/bin ...
The file "coraenv" already exists in /usr/local/bin.  Overwrite it? (y/n) 
[n]: y
   Copying coraenv to /usr/local/bin ...

Entries will be added to the /etc/oratab file as needed by
Database Configuration Assistant when a database is created
Finished running generic part of root script.
Now product-specific root actions will be performed.




12cR1 installation done.

Please say your comments and let me know if you need any different scenario.

adding swap space in linux

Adding swap space in linux


easy  way is to use dd and add it on


1. decide the mountpoint where you are going to create swapspace. In my example, I plan to add swapspace in "/media/db_disk" mount point.

cd /media/db_disk
as root user



[root@ovs1 Desktop]#  dd if=/dev/zero of=/media/db_disk/myswapfile3 bs=1M count=2048
2048+0 records in
2048+0 records out
2147483648 bytes (2.1 GB) copied, 74.1111 s, 29.0 MB/s


checking the swap file

[root@ovs1 Desktop]# ls -l /media/db_disk/myswapfile3
-rw-r--r--. 1 root root 2147483648 Jun 28 15:45 /media/db_disk/myswapfile3


change the permission of the swap file

[root@ovs1 Desktop]#
ls -l /media/db_disk/myswapfile3
-rw-------. 1 root root 2147483648 Jun 28 15:45 /media/db_disk/myswapfile


run mkswap command to format and ready for swap file use

[root@ovs1 Desktop]# mkswap /media/db_disk/myswapfile3
Setting up swapspace version 1, size = 2097148 KiB
no label, UUID=c0928bcc-ffe3-47c1-9051-a9bf43c14228



add the swapfile to swap group

[root@ovs1 Desktop]# swapon /media/db_disk/myswapfile3
[root@ovs1 Desktop]# swapon -s
Filename                Type        Size    Used    Priority
/dev/dm-1                               partition    2064380    0    -1
/media/grid/swapfile1                   file        1048572    0    -2
/media/db_disk/myswapfile3              file        2097148    0    -3



now important thing is that we need to add this swapfile in automount list. otherwise after reboot it wont get appear in the swap list


/etc/fstab is the file which is readed to do automount during startup.

# /etc/fstab
# Created by anaconda on Thu Jan 12 13:21:03 2012
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
/dev/mapper/vg_oraclelinux6-lv_root /                       btrfs    defaults        1 1
UUID=ed6b5002-07d3-4381-9057-47ee31704c78 /boot                   ext4    defaults        1 2
/dev/sde                /media/grid             ext4    defaults        0 0
/dev/sdf                /media/db_disk          ext4    defaults        0 0
/dev/sdg                /media/12c_db           ext4    defaults        0 0
/dev/mapper/vg_oraclelinux6-lv_swap swap                    swap    defaults        0 0
/media/grid/swapfile1   swapfile1               swap  defaults        0 0
tmpfs                   /dev/shm                tmpfs   defaults        0 0
devpts                  /dev/pts                devpts  gid=5,mode=620  0 0
sysfs                   /sys                    sysfs   defaults        0 0
proc                    /proc                   proc    defaults        0 0


now add the following line in /etc/fstab


/media/db_disk/myswapfile3 swapfile3            swap  defaults        0 0



[root@ovs1 Desktop]#
[root@ovs1 Desktop]# cat /etc/fstab

#
# /etc/fstab
# Created by anaconda on Thu Jan 12 13:21:03 2012
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
/dev/mapper/vg_oraclelinux6-lv_root /                       btrfs    defaults        1 1
UUID=ed6b5002-07d3-4381-9057-47ee31704c78 /boot                   ext4    defaults        1 2
/dev/sde                /media/grid             ext4    defaults        0 0
/dev/sdf                /media/db_disk          ext4    defaults        0 0
/dev/sdg                /media/12c_db           ext4    defaults        0 0
/dev/mapper/vg_oraclelinux6-lv_swap swap                    swap    defaults        0 0
/media/grid/swapfile1   swapfile1               swap  defaults        0 0
/media/db_disk/myswapfile3 swapfile3            swap  defaults        0 0
tmpfs                   /dev/shm                tmpfs   defaults        0 0
devpts                  /dev/pts                devpts  gid=5,mode=620  0 0
sysfs                   /sys                    sysfs   defaults        0 0
proc                    /proc                   proc    defaults        0 0

[root@ovs1 Desktop]#


now after restart the swap file will get automatically mounted

Tuesday, February 21, 2012

ASH - Active session history

Active Session History


For performance issues, normally we will go with top-down approach.
Okay if we are coming to database level , from 11gR2 on-wards we could use the ASH efficiently and quickly to look the top events. Please note that ASH have added feature in 11GR2 than in 10g.

Most important thing is that we don’t have to depend on sql trace instead which we get all the information from dba_hist_active_session_history. (only thing is this needs license which sql trace doesn’t) but you know need to have manual work to capture all these things.

The ASH report will provide you the following thing which helps us to drill down quickly than AWR reports.

ASH Report
• Top Events
• Load Profile
• Top SQL
• Top PL/SQL
• Top Java
• Top Call Types
• Top Sessions
• Top Objects/Files/Latches
• Activity Over Time

When you invoke the ASH report it will give you the available min of reports for you. So you could give -1 (which will consider as sysdate -1 hour) or 0.5 (which will consider as sysdate – 0.5 hour).

Example

Oldest ASH sample available: 01-Feb-12 22:00:26 [ 12381 mins in the past]
Latest ASH sample available: 10-Feb-12 12:21:41 [ 0 mins in the past]

Specify the timeframe to generate the ASH report
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Enter begin time for report:
- Valid input formats:
-- To specify absolute begin time:
-- [MM/DD[/YY]] HH24:MI[:SS]
-- Examples: 02/23/03 14:30:15
-- 02/23 14:30:15
-- 14:30:15
-- 14:30
-- To specify relative begin time: (start with '-' sign)
-- -[HH24:]MI
-- Examples: -1:15 (SYSDATE - 1 Hr 15 Mins)
-- -25 (SYSDATE - 25 Mins)

Example report
Views
• V$ACTIVE_SESSION_HISTORY
• DBA_HIST_ACTIVE_SESS_HISTORY
This view dba_hist_active_sess_history will give information like “ event 10046 trace”. This view will give lots of information so we need to trill down it.
Example we could use column EVENT to point in particual column
For example
Where event=’ buffer busy waits’ Or event like ‘%I/O%’

Likewise there are many useful ways to make this table to have good information.

If you combine the view dba_hist_snapshot and dba_hist_active_sess_history. You could able to find lots of information



Reports
@?/rdbms/admin/ashrpt.sql
@?/rdbms/admin/ashrpti.sql

Monday, September 20, 2010

basic unix commands used by oracle dba

UNIX commands useful for DBA

Vi commands

FILE manipulation:

:x quit vi, writing out modified file to file named in original invocation

:wq quit vi, writing out modified file to file named in original invocation

:q quit (or exit) vi

:q! quit vi even though latest changes have not been saved for this vi call

Cursor Movements:

j or [or down-arrow] move cursor down one line

k [or up-arrow] move cursor up one line

h [or left-arrow] move cursor left one character

l or [or right-arrow] move cursor right one character

0 (zero) move cursor to start of current line (the one with the cursor)

$ move cursor to end of current line

w move cursor to beginning of next word

b move cursor back to beginning of preceding word

:0 or 1G move cursor to first line in file

:n or nG move cursor to line n

:$ or G move cursor to last line in file

FIND command

find . -type f -mtime -200 -size +1000c -exec ls -l {} \; | awk '{print $5, $NF}'| sort -k 1,1n

-mtime +n --> not modified n days

-mtime -n --> modified within n days

The above example will search the file which is modified with 200 days and have size greater than speificed

Another example

find . -mtime +200 -exec ls -l {} \; listing not modified more than 200 days

find . –type f –exec grep –l “ORA-” {} \; | grep –v sample > loc_files.lst

this above example will search the ORA- matching string in the files which are searched

CPIO command

cpio -idmv < command to extract cpio

example : cpio –idmv <>

Checking OS bit commands

solaris --> isainfo –kv

example:

> isainfo -kv

64-bit sparcv9 kernel modules

AIX à getconf -a|grep KERN

$ getconf -a|grep KERN

KERNEL_BITMODE: 64

Windowsà

  1. Click Start, then click on Run or Start Search.
  2. Type msinfo32.exe and then press Enter key.
  3. In “System Information”, review the value for the System Type item:
  • For 32-bit editions of Windows, the value of the System Type item is x86-based PC.
  • For 64-bit editions of Windows, the value of the System Type item is x64-based PC.

IP and servernames /etc/hosts

> more /etc/hosts

#

# Internet host table

#

127.0.0.1 localhost

10.231.5.24 xxx.admin xx-admin xxx.admin.telecom.co.nz xxx loghost

BASIC unix commands

  • cat --- for creating and displaying short files
  • chmod --- change permissions
  • cd --- change directory
  • cp --- for copying files
  • date --- display date
  • echo --- echo argument
  • ftp --- connect to a remote machine to download or upload files
  • grep --- search file
  • head --- display first part of file
  • ls --- see what files you have
  • lpr --- standard print command (see also print )
  • more --- use to read files
  • mkdir --- create directory
  • mv --- for moving and renaming files
  • ncftp --- especially good for downloading files via anonymous ftp.
  • print --- custom print command (see also lpr )
  • pwd --- find out what directory you are in
  • rm --- remove a file
  • rmdir --- remove directory
  • rsh --- remote shell
  • setenv --- set an environment variable
  • sort --- sort file
  • tail --- display last part of file
  • tar --- create an archive, add or extract files
  • telnet --- log in to another machine
  • wc --- count characters, words, lines

Shared memory and semaphores

Ipcs

To see what semaphores have been allocated, use the Unix command 'ipcs -b'.

Ipcrm

To remove the shared memory and semaphores

ipcrm -m       <== Use for the Shared Memory entry
 
ipcrm -s       <== Use for the Semaphore entry

TOP/TOPAS

This commands is used to check the top consuming resources