isitdevops.com/databases

Useful computing notes
  • Archive
  • Home
  • Posts

Categories

  • Chef (Cat) (2)
  • Chef Cookbook Tutorials (8)
  • CHEF Full Tutorial (18)
  • Jernkins (Cat) (1)
  • Oracle (354)
    • Oracle 11g (Sect) (309)
      • Oracle 11.2 Notes (Cat) (18)
      • Oracle ASM (Cat) (1)
      • Oracle Data Guard Notes (Cat) (45)
      • Oracle DB and SQL performance analysis (Cat) (67)
      • Oracle DB Objects (tables, sql etc) (Cat) (56)
      • Oracle Exadata (Cat) (21)
      • Oracle Flashback Notes (Cat) (12)
      • Oracle Golden Gate (Cat) (11)
      • Oracle odds and ends (Cat) (39)
      • Oracle oui and dbca (Cat) (4)
      • Oracle RAC (Cat) (24)
      • Oracle Rman Notes (Cat) (10)
      • Oracle sql one liners (Cat) (1)
    • Oracle 12c (Sect) (45)
      • 12c Cloud control (Cat) (4)
      • 12c Cloud Control Agent (Cat) (2)
      • 12c General (Cat) (19)
      • 12c Performance (Cat) (4)
      • 12c rman (cat) (16)
  • SQL Server (Sect) (31)
    • MS SQL Server (Cat) (31)
  • Uncategorized (7)
  • Unix Notes (Sect) (50)
    • Configuration (Cat) (16)
    • Resource Management (Cat) (18)
    • Unix notes (Cat) (16)

Categories

  • Chef (Cat)
  • Chef Cookbook Tutorials
  • CHEF Full Tutorial
  • Jernkins (Cat)
  • Oracle
    • Oracle 11g (Sect)
      • Oracle 11.2 Notes (Cat)
      • Oracle ASM (Cat)
      • Oracle Data Guard Notes (Cat)
      • Oracle DB and SQL performance analysis (Cat)
      • Oracle DB Objects (tables, sql etc) (Cat)
      • Oracle Exadata (Cat)
      • Oracle Flashback Notes (Cat)
      • Oracle Golden Gate (Cat)
      • Oracle odds and ends (Cat)
      • Oracle oui and dbca (Cat)
      • Oracle RAC (Cat)
      • Oracle Rman Notes (Cat)
      • Oracle sql one liners (Cat)
    • Oracle 12c (Sect)
      • 12c Cloud control (Cat)
      • 12c Cloud Control Agent (Cat)
      • 12c General (Cat)
      • 12c Performance (Cat)
      • 12c rman (cat)
  • SQL Server (Sect)
    • MS SQL Server (Cat)
  • Uncategorized
  • Unix Notes (Sect)
    • Configuration (Cat)
    • Resource Management (Cat)
    • Unix notes (Cat)

Meta

  • Log in
  • Entries feed
  • Comments feed
  • WordPress.org

Oracle Fusion Middleware

on December 13, 2011 at 2:01 pm
Posted In: Oracle odds and ends (Cat)

Installation.

Database must exist with, processes=500, sessions=500, open_cursors=500

The db must have JAVA_JIT_ENABLED=FALSE

========================

Run RCU first, exclude Oracle Internet Directory.

======================== Weblogic Server 12c Release 1 (12.1.1)

Run wls1211_linux32.bin

Select CUSTOM installation and include the “Server Examples” and “Coherence Examples”.

 

For DEV select the SUN SDK, not the JRockit.

========================

Run Quickstart

Getting started with WebLogic Server 12.1.1

Select Create a new weblogic domain.

Select the “Generate …” – don’t bother with anything else.

Take the defaults “base_domain” etc

Use weblogic and password H..32

Select “Development Mode” , Select SUN JDK

Select “Administration Server” and “Managed Servers, Clusters and Machines”

AdminServer, All Local Addresses, 7001

Configure Managed Servers: ADD, new_ManagedServer_1 , All Local Addresses, 7003

Configure Clusters – Next

Configure Machines: “UNIX MACHINE”, Add,New_UnixMachine_1, All Local Addresses, Port 5556

Domain Location: /cs/oracle/Middleware/user_projects/domains/base_domain

Admin Server URL: http://gbl10105055.eu…:7001

 

 

 Comment 

CPU in redhat

on February 2, 2011 at 9:03 am
Posted In: Configuration (Cat)

$ egrep “^processor|^cpu cores|^core id” /proc/cpuinfo
processor       : 0
core id         : 0
cpu cores       : 1
processor       : 1
core id         : 0
cpu cores       : 1
processor       : 2
core id         : 0
cpu cores       : 1
processor       : 3
core id         : 0
cpu cores       : 1

i.e.

processor = 0 to 3 == total number of cores (4)

cpu cores = 1        == 1 cpu per core.

 Comment 

pingManager Error – OEM / OMS / Weblogic Oracle error

on October 6, 2010 at 9:52 am
Posted In: Oracle odds and ends (Cat)

Oracle say this is due to network problems but, when installing weblogic and grid control on a rac cluster we frequently experienced this error when using the scan addresses as the connect string.

I believe, but can not prove, the issue is based around the use of SCAN addresses for an 11.2 grid and 11.2 db when using an 11.1 Grid Control.

To get around this issue we modified the tnsnames.ora file to use all 3 physical addresses for the scan name and rebooted the systems (I should have stopped OMS and DB and restarted).

The SCAN addresses balanced themselves across the cluster and everything is up.

 Comment 

emctl move agent

on September 30, 2010 at 10:27 am
Posted In: Oracle odds and ends (Cat)

Remove everything being monitored by the old grid control
=========================================================

In OEM Grid control:
select ‘All TARGETS’
select ‘HOSTS’
Select the host.
Select ‘Targets’
Select ‘Select All’
Select ‘Remove’
Wait 1 minute.

On the host:
Stop the agent:
. oraenv
agent10g
emctl stop agent
Wait 1 minute.

On OEM:
Select ‘Select All’
Select ‘Remove’
Wait 1 minute.

Select ‘Hosts’
Select the radio button next to the host.
Select ‘Remove’

On the host:

Edit the Agent’s $ORACLE_HOME/sysman/config/emd.properties file
Change the REPOSITORY_URL to point to the new host.
e.g.
CHANGE:
REPOSITORY_URL=https://z1ns01orcp001.ar01.local:1159/em/upload
TO:
REPOSITORY_URL=https://z1ns02orcp001.ar01.local:4900/em/upload
AND
CHANGE:
emdWalletSrcUrl=http://z1ns01orcp001.ar01.local:4889/em/wallets/emd
emdWalletDest=/u01/app/oracle/product/10.2.0/agent10g/sysman/config/server
TO:
emdWalletSrcUrl=http://z1ns02orcp001.ar01.local:4889/em/wallets/emd
emdWalletDest=/u01/app/oracle/product/10.2.0/agent10g/sysman/config/server

Delete all the files in the following directories:
rm $ORACLE_HOME/sysman/emd/upload/*
rm $ORACLE_HOME/sysman/emd/state/*

Secure the agent:
emctl secure agent

emctl start agent

Register the host and databases in the ‘new’ grid control.

=======

Get the host name
get the agent home name
. oraenv
agent_home_name
cd $ORACLE_HOME/sysman/config
stop the agent
change host1 to host2
change port1 to port2
secure the agent
start the agent

 

OR

==

export ORAENV_ASK=NO
export ORACLE_SID=agent11g
. oraenv
emctl stop agent
find $ORACLE_HOME/sysman/config -name emd.properties | xargs perl -pi -e ‘s/OLD_NODE/NEW_NODE/g’
rm $ORACLE_HOME/sysman/emd/upload/*
rm $ORACLE_HOME/sysman/emd/state/*
emctl secure agent F1rec0n1
emctl start agent
emctl status agent

 Comment 

dbms_metadata.get_ddl for a full schema

on August 27, 2010 at 2:04 pm
Posted In: Oracle DB Objects (tables, sql etc) (Cat)

LATEST VERSION

 

set long 100000

set head off

set echo off

set pagesize 0

set lines 256

set verify off

set feedback off

spool schema_BID_UTIL.out

select dbms_metadata.get_ddl(object_type, object_name, owner)

from

(

select

owner,

object_name,

decode(object_type,

‘DATABASE LINK’,      ‘DB_LINK’,

‘JOB’,                ‘PROCOBJ’,

‘RULE SET’,           ‘PROCOBJ’,

‘RULE’,               ‘PROCOBJ’,

‘EVALUATION CONTEXT’, ‘PROCOBJ’,

‘PACKAGE’,            ‘PACKAGE_SPEC’,

‘PACKAGE BODY’,       ‘PACKAGE_BODY’,

‘TYPE’,               ‘TYPE_SPEC’,

‘TYPE BODY’,          ‘TYPE_BODY’,

‘MATERIALIZED VIEW’,  ‘MATERIALIZED_VIEW’,

‘QUEUE’,              ‘AQ_QUEUE’,

‘JAVA CLASS’,         ‘JAVA_CLASS’,

‘JAVA TYPE’,          ‘JAVA_TYPE’,

‘JAVA SOURCE’,        ‘JAVA_SOURCE’,

‘JAVA RESOURCE’,      ‘JAVA_RESOURCE’,

object_type

) object_type

from dba_objects

where owner in (‘UTIL’)

and object_type not in (‘INDEX PARTITION’,’INDEX SUBPARTITION’,

‘LOB’,’LOB PARTITION’,’TABLE PARTITION’,’TABLE SUBPARTITION’)

and not (object_type = ‘TYPE’ and object_name like ‘SYS_PLSQL_%’)

and (owner, object_name) not in (select owner, table_name from dba_nested_tables)

and (owner, object_name) not in (select owner, table_name from dba_tables where iot_type = ‘IOT_OVERFLOW’)

)

order by owner, object_type, object_name;

spool off

 

OLD VERSION
==========

— Comments and Script Documentation
— Script Name   : extract_schema_ddl.sql
— Purpose       : Extract schema ddl
— Requirements  : User calling script must be logged in with DBA privs
–                 The directory the script is being called FROM must be writeable by Oracle
— Parameters    : &1 – schema_owner – Username of the schema owner
— Author        : Daniel W. Fink
— Created Date  : July 12, 2004
— Updates     
–               : 07/12/2004 dwf Original version
— Comments      : This can be called standalone or as part of extract_schema_menu.sql
–                 Compatible with Oracle9i/10g.
–                 Numerous workarounds are coded for bugs

DEFINE schema_owner = &1
— WHENEVER SQLERROR EXIT FAILURE

SET LINESIZE 132 PAGESIZE 0 FEEDBACK off VERIFY off TRIMSPOOL on LONG 1000000
COLUMN ddl_string FORMAT A100 WORD_WRAP
COLUMN row_order FORMAT 999 NOPRINT

EXECUTE DBMS_METADATA.SET_TRANSFORM_PARAM(DBMS_METADATA.SESSION_TRANSFORM,’STORAGE’,false);
EXECUTE DBMS_METADATA.SET_TRANSFORM_PARAM(DBMS_METADATA.SESSION_TRANSFORM,’PRETTY’,true);
EXECUTE DBMS_METADATA.SET_TRANSFORM_PARAM(DBMS_METADATA.SESSION_TRANSFORM,’SQLTERMINATOR’,true);
EXECUTE DBMS_METADATA.SET_TRANSFORM_PARAM(DBMS_METADATA.SESSION_TRANSFORM,’REF_CONSTRAINTS’,false);

COLUMN rundate FORMAT A8 NEW_VALUE ddl_date NOPRINT
COLUMN dbname FORMAT A10 NEW_VALUE db_name NOPRINT
COLUMN spoolname FORMAT A50 NEW_VALUE spool_name NOPRINT
COLUMN maxtextlength FORMAT 9999 NEW_VALUE max_text_length NOPRINT
COLUMN schemaid NEW_VALUE schema_id NOPRINT

SELECT u.user# schemaid
FROM sys.user$ u
WHERE u.name = UPPER(‘&&schema_owner’)
/

SELECT TO_CHAR(SYSDATE, ‘YYYYMMDD’) rundate
FROM dual
/

SELECT UPPER(SYS_CONTEXT(‘USERENV’, ‘DB_NAME’)) dbname
FROM dual
/

SELECT ‘schema_’||’&&db_name’||’_’||’&&schema_owner’||’_’||’&&ddl_date’||’_ddl.log’ spoolname
FROM dual
/

SELECT MAX(LENGTH(s.source)) maxtextlength
FROM sys.obj$ o,
sys.source$ s
WHERE o.owner# = &&schema_id
AND o.obj# = s.obj#
/

SET LINESIZE &&max_text_length

— SPOOL schema_&&db_name\_&&schema_owner\_&&ddl_date\_ddl.sql
SPOOL schema_ddl.sql

PROMPT WHENEVER SQLERROR EXIT FAILURE
PROMPT WHENEVER OSERROR EXIT FAILURE
PROMPT SPOOL &&spool_name
PROMPT
PROMPT

SELECT 0 row_order, ‘– Object Count’ ddl_string
FROM dual
UNION
SELECT 1 row_order, ‘– ‘||DECODE(o.type#,
1, ‘INDEX’, 2, ‘TABLE’, 3, ‘CLUSTER’, 4, ‘VIEW’, 5, ‘SYNONYM’,
6, ‘SEQUENCE’, 7, ‘PROCEDURE’, 8, ‘FUNCTION’, 9, ‘PACKAGE’,
10, ‘NON-EXISTENT’, 11, ‘PACKAGE BODY’, 12, ‘TRIGGER’, 13, ‘TYPE’,
14, ‘TYPE BODY’, 28, ‘JAVA SOURCE’, 29, ‘JAVA CLASS’, 42, ‘MATERIALIZED VIEW’,
43, ‘DIMENSION’, 56, ‘JAVA DATA’, ‘UNDEFINED’)||’ — ‘||COUNT(1)
FROM sys.obj$ o
WHERE o.owner# = &&schema_id
GROUP BY 1, o.type#
UNION
SELECT 2 row_order, CHR(10)||CHR(10)
FROM dual
/

PROMPT
PROMPT — Profile Creation
PROMPT

SELECT DBMS_METADATA.GET_DDL(‘PROFILE’, pr.name) ddl_string
FROM (SELECT DISTINCT pi.name
FROM sys.profname$ pi
WHERE pi.name != ‘DEFAULT’) pr
/

PROMPT
PROMPT — User Creation
PROMPT

SELECT TO_CHAR(DBMS_METADATA.GET_DDL(‘USER’, ‘&&schema_owner’)) ddl_string
FROM dual
/

PROMPT
PROMPT — User Tablespace Quotas
PROMPT
— This is failing with an error message, causing the script to terminate. No workaround yet.

/*
SELECT CASE
WHEN COUNT(1) != 0 THEN DBMS_METADATA.GET_GRANTED_DDL(‘TABLESPACE_QUOTA’, ‘&&schema_owner’)
ELSE NULL
END ddl_string
FROM sys.ts$ ts,
sys.tsq$ tq
WHERE tq.user# = &&schema_id
AND ts.ts# = tq.ts#
/
*/

PROMPT
PROMPT — User Role
PROMPT

SELECT /*+ ordered */ ‘GRANT “‘||u.name||'” TO “‘||upper(‘&&schema_owner’)||'”‘||
CASE WHEN min(sa.option$) = 1 THEN ‘ WITH ADMIN OPTION;’ ELSE ‘;’ END ddl_string
FROM sys.sysauth$ sa,
sys.user$ u
WHERE sa.grantee# = &&schema_id
AND u.user# = sa.privilege#
AND sa.grantee# != 1
GROUP BY u.name
/

PROMPT
PROMPT — User System Privileges
PROMPT
— If the dbms_metadata call for system grants does not find any for the schema owner
— it fails with an error message, causing the script to terminate. The SELECT is used as a
— workaround. A TAR has been filed w/Oracle (response ‘expected behaviour’ – RFE filed)

SELECT CASE
WHEN COUNT(1) != 0 THEN DBMS_METADATA.GET_GRANTED_DDL(‘SYSTEM_GRANT’, ‘&&schema_owner’)
ELSE NULL
END ddl_string
FROM sys.sysauth$ sa
WHERE sa.grantee# = &&schema_id
/

PROMPT
PROMPT — User Object Privileges
PROMPT
— If the dbms_metadata call for object grants does not find any for the schema owner
— it fails with an error message, causing the script to terminate. The SELECT is used as a
— workaround. A TAR has been filed w/Oracle (response ‘expected behaviour’ – RFE filed)

SELECT CASE
WHEN COUNT(1) != 0 THEN DBMS_METADATA.GET_GRANTED_DDL(‘OBJECT_GRANT’, ‘&&schema_owner’)
ELSE NULL
END ddl_string
FROM sys.objauth$ oa
WHERE oa.grantee# = &&schema_id
/

PROMPT
PROMPT — Schema Sequences
PROMPT

SELECT TO_CHAR(DBMS_METADATA.GET_DDL(‘SEQUENCE’, o.name,’&&schema_owner’)) ddl_string
FROM sys.seq$ s,
sys.obj$ o
WHERE o.owner# = &&schema_id
AND o.obj# = s.obj#
/

PROMPT
PROMPT — Schema Database Links
PROMPT

SELECT TO_CHAR(DBMS_METADATA.GET_DDL(‘DB_LINK’, l.name,’&&schema_owner’)) ddl_string
FROM sys.link$ l
WHERE l.owner# = &&schema_id
/

PROMPT
PROMPT — Schema Directories
PROMPT

SELECT DBMS_METADATA.GET_DDL(‘DIRECTORY’, o.name, ‘&&schema_owner’) ddl_string
FROM sys.obj$ o,
sys.dir$ d
WHERE o.owner# = &&schema_id
AND o.obj# = d.obj#
/

PROMPT
PROMPT — Schema Tables
PROMPT

/* Add the BITAND(o.flags, 128) to exclude tables in the recyclebin */

SELECT     TO_CHAR(DBMS_METADATA.GET_DDL(‘TABLE’, o.name,’&&schema_owner’)) ddl_string
FROM       sys.obj$ o,
sys.tab$ t
WHERE      o.owner# = &&schema_id
AND      o.obj# = t.obj#
AND      BITAND(o.flags, 128) = 0
/

PROMPT
PROMPT — Schema Table RI Constraints
PROMPT

SELECT DBMS_METADATA.GET_DDL(‘REF_CONSTRAINT’, oc.name, ‘&&schema_owner’)||’/’ ddl_string
FROM sys.con$ oc,
sys.obj$ o,
sys.cdef$ c
WHERE oc.owner# = &&schema_id
AND oc.con# = c.con#
AND c.obj# = o.obj#
AND c.type# = 4
/

PROMPT
PROMPT — Schema Indexes
PROMPT
— This is used to exclude primary key and unique key indexes that have already been defined
— as part of the table generation statement.

SELECT TO_CHAR(DBMS_METADATA.GET_DDL(‘INDEX’, o.name,’&&schema_owner’)) ddl_string
FROM sys.ind$ i,
sys.obj$ o
WHERE o.owner# = &&schema_id
AND o.obj# = i.obj#
AND bitand(i.property,1) = 1
AND i.type# != 8
/

PROMPT
PROMPT — Schema Views
PROMPT
— View extraction is not functioning properly in 9.2. Breaks occur in middle of words (column_names, clauses, etc).
— Bug has been accepted with Oracle. No response of when/if backport to 9.2.0.5 will be available

— SELECT REPLACE(TO_CHAR(DBMS_METADATA.GET_DDL(‘VIEW’, v.view_name,’&&schema_owner’)), ‘”,”‘,'”, “‘) ddl_string
— FROM dba_views v
— WHERE v.owner = ‘&&schema_owner’
— /

— Here is a workaround version
COLUMN viewname NOPRINT

CREATE GLOBAL TEMPORARY TABLE parsed_view_text
(view_name VARCHAR2(30),
text_id NUMBER,
view_text VARCHAR2(4000)
) ON COMMIT PRESERVE ROWS;

DECLARE
num_iter NUMBER := 0;
whole_clob CLOB;
parsed_string VARCHAR2(32767);
start_pos NUMBER := 1;
num_chars NUMBER := 3000;

CURSOR view_text_cur IS
SELECT o.name view_name, v.text text, v.textlength text_length, v.cols view_columns
FROM sys.obj$ o,
sys.view$ v
WHERE o.obj# = v.obj#
AND o.owner# = &&schema_id;

view_text_rec view_text_cur%ROWTYPE;

BEGIN

FOR view_text_rec IN view_text_cur
LOOP
whole_clob := TO_CLOB(view_text_rec.text);

DBMS_OUTPUT.PUT_LINE(‘View Name: ‘||view_text_rec.view_name||’ Text Length :’|| view_text_rec.text_length);
LOOP
IF (view_text_rec.text_length – start_pos) THEN
parsed_string := SUBSTR(whole_clob, start_pos);
INSERT INTO parsed_view_text VALUES (view_text_rec.view_name, (view_text_rec.view_columns + num_iter), parsed_string||CHR(10)||’/’);
EXIT;
END if;
parsed_string := SUBSTR(whole_clob, start_pos, 3000);
num_chars := GREATEST(INSTR(parsed_string, ‘, ‘, -1, 1), INSTR(parsed_string, ‘,”‘, -1, 1),
(INSTR(parsed_string, ‘),’, -1, 1)+1), INSTR(parsed_string, ‘)’, -1, 1));
parsed_string := SUBSTR(whole_clob, start_pos, num_chars);
INSERT INTO parsed_view_text VALUES (view_text_rec.view_name, (view_text_rec.view_columns + num_iter), parsed_string);
start_pos := start_pos + num_chars;
num_iter := num_iter + 1;
END LOOP;
COMMIT;
start_pos := 1;
num_chars := 3000;
num_iter := 1;
END LOOP;
END;
/

SELECT 0 row_order,
o.name viewname,
‘CREATE OR REPLACE FORCE VIEW “‘||’&&schema_owner’||'”.”‘||o.name||'”‘ ddl_string
FROM sys.obj$ o,
sys.view$ v
WHERE o.obj# = v.obj#
AND o.owner# = &&schema_iD
UNION
SELECT decode(c.col#, 0, to_number(null), c.col#) row_order,
o.name viewname,
CASE WHEN decode(c.col#, 0, to_number(null), c.col#) = 1 THEN ‘(“‘||c.name||'”,’
WHEN decode(c.col#, 0, to_number(null), c.col#) = v.cols THEN ‘ “‘||c.name||'”) AS ‘
ELSE ‘ “‘||c.name||'”,’
END ddl_string
FROM sys.col$ c,
sys.obj$ o,
sys.view$ v
WHERE o.obj# = c.obj#
AND o.owner# = &&schema_id
AND o.obj# = v.obj#
UNION
SELECT pv.text_id row_order,
pv.view_name viewname,
REPLACE(TO_CHAR(pv.view_text), ‘”,”‘, ‘”, “‘) ddl_string
FROM parsed_view_text pv
ORDER BY viewname, row_order
/

TRUNCATE TABLE parsed_view_text;
DROP TABLE parsed_view_text;

SET LINESIZE 4005
COLUMN ddl_string FORMAT A4000

PROMPT
PROMPT — Schema Functions
PROMPT

SELECT DBMS_METADATA.GET_DDL(‘FUNCTION’, o.name,’&&schema_owner’) ddl_string
FROM sys.obj$ o
WHERE o.owner# = &&schema_id
AND o.type# = 8
/

PROMPT
PROMPT — Schema Packages (specs and body)
PROMPT

SELECT DBMS_METADATA.GET_DDL(‘PACKAGE’, o.name,’&&schema_owner’) ddl_string
FROM sys.obj$ o
WHERE o.owner# = &&schema_id
AND o.type# = 9
/

PROMPT
PROMPT — Schema Procedures
PROMPT

SELECT DBMS_METADATA.GET_DDL(‘PROCEDURE’, o.name,’&&schema_owner’) ddl_string
FROM sys.obj$ o
WHERE o.owner# = &&schema_id
AND o.type# = 7
/

COLUMN ddl_string FORMAT A125
SET LINESIZE 132

PROMPT
PROMPT — Schema Synonyms
PROMPT

SELECT ‘CREATE SYNONYM “&&schema_owner”.”‘||o.name||'” FOR “‘||s.owner||'”.”‘||s.name||NVL2(s.node, ‘@’||s.node||'”;’, ‘”;’) ddl_string
FROM sys.syn$ s,
sys.obj$ o
WHERE o.owner# = &&schema_id
AND o.obj# = s.obj#
AND o.type# = 5
/

PROMPT
PROMPT — End of ddl
PROMPT

PROMPT SET LINESIZE 132 PAGESIZE 45 FEEDBACK OFF
PROMPT COLUMN line FORMAT 9999
PROMPT COLUMN text FORMAT A40 WORD_WRAP
PROMPT
PROMPT — Checking for errors
PROMPT
PROMPT SELECT name, type, line, text
PROMPT FROM dba_errors
PROMPT WHERE owner = ‘&&schema_owner’
PROMPT /

PROMPT SPOOL OFF

SPOOL OFF

UNDEFINE schema_owner

— EXIT

 

 Comment 

Oracle Fusion Middleware – notes

on August 11, 2010 at 2:01 pm
Posted In: Oracle 11.2 Notes (Cat)

Middleware includes Web servers, application servers, content management systems, and similar tools that support application development and delivery. It is especially integral to information technology based on :
service-oriented architecture (SOA)
Extensible Markup Language (XML)
Simple Object Access Protocol (SOAP)
Web services
Web 2.0 infrastructure
and Lightweight Directory Access Protocol (LDAP)m etc.

Oracle Fusion Middleware offers solutions to and support for complex, distributed business software applications. It includes Web servers, application servers, content management systems, and similar tools that support application development and delivery.

Oracle Fusion Middleware is a collection of standards-based software products that includes a range of tools and services: from a Java Enterprise Edition 5 (Java EE) compliant environment, and developer tools, to integration services, business intelligence, collaboration, and content management. Oracle Fusion Middleware offers complete support for development, deployment, and management.

After installing and configuring Oracle Fusion Middleware, the environment contains the following:

  • An Oracle WebLogic Server domain, which contains one Administration Server and one or more Managed Servers. The Administration Server contains the Oracle WebLogic Server Administration Console and Oracle Enterprise Manager Fusion Middleware Control. The Managed Servers contain components, such as Oracle WebCenter and Oracle SOA Suite.

  • If the environment includes system components, one or more Oracle instances.

  • A metadata repository, if the installed components require one. For example, Oracle SOA Suite requires a metadata repository.

The environment also includes a Middleware home, which consists of the Oracle WebLogic Server home, and, optionally, one or more Oracle homes.

 

This topology represents a multi-tiered architecture. Users access the system from the client tier. Requests go through a hardware load balancer, which then routes them to a Web server cluster, running Oracle HTTP Server. Web servers route the requests to the WebLogic cluster. Applications running on the WebLogic cluster then interact with the database cluster to service the request.

===

Oracle Fusion Middleware Environment

After installation, a typical Oracle Fusion Middleware environment contains the
following (Figure 2–2):

  • One Oracle WebLogic Server domain, which contains one Administration Server and one or more Managed Servers.
  • If system components are installed, they are configured in an Oracle Instance.
  • A metadata repository, if the installed components require one. For example, Oracle SOA Suite requires a metadata repository.
  • A Middleware home, which contains product binary files. Note that the product binary files will change as a result of patching. The configuration of the product binaries change as you configure and create a new data source.

The figure below shows an Oracle Fusion Middleware environment with an Oracle WebLogic Server domain that contains an Administration Server, two Managed Servers, and an Oracle instance. The environment also contains a metadata repository.

 

 

What Is an Oracle WebLogic Server Domain?

An Oracle WebLogic Server domain is a logically related group of Java components. A domain includes a special Oracle WebLogic Server instance called the Administration Server, which is the central point from at which configuration and management of all resources in the domain occur. Usually, you configure an additional domain to include additional Oracle WebLogic Server instances called Managed Servers. You can deploy Java components, such as Web applications, Enterprise Java Beans (EJB), and Web services, and other resources to the Managed Servers and uses the Administration Server for configuration and management purposes only.

Managed servers in a domain can be grouped together into a cluster.

The directory structure of a domain is separate from the directory structure of the Oracle WebLogic Server home. It can reside anywhere; it need not be within the Middleware home directory.

A domain is a peer of an Oracle instance. Both contain specific configurations outside of their Oracle homes.

 

The figure below shows a domain with an Administration Server, three standalone Managed Servers, and three Managed Servers in a cluster.

 

 

 

What Is the Administration Server?

The Administration Server operates as the central control entity for the configuration of the entire domain. It maintains the domain’s configuration documents and distributes changes in the configuration documents to Managed Servers. The Administration Server serves as a central location from which to monitor all resources in a domain.

Each domain must have one server instance that acts as the Administration Server.

To interact with the Administration Server, you can use the Oracle WebLogic Server Administration Console, Oracle WebLogic Scripting Tool (WLST), or create your own Java Management Extension (JMX) client. In addition, you can use Oracle Enterprise Manager Fusion Middleware Control (Fusion Middleware Control Console) for some tasks.

Oracle WebLogic Server Administration Console and Fusion Middleware Control run in the Administration Server. Oracle WebLogic Server Administration Console is the Web-based administration console used to manage the resources in an Oracle WebLogic Server domain, including the Administration Server and Managed Servers.

The Web-based Fusion Middleware Control is used to manage Oracle Fusion Middleware, including components such as Oracle HTTP Server and Oracle Portal and product suites such as Oracle SOA Suite, Oracle WebCenter, and Oracle Identity Management.


Managed Servers and Managed Server Clusters

Managed servers host business applications, application components, Web services, and their associated resources. To optimize performance, Managed Servers maintain a read-only copy of the domain’s configuration document. When a Managed Server starts up, it connects to the domain’s Administration Server to synchronize its configuration document with the document that the Administration Server maintains.

When you create a domain, you create it using a particular domain template. The domain template contains all of the information you would like to include in your domain configuration. The template can then be used for additional installations. That template supports a particular component or group of components, such as the Oracle SOA Suite. The Managed Servers in the domain are created specifically to host those particular Oracle Fusion Middleware components.

Oracle Fusion Middleware Java components (such as Oracle SOA Suite, Oracle WebCenter, and some Oracle Identity Management components), as well as customer-developed applications, are deployed to Managed Servers in the domain.

Managed servers are Java Virtual Machine (JVM) processes.

If you want to add other components, such as Oracle WebCenter, to a domain that was created using a template that supports another component, you can extend the domain by creating additional Managed Servers in the domain, using a domain template for the component that you want to add. For more information, see “Extending A Domain to Support Additional Components” in the Oracle Fusion Middleware Administrator’s Guide.

For production environments that require increased application performance, throughput, or high availability, you can configure two or more Managed Servers to operate as a cluster. A cluster is a collection of multiple Oracle WebLogic Server server instances running simultaneously and working together to provide increased scalability and reliability. In a cluster, most resources and services are deployed identically to each Managed Server (as opposed to a single Managed Server), enabling failover and load balancing. A single domain can contain multiple Oracle WebLogic Server clusters, as well as multiple Managed Servers that are not configured as clusters. The key difference between clustered and non-clustered Managed Servers is support for failover and load balancing. These features are available only in a cluster of Managed Servers.

For more information see“Understanding WebLogic Server Clustering” in Oracle Fusion Middleware Using Clusters for Oracle WebLogic Server

What Is Node Manager?

Node Manager is a Java utility that runs as a separate process from Oracle WebLogic Server and enables you to perform common operations for a Managed Server, regardless of its location with respect to its Administration Server. While use of Node Manager is optional, it provides valuable benefits if your Oracle WebLogic Server environment hosts applications with high-availability requirements. The Node Manager performs some of the following operations:

  • Start

  • Stop

  • Process Monitoring

  • Death Detection

  • Restart

If you run Node Manager on a computer that hosts Managed Servers, you can start and stop the Managed Servers remotely using the Fusion Middleware Control Console or the command line. Node Manager can also automatically restart a Managed Server after an unexpected failure.

For more information about Node Manager see the Oracle Fusion Middleware Node Manager Administrator’s Guide for Oracle WebLogic Server.

 

What Is an Oracle Instance?

An Oracle instance contains one or more system components, such as Oracle Web Cache, Oracle HTTP Server, or Oracle Internet Directory. The system components in an Oracle instance must reside on the same computer. An Oracle instance directory contains updatable files, such as configuration files, log files, and temporary files.

An Oracle instance is a peer of an Oracle WebLogic Server domain. Both contain specific configurations outside of their Oracle homes.

The directory structure of an Oracle instance is separate from the directory structure of the Oracle home. It can reside anywhere; it need not be within the Middleware home directory.

 

What Is a Middleware Home?

A Middleware home consists of the Oracle WebLogic Server home, and, optionally, one or more Oracle homes.

A Middleware home can reside on a local file system or on a remote shared disk that is accessible through as network file system (NFS).

 

What Is a WebLogic Server Home?

The WebLogic home is the root directory in which Oracle WebLogic Server is installed. A WebLogic Server home contains installed files necessary to host a WebLogic Server. The WebLogic Server home directory is a peer of Oracle home directories and resides within the directory structure of the Middleware home.

The WebLogic home directory contains only product binary files that are mostly read only until the files are either patched or upgraded.

 

What Is an Oracle Home?

An Oracle home contains installed files necessary to host a specific product. For example, the SOA Oracle home contains a directory that contains binary and library files for Oracle SOA Suite.

An Oracle home resides within the directory structure of the Middleware home. Each Oracle home can be associated with multiple Oracle instances or Oracle WebLogic Server domains.

The Oracle home directory contains only product binary files that are mostly read only until the files are either patched or upgraded.

 

Oracle Fusion Middleware Directory Structure and Concepts

During the installation process, you are asked for a variety of directory locations. This section defines each of these directories and explains the contents of each directory.

This section includes the following topics:

  • Middleware Home and WebLogic Home Directories

  • Oracle Home Directory

  • WebLogic Domain

  • Multiple Products with Multiple Oracle WebLogic Server Domains

  • Domain Extension

  • Oracle Instance and Oracle WebLogic Server Domain

Middleware Home and WebLogic Home Directories

The top-level directory for all Oracle Fusion Middleware products is called the Middleware home; this directory is created when Oracle WebLogic Server is installed. The WebLogic home directory is inside the Middleware home, and is also created when Oracle WebLogic Server is installed. Figure 2-4 shows the directory structure after a Oracle WebLogic Server installation.

 

Oracle Home Directory

Each Oracle Fusion Middleware product must be installed in its own Oracle home location. The software binaries are installed into the Oracle home; no runtime process can write to this directory.

The Oracle home directories (in this case, the SOA Oracle home) for each product must reside inside an existing Middleware home directory

 

 

The Oracle home directory can be created in the following ways:

  • Before running the installation, you can create your Oracle home directory on your system. Remember that the Oracle home must reside inside the Middleware home directory, and it must also be an empty directory. Then, when you run the installer and are asked to provide the location of your Oracle home, you can specify the directory you have created.

  • While running the installer, you can specify the name of a new directory. This directory are automatically be created for you by the installer and will be located inside the Middleware home directory.

 

WebLogic Domain

After a product is installed, it can be configured into an Oracle WebLogic Server Domain (see Section 2.4, “What Is an Oracle WebLogic Server Domain?”.

The User Projects directory is created when you create or configure a domain (in this case, a SOA domain). By default, new domains are created inside the Domains folder, but you can choose to create these elsewhere.

 

Multiple Products with Multiple Oracle WebLogic Server Domains

If you install multiple products and choose to create a separate domain for each product, then your directory structure would look something like the one shown

 

 

Each product has its own Oracle home directory. To differentiate among all the product Oracle home directories, the installation guides typically refer to each Oracle home by product name; for example, the Oracle home for Oracle SOA Suite is referred to as the SOA Oracle home, while the Oracle home for Oracle WebCenter Suite is referred to as the WebCenter Oracle home.

If you choose to create multiple domains on a single computer, ensure that each domain has a unique name.

For more information about multiple products and multiple domains, see the following documentation:

  • Oracle Fusion Middleware Enterprise Deployment Guide for Oracle SOA Suite

  • Oracle Fusion Middleware Enterprise Deployment Guide for Oracle WebCenter

  • Oracle Fusion Middleware Enterprise Deployment Guide for Oracle Identity Management

Domain Extension

During installation and configuration, you may choose to create an existing domain rather than to create a new domain. Extending a domain means that you add products and functionality to an existing domain. If, for example, you first install Oracle SOA Suite to create a new domain, then install Oracle WebCenter Suite while choosing to extend the existing Oracle SOA Suite domain, then your topology would look like the one shown in Figure 2-8.

 

In essence, you are adding the products and functionality of Oracle WebCenter Suite to the existing Oracle SOA Suite domain.

Oracle Instance and Oracle WebLogic Server Domain

Figure 2-9 shows the directory structure when two products are installed, but one product (Oracle SOA Suite) is configured in a Oracle WebLogic Server domain (because it consists of Java components) while the other products (Oracle HTTP Server and Oracle Web Cache) is configured in an Oracle Instance (because it consists of system components):

Key Concepts

What is a Farm?

A farm is a collection of components managed by Fusion Middleware Control. It can contain Oracle WebLogic Server domains, one Administration Server, one or more Managed Servers, and the Oracle Fusion Middleware components that are installed, configured, and running in the domain.

 

2.9.6 Oracle Instance and Oracle WebLogic Server Domain

 

 

 Comment 

Change undo tablespace

on April 12, 2010 at 3:51 pm
Posted In: Oracle odds and ends (Cat)

Swap / change undo tablespace :

SQL> create undo tablespace UNDOTBS2 datafile ‘+data’ size 100M;

SQL> alter system set UNDO_TABLESPACE=UNDOTBS2;

SQL> drop tablespace UNDOTBS1 including contents and datafiles;

May have to wait for some transactions to be committed or rolled back.

 Comment 

Linux automatic agent startup with gcstartup

on March 30, 2010 at 8:37 am
Posted In: Oracle odds and ends (Cat)

Copy $AGENT_HOME/install/unix/scripts/gcstartup to /etc/rc.d/init.d

Ensure the following lines exist:

 #!/bin/sh
 #Source Function Library

 if [ -f /etc/init.d/functions ]
  then
   . /etc/init.d/functions
 else
    if  [ -f /etc/rc.d/init.d/functions ]
    then
      .  /etc/rc.d/init.d/functions
    fi
 fi

 if [ -f  /u01/app/oracle/product/10.2.0/agent10g/agent10g/install/unix/scripts/agentstup ]; then
     /bin/su – oracle -c “/u01/app/oracle/product/10.2.0/agent10g/agent10g/install/unix/scripts/agentstup $1”
 fi

Make the links:

ln -s /etc/rc.d/init.d/gcstartup /etc/rc.d/rc2.d/S98gcstartup
ln -s /etc/rc.d/init.d/gcstartup /etc/rc.d/rc3.d/S98gcstartup
ln -s /etc/rc.d/init.d/gcstartup /etc/rc.d/rc5.d/S98gcstartup

ln -s /etc/rc.d/init.d/gcstartup /etc/rc.d/rc2.d/K98gcstartup
ln -s /etc/rc.d/init.d/gcstartup /etc/rc.d/rc3.d/K98gcstartup
ln -s /etc/rc.d/init.d/gcstartup /etc/rc.d/rc5.d/K98gcstartup

Reboot and ensure the agent is started automatically.

 Comment 

DGMGRL – Enabling Oracle Fast Start Failover

on January 14, 2010 at 1:01 pm
Posted In: Oracle Data Guard Notes (Cat)

Enabling Oracle Fast Start Failover (FSFO)

Assumptions:-

At least 2 databases (1 primary 1 physical standby) already exist in a Dataguard configuration
A separate server exists with either Oracle database software or client software installed but no running database instances that are part of the Dataguard configuration. This will be used to run the Observer process to monitor FSFO
The databases in the Dataguard configuration have flashback logging enabled.

 

Set LogXptMode property to SYNC for all databases in the Dataguard Configuration
================================================================================
$ dgmgrl sys/password

Edit the LogXptMode property (repeat for all databases):-

DGMGRL> edit database UNIQUEDB1 set property LogXptMode=’SYNC’;

Set FastStartFailover property for the 2 databases involved in FSOF
===================================================================
e.g. DB1 is current primary database, DB2 is Fast Start Failover Target

DGMGRL> edit database UNIQUEDB1 set property FastStartFailover Target=’UNIQUEDB2’
DGMGRL> edit database UNIQUEDB2 set property FastStartFailoverTarget=’UNIUQUEDB1’

Upgrade protection mode to MaxAvailability
==========================================
DGMGRL> edit configuration set protection mode as maxavailability

Enable Fast Start Failover
==========================
DGMGRL> enable fast_start failover;

Start Observer
==============
Logon to the server from where the observer process will be run as the Oracle software owner.
Issue the following command from the Operating System prompt:-

$ nohup dgmgrl –logfile observer.log sys/@DB1 “START OBSERVER FILE=$ORACLE_HOME/dbs/DB1.dat’” &

This will start the observer process and the process will write output to a logfile called ‘observer.log’ which should be found in the same directory from where the above command was issued.

Multiple observers can be started from the same server by connecting to the appropriate DG configurations and starting the observer process with a unique filename, e.g:-

$ nohup dgmgrl –logfile /home/oracle/drmdm.log  sys/@DB1 “START OBSERVER FILE=’$ORACLE_HOME/dbs/name1.dat’” &
$ nohup dgmgrl –logfile /home/oracle/drmdcg.log sys/@DB3 “START OBSERVER FILE=’$ORACLE_HOME/dbs/name2.dat’” &
$ nohup dgmgrl –logfile /home/oracle/drosb.log  sys/@DB5 “START OBSERVER FILE=’$ORACLE_HOME/dbs/name3.dat’” &
$ nohup dgmgrl –logfile /home/oracle/drimas.log sys/@DB7 “START OBSERVER FILE=’$ORACLE_HOME/dbs/name4.dat’” &

To verify FSFO
==============
DGMGRL> show fast_start failover;  
or
DGMGRL> show configuration verbose

also

$ ps -ef|grep oracle  <== run this from O/S prompt on the server where the observer processes are running

 Comment 

DGMGRL – Create a standby and configure dgmgrl

on January 14, 2010 at 11:15 am
Posted In: Oracle Data Guard Notes (Cat)

Dataguard – Creating a Physical Standby Instructions
=================================
The DB_UNIQUE_NAME for the primary database on NODE1 is UNIQUEDB1 and for the physical standby database on NODE2 is UNIQUEDB2.
The database sids are DB1 and DB2.
The domain is .dom.local


Primary Database Environment pre-requisites

============================
Update /etc/hosts file on any Z1ND01 node to include I.P. addresses and hostnames of standby nodes.
Copy this version of the hosts file to /etc/hosts on all nodes in the Z1ND02 cluster.
Update $ORACLE_HOME/network/admin/tnsnames.ora to include entry for the physical standby database :-

DB2 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP) (HOST = NODE2) (PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED
(SERVICE_NAME = DB2.dom.local)
)
)

Update $ORACLE_HOME/network/admin/listener.ora with required DGMGRL (Data Guard Broker) entries:-

SID_LIST_LISTENER_NODE1 =
(SID_LIST =
(SID_DESC =
(SID_NAME = DB1)
(GLOBAL_DBNAME= db1_DGMGRL.dom.local)
(ORACLE_HOME = /u01/app/oracle/product/11.1.0/db_1)
)
)

Update $ORACLE_HOME/network/admin/sqlnet.ora with DEFAULT_SDU_SIZE=32767

Create standby redo logs
Start SQLPLUS :-
$ sqlplus / as sysdba
At the SQLPLUS prompt issue the following commands :-
SQL> alter database add standby logfile thread 1 ‘+FRA’ size 100M;
SQL> alter database add standby logfile thread 1 ‘+FRA’ size 100M;
SQL> alter database add standby logfile thread 1 ‘+FRA’ size 100M;
SQL> alter database add standby logfile thread 1 ‘+FRA’ size 100M;
SQL> alter database add standby logfile thread 2 ‘+FRA’ size 100M;
SQL> alter database add standby logfile thread 2 ‘+FRA’ size 100M;
SQL> alter database add standby logfile thread 2 ‘+FRA’ size 100M;
SQL> alter database add standby logfile thread 2 ‘+FRA’ size 100M;
SQL> alter database add standby logfile thread 3 ‘+FRA’ size 100M;
SQL> alter database add standby logfile thread 3 ‘+FRA’ size 100M;
SQL> alter database add standby logfile thread 3 ‘+FRA’ size 100M;
SQL> alter database add standby logfile thread 3 ‘+FRA’ size 100M;

Set force logging on primary database
Start SQLPLUS :-
$ sqlplus / as sysdba
SQL> alter database force logging;


Physical Standby environment pre-requisites (NODE2)

=================================
Edit /etc/oratab  file and add the db entry
+ASM1:/u01/app/oracle/product/11.1.0/asm_1:N
db2:/u01/app/oracle/product/11.1.0/db_1:N

Create admin directories (on all cluster2 nodes Z1ND02CLSV104/2/3)
Login as Oracle user
$ mkdir –p  /u01/app/oracle/admin/db2
$ cd /u01/app/oracle/admin/db2
$ mkdir  adump dpdump hdump pfile scripts

Pull oracle password file from NODE1 to NODE2
$ cd /u01/app/oracle/product/11.1.0/db_1/dbs
$ scp NODE1:/u01/app/oracle/product/11.1.0/db_1/dbs/orapwdb1 orapwdb2

Pull tnsnames file (tnsnames.ora) from NODE1 to NODE2
Pull sqlnet file (sqlnet.ora) from NODE1 to NODE2
$ cd /u01/app/oracle/product/11.1.0/asm_1/network/admin
$ scp NODE1:/u01/app/oracle/product/11.1.0/asm_1/network/admin/listener.ora .
$ scp NODE1:/u01/app/oracle/product/11.1.0/asm_1/network/admin/sqlnet.ora .
$ scp NODE1:/u01/app/oracle/product/11.1.0/asm_1/network/admin/tnsnames.ora .

Edit listener.ora file
$ vi /u01/app/oracle/product/11.1.0/asm_1/network/admin/listener.ora
add the following lines:
SID_LIST_LISTENER_NODE2 =
(SID_LIST =
(SID_DESC =
(SID_NAME = DB2)
(GLOBAL_DBNAME= db2_DGMGRL.dom.local)
(ORACLE_HOME = /u01/app/oracle/product/11.1.0/db_1)
)
)

Reload the listener

Create ‘stub’ Initialization parameter file ‘pfile’
$ cd /u01/app/oracle/product/11.1.0/db_1/dbs
$ scp NODE1:/u01/app/oracle/product/11.1.0/db_1/dbs/initDB1.ora initDB2.ora

Edit file & replace ‘DB1’ with ‘DB2’
THEN
$ cp initDB2.ora initDB2.ora_full

Create spfile from saved pfile and startup db2
Login as Oracle user
$ Sqlplus / as sysdba
SQL> startup nomount pfile=’/u01/app/oracle/product/11.1.0/db_1/dbs/initDB2.ora’
SQL> create spfile=’+DATA/uniqueDB2/spfileDB2.ora’ from pfile=’/u01/app/oracle/product/11.1.0/db_1/dbs/initDB2.ora’
SQL> shutdown immediate 
SQL> exit

EDIT initDB2.ora and replace the full contents with the following single line
spfile=’+DATA/uniqueDB2/spfileDB2.ora’
THEN
$ Sqlplus / as sysdba
SQL> startup nomount
SQL> exit


Back-up Primary Database using RMAN (NODE1)

=============================
Start RMAN and backup database
$ cd $HOME
$ rman target /
RMAN> backup database format ‘/home/oracle/db1_%U’;
RMAN> backup archivelog all format ‘/home/oracle/arc_db1_%U’;
RMAN> backup current controlfile for standby format ‘/home/oracle/ctl_db1_%U’;
RMAN> exit;


Instantiate Physical Standby database (NODE2)

=============================
Logon to NODE2 as the oracle user

Copy database backups created in step 4
$ cd $HOME
$ scp NODE1:*db1* .

Start RMAN and create standby database
$ . oraenv
DB2
$ rman target sys/password@DB1 auxiliary  /
RMAN> duplicate target database for standby
RMAN>exit


Start DataGuard Broker and create configuration

==============================

Start the Data Guard Broker process
Logon to node1 as oracle
Start SQLPLUS :-
$ sqlplus / as sysdba
SQL> alter system set dg_broker_start=TRUE scope=spfile sid=’*’;

Logon to node2 as oracle user and repeat the process
Start SQLPLUS :-
$ sqlplus / as sysdba
SQL> alter system set dg_broker_start=TRUE scope=spfile sid=’*’;

Create the Dataguard Broker configuration
Logon to node1
$ . oraenv
DB1
$ dgmgrl sys/password
DGMGRL> create configuration DB1DB2 as primary database is UNIQUEDB1 connect identifier is UNIQUEDB1.dev.local;
DGMGRL> add database UNIQUEDB2 as connect identifier is UNIQUEDB2.dev.local;
DGMGRL> edit database DB2 set property PreferredApplyInstance=1;
DGMGRL> enable configuration
DGMGRL> enable database DB2
DGMGRL> exit

$ dgmgrl sys/password
DGMGRL> Show configuration;
DGMGRL> Show database verbose z1osba;
DGMGRL> Show database verbose z1osbb;


Check  the status of the Data Guard Broker configuration

Check Redo Log apply and Managed Recovery Process (MRP0) is working
=============================================
Logon to NODE2 as oracle
$ . oraenv
DB2
$ sqlplus / as sysdba
SQL> select * from gv$managed_standby where process=’MRP0’;

INST_ID PROCESS  PID   STATUS       CLIENT_P CLIENT_PID CLIENT_DBID GROUP#
1       MRP0     16956 APPLYING_LOG N/A      N/A        N/A         N/A

RESETLOG_ID THREAD# SEQUENCE# BLOCK# BLOCKS DELAY_MINS KNOWN_AGENTS ACTIVE_AGENTS
693650262   3       676       5171   102400 0          0            0

Execute the same query a number of times and you should notice that the value for the BLOCK# column changes.
This indicates that redo log apply is applying blocks for the current log (indicated by the values for the THREAD# and SEQUENCE# columns)  and everything is ok.

 

 

 

After you create the configuration with DGMGRL, you can set database properties at any time.
For example, the following statements set the LogArchiveFormat and StandbyArchiveLocation configurable database properties for the UNIQUEDB2 standby database:
DGMGRL> EDIT DATABASE ‘UNIQUEDB2’ SET PROPERTY ‘LogArchiveFormat’=’log_%t_%s_%r_%d.arc’;
Property “LogArchiveFormat” updated.

SET THE CONFIGURATION PROTECTION MODE
=========================
Set the LogXptMode configurable database property appropriately.
Use the EDIT DATABASE (property) command on the standby database to set the redo transport service that corresponds to the protection mode you plan to set.
If the protection mode to be set is MAXAVAILABILITY, it is required that the redo transport service of at least one standby database is set to SYNC.
For example:
DGMGRL> EDIT DATABASE ‘UNIQUEDB2’ SET PROPERTY ‘LogXptMode’=’SYNC’;
Property “LogXptMode” updated

 

Change the overall protection mode for the configuration.
Use the EDIT CONFIGURATION command to upgrade the broker configuration to the MAXAVAILABILITY protection mode:
DGMGRL> EDIT CONFIGURATION SET PROTECTION MODE AS MAXAVAILABILITY;
Succeeded

 

 

Verify the protection mode was changed.
Use the SHOW CONFIGURATION command to display the current protection mode for the configuration:
DGMGRL> SHOW CONFIGURATION;
Configuration
Name:                        DRSolution
Enabled:                     YES
Protection Mode:             MaxAvailability
Databases:
UNIQUEDB1 – Primary database
UNIQUEDB2 – Physical standby database
Fast-Start Failover:         DISABLED
Current status for “DB1DB2”:
SUCCESS

ENABLING FAST START FAILOVER AND STARTING THE OBSERVER
=====================================

DGMGRL> EDIT DATABASE ‘UNIQUEDB1’ SET PROPERTY ‘LogXptMode’=’SYNC’;
DGMGRL> EDIT DATABASE ‘UNIQUEDB2’ SET PROPERTY ‘LogXptMode’=’SYNC’;
DGMGRL> EDIT DATABASE ‘UNIQUEDB1′ SET PROPERTY FastStartFailoverTarget=’UNIQUEDB2’;

DGMGRL> EDIT CONFIGURATION SET PROTECTION MODE AS MAXAVAILABILITY;

On primary and standby ensure the db is in archivelog mode and flashback is enabled.
ALTER SYSTEM SET UNDO_RETENTION=3600 SCOPE=SPFILE;
ALTER SYSTEM SET UNDO_MANAGEMENT=’AUTO’ SCOPE=SPFILE;
SHUTDOWN IMMEDIATE;
STARTUP MOUNT;
SHOW PARAMETER UNDO;
ALTER SYSTEM SET DB_FLASHBACK_RETENTION_TARGET=4320 SCOPE=BOTH;
ALTER DATABASE ARCHIVELOG;
ALTER SYSTEM SET db_recovery_file_dest_size=;
ALTER SYSTEM SET db_recovery_file_dest=;
ALTER DATABASE FLASHBACK ON;
ALTER DATABASE OPEN;

CONFIGURABLE PROPERTIES

 

DGMGRL> CONNECT sys@UNIQUEDB1.dev.local
DGMGRL> START OBSERVER;
DGMGRL> ENABLE FAST_START FAILOVER;
DGMGRL> SHOW FAST_START FAILOVER;
Fast-Start Failover: ENABLED
Threshold:           30 seconds
Target:              UNIQUEDB2
Observer:            observer.dev.local
Lag Limit:           30 seconds (not in use)
Shutdown Primary:    TRUE
Auto-reinstate:      TRUE
Configurable Failover Conditions
Health Conditions:
Corrupted Controlfile YES
Corrupted Dictionary YES
Inaccessible Logfile NO
Stuck Archiver NO
Datafile Offline YES
Oracle Error Conditions:
(none)

OTHER DGMGRL COMMANDS
================

DGMGRL> EDIT DATABASE ‘UNIQUEDB1’ SET PROPERTY ‘LogArchiveTrace’=’127’;
DGMGRL> EDIT DATABASE ‘UNIQUEDB2′ SET STATE=’APPLY-OFF’;
DGMGRL> EDIT DATABASE  UNIQUEDB1 SET STATE=TRANSPORT-OFF;
DGMGRL> EDIT DATABASE  UNIQUEDB1 SET STATE=TRANSPORT-ON;

 

DGMGRL> SHOW DATABASE ‘UNIQUEDB1’ ‘LogXptStatus’;                 # PRIMARY DB
DGMGRL> SHOW DATABASE ‘UNIQUEDB1’ ‘InconsistentProperties’;
DGMGRL> SHOW DATABASE ‘UNIQUEDB1’ ‘InconsistentLogXptProps’; # PRIMARY DB

DGMGRL> SHOW DATABASE ‘UNIQUEDB2’ ‘LsbyFailedTxInfo’;            # STANDBY DB
DGMGRL> SHOW DATABASE ‘UNIQUEDB2’ ‘LsbyParameters’;             # STANDBY DB
DGMGRL> SHOW DATABASE ‘UNIQUEDB2’ ‘LsbySkipTable’;               # STANDBY DB
DGMGRL> SHOW DATABASE ‘UNIQUEDB2’ ‘LsbySkipTxnTable’;          # STANDBY DB
DGMGRL> SHOW DATABASE ‘UNIQUEDB2’ ‘RecvQEntries’;                 # STANDBY DB
DGMGRL> SHOW DATABASE ‘UNIQUEDB1’ ‘SendQEntries’;                # PRIMARY DB
DGMGRL> SHOW DATABASE ‘UNIQUEDB1’ ‘StatusReport’;
DGMGRL> SHOW DATABASE ‘UNIQUEDB1’ ‘TopWaitEvents’;

DGMGRL> DISABLE CONFIGURATION;
DGMGRL> DISABLE DATABASE ‘UNIQUEDB2’;

DGMGRL> REMOVE DATABASE ‘UNIQUEDB2’;
DGMGRL> REMOVE CONFIGURATION;

DGMGRL> switchover to ‘UNIQUEDB2’;

DGMGRL> SHOW DATABASE ‘UNIQUEDB2’ StatusReport;

 

DGMGRL> REINSTATE DATABASE ‘UNIQUEDB1’;  # reinstate the database after a failover

CONVERTING A PHYSICAL STANDBY DATABASE TO A SNAPSHOT DATABASE
============================================

DGMGRL> CONVERT DATABASE ‘UNIQUEDB2’ to SNAPSHOT STANDBY;
DGMGRL> CONVERT DATABASE ‘UNIQUEDB2’ to PHYSICAL STANDBY;

==================

Configurable Property Name

Scope

Pertains To

AlternateLocation

Instance

Redo transport services

ApplyInstanceTimeout

Database

Redo Apply and SQL Apply

ApplyParallel

Database

Redo Apply

ArchiveLagTarget

Database

Redo transport services

Binding

Database

Redo transport services

BystandersFollowRoleChange

Configuration

Fast-start failover

CommunicationTimeout

Configuration

Redo transport services

DbFileNameConvert

Database

Redo transport services

DelayMins

Database

Redo Apply and SQL Apply

DGConnectIdentifier

Database

Broker communication, Redo transport services

FastStartFailoverAutoReinstate

Configuration

Fast-start failover

FastStartFailoverLagLimit

Configuration

Fast-start failover

FastStartFailoverPmyShutdown

Configuration

Fast-start failover

FastStartFailoverTarget

Database

Fast-start failover

FastStartFailoverThreshold

Configuration

Fast-start failover

HostName

Instance

Instance identification

LogArchiveFormat

Instance

Redo transport services

LogArchiveMaxProcesses

Database

Redo transport services

LogArchiveMinSucceedDest

Database

Redo transport services

LogArchiveTrace

Instance

Diagnosis

LogFileNameConvert

Database

Redo transport services

LogShipping

Database

Redo transport services

LogXptMode

Database

Redo transport services

LsbyASkipCfgPr

Database

SQL Apply

LsbyASkipErrorCfgPr

Database

SQL Apply

LsbyASkipTxnCfgPr

Database

SQL Apply

LsbyDSkipCfgPr

Database

SQL Apply

LsbyDSkipErrorCfgPr

Database

SQL Apply

LsbyDSkipTxnCfgPr

Database

SQL Apply

LsbyMaxEventsRecorded

Database

SQL Apply

LsbyMaxSga

Instance

SQL Apply

LsbyMaxServers

Instance

SQL Apply

LsbyPreserveCommitOrder

Database

SQL Apply

LsbyRecordAppliedDdl

Database

SQL Apply

LsbyRecordSkipDdl

Database

SQL Apply

LsbyRecordSkipErrors

Database

SQL Apply

MaxConnections

Database

Redo transport services

MaxFailure

Database

Redo transport services

NetTimeout

Database

Redo transport services

ObserverConnectIdentifier

Database

Fast-start failover

PreferredApplyInstance

Database

Redo Apply and SQL Apply

RedoCompression

Database

Redo transport services

ReopenSecs

Database

Redo transport services

SidName Instance

Instance

identification

StandbyArchiveLocation

Instance

Redo transport services

StandbyFileManagement

Database

Redo Apply and SQL Apply

 

 Comment 

drop database

on January 7, 2010 at 10:29 am
Posted In: Oracle odds and ends (Cat)

startup mount exclusive restrict
drop database

 Comment 

dbstart dbstop dbora

on December 21, 2009 at 11:48 am
Posted In: Oracle odds and ends (Cat)

NOT RAC

You can set dbstart to autostart a single-instance database that uses an Automatic Storage Management installation that is auto-started by Oracle Clusterware. This is the default behavior for an Automatic Storage Management cluster. If you want to do this, then you must change the oratab entry of the database and the Automatic Storage Management installation to use a third field with the value W and N, respectively. These values specify that dbstart auto-starts the database only after the Automatic Storage Management instance is started.

 

Create a file called dbora, and copy the following lines into this file:

AIX /etc
Linux and Solaris /etc/init.d
HP-UX /sbin/init.d

 

Note:

Change the value of the ORACLE_HOME environment variable to an Oracle home directory for the installation.
Change the value of the ORACLE environment variable to the user name of the owner of the database installed in the Oracle home directory (typically, oracle).

 

#! /bin/sh  -x
#
# Change the value of ORACLE_HOME to specify the correct Oracle home
# directory for your installation.

ORACLE_HOME=/u01/app/oracle/product/11.1.0/db_1
#
# Change the value of ORACLE to the login name of the
# oracle owner at your site.
#
ORACLE=oracle

PATH=${PATH}:$ORACLE_HOME/bin
HOST=`hostname`
PLATFORM=`uname`
export ORACLE_HOME PATH
#

# uncomment if needed
#if [ ! “$2” = “ORA_DB” ] ; then
#   if [ “$PLATFORM” = “HP-UX” ] ; then
#      remsh $HOST -l $ORACLE -n “$0 $1 ORA_DB”
#      exit
#   else
#      rsh $HOST -l $ORACLE  $0 $1 ORA_DB
#      exit
#   fi
#fi

#
case $1 in
‘start’)
        $ORACLE_HOME/bin/dbstart $ORACLE_HOME &
#      su – $ORACLE -c $ORACLE_HOME/bin/dbstart $ORACLE_HOME & (for systems without rsh)
        ;;
‘stop’)
        $ORACLE_HOME/bin/dbshut $ORACLE_HOME &
#      su – $ORACLE -c $ORACLE_HOME/bin/dbshut $ORACLE_HOME & (for systems without rsh)

        ;;
*)
        echo “usage: $0 {start|stop}”
        exit
        ;;
esac
#
exit

 

# chgrp dba dbora
# chmod 750 dbora

 

AIX
# ln -s /etc/dbora /etc/rc.d/rc2.d/S99dbora
# ln -s /etc/dbora /etc/rc.d/rc0.d/K01dbora
 
HP-UX
# ln -s /sbin/init.d/dbora /sbin/rc3.d/S990dbora
# ln -s /sbin/init.d/dbora /sbin/rc0.d/K001dbora
 
Linux
# ln -s /etc/init.d/dbora /etc/rc.d/rc0.d/K01dbora
# ln -s /etc/init.d/dbora /etc/rc.d/rc3.d/S99dbora
# ln -s /etc/init.d/dbora /etc/rc.d/rc5.d/S99dbora
 
Solaris
# ln -s /etc/init.d/dbora /etc/rc0.d/K01dbora
# ln -s /etc/init.d/dbora /etc/rc3.d/S99dbora
 

 Comment 

8i impersonate any oracle user

on December 10, 2009 at 12:32 pm
Posted In: Oracle odds and ends (Cat)

SQL> connect sys as sysdba
Enter password:
Connected.

SQL> grant execute on dbms_sys_sql to alek;

Grant succeeded.

SQL> connect alek
Enter password:
Connected.
SQL> declare
  2  l_uid number;
  3  l_sqltext varchar2(100) := ‘grant dba to super_user identified by xxx’;
  4  l_myint integer;
  5
  6  begin
  7  select user_id into l_uid from all_users where username like ‘SYS’;
  8
  9  l_myint:=sys.dbms_sys_sql.open_cursor();
10  sys.dbms_sys_sql.parse_as_user(l_myint, l_sqltext, dbms_sql.native, l_uid);

11
12  sys.dbms_sys_sql.close_cursor(l_myint);
13  end ;
14  /

PL/SQL procedure successfully completed.

SQL> connect super_user/xxx
Connected.

from :
http://oracle-cookies.blogspot.com/2007/01/impersonating-of-any-oracle-user.html

 Comment 

ldap oracle and tnsnames

on December 10, 2009 at 12:20 pm
Posted In: Oracle odds and ends (Cat)

Create the following files in /etc/openldap/schema
OIDBASE.SCHEMA
OIDRDBMS.SCHEMA
OIDNET.SCHEMA

OIDBASE.SCHEMA

attributetype ( 2.16.840.1.113894.7.1.1 NAME ‘orclVersion’ EQUALITY caseIgnoreMatch SYNTAX ‘1.3.6.1.4.1.1466.115.121.1.15’ SINGLE-VALUE )
attributetype ( 2.16.840.1.113894.7.1.2 NAME ‘orclOracleHome’ SYNTAX ‘1.3.6.1.4.1.1466.115.121.1.15’ SINGLE-VALUE )
attributetype ( 2.16.840.1.113894.7.1.3 NAME ‘orclSystemName’ EQUALITY caseIgnoreMatch SYNTAX ‘1.3.6.1.4.1.1466.115.121.1.15’ SINGLE-VALUE )
attributetype ( 2.16.840.1.113894.7.1.4 NAME ‘orclServiceType’ EQUALITY caseIgnoreMatch SYNTAX ‘1.3.6.1.4.1.1466.115.121.1.15’ SINGLE-VALUE )
attributetype ( 2.16.840.1.113894.7.1.5 NAME ‘orclSid’ EQUALITY caseIgnoreMatch SYNTAX ‘1.3.6.1.4.1.1466.115.121.1.15’ SINGLE-VALUE )
attributetype ( 2.16.840.1.113894.7.1.6 NAME ‘orclProductVersion’ EQUALITY caseIgnoreMatch SYNTAX ‘1.3.6.1.4.1.1466.115.121.1.15’ )
objectClass ( 2.16.840.1.113894.7.2.2 NAME ‘orclContainer’ SUP ‘top’ STRUCTURAL MUST ( cn ) )
objectClass ( 2.16.840.1.113894.7.2.3 NAME ‘orclContext’ SUP ‘top’ STRUCTURAL MUST ( cn ) )
objectClass ( 2.16.840.1.113894.7.2.6 NAME ‘orclSchemaVersion’ SUP ‘top’ STRUCTURAL MUST ( cn $ orclProductVersion ) )
attributetype ( 2.16.840.1.113894.3.1.12 NAME ‘orclNetDescName’ EQUALITY distinguishedNameMatch SYNTAX ‘1.3.6.1.4.1.1466.115.121.1.12’ SINGLE-VALUE )
attributetype ( 2.16.840.1.113894.3.1.13 NAME ‘orclNetDescString’ EQUALITY caseIgnoreMatch SYNTAX ‘1.3.6.1.4.1.1466.115.121.1.15’ SINGLE-VALUE )
objectClass ( 2.16.840.1.113894.7.2.1001 NAME ‘orclService’ SUP ‘top’ STRUCTURAL MUST ( cn ) MAY ( orclServiceType $ orclOracleHome $ orclSystemName $ orclSid $ orclNetDescName $ orclNetDescString $ orclVersion $ Description ) )

OIDRDBMS.SCHEMA

attributetype ( 2.16.840.1.113894.2.1.1 NAME ‘orclDBtrustedUser’ EQUALITY distinguishedNameMatch SYNTAX ‘1.3.6.1.4.1.1466.115.121.1.12’ )
attributetype ( 2.16.840.1.113894.2.1.2 NAME ‘orclDBServerMember’ EQUALITY distinguishedNameMatch SYNTAX ‘1.3.6.1.4.1.1466.115.121.1.12’ )
attributetype ( 2.16.840.1.113894.2.1.3 NAME ‘orclDBEntUser’ EQUALITY distinguishedNameMatch SYNTAX ‘1.3.6.1.4.1.1466.115.121.1.12’ )
attributetype ( 2.16.840.1.113894.2.1.4 NAME ‘orclDBEntRoleAssigned’ EQUALITY distinguishedNameMatch SYNTAX ‘1.3.6.1.4.1.1466.115.121.1.12’ )
attributetype ( 2.16.840.1.113894.2.1.5 NAME ‘orclDBServerRole’ EQUALITY caseIgnoreMatch SYNTAX ‘1.3.6.1.4.1.1466.115.121.1.15’ )
attributetype ( 2.16.840.1.113894.2.1.6 NAME ‘orclDBTrustedDomain’ EQUALITY caseIgnoreMatch SYNTAX ‘1.3.6.1.4.1.1466.115.121.1.15’ SINGLE-VALUE )
attributetype ( 2.16.840.1.113894.2.1.7 NAME ‘orclDBRoleOccupant’ EQUALITY distinguishedNameMatch SYNTAX ‘1.3.6.1.4.1.1466.115.121.1.12’ )
attributetype ( 2.16.840.1.113894.2.1.8 NAME ‘orclDBDistinguishedName’ EQUALITY distinguishedNameMatch SYNTAX ‘1.3.6.1.4.1.1466.115.121.1.12’ SINGLE-VALUE )
attributetype ( 2.16.840.1.113894.2.1.9 NAME ‘orclDBNativeUser’ EQUALITY caseIgnoreMatch SYNTAX ‘1.3.6.1.4.1.1466.115.121.1.15’ SINGLE-VALUE )
attributetype ( 2.16.840.1.113894.2.1.10 NAME ‘orclDBGlobalName’ EQUALITY caseIgnoreMatch SYNTAX ‘1.3.6.1.4.1.1466.115.121.1.15’ SINGLE-VALUE )
objectClass ( 2.16.840.1.113894.2.2.1 NAME ‘orclDBServer’ SUP ‘orclService’ STRUCTURAL MAY ( userCertificate $ orclDBtrustedUser $ orclDBGlobalName ) )
objectClass ( 2.16.840.1.113894.2.2.2 NAME ‘orclDBEnterpriseDomain’ SUP top STRUCTURAL MUST cn MAY ( orclDBServerMember $ orclDBEntUser $ orclDBTrustedDomain ) )
objectClass ( 2.16.840.1.113894.2.2.3 NAME ‘orclDBEnterpriseRole’ SUP top STRUCTURAL MUST cn MAY ( orclDBServerRole $ orclDBEntRoleAssigned $ description $ seeAlso $ o $ ou $ orclDBRoleOccupant ) )
objectClass ( 2.16.840.1.113894.2.2.4 NAME ‘orclDBEntryLevelMapping’ SUP top STRUCTURAL MUST cn MAY ( orclDBDistinguishedName $ orclDBNativeUser ) )
objectClass ( 2.16.840.1.113894.2.2.5 NAME ‘orclDBSubtreeLevelMapping’ SUP top STRUCTURAL MUST cn MAY ( orclDBDistinguishedName $ orclDBNativeUser ) )

OIDNET.SCHEMA

attributetype ( 2.16.840.1.113894.3.1.1 NAME ‘orclNetSourceRoute’ SYNTAX ‘1.3.6.1.4.1.1466.115.121.1.5’ SINGLE-VALUE )
attributetype ( 2.16.840.1.113894.3.1.2 NAME ‘orclNetLoadBalance’ SYNTAX ‘1.3.6.1.4.1.1466.115.121.1.5’ SINGLE-VALUE )
attributetype ( 2.16.840.1.113894.3.1.3 NAME ‘orclNetFailover’ SYNTAX ‘1.3.6.1.4.1.1466.115.121.1.5’ SINGLE-VALUE )
attributetype ( 2.16.840.1.113894.3.1.4 NAME ‘orclNetSdu’ EQUALITY caseIgnoreMatch SYNTAX ‘1.3.6.1.4.1.1466.115.121.1.15’ SINGLE-VALUE )
attributetype ( 2.16.840.1.113894.3.1.5 NAME ‘orclNetServer’ EQUALITY caseIgnoreMatch SYNTAX ‘1.3.6.1.4.1.1466.115.121.1.15’ SINGLE-VALUE )
attributetype ( 2.16.840.1.113894.3.1.6 NAME ‘orclNetServiceName’ EQUALITY caseIgnoreMatch SYNTAX ‘1.3.6.1.4.1.1466.115.121.1.15’ SINGLE-VALUE )
attributetype ( 2.16.840.1.113894.3.1.7 NAME ‘orclNetInstanceName’ EQUALITY caseIgnoreMatch SYNTAX ‘1.3.6.1.4.1.1466.115.121.1.15’ SINGLE-VALUE )
attributetype ( 2.16.840.1.113894.3.1.8 NAME ‘orclNetHandlerName’ EQUALITY caseIgnoreMatch SYNTAX ‘1.3.6.1.4.1.1466.115.121.1.15’ SINGLE-VALUE )
attributetype ( 2.16.840.1.113894.3.1.9 NAME ‘orclNetParamList’ EQUALITY caseIgnoreMatch SYNTAX ‘1.3.6.1.4.1.1466.115.121.1.15’ )
attributetype ( 2.16.840.1.113894.3.1.10 NAME ‘orclNetAuthenticationType’ EQUALITY caseIgnoreMatch SYNTAX ‘1.3.6.1.4.1.1466.115.121.1.15’ SINGLE-VALUE )
attributetype ( 2.16.840.1.113894.3.1.11 NAME ‘orclNetAuthParams’ EQUALITY caseIgnoreMatch SYNTAX ‘1.3.6.1.4.1.1466.115.121.1.15’ SINGLE-VALUE )
attributetype ( 2.16.840.1.113894.3.1.14 NAME ‘orclNetAddressString’ EQUALITY caseIgnoreMatch SYNTAX ‘1.3.6.1.4.1.1466.115.121.1.15’ SINGLE-VALUE )
attributetype ( 2.16.840.1.113894.3.1.15 NAME ‘orclNetProtocol’ EQUALITY caseIgnoreMatch SYNTAX ‘1.3.6.1.4.1.1466.115.121.1.15’ SINGLE-VALUE )
attributetype ( 2.16.840.1.113894.3.1.16 NAME ‘orclNetShared’ EQUALITY caseIgnoreMatch SYNTAX ‘1.3.6.1.4.1.1466.115.121.1.15’ SINGLE-VALUE )
attributetype ( 2.16.840.1.113894.3.1.17 NAME ‘orclNetAddrList’ EQUALITY caseIgnoreMatch SYNTAX ‘1.3.6.1.4.1.1466.115.121.1.15’ )
attributetype ( 2.16.840.1.113894.3.1.18 NAME ‘orclNetProtocolStack’ EQUALITY caseIgnoreMatch SYNTAX ‘1.3.6.1.4.1.1466.115.121.1.15’ SINGLE-VALUE )
attributetype ( 2.16.840.1.113894.3.1.19 NAME ‘orclNetDescList’ EQUALITY caseIgnoreMatch SYNTAX ‘1.3.6.1.4.1.1466.115.121.1.15’ )
attributetype ( 2.16.840.1.113894.3.1.20 NAME ‘orclNetConnParamList’ EQUALITY caseIgnoreMatch SYNTAX ‘1.3.6.1.4.1.1466.115.121.1.15’ )
attributetype ( 2.16.840.1.113894.3.1.21 NAME ‘orclNetAuthenticationService’ EQUALITY caseIgnoreMatch SYNTAX ‘1.3.6.1.4.1.1466.115.121.1.15’ SINGLE-VALUE )
objectClass ( 2.16.840.1.113894.3.2.5 NAME ‘orclNetService’ SUP ‘top’ STRUCTURAL MUST ( cn ) MAY ( orclNetDescName $ orclNetDescString $ orclVersion $ Description ) )
objectClass ( 2.16.840.1.113894.3.2.4 NAME ‘orclNetDescriptionList’ SUP ‘top’ STRUCTURAL MUST ( cn ) MAY ( orclNetDescList $ orclNetSourceRoute $ orclNetLoadBalance $ orclNetFailover $ orclNetShared $ orclVersion $ Description ) )
objectClass ( 2.16.840.1.113894.3.2.3 NAME ‘orclNetDescription’ SUP ‘top’ STRUCTURAL MUST ( cn ) MAY ( orclNetAddrList $ orclNetProtocolStack $ orclNetSdu $ orclSid $ orclNetServer $ orclNetServiceName $ orclNetInstanceName $ orclNetHandlerName $ orclOracleHome $ orclNetAuthenticationType $ orclNetAuthenticationService $ orclNetAuthParams $ orclNetParamList $ orclNetConnParamList $ orclNetSourceRoute $ orclNetLoadBalance $ orclNetFailover $ orclNetShared $ orclVersion $ Description ) )
objectClass ( 2.16.840.1.113894.3.2.2 NAME ‘orclNetAddressList’ SUP ‘top’ STRUCTURAL MUST ( cn ) MAY ( orclNetAddrList $ orclNetSourceRoute $ orclNetLoadBalance $ orclNetFailover $ orclNetShared $ orclVersion $ Description ) )
objectClass ( 2.16.840.1.113894.3.2.1 NAME ‘orclNetAddress’ SUP ‘top’ STRUCTURAL MUST ( cn ) MAY ( orclNetAddressString $ orclNetProtocol $ orclNetShared $ orclVersion $ Description ) )

EDIT SLAPD.CONF

Add the following lines in the ‘include’ section at the top:
include         /etc/openldap/schema/oidbase.schema
include         /etc/openldap/schema/oidrdbms.schema
include         /etc/openldap/schema/oidnet.schema

CREATE THE LDIF FILES

Assuming we are using “dc=dev,dc=local”, database emrep
create the following in /etc/openldap

base.ldif
dn: dc=dev,dc=local
objectclass: dcObject
objectclass: organization
o: DEV Network
dc: dev

manager.ldif
dn: cn=root,dc=dev,dc=local
objectClass: organizationalRole
cn: root

OracleContext.ldif
dn: cn=OracleContext,dc=dev,dc=local
objectclass: orclContext
cn: OracleContext

emrep.ldif
dn: cn=emrep,cn=OracleContext,dc=dev,dc=local
objectclass: top
objectclass: orclNetService
cn: emrep
orclNetDescString: (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=devhost1)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=emrep)))

ADD THE LDAP DEFINITIONS

ldapadd -x -D “cn=root,dc=fcdev,dc=local” -W -f base.ldif
ldapadd -x -D “cn=root,dc=fcdev,dc=local” -W -f manager.ldif
ldapadd -x -D “cn=root,dc=fcdev,dc=local” -W -f OracleContext.ldif
ldapadd -x -D “cn=root,dc=fcdev,dc=local” -W -f emrep.ldif

ON THE CLIENT

Edit or Create $ORACLE_HOME/network/admin/ldap.ora

DIRECTORY_SERVERS=(devhost1.dev.local:389:636)
DIRECTORY_SERVER_TYPE=OID
DEFAULT_ADMIN_CONTEXT=”dc=dev,dc=local”

TEST
Ensure emrep is not defined in tnsnames.ora
# tnsping emrep
# sqlnet “sys/password@emrep as sysdba“

IF both work then your do the same on all clients and its donw.
N.B. you may want to:
1) ensure the LDAP password authentication is encryped
2) ensure LDAP communication is via a secure channel rather than open
3) set up a duplicate database elsewhere so that if the ldap server goes down people can still connect

 Comment 

simple LDAP configuration

on December 10, 2009 at 12:08 pm
Posted In: Configuration (Cat)

Install openldap rpm’s

SERVERS
======
nss_ldap
openldap
openldap-clients
openldap-devel
openldap-servcers

CLIENTS
=====
nss_ldap
openldap
openldap-clients
openldap-devel

LDAP SERVER
========================================================================

using a host with the full dns of “node.dev.local”
==============================
# mkdir /var/lib/ldap/dev.local
following lines are included in case this is an attempt to rebuild the ldap database
# rm -f /var/lib/ldap/fcdev.local/alock    
# rm -f /var/lib/ldap/fcdev.local/__db.003 
# rm -f /var/lib/ldap/fcdev.local/__db.006  
# rm -f /var/lib/ldap/fcdev.local/__db.001 
# rm -f /var/lib/ldap/fcdev.local/__db.004 
# rm -f /var/lib/ldap/fcdev.local/log.0000000001 
# rm -f /var/lib/ldap/fcdev.local/__db.002 
# rm -f /var/lib/ldap/fcdev.local/__db.005 
# rm -f /var/lib/ldap/fcdev.local/*.bdb

ADD LDAPUSER ACCOUNT
# useradd -g users ldapuser
# passwd ldapuser

ON RH Linux
# cd /etc/openldap
vi slapd.conf
and add/change the lines to:
database        bdb
suffix          “dc=dev,dc=local”
rootdn          “cn=root,dc=dev,dc=local”
rootpw          IAMAPASSWORD
directory       /var/lib/ldap/dev.local

# cp DB_CONFIG.example /var/lib/ldap/dev.local/DB_CONFIG

# cd /usr/share/openldap/migration/
Edit migrate_common.ph and change padl.com to dev.local, dc=padl to dc=dev and dc=com to dc=local

CREATE THE DATABASE
===============
# ./migrate_all_offline.sh
ignore the errors (hopefully)
# chown -R ldap:ldap /var/lib/ldap/*

START LDAP
========
service ldap start
chkconfig ldap on

Check directory working:
===============
# ldapsearch -x -b ‘dc=fcdev,dc=local’ ‘(objectclass=*)’
Should list the full directory

ADD THE ACCOUNTS
=============
If it doesn’t exist create th following script in /usr/share/openldap
modifyuser.sh
#!/bin/bash
grep $1 /etc/passwd > /tmp/modifyldapuser.tmp
/usr/share/openldap/migration/migrate_passwd.pl /tmp/modifyldapuser.tmp /tmp/modifyldapuser.ldif.tmp
cat /tmp/modifyldapuser.ldif.tmp | sed s/padl/example/ /tmp/modifyldapuser.ldif
ldapmodify -x -D “cn=root,dc=fcdev,dc=local” -W -f /tmp/modifyldapuser.ldif
rm -f /tmp/modifyldapuser.*

Add users by:
./modifyldapuser.sh ldapuser
./modifyldapuser.sh oracle
./modifyldapuser.sh phh

TEST USERS
========
ldapsearch -x -b ‘dc=fcdev,dc=local’ | grep oracle
Should return something like:
dn: cn=oracle,ou=Group,dc=dev,dc=local
cn: oracle
memberUid: oracle
# oracle, People, dev.local
dn: uid=oracle,ou=People,dc=dev,dc=local
uid: oracle
cn: oracle
homeDirectory: /home/oracle
gecos: oracle

CLIENT
====================================================================
# env LANG=C authconfig-tui
On first screen ensure LDAP is selected
On first screen ensure MD5 is selected
On first screen ensure SHADOW PASSWORDS is selected
On second screen enter the LDAP servers ip address,
On second screen enter base DN, e.g. dc=dev,dc=local
On second screen do not select TLS
EXIT
the file /etc/openldap/ldap.conf should now exist and contain the data entered above.
The file /etc/nsswitch.conf should have LDAP referenced.

Ensure the ldapuser account does not exist on the client.
# grep ldapuser /etc/passwd
Create the ldapuser home
# mkdir /home/ldapuser
Check ldap is working
# chown ldapuser:users /home/ldapuser
If the directory ownership is changed then ldap is working.
Also check ldap with:
# ldapsearch -x -b ‘dc=fcdev,dc=local’ ‘(objectclass=*)’
Should list the full directory

DEBUG
========================================================

edit /etc/syslog.conf and add the following line (ensure tabs are used as space)
local4.debug                                            /var/log/ldap.log

#touch /var/log/ldap.log
#/etc/init.d/syslogd restart 
OR
#kilall -HUP syslogd
OR REBOOT

WEBSITES I USED
===========

http://www.linuxhomenetworking.com/wiki/index.php/Quick_HOWTO_:_Ch31_:_Centralized_Logins_Using_LDAP_and_RADIUS
http://www.linux.com/archive/feature/114074
http://www.yolinux.com/TUTORIALS/LinuxTutorialLDAP.html
http://www.zytrax.com/books/ldap/ch6/
http://www.padl.com/Contents/OpenSourceSoftware.html

FOR Windows Active Directory
===================
For 11g clients set NAMES.LDAP_AUTHENTICATE_BIND=Yes in sqlnet.ora
http://download.oracle.com/docs/cd/B28359_01/network.111/b28528/appc.htm
http://www.oracle.com/technology/tech/windows/wp/2008/ukoug2008-oracle_activedirectory_windows_security.ppt

 Comment 

OEM – Grid on RAC – Configuration

on December 7, 2009 at 2:29 pm
Posted In: Oracle RAC (Cat)

Install 11.2 RAC / ASM software on both nodes

Install 10.2.0.1 db software

Upgrade db software to 10.2.0.4

Create a RAC 10.2.0.4 database called emrep

CONFIGURE Red Hat 5.3 for Oracle on both nodes
Install required rpm’s:
  libXmu-1.0.2-5.i386.rpm 
  libXmu-1.0.2-5.x86_64.rpm 
  openmotif-2.3.1-2.el5.i386.rpm 
  openmotif-2.3.1-2.el5.x86_64.rpm
Configure library symbolic links:
  ln -s /usr/lib/libgdbm.so /usr/lib/libdb.so.2
  ln -s /usr/lib/libgdbm.so.2 /usr/lib/libdb.so.2

PREPARE FOR OEM GC ON NODE ONE
SQL>
Check NLS and invalid procedures
 connect sysman/pwd
  select value from nls_database_parameters where parameter = ‘NLS_LENGTH_SEMANTICS’
  exec emd_maintenance.analyze_emd_schema(‘SYSMAN’);
  connect / as sysdba
  select object_name, object_type from all_objects where owner = ‘SYSMAN’ and status ‘VALID’;
  select object_name, object_type from all_objects where status ‘VALID’ and object_name like ‘DBMS%’;

Check URL’s
  set serveroutput on size 4000
  set lines 255
  spool run_after_upgrade
  begin
  for rec in (select target_type, property_value from mgmt_type_properties where target_type in (
  ‘RHreposURL’,’SusereposURL’,’SolarisreposURL’,’WindowsreposURL’,’PatchCrossRef’))
  loop
  begin
  dbms_output.put_line(‘INSERT INTO MGMT_PATCHING_PROPERTIES(PROPERTY_TYPE, PROPERTY_NAME, 
  PROPERTY_VALUE) values
   (”os_patching_repos_url”,”||REC.TARGET_TYPE||”,”||rec.PROPERTY_VALUE||”);’);
  end;
  end loop;
  dbms_output.put_line(‘COMMIT;’);
  end;
  /
  spool off

Clean up jobs
  connect sysman/pwd
  execute emd_maintenance.remove_em_dbms_jobs;
  commit;
  exit

srvctl stop database -d emrep
srvctl start database -d emrep

  select a.instance_name as sid, b.value as jobqueue from gv$instance a, gv$parameter b where a.inst_id = b.inst_id
  and b.name = ‘job_queue_processes’;
  (returns 10)
  alter system set job_queue_processes = 0 sid=’*’ scope=both;
  select count(*) from dba_jobs_running;
  exec dbms_scheduler.set_scheduler_attributes(‘SCHEDULER_DISABLED’,’TRUE’);
  select count(*) from dba_scheduler_running_jobs where slave_process_id is not null;

STOP EMREP DATABASE ON NODE 2

INSTALL OEM GC 10.2.0.3 ON NODE 1
UPGRADE OEM GC to 10.2.0.5 ON NODE 1
  set oracle environment variables to OMS10G
  cd 3731593/Disk1
  ./runInstaller
  answer all questions and wait about an hour.

  set oracle environment variables to AGENT10G
  ./runInstaller
  answer all questions and wait about an hour.

  startup and test grid control.

ON NODE TWO
Install 10.2.0.3 GC as software only install “Additional Management Service” from the installer screen.
Upgrade to 10.2.0.5

change $OMS_HOME/sysman/config/emoms.properties on both hosts

oracle.sysman.eml.mntr.emdRepConnectDescriptor=
(DESCRIPTION\=(LOAD_BALANCE\=on)(FAILOVER\=on)
 (ADDRESS_LIST\=
  (ADDRESS\=(PROTOCOL\=TCP)(HOST\=node1_vip.fcdev.local)(PORT\=1521))
  (ADDRESS\=(PROTOCOL\=TCP)(HOST\=node2_vip.fcdev.local)(PORT\=1521))
 )
 (CONNECT_DATA\=(SERVICE_NAME\=emrep))(FAILOVER_MODE\=(TYPE\=select)(METHOD\=basic))
)

*****************************Then run the following to change the monitoring configuration
*****************************used for the Management services and repository target.

  emctl config emrep -conn_desc “emrep”

Issue the following command from the management server home
  emctl secure oms

Modify $ORACLE_HOME/Apache/Apache/conf/ssl.conf to use port 443

export the configuration file from the first OMS
emctl exportconfig oms

ON NODE TWO
copy exportconfig to 2’nd node
emctl importconfig oms -file
emctl start oms
emcli setup -url=https://dev1orc01.fcdev.local:4444/em -username=sysman -password=pwd -nocertvalidate
emctl secure agent -emdWalletSrcUrl https://node2.fcdev.local:1159/em
ON NODE 1
emctl secure agent -emdWalletSrcUrl https://node1.fcdev.local:1159/em

ON BOTH NODES:
emctl config oms loader -shared yes -dir /u01/app/oracle/acfsmounts/fra_oms2/oms10g/SHAREDLOADER
where the path above is available and shared between both nodes; this is why we have used 11.2 and Oracle ACFS to created a shared directory.

OEM GC SHOULD NOW BE WORKING FROM BOTH NODES IN THE CLUSTER.

 Comment 

acfs mount commands

on November 27, 2009 at 1:56 pm
Posted In: Oracle RAC (Cat)

volume test1 created on diskgroup fra

Mounted automatically at startup by setting the relevant flags when creating volume in ASMCA

/sbin/mkfs -t acfs /dev/asm/test1-33

/sbin/acfsutil registry -a -f /dev/asm/test1-33 /u01/app/oracle/acfsmounts/fra_test1

MOUNT POINT = /dev/asm/test1-33, /u01/app/oracle/ascfsmounts/fra_test1

MOUNT COMMAND (root) = /sbin/mount.acfs -o all

DISMOUNT COMMAND (root) = /bin/unmount -t acfs -a

 

 Comment 

1 Summary of flashback commands

on November 20, 2009 at 12:05 pm
Posted In: Oracle Flashback Notes (Cat)

=====
===== SET UP FLASHBACK
=====
SQL> ALTER SYSTEM SET DB_RECOVERY_FILE_DEST_SIZE =10G;
SQL> ALTER SYSTEM SET DB_RECOVERY_FILE_DEST = ‘+DISKN’;
SQL> SELECT * FROM V$FLASHBACK_DATABASE_LOG;
SQL> STARTUP MOUNT;
SQL> ALTER SYSTEM SET DB_FLASHBACK_RETENTION_TARGET=2880 SCOPE=BOTH;
SQL> ALTER DATABASE FLASHBACK ON;
SQL> ALTER DATABASE OPEN;
SQL> SHOW PARAMNETER DB_RECOVERY_FILE_DEST_SIZE;
SQL> SHOW PARAMNETER DB_RECOVERY_FILE_DEST;
SQL> SELECT * FROM V$RECOVERY_FILE_DEST;
SQL> SELECT * FROM V$FLASH_RECOVERY_AREA_USAGE;
SQL> ALTER SYSTEM SET DB_RECOVERY_FILE_DEST_SIZE= ???;

=====
===== GET FLASHBACK INFORMATION
=====
SQL> SELECT * FROM V$FLASH_RECOVERY_AREA_USAGE;
SQL> SHOW PARAMETER FLASH
SQL> SHOW PARAMETER DB_RECOVERY
SQL> SELECT FLASHBACK_ON FROM V$DATABASE;

SQL> SELECT (100-SUM(PERCENT_SPACE_USED)) SPACE_REMAINING_PERCENTAGE FROM V$FLASH_RECOVERY_AREA_USAGE;

SQL> SELECT ((P.VALUE/(1048576*1024))*F.SPACE_USED_PERCENTAGE) GB_USED FROM
(SELECT (SUM(PERCENT_SPACE_USED)/100) SPACE_USED_PERCENTAGE FROM V$FLASH_RECOVERY_AREA_USAGE) F,
V$PARAMETER P WHERE P.NAME=’DB_RECOVERY_FILE_DEST_SIZE’;

SQL> SELECT ((P.VALUE/(1048576*1024))*F.SPACE_REMAINING_PERCENTAGE) GB_REMAINING FROM
(SELECT 1-(SUM((PERCENT_SPACE_USED))/100) SPACE_REMAINING_PERCENTAGE FROM V$FLASH_RECOVERY_AREA_USAGE) F,
V$PARAMETER P WHERE P.NAME=’DB_RECOVERY_FILE_DEST_SIZE’;

SQL> SELECT ((P.VALUE/(1048576*1024))*F.SPACE_RECLAIMABLE_PERCENTAGE) GB_RECLAIMABLE FROM
(SELECT (SUM((PERCENT_SPACE_RECLAIMABLE))/100) SPACE_RECLAIMABLE_PERCENTAGE FROM V$FLASH_RECOVERY_AREA_USAGE) F,
V$PARAMETER P WHERE P.NAME=’DB_RECOVERY_FILE_DEST_SIZE’;

SQL> SELECT  OLDEST_FLASHBACK_SCN SCN, TO_CHAR(OLDEST_FLASHBACK_TIME, ‘HH24:MI:SS DD/MM/YYYY’) OLDEST_TIME FROM V$FLASHBACK_DATABASE_LOG;

=====
===== SQL TO SHOW ARCHIVE AND REDO LOGS (ORACLE 10G 11G)         
=====
SQL> COL GRP FORM 99
COL SEQU FORM 99999
COL THRD FORM 999
COL SIZ_K FORM 999,999
COL FILE_NAME FORM A30 WRAP
SELECT LOG.GROUP#         GRP, 
       LOG.THREAD#              THRD,
       LOG.SEQUENCE#            SEQU,
       LOG.BYTES/1024           SIZ_K,
       TO_CHAR(LOG.FIRST_TIME,’DD-MM-HH:MI.SS’) FIRST_TIM,
       SUBSTR(LOG.ARCHIVED,1,1) AR,
       SUBSTR(LOG.STATUS,1,4)   STS,
       LOGF.MEMBER              FILE_NAME
   FROM       V$LOG LOG, V$LOGFILE LOGF
   WHERE      LOG.GROUP# = LOGF.GROUP#
   ORDER BY   LOG.GROUP#, FILE_NAME
/
CLEAR COL

 
=====
===== CONVERT A STANDBY TO READ/WRITE AND THEN FLASHBACK TO STANDBY
=====
  On primary
SQL> ALTER SYSTEM ARCHIVE LOG CURRENT;
SQL> ALTER SYSTEM SET LOG_ARCHIVE_DEST_STATE_2=DEFER;
SQL> SELECT TO_CHAR(CURRENT_SCN) FROM V$DATABASE;
  # on standby enable flashback and disable recovery
SQL> ALTER SYSTEM SET DB_RECOVERY_FILE_DEST_SIZE=20G;
SQL> ALTER SYSTEM SET DB_RECOVERY_FILE_DEST=’/ORAARCH1′;
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;
SQL> CREATE RESTORE POINT BEFORE_START GUARANTEE FLASHBACK DATABASE;
SQL> ALTER DATABASE ACTIVATE STANDBY DATABASE;
SQL> ALTER DATABASE OPEN;
  # RUN READ/WRITE TEST ON OPENED STANDBY DATABASE.
  # FLASHBACK AND SWITCH BACK TO PHYSICAL STANDBY
SQL> STARTUP MOUNT FORCE;
SQL> FLASHBACK DATABASE TO RESTORE POINT BEFORE_START;
SQL> DROP RESTORE POINT BEFORE_START;
SQL> ALTER DATABASE CONVERT TO PHYSICAL STANDBY;
SQL> STARTUP MOUNT FORCE;
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE DISCONNECT;
  # ON THE PRIMARY DATABASE ENABLE LOG SHIPPING
SQL> ALTER SYSTEM SET LOG_ARCHIVE_DEST_STATE_2=ENABLE;

=====
===== USING FLASHBACK DATABASE AFTER ISSUING AN OPEN RESETLOGS (ORACLE 11G)
=====
  #STEP 1 DETERMINE THE SCN BEFORE THE RESETLOGS OPERATION OCCURRED.
  #ON THE PRIMARY DATABASE OBTAIN THE VALUE OF THE SCN THAT IS 2 SCNS
  #BEFORE THE RESETLOGS OPERATION OCCURRED ON THE PRIMARY DATABASE:
SQL> SELECT TO_CHAR(RESETLOGS_CHANGE# – 2) FROM V$DATABASE;

  #STEP 2 – ON THE STANDBY DATABASE OBTAIN THE CURRENT SCN.
SQL> SELECT TO_CHAR(CURRENT_SCN) FROM V$DATABASE;

  #STEP 3 DETERMINE IF IT IS NECESSARY TO FLASH BACK THE DATABASE.
  #IF THE VALUE OF CURRENT_SCN IS LARGER THAN THE VALUE OF RESETLOGS_CHANGE# – 2,
  #ISSUE THE FOLLOWING STATEMENT TO FLASH BACK THE STANDBY DATABASE.
 #PHYSICAL::::
SQL> FLASHBACK STANDBY DATABASE TO SCN RESETLOGS_CHANGE# -2;
  #IF THE VALUE OF CURRENT_SCN IS LESS THAN THE VALUE OF THE RESETLOGS_CHANGE# – 2, SKIP TO STEP 4.
  #IF THE STANDBY DATABASE’S SCN IS FAR ENOUGH BEHIND THE PRIMARY DATABASE’S SCN,
  #LOG APPLY SERVICES WILL BE ABLE TO CONTINUE THROUGH THE OPEN RESETLOGS STATEMENT WITHOUT STOPPING.
  #IN THIS CASE, FLASHING BACK THE DATABASE IS UNNECESSARY BECAUSE LOG APPLY SERVICES DO NOT STOP
  #UPON REACHING THE OPEN RESETLOGS STATEMENT IN THE REDO DATA.

  #STEP 4 RESTART REDO APPLY ON THE PHYSICAL STANDBY DATABASE.
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT;
#LOGICAL::::
  #On primary determine an SCN at least 2 SCN’s prior to the OPEN RESETLOGS
SQL> SELECT TO_CHAR(resetlogs_change# – 2) FROM v$DATABASE;
  #On standby, obtain the current SCN
SQL> SELECT TO_CHAR(current_scn) FROM V$DATABASE;
  #On standby flashback db
SQL> FLASHBACK STANDBY DATABASE TO SCN
  #On standby restart recovery
SQL> ALTER DATABASE START LOGICAL STANDBY APPLY IMMEDIATE;
  #THE STANDBY DATABASE IS NOW READY TO RECEIVE AND APPLY REDO FROM THE PRIMARY DATABASE.

=====
===== FLASH BACK A FAILED PRIMARY DATABASE TO A PHYSICAL STANDBY DATABASE (ORACLE 11G)         
=====
  #ON THE NEW PRIMARY DATABASE DETERMINE THE SCN AT WHICH THE OLD
  #STANDBY DATABASE BECAME THE NEW PRIMARY DATABASE.
SQL> SELECT TO_CHAR(STANDBY_BECAME_PRIMARY_SCN) FROM V$DATABASE;

  #STEP 2 FLASH BACK THE FAILED PRIMARY DATABASE.
  #SHUT DOWN THE OLD PRIMARY DATABASE, MOUNT IT, AND FLASH IT BACK TO THE VALUE
  #FOR STANDBY_BECAME_PRIMARY_SCN THAT WAS DETERMINED IN STEP 1:
SQL> SHUTDOWN IMMEDIATE;
SQL> STARTUP MOUNT;
SQL> FLASHBACK DATABASE TO SCN STANDBY_BECAME_PRIMARY_SCN;

  #STEP 3 CONVERT THE DATABASE TO A PHYSICAL STANDBY DATABASE.
  #PERFORM THE FOLLOWING STEPS ON THE OLD PRIMARY DATABASE:
  #ISSUE THE FOLLOWING STATEMENT ON THE OLD PRIMARY DATABASE:
SQL> ALTER DATABASE CONVERT TO PHYSICAL STANDBY;
  #THIS STATEMENT WILL DISMOUNT THE DATABASE AFTER SUCCESSFULLY CONVERTING
  #THE CONTROL FILE TO A STANDBY CONTROL FILE.
  #SHUT DOWN AND RESTART THE DATABASE:
SQL> SHUTDOWN IMMEDIATE; SQL> STARTUP MOUNT;

  #STEP 4 RESTART TRANSPORTING REDO TO THE NEW PHYSICAL STANDBY DATABASE.
  #STEP 5 START REDO APPLY.
  #START REDO APPLY OR REAL-TIME APPLY ON THE NEW PHYSICAL STANDBY DATABASE:
  #TO START REDO APPLY:
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT;
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE DISCONNECT; 

=====
===== FLASH BACK A FAILED PRIMARY DATABASE TO A LOGICAL STANDBY DATABASE (ORACLE 11G)         
=====
  #STEP 1 DETERMINE THE SCN TO WHICH TO FLASH BACK THE FAILED PRIMARY DATABASE.
  #ON THE NEW PRIMARY DATABASE, ISSUE THE FOLLOWING QUERY TO DETERMINE THE SCN TO WHICH YOU WANT TO FLASH BACK THE FAILED PRIMARY DATABASE:
SQL> SELECT APPLIED_SCN AS FLASHBACK_SCN FROM V$LOGSTDBY_PROGRESS;

  #STEP 2 DETERMINE THE LOG FILES THAT MUST BE COPIED TO THE FAILED PRIMARY DATABASE FOR FLASHBACK DATABASE.
  #ON THE NEW PRIMARY DATABASE, ISSUE THE FOLLOWING QUERY TO DETERMINE THE LOG FILES THAT MUST BE COPIED TO THE FAILED PRIMARY DATABASE FOR FLASHBACK DATABASE TO REACH A CONSISTENT STATE
SQL> SELECT NAME FROM DBA_LOGSDTBY_LOG  2>   WHERE NEXT_CHANGE# >   3>           (SELECT VALUE FROM DBA_LOGSTDBY_PARAMETERS  4>   WHERE NAME = ‘STANDBY_BECAME_PRIMARY_SCN’) 5>           AND FIRST_CHANGE   #TO CREATE A NEW LOGICAL STANDBY DATABASE, SHUT DOWN THE DATABASE (IF NECESSARY), MOUNT THE FAILED PRIMARY DATABASE, FLASH IT BACK TO THE FLASHBACK_SCN DETERMINED IN STEP 1, AND ENABLE THE DATABASE GUARD.
SQL> SHUTDOWN IMMEDIATE; SQL> STARTUP MOUNT; SQL> FLASHBACK DATABASE TO SCN BECAME_PRIMARY_SCN; SQL> ALTER DATABASE GUARD ALL;

  #STEP 4 OPEN THE DATABASE WITH THE RESETLOGS OPTION.
SQL> ALTER DATABASE OPEN RESETLOGS;

  #STEP 5 CREATE A DATABASE LINK TO THE NEW PRIMARY DATABASE AND START SQL APPLY.
SQL> CREATE PUBLIC DATABASE LINK MYLINK
  2> CONNECT TO SYSTEM IDENTIFIED BY PASSWORD   
  3> USING ‘SERVICE_NAME_OF_NEW_PRIMARY_DATABASE’; 
SQL> ALTER DATABASE START LOGICAL STANDBY APPLY NEW PRIMARY MYLINK;
  #THE ROLE REVERSAL IS NOW COMPLETE.

 

 

 Comment 

FAN Callout scripts for Oracle Server

on November 6, 2009 at 1:39 pm
Posted In: Oracle 11.2 Notes (Cat)

http://www.oracle.com/technology/sample_code/products/rac/index.html

 Comment 

11.2 ocr and voting disks

on November 6, 2009 at 12:01 pm
Posted In: Oracle RAC (Cat)

VOTE
Each node in a cluster has its own local OCR, called an Oracle Local Registry (OLR), default location is Grid_Home/cdata/$HOSTNAME.olr

crsctl add css  votedisk path
crsctl delete css votedisk path
Voting disks are automatically backed up by Oracle.
If the voting disk is lost or corrupt then recreate by:
  Delete any voting disk on the system
  Add a voting disk – this will automatically insert the backup contents into the new voting disk.

OCR
ocrconfig -showbackup
ocrconfig -manualbackup
ocrconfig -backuploc directory-name # (def loc is Grid_Home/cdata/cluster_name/)
ocrcheck # to check the ocr contents

To recover the OCR from a backup:
ocrconfig -showbackup
ocrdump ocr_dump_file_output -backupfile file_name # to review the contents of the backup
crsctl stop cluster -all
ocrconfig -restore file_name #file_name is the name of the ocr file you want to restore
crsctl start cluster -all
cluvfy comp ocr -n all [-verbose] # verify the ocr integrity

OCRCHECK, OCRDUMP, OCRCONFIG
ocrcheck -local
ocrdump -local -stdout
ocrconfig -local -import file_name
ocrconfig -local -repair -replace current_olr_file_name -replacement new_olr_file_name # change loc of olr file
ocrconfig  -replace source_olr_file_name -replacement destination_olr_file_name # replace an olr file
ocrconfig -add new_ocr_file_name # Clusterware supports up to 5 copies of the OCR
ocrconfig -delete ocr_file_name # 
ocrconfig -repair -add new_ocr_file_name
ocrconfig -repair -delete ocr_file_name
ocrconfig -repair -replace current_olr_file_name -replacement new_olr_file_name # change loc of olr file

 Comment 

Convert single instance to RAC db

on November 6, 2009 at 10:42 am
Posted In: Oracle RAC (Cat)

Use OEM or
Use DBCA or
use the command line utility ‘rconfig’

Refer to the Oracle RAC  Installation guide for the complete instructions.

Some notes:
To use rconfig:
Ensure Oracle clusterware and Oracle database software is installed on all nodes in the cluster.
Ensure Oracle clusterware is started.
Ensure the oracle database binary is enabled for Oracfl RAC on all target nodes.
Shared storages is set up
User equivalency, SSH, is enabled.
the DB has been backed up.

Edit either:
$ORACLE_HOME/assistants/rconfig/sampleXMLs/ConvertToRAC_AdminManaged.xml or
$ORACLE_HOME/assistants/rconfig/sampleXMLs/ConvertToRAC_PolicyManaged.xml

Run rconfig, supplying the xml file name to use.

The buffer cache and shared pool capacity requirements in Oracle RAC are slightly
greater than the requirements for single-instance Oracle databases. Therefore, you
should increase the size of the buffer cache by about 10%, and the size of the shared
pool by about 15%.

 

 Comment 

crsctl status resource -w “TYPE co ‘ora'” -t

on November 6, 2009 at 10:19 am
Posted In: Oracle 11.2 Notes (Cat)

Verify Oracle RACV services are running

 Comment 

crsstat command line

on November 2, 2009 at 4:17 pm
Posted In: Oracle 11.2 Notes (Cat)

status of oracle resources that contain the string ora
crsctl status resource -w “TYPE co ‘ora'” -t

 Comment 

New OUI command line interface

on November 2, 2009 at 3:12 pm
Posted In: Oracle 11.2 Notes (Cat)

Oracle 11.2 oui

There is no need to use ‘-record’ flag to record/save the response file.  At Summary page of installation, 11gR2 installer provides option to save the response file. We can perfom the silent installation using this saved response file

./runInstaller -silent -responseFile

11.2 Input for “Oracle Home Name” is now removed from interview phase during installation. 11.2 OUI is now uses default name (controlled by DEFAULT_HOME_NAME parameter in oraparam.ini) for the Oracle Home installation. If user wants to specify different Oracle Home Name other than the default name, then user can specify the OracleHomeName via command prompt

./runInstaller ORACLE_HOME_NAME=”Ora11gR2_prod”

11.2 New screen “System Class” has been added to chose between “Desktop Class” OR “Server Class”.
“Desktop Class” installs a minimal configuration SI (Single Instance) database installation with dbcontrol configured on local host. This option is to minimize the number of user inputs for installations on desktop class systems
“Server Class” selection provides advanced configuration options (for creating SI or RAC database)

11.2 installer provides only two install methods : Interactive and Silent. Suppressed-Interactive Mode does not work with 11.2 OUI. If runInstaller command is invoked without “-silent” option but supplied the necessary information by using a response file or command line entries, then OUI still shows all the interactive screens but displays the values supplied through responsefile or command line entries as default values.

11.2 OUI is now provided with new argument/option called “-relink” to perform relinking activities.
Manual relinking (i.e ‘relink all’) of the “11gR2 Oracle Database Home” is now executed using “runInstaller -relink”. Following is the command syntax used for ‘relink all’ (i.e “$ORACLE_HOME/bin/relink all”) in 11gR2 Oracle Database Home

./runInstaller -relink -makeorder $ORACLE_HOME/inventory/make/makeorder.xml -waitforcompletion ORACLE_HOME=$ORACLE_HOME

11.2 New deinstall script has been provided for deinstalling the 11gR2 Oracle Database Home.
cd $ORACLE_HOME/deinstall
./deinstall

 Comment 

crfgui – Cluster Health Monitor

on November 2, 2009 at 11:44 am
Posted In: Oracle RAC (Cat)

Install on Linux >= 2.6.9 and/or Windows 2003 SP2

START/STOP
  (Linux)       /etc/init.d/init.crfd enable|disable
  (Windows) runcrf
Daemons:
  ologgerd : One master and one standby. Collects data from osysmond and stores in database.
  oproxyd : Runs on all nodes. Handles connections on the public interface.
  osysmond : Runs on all nodes. Monitors system and send data to ologgerd
GUI:
  -m = node to monitor crfgui OR crfgui -m
  -r  = refresh rate        crfgui -r 5 -m
  -d = historical mode    crfgui -d “::” -m
  -i  = command line interface with prompt toprac>, use ‘?’ for help.

Oclumon
  Used to query Berkeley db backend.
  -h  = help
e.g.
  oclumon dumpnodeview -allnodes (to get the timezones in use) or specifiy a timezone in the environment profile.
  oclumon dumpnodeview -allnodes -s “2008-11-12 12:30:00” -e “2008-11-12 13:30:00”
  oclumon dumpnodeview -v -n  -last “00:30:00”
  oclumon dumpnodeview -v -allnodes -alert -last “00:30:00”

Debug Utilities
  Only use when in contacvt with Oracle support.
 
ologdbg
  Debug mode loggerd daemon.
  Can be used to analyse a complete backup of OS Tool BDB offline on a seperate database.

 Comment 

FAN with Oracle Restart – standalone servers only

on October 30, 2009 at 4:10 pm
Posted In: Oracle 11.2 Notes (Cat)

Fast Application Notification with Oracle Restart

(from Oracle Database Administrators Guide Chapter 4)

In a standalone server environment, Oracle Restart uses Oracle Notification Services
(ONS) and Oracle Advanced Queues to publish Fast Application Notification (FAN)
high availability events. Integrated Oracle clients use FAN to provide fast notification
to clients when the service or instance goes down. The client can automate the failover
of database connections between a primary database and a standby database.
This section describes how ONS and FAN work with Oracle Restart. It contains the
following topics:
Overview of Fast Application Notification
Application High Availability with Services and FAN
Managing Unplanned Outages
Managing Planned Outages
Fast Application Notification High Availability Events
Using Fast Application Notification Callouts
Oracle Clients That Are Integrated with Fast Application Notification

Overview of Fast Application Notification
FAN is a notification mechanism that Oracle Restart can use to notify other processes
about configuration changes that include service status changes, such as UP or DOWN
events. FAN provides the ability to immediately terminate inflight transaction when
an instance or server fails. Integrated Oracle clients receive the events and respond.
Applications can respond either by propagating the error to the user or by
resubmitting the transactions and masking the error from the application user. When a
DOWN event occurs, integrated clients immediately clean up connections to the
terminated database. When an UP event occurs, the clients create new connections to
the new primary database instance.
Oracle Restart publishes FAN events whenever a managed instance or service goes up
or down. After a failover, the Oracle Data Guard Broker (broker) publishes FAN
events. These FAN events can be used in the following ways:

Applications can use FAN with Oracle Restart without programmatic changes if
they use one of these Oracle integrated database clients: Oracle Database JDBC,
Universal Connection Pool for Java, Oracle Call Interface, and Oracle Database
ODP.NET. These clients can be configured for Fast Connection Failover (FCF) to
automatically connect to a new primary database after a failover.

FAN server-side callouts can be configured on the database tier.
For DOWN events, such as a failed primary database, FAN provides immediate
notification to the clients so that they can failover as fast as possible to the new
primary database. The clients do not wait for a timeout. The clients are notified
immediately, and they must be configured to failover when they are notified.

For UP events, when services and instances are started, new connections can be created
so that the application can immediately take advantage of the extra resources.

Through server-side callouts, you can also use FAN to:
Log status information
Page DBAs or open support tickets when resources fail to start
Automatically start dependent external applications that must be co-located with a service

FAN events are published using ONS and Oracle Streams Advanced Queuing queues.
The queues are configured automatically when you configure a service. You must
configure ONS manually using SRVCTL commands.

The Connection Manager (CMAN) and Oracle Net Services listeners are integrated
with FAN events, enabling the CMAN and the listener to immediately de-register
services provided by the failed instance and to avoid erroneously sending connection
requests to a failed database.

Application High Availability with Services and FAN
Oracle Database focuses on maintaining service availability. With Oracle Restart,
Oracle services are designed to be continuously available. Oracle Restart monitors the
database and its services and, when configured, sends event notifications using FAN.

Managing Unplanned Outages If Oracle Restart detects an outage, then it isolates the
failed component and recovers the dependent components. If the failed component is
the database instance, then after Oracle Data Guard fails over to the standby database,
Oracle Restart on the new primary database starts any services defined with the
current role.

FAN events are published by Oracle Restart and the Oracle Data Guard Broker
through ONS and Advanced Queuing. You can also perform notifications using FAN
callouts.

With Oracle Restart, restart and recovery are automatic, including the restarting of the
subsystems, such as the listener and the Oracle Automatic Storage Management
(Oracle ASM) processes, not just the database. You can use FAN callouts to report
faults to your fault management system and to initiate repair jobs.

Managing Planned Outages For repairs, upgrades, and changes that require you to shut
down the primary database, Oracle Restart provides interfaces that disable and enable
services to minimize service disruption to application users. Using Oracle Data Guard
Broker with Oracle Restart allows a coordinated failover of the database service from
the primary to the standby for the duration of the planned outage. Once you complete
the operation, you can return the service to normal operation.

The management policy for a service controls whether the service starts automatically
when the database is restarted. If the management policy for a service is set to
AUTOMATIC, then it restarts automatically. If the management policy for a service is set
to MANUAL, then it must be started manually.

Fast Application Notification High Availability Events Table 4–4 describes the FAN event
record parameters and the event types, followed by name-value pairs for the event
properties. The event type is always the first entry and the timestamp is always the
last entry. In the following example, the name in the name-value pair is shown in Fan
event type (service_member), and the value in the name-value pair is shown in
Properties:

FAN event type: service_member
Properties: version=1.0 service=ERP database=FINPROD instance=FINPROD host=node1
status=up

Table 4-4
VERSION    Version of the event record. Used to identify release changes.
EVENT TYPE   SERVICE, SERVICE_MEMBER, DATABASE, INSTANCE, NODE, ASM, SRV_PRECONNECT.
Note that database and Instance types provide the database service, such as DB_UNIQUE_NAME.DB_DOMAIN.
DATABASE UNIQUE NAME  The unique database supporting the service; matches the
initialization parameter value for DB_UNIQUE_NAME, which
defaults to the value of the initialization parameter DB_NAME.
INSTANCE   The name of the instance that supports the service; matches the ORACLE_SID value.
NODE NAME   The name of the node that supports the service or the node that has stopped; matches the node name known to Cluster
Synchronization Services (CSS).
SERVICE   The service name; matches the service in DBA_SERVICES.
STATUS    Values are UP, DOWN, NOT_RESTARTING, PRECONN_UP, PRECONN_DOWN, and UNKNOWN.
REASON    Data_Guard_Failover, Failure, Dependency, User, Autostart, Restart.
CARDINALITY   The number of service members that are currently active; included in all UP events.
TIMESTAMP   The local time zone to use when ordering notification events.

A FAN record matches the database signature of each session as shown in Table 4-5
Table 4-5
SERVICE   sys_context(‘userenv’, ‘service_name’)
DATABASE UNIQUE NAME  sys_context(‘userenv’, ‘db_unique_name’)
INSTANCE   sys_context(‘userenv’, ‘instance_name’)
NODE NAME   sys_context(‘userenv’, ‘server_host’)

Using Fast Application Notification Callouts FAN callouts are server-side executables that
Oracle Restart executes immediately when high availability events occur. You can use
FAN callouts to automate the following activities when events occur, such as:
Opening fault tracking tickets
Sending messages to pagers
Sending e-mail
Starting and stopping server-side applications
Maintaining an uptime log by logging each event as it occurs

To use FAN callouts, place an executable in the directory grid_home/racg/usrco on
both the primary and the standby database servers. If you are using scripts, then set
the shell as the first line of the executable. The following is an example file for the
grid_home/racg/usrco/callout.sh callout:

#! /bin/ksh
FAN_LOGFILE= [your path name]/admin/log/`hostname`_uptime.log
echo $* “reported=”`date` >> $FAN_LOGFILE &

The following output is from the previous example:
NODE VERSION=1.0 host=sun880-2 status=nodedown reason=
timestamp=08-Oct-2004 04:02:14 reported=Fri Oct 8 04:02:14 PDT 2004

A FAN record matches the database signature of each session, as shown in Table 4-5
Use this information to take actions on sessions that match the FAN event data.

Oracle Clients That Are Integrated with Fast Application Notification Oracle has integrated
FAN with many of the common Oracle client drivers that are used to connect to Oracle
Restart databases. Therefore, the easiest way to use FAN is to use an integrated Oracle
Client.

You can use the CMAN session pools, Oracle Call Interface, Universal Connection
Pool for Java, JDBC simplefan API, and ODP.NET connection pools. The overall goal is
to enable applications to consistently obtain connections to the available primary
database at anytime.

 Comment 

Oracle automatic stop, start, restart

on October 30, 2009 at 4:00 pm
Posted In: Oracle 11.2 Notes (Cat)

Automatic start/stop
$ORACLE_HOME/bin/dbstart or dbstop

oratab :
SID:oracle_home:{y|n|w}

y|n  : for automatic start/stop of the database, or not
n|w : w specifies that the db starts up only after ASM is up.

cd /etc/init.d (/sbin/init.d for HP-UX)
create a file dbora with the following:
#===============
#! /bin/sh -x
#
# Change the value of ORACLE_HOME to specify the correct Oracle home
# directory for your installation.
ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1
#
# Change the value of ORACLE to the login name of the
# oracle owner at your site.
#
ORACLE=oracle
PATH=${PATH}:$ORACLE_HOME/bin
HOST=`hostname`
PLATFORM=`uname`
export ORACLE_HOME PATH
#
if [ ! “$2” = “ORA_DB” ] ; then
if [ “$PLATFORM” = “HP-UX” ] ; then
remsh $HOST -l $ORACLE -n “$0 $1 ORA_DB”
exit
else
rsh $HOST -l $ORACLE $0 $1 ORA_DB
if [ “$PLATFORM” = “Linux” ] ; then
touch /var/lock/subsys/dbora
fi
exit
fi
fi
#
case $1 in
‘start’)
$ORACLE_HOME/bin/dbstart $ORACLE_HOME &
;;
‘stop’)
$ORACLE_HOME/bin/dbshut $ORACLE_HOME &
;;
*)
echo “usage: $0 {start|stop}”
exit
;;
esac
#
exit
#==============

Then
# chgrp dba dbora
# chmod 750 dbora

Create symbolic links to the dbora script in the appropriate run-level script directories as follows.
HP-UX # ln -s /sbin/init.d/dbora /sbin/rc3.d/S990dbora
# ln -s /sbin/init.d/dbora /sbin/rc0.d/K001dbora
Linux # ln -s /etc/init.d/dbora /etc/rc.d/rc0.d/K01dbora
# ln -s /etc/init.d/dbora /etc/rc.d/rc3.d/S99dbora
# ln -s /etc/init.d/dbora /etc/rc.d/rc5.d/S99dbora

ORACLE RESTART
===========
crsctl start/stop has
has = High Availability Service

Oracle Restart improves the availability of your Oracle database. When you install Oracle Restart, various Oracle components can be automatically restarted after a hardware or software failure or whenever your database host computer restarts.

Database instance : 
Oracle Restart can accommodate multiple databases on a single host computer.

Oracle Net listener:
Database services :
Does not include the default service created upon installation because it is automatically managed by Oracle Database, and does not include any default services created during database creation.

Oracle Automatic Storage Management (Oracle ASM) instance:
Oracle ASM disk groups:
Restarting a disk group means mounting it.

Oracle Notification Services (ONS/eONS):
In a standalone server environment, ONS/eONS can be used in Oracle Data Guard installations for automating failover of connections between primary and standby database through Fast Application Notification (FAN). ONS/eONS is a service for sending FAN events to integrated clients upon failover.

Oracle Restart runs periodic check operations to monitor the health of these components. If a check operation fails for a component, the component is shut down and restarted.
Oracle Restart is used in standalone server (non-clustered) environments only.
For Oracle Real Application Clusters (Oracle RAC) environments, the functionality to automatically restart components is provided by Oracle Clusterware.
Oracle Restart runs out of the Oracle Grid Infrastructure home, which you install separately from Oracle Database homes. See the Oracle Database Installation Guide for your platform for information about installing the Oracle Grid Infrastructure home.

Created Component       Create Operation
Automatically
Added to Oracle
Restart Configuration?
YES                     Create a database with OUI or DBCA
NO                      Create a database with the CREATE DATABASE SQL statement
YES                     Create an Oracle ASM instance with OUI, DBCA, or ASMCA
YES                     Create a disk group (any method)
YES                     Add a listener with NETCA
YES                     Create a database service with SRVCTL
NO                      Create a database service by modifying the SERVICE_NAMES initialization parameter1 No
NO                      Create a database service with DBMS_SERVICE.CREATE_SERVICE
NO                      Create a standby database

Deleted Component       Delete Operation
Automatically
Added to Oracle
Restart Configuration?
YES                     Delete a database with DBCA Yes
YES                     Delete a listener with NETCA Yes
YES                     Drop an Oracle ASM disk group (any method) Yes
YES                     Delete a database service with SRVCTL Yes
NO                      Delete a database service by any other means No
NO                      Delete a database by removing database files with operating system commands

 Comment 

ACFS – ASM Clustered File System

on October 30, 2009 at 2:49 pm
Posted In: Oracle ASM (Cat)

To create a volume:

ASMCMD [+] > volcreate -G data -s 10G volume1

Determine the device name of the volume that was created.

 

 

 

 

 

 

ASMCMD [+] > volinfo -G data volume1

 

 

Diskgroup Name: DATA

Volume Name: VOLUME1

Volume Device: /dev/asm/volume1-123

State: ENABLED

…

SQL> SELECT volume_name, volume_device FROM V$ASM_VOLUME

WHERE volume_name =’VOLUME1′;

VOLUME_NAME VOLUME_DEVICE

—————– ————————————–

VOLUME1 /dev/asm/volume1-123

Create a file system with the Oracle ACFS

 

 

 

mkfs command.


 

 

 

$ /sbin/mkfs -t acfs /dev/asm/volume1-123

mkfs.acfs: version = 11.2.0.1.0.0

mkfs.acfs: on-disk version = 39.0

mkfs.acfs: volume = /dev/asm/volume1-123

mkfs.acfs: volume size = 10737418240

mkfs.acfs: Format complete.

 

 

 

 

Register the file system with the

 

 

 

acfsutil registry command.

For example:

 

 

$ /sbin/acfsutil registry -a /dev/asm/volume1-123 /u01/app/acfsmounts/myacfs

acfsutil registry: mount point /u01/app/acfsmounts/myacfs successfully added

to Oracle Registry

 

 

 

 

 

Mount the file system with the Oracle ACFS

 

 

 

mount command.

# /bin/mount -t acfs /dev/asm/volume1-123 /u01/app/acfsmounts/myacfs

 

 

 

 

# chown -R oracle:dba /u01/app/acfsmounts/myacfs

 

 

 

 

Create a test file in the file system.

 

$ echo “Oracle ACFS File System” > /u01/app/acfsmounts/myacfs/myfile

 

 

 

 

List the contents of the test file that was created in the file system.

 

 

$ cat /u01/app/acfsmounts/myacfs/myfile

 

 

 

 

Accessing an Oracle ACFS File System on a Different Node in the Cluster

 

 

 

ASMCMD [+] > volinfo -G data volume1

 

 

 

# /bin/mount -t acfs /dev/asm/volume1-123 /u01/app/acfsmounts/myacfs

 

After the file system has been mounted, ensure that the permissions are set to

allow access for the appropriate users.

 

 

 

$ cat /u01/app/acfsmounts/myacfs/myfile

 

 

 

Managing Oracle ACFS Snapshots


 

 

 

 

 

 


 

 

 

 

 

 

 

To create and verify a snapshot on node 1:

1.

 

 

Create snapshot of the new file system created on node 1.

For example:

 

$ /sbin/acfsutil snap create mysnapshot_20090725 /u01/app/acfsmounts/myacfs

See

 

 

“acfsutil snap create”

on page 13-30.

2.

 

 

Update the test file in the file system so that it is different than the snapshot.

For example:

 

$ echo “Modifying a file in Oracle ACFS File System” >

/u01/app/acfsmounts/myacfs/myfile

3.

 

 

List the contents of the test file and the snapshot view of the test file.

For example:

 

$ cat /u01/app/acfsmounts/myacfs/myfile

$ cat /u01/app/acfsmounts/myacfs/.ACFS/snaps/mysnapshot_20090725/myfile

The contents of the test file and snapshot should be different. If node 1 is in a

cluster, then you can perform the same list operation on node 2.

 

 

 

Deregistering, Dismounting, and Disabling Volumes and Oracle ACFS File Systems

You can deregister an Oracle ACFS file system if you do not want the file system to be

automatically mounted.

$ /sbin/acfsutil registry -d /u01/app/acfsmounts/myacfs

 

 

 

You can dismount a file system without deregistering the file system or disabling the

volume on which the file system is mounted.

 

# /bin/umount /u01/app/acfsmounts/myacfs

# /sbin/fsck -a -v -y -t acfs /dev/asm/volume1-123

 

 

 

To disable a volume, you must first dismount the file system on which the volume is

mounted.

 

# /bin/umount /u01/app/acfsmounts/myacfs

After a file system is dismounted, you can disable the volume and remove the volume

device file.

ASMCMD> voldisable -G data volume1

 

 

 

Removing an Oracle ACFS File System and a Volume

$ /sbin/acfsutil registry -d /oracle/acfsmounts/acfs1

acfsutil registry: successfully removed ACFS mount point

/oracle/acfsmounts/acfs1 from Oracle Registry

 

 

 

# /bin/umount /oracle/acfsmounts/acfs1

 

 

 

$ /sbin/acfsutil rmfs /dev/asm/volume1-123

 

 

 

ASMCMD> voldisable -G data volume1

 

 

 

 

ASMCMD> voldelete -G data volume1

 

 

 

 

 

 

 

 

 

acfsdbg

 

 

 

Debugs an Oracle ACFS file system.

 

 

 

 

 

 

 

 

 

 

acfsutil info

 

 

Displays various Oracle ACFS file system information.

acfsutil registry

 

 

Registers an Oracle ACFS file system with the Oracle ACFS mount

registry.

 

acfsutil rmfs

 

 

Removes an Oracle ACFS file system.

acfsutil size

 

 

Resizes an Oracle ACFS file system.

acfsutil snap create

 

 

Creates a read-only snapshot of an Oracle ACFS file system.

acfsutil snap delete

 

 

Deletes a read-only snapshot of an Oracle ACFS file system.

acfsutil tune

 

 

Modifies or displays Oracle ACFS tuneables.

advmutil tune

 

 

Modifies or displays Oracle ADVM parameters.

advmutil volinfo

 

 

Displays information about Oracle ADVM volumes.


 

 

 

 

 

 

 

 

 

 

 

 

 

 

 Comment 

Modifying clusterware binaries

on October 30, 2009 at 12:24 pm
Posted In: Oracle 11.2 Notes (Cat)

After installation, if you need to modify the Oracle Clusterware configuration, then you must unlock the Grid home.

For example, if you want to apply a one-off patch, or if you want to modify an Oracle Exadata configuration to run IPC traffic over RDS on the interconnect instead of using the default UDP, then you must unlock the Grid home.
Unlock the home using the following procedure:

1.
Change directory to the path Grid_home/crs/install, where Grid_home is the path to the Grid home, and unlock the Grid home using the command rootcrs.pl -unlock -crshome Grid_home, where Grid_home is the path to your Grid infrastructure home.
For example, with the grid home /u01/app/11.2.0/grid,
enter the following command:
# cd /u01/app/11.2.0/grid/crs/install
# perl rootcrs.pl -unlock -crshome /u01/app/11.2.0/grid

2.
Change user to the grid infrastructure software owner, and relink binaries using the command syntax make -f Grid_home/lib/ins_rdbms.mk target, where Grid_ome is the Grid home, and target is the binaries that you want to relink.
For example, where the grid user is grid, $ORACLE_HOME is set to the Grid home, and where you are updating the interconnect protocol from UDP to IPC, enter the following command:
# su grid
$ make -f $ORACLE_HOME/lib/ins_rdbms.mk ipc_rds ioracle

Caution: Before relinking executables, you must shut down all executables that run in the Oracle home directory that you are relinking. In addition, shut down applications linked with Oracle shared libraries.
Note: To relink binaries, you can also change to the grid installation owner and run the command Grid_home/bin/relink.

3.
Relock the Grid home and restart the cluster using the following command:
# perl rootcrs.pl -patch

4. Repeat steps 1 through 3 on each cluster member node.

 Comment 

Pinning Cluster Nodes

on October 30, 2009 at 12:20 pm
Posted In: Oracle 11.2 Notes (Cat)

When Oracle Database version 10.x or 11x is installed on a new Oracle grid infrastructure for a cluster configuration, it is configured for dynamic cluster configuration, in which some or all IP addresses are provisionally assigned, and other cluster identification information is dynamic.

This configuration is incompatible with older database releases, which require fixed addresses and configuration.

You can change the nodes where you want to run the older database to create a persistent configuration. Creating a persistent configuration for a node is called pinning a node.

To pin a node in preparation for installing an older Oracle Database version, use Grid_home/bin/crsctl with the following command syntax, where nodes is a space-delimited list of one or more nodes in the cluster whose configuration you want
to pin:
crsctl pin css -n nodes

For example, to pin nodes node3 and node4, log in as root and enter the following command:
$ crsctl pin css -n node3 node4

To determine if a node is in a pinned or unpinned state, use Grid_home/bin/olsnodes with the following command syntax:
To list all pinned nodes:
olsnodes -t -n
For example:
# /u01/app/11.2.0/grid/bin/olsnodes -t -n
node1 1 Pinned
node2 2 Pinned
node3 3 Pinned
node4 4 Pinned

To list the state of a particular node:
olsnodes -t -n node3
For example:
# /u01/app/11.2.0/grid/bin/olsnodes -t -n node3
node3 3 Pinned

 Comment 

Fast Recovery Area – FRA

on October 30, 2009 at 12:13 pm
Posted In: Oracle Flashback Notes (Cat)

Create Fast Recovery Area disk group (FRA).

The Fast Recovery Area is a unified storage location for all Oracle Database files related to recovery. Database administrators can define the DB_RECOVERY_FILE_DEST parameter to the path for the Fast Recovery Area to enable on-disk backups, and rapid recovery of data. Enabling rapid backups for recent data can reduce requests to system administrators to retrieve ackup tapes for recovery operations.

When you enable Flash Recovery in the init.ora file, all RMAN backups, archive logs, control file automatic backups, and database copies are written to the Fast Recovery Area. RMAN automatically manages files in the Fast Recovery Area by deleting obsolete backups and archive files no longer required for recovery.

Oracle recommends that you create a Fast Recovery Area disk group. Oracle
Clusterware files and Oracle Database files can be placed on the same disk group, and
you can also place flash recovery files in the same disk group. However, Oracle
recommends that you create a separate Flash Recovery disk group to reduce storage
device contention.

The Fast Recovery Area is enabled by setting DB_RECOVERY_FILE_DEST. The size of the Fast Recovery Area is set with DB_RECOVERY_FILE_DEST_SIZE. As a general rule, the larger the Fast Recovery Area, the more useful it becomes. For ease of use, Oracle recommends that you create a Fast Recovery Area disk group on storage devices that can contain at least three days of recovery information. Ideally, the Fast Recovery Area should be large enough to hold a copy of all of your data files and control files, the online redo logs, and the archived redo log files needed to recover your database using the data file backups kept under your retention policy.

Multiple databases can use the same Fast Recovery Area.
For example, assume you have created one Fast Recovery Area disk group on disks with 150 GB of storage, shared by three different databases. You can set the size of the Fast Recovery Area for each database depending on the importance of each database. For example, if database1 is your least important database, database 2 is of greater importance and database 3 is of greatest importance, then you can set different DB_RECOVERY_FILE_DEST_SIZE settings for each database to meet your retention target for each database: 30 GB for database 1, 50 GB for database 2, and 70 GB for database 3.

 Comment 

Post installation

on October 30, 2009 at 12:11 pm
Posted In: Oracle 11.2 Notes (Cat)

Back up root.sh

Install IPD/OS – Instantaneous Problem Detection OS Tool
Linux kernel > 2.6.9.
Download from http://www.oracle.com/technology/products/database/clustering/ipd_download_homepage.html

Tune semaphore parameters.
semmns = 2*sum(process parameters of all db instances) +
overhead for background processes +
system and other application requirements. (Refer OS).
semmsl = 256
semmni = semmns / semmsl (round up to nearest multiple of 1024)

Create Fast Recovery Area disk group (FRA).
The Fast Recovery Area is a unified storage location for all Oracle Database files related to recovery. Database administrators can define the DB_RECOVERY_FILE_DEST parameter to the path for the Fast Recovery Area to enable on-disk backups, and rapid recovery of data. Enabling rapid backups for recent data can reduce requests to system administrators to retrieve ackup tapes for recovery operations.

When you enable Flash Recovery in the init.ora file, all RMAN backups, archive logs, control file automatic backups, and database copies are written to the Fast Recovery Area. RMAN automatically manages files in the Fast Recovery Area by deleting obsolete backups and archive files no longer required for recovery.

Oracle recommends that you create a Fast Recovery Area disk group. Oracle
Clusterware files and Oracle Database files can be placed on the same disk group, and
you can also place flash recovery files in the same disk group. However, Oracle
recommends that you create a separate Flash Recovery disk group to reduce storage
device contention.

The Fast Recovery Area is enabled by setting DB_RECOVERY_FILE_DEST. The size of the Fast Recovery Area is set with DB_RECOVERY_FILE_DEST_SIZE. As a general rule, the larger the Fast Recovery Area, the more useful it becomes. For ease of use, Oracle recommends that you create a Fast Recovery Area disk group on storage devices that can contain at least three days of recovery information. Ideally, the Fast Recovery Area should be large enough to hold a copy of all of your data files and control files, the online redo logs, and the archived redo log files needed to recover your database using the data file backups kept under your retention policy.

Multiple databases can use the same Fast Recovery Area.
For example, assume you have created one Fast Recovery Area disk group on disks with 150 GB of storage, shared by three different databases. You can set the size of the Fast Recovery Area for each database depending on the importance of each database. For example, if database1 is your least important database, database 2 is of greater importance and database 3 is of greatest importance, then you can set different DB_RECOVERY_FILE_DEST_SIZE settings for each database to meet your retention target for each database: 30 GB for database 1, 50 GB for database 2, and 70 GB for database 3.

 Comment 

New features

on October 30, 2009 at 12:00 pm
Posted In: Oracle 11.2 Notes (Cat)

ASMCA – ASM Configuration Assistant

ASM and Clusterware now in the same home.

OCR and VOTE files can be placed in ASM

ASM File system – ACFS – asm cluster file system

SYSASM (OSASM group) now totally seperate from SYSDBA priv.

Cluster Time Synchronisation Service

OEM now able to add nodes to a cluster.

GRID Plug and Play to add / remove nodes easilly.

OUI (runcluvfy) can now generate fixup scripts

Oracle Clusterware Out-of-place Upgrade. Install / upgrade clusterware in a seperate home to reduce downtime.

OEM – better manageability.

SRVCTL – new commands to shut down all oracle software running from an oracle home.

DEINSTALL kit

 Comment 

SCAN – Single Client Access Name

on October 30, 2009 at 11:50 am
Posted In: Oracle 11.2 Notes (Cat)

11.2 requires a Single Client Access Name (SCAN) name for the cluster (max 15 chars).

The single client access name (SCAN) is the hostname to provide for all clients connecting to the cluster.
The SCAN is a domain name registered to at least one and up to three IP addresses, either in the domain name service (DNS) or the Grid Naming Service (GNS).
The SCAN eliminates the need to change clients when nodes are added to or removed from the cluster. Clients using the SCAN can also access the cluster using EZCONNECT.

The default name for the SCAN defaults to the local node name on installation.
In a typical installation the SCAN is also the name of the cluster.

If you need to use more than 15 chars choose the advanced installation option.

The SCASN can be defined in the hosts file if required.

 Comment 

alert log – V$DIAG_INFO

on October 30, 2009 at 11:21 am
Posted In: Oracle 11.2 Notes (Cat)

select name, value from v$diag_info;

 Comment 

Linux in a Virtual Environment

on October 29, 2009 at 3:43 pm
Posted In: Resource Management (Cat)

Managing Linux in a Virtual Environment

Linux has been running in data centers all over the world for a quite a while now. Traditionally, the concept of a server means a physical machine distinct from other physical machines. This was true until the arrival of virtualization, where a single server could be carved up to become several virtual servers, with each one appearing as if they are independent servers on the network. Conversely, a ”pool” of servers made up of several physical servers can be carved up as deemed necessary.

Since there is a no longer a one-on-one relationship between a physical server and a logical or virtual server, some concepts might appear tricky. For instance, what is available memory? Is it available memory of (1) the virtual server, (2) the individual physical server from where the virtual server was carved out of, or (3) the total of the pool of servers the virtual server is a part of? So Linux commands may behave a little differently when operated under a virtual environment.

In addition, the virtual environment also needs some administration so there are specialized commands for the management of the virtualized infrastructure. In this section you will learn about the specialized commands and activities related to the virtual environment. We will use Oracle VM as an example.

One of the key components of the virtualization in an Oracle VM environment is the Oracle VM Agent, which must be up for Oracle VM to be fully operational. To check if the agent is up, you have to get on to the Administration server (provm1, in this case) and use the service command:

[root@provm1 vnc-4.1.2]# service ovs-agent status ok! process OVSMonitorServer exists. ok! process OVSLogServer exists. ok! process OVSAgentServer exists. ok! process OVSPolicyServer exists. ok! OVSAgentServer is alive.

The output shows clearly that all the key processes are up. If they are not up, they may have been misconfigured and you may want to configure it (or configure it the first time):

# service ovs-agent configure

The same service command is also used to start, restart and stop the agent processes:

service ovs-agent start service ovs-agent restart service ovs-agent stop	

The best way, however, to manage the environment is via the GUI console, which is Web based. The Manager Webpage is available on the Admin server, at the port 8888, by default. You can bring it up by entering the following on any Web browser (assuming the admin server name is oradba2).

http://oradba2:8888/OVS

Login as admin and the password you created during installation. It brings up a screen shown below:

 

The bottom of the screen shows the physical servers of the server pool. Here the server pool is called provmpool1 and the physical server IP is 10.14.106.0. On this screen, you can reboot the server, power it off, take it off the pool and edit the details on the server. You can also add a new physical server to this pool by clicking on the Add Server button.

Clicking on the IP address of the server brings up the details of that physical server, as shown below:

Perhaps the most useful is the Monitor tab. If you click on it, it shows up the utilization of resources on the server – CPU, disk and memory, as shown below. From this page you can visually check if the resources are under or over utilized, if you need to add more physical servers and so on.

Going back to the main page, the Server Pools tab shows the various server pools defined. Here you can define another pool, stop, reinstate the pool and so on:

If you want to add a user or another administrator, you need to click on the Administration tab. There is a default administrator called ”admin”. You can check all the admins here, set their properties like email addresses, names, etc.:

Perhaps the most frequent activity you will perform is the management of individual virtual machines. Almost all the functions are located on the Virtual Machines tab on the main home page. It shows the VMs you have created so far. Here is a partial screenshot showing two machines called provmlin1 and provmlin2:

The VM named provmlin2 shows as ”powered off”, i.e. it appears as down to the end users. The other one – provmlin1 – has some kind of error. First, let’s start the provmlin2 VM. Select the radio button next to it and click on the button Power On. After some time it will show as ”Running”, shown below:

If you click on the VM name, you will be able to see the details of the VM, as shown below:

From the above screen we know that the VM have been allocated 512MB of RAM; it runs Oracle Enterprise Linux 5; it has only one core and so on. One of the key information available on the page is the VNC port: 5900. Using this, you can bring up the VNC terminal of this virtual machine. Here, I have used a VNV viewer, using the hostname provm1 and port 5900:

This brings up the VNC session on the server. Now you can start a terminal session:

Since the VNC port 5900 pointed to the virtual machine called provmlin4, the terminal on that VM came up. Now you can issue your regular Linux commands on this terminal.

xm

On the server running the virtual machines, the performance measurement commands like uptime (described in Installment 3) and top (described in Installment 2) have different meanings compared to their physical server counterparts. In a physical server the uptime refers to the amount if time the server has been up, while in a virtual world it could be ambiguous – referring to the individual virtual servers on that server. To measure performance of the physical serverpool, you use a different command, xm. The commands are issued from this main command. For instance, to list the virtual servers, you can use the command xm list:

[root@provm1 ~]# xm list Name                                        ID   Mem VCPUs      State   Time(s) 22_provmlin4                                1   512     1         -b----   27.8 Domain-0                                    0   532     2         r-----   4631.9

To measure uptime, you would use xm uptime:

[root@provm1 ~]# xm uptime Name                                ID Uptime  22_provmlin4                        1  0:02:05 Domain-0                            0  8:34:07

The other commands available in xm are shown below. Many of these commands can be executed via the GUI as well.

console             Attach to 's console.                       create             Create a domain based on .              new                Adds a domain to Xend domain management             delete             Remove a domain from Xend domain management.        destroy            Terminate a domain immediately.                     dump-core          Dump core for a specific domain.                    help               Display this message.                               list               List information about all/some domains.            mem-set            Set the current memory usage for a domain.          migrate            Migrate a domain to another machine.                pause              Pause execution of a domain.                        reboot             Reboot a domain.                                    restore            Restore a domain from a saved state.                resume             Resume a Xend managed domain.                        save               Save a domain state to restore later.               shell              Launch an interactive shell.                        shutdown           Shutdown a domain.                                 start              Start a Xend managed domain.                        suspend            Suspend a Xend managed domain.                      top                Monitor a host and the domains in real time.        unpause            Unpause a paused domain.                            uptime             Print uptime for a domain.                          vcpu-set           Set the number of active VCPUs for allowed for the domain.

Let’s see some frequently used ones. Besides uptime, you may be interested in the system performance via the top command. This command xm top acts pretty much like the top command in the regular server shell – it refreshes automatically, has some keys that bring up different types of measurements such as CPU, I/O, Network, etc. Here is the output of the basic xm top command:

xentop - 02:16:58   Xen 3.1.4 2 domains: 1 running, 1 blocked, 0 paused, 0 crashed, 0 dying, 0 shutdown Mem: 1562776k total, 1107616k used, 455160k free    CPUs: 2 @ 2992MHz NAME  STATE   CPU(sec) CPU(%)     MEM(k) MEM(%)  MAXMEM(k) MAXMEM(%) VCPUS NETS NETTX(k) NETRX(k) VBDS   VBD_OO   VBD_RD   VBD_WR SSID 22_provmlin4 --b---       27      0.1    524288  33.5    1048576     67.1     1    1        9      154    1        06598     1207    0  Domain-0 -----r        4647      23.4   544768  34.9   no limit      n/a     2    8    68656  2902548    0        0         0       0

It shows the stats like the percentages of CPU used, memory used and so on for each Virtual Machine. If you press N, you will see network activities as shown below:

 xentop - 02:17:18   Xen 3.1.4 2 domains: 1 running, 1 blocked, 0 paused, 0 crashed, 0 dying, 0 shutdown Mem: 1562776k total, 1107616k used, 455160k free    CPUs: 2 @ 2992MHz Net0 RX:   180692bytes     2380pkts        0err      587drop  TX:     9414bytes       63pkts        0err        0drop   Domain-0 -----r       4650   22.5     544768   34.9   no limit       n/a     2    8    68665  2902570    0        0  0        0    0 Net0 RX: 2972232400bytes  2449735pkts        0err        0drop  TX: 70313906bytes  1017641pkts        0err        0drop Net1 RX:        0bytes        0pkts        0err        0drop  TX:        0bytes        0pkts        0err        0drop Net2 RX:        0bytes        0pkts        0err        0drop  TX:        0bytes        0pkts        0err        0drop Net3 RX:        0bytes        0pkts        0err        0drop  TX:        0bytes        0pkts        0err        0drop Net4 RX:        0bytes        0pkts        0err        0drop  TX:        0bytes        0pkts        0err        0drop Net5 RX:        0bytes        0pkts        0err        0drop  TX:        0bytes        0pkts        0err        0drop Net6 RX:        0bytes        0pkts        0err        0drop  TX:        0bytes        0pkts        0err        0drop Net7 RX:        0bytes        0pkts        0err        0drop  TX:        0bytes        0pkts        0err        0drop

Pressing V brings up VCPU (Virtual CPU) stats.

xentop - 02:19:02   Xen 3.1.4 2 domains: 1 running, 1 blocked, 0 paused, 0 crashed, 0 dying, 0 shutdown Mem: 1562776k total, 1107616k used, 455160k free    CPUs: 2 @ 2992MHz NAME  STATE   CPU(sec) CPU(%)     MEM(k) MEM(%)  MAXMEM(k) MAXMEM(%) VCPUS NETS NETTX(k) NETRX(k) VBDS   VBD_OO   VBD_RD   VBD_WR SSID 22_provmlin4 --b---      28      0.1     524288   33.5    1048576    67.1     1    1        9     282    1       06598     1220    0 VCPUs(sec):   0:         28s Domain-0 -----r          4667    1.6     544768   34.9   no limit     n/a     2    8    68791  2902688   0       00        0       0 VCPUs(sec):   0:       2753s  1:       1913s

Let’s go through some fairly common activities – one of which is distributing the available memory among the VMs. Suppose you want to give each VM 256 MB of RAM, you should use xm mem-set command as shown below. Later you should use xm list command to confirm that.

[root@provm1 ~]# xm mem-set 1 256 [root@provm1 ~]# xm mem-set 0 256 [root@provm1 ~]# xm list Name ID Mem VCPUs State Time(s) 22_provmlin4 1 256 1 -b---- 33.0 Domain-0 0 256 2 r----- 4984.4







(Extracted from oracle technet notes author Arup Nanda)





 Comment 

Shell keywords, PS1, IFS, PATH, CDPATH, set, type, history, fc, cpio, tar, zip, gzip

on October 29, 2009 at 3:26 pm
Posted In: Unix notes (Cat)

Shell Keyword Variables

When in the command line, you are using a ”shell” – most likely the bash shell. In a shell you can define a variable and set a value to it to be retrieved later. Here is an example of a variable named ORACLE_HOME:

# export ORACLE_HOME=/opt/oracle/product/11gR2/db1

Later, you can refer to the variable by prefixing a ”$” sign to the variable name, e.g.:

# cd $ORACLE_HOME

This is called a user defined variable. Likewise, there are several variables defined in the shell itself. These variables — whose names have been pre-defined in the shell — control how you interact with the shell. You should learn about these variables (at least a handful of important ones) to improve the quality and efficiency of your work.

PS1
This variable sets the Linux command prompt. Here is an example when the command where we are trying to change the prompt from the default ”# ” to ”$ ”:

# export PS1="$ " $ 

Note how the prompt changed to $? You can place any character here to change the default prompt. The double quotes are not necessary but since we want to put a space after the ”$” sign, we have to place quotes around it.

Is that it – to show the prompt in a fancy predefined character or character strings? Not at all. You can also place special symbols in the variable to show special values. For instance the symbol \u shows the username who logged in and \h shows the hostname. If we use these two symbols, the prompt can be customized to show who logged in and where:

$export PS1="\u@\h# " oracle@oradba1#     

This shows the prompt as oracle logged in on the server called oradba1 – enough to remind yourself who and where you are. You can further customize the prompt using another symbol, \W, which shows the basename of the current directory. Here is how the prompt looks now:

# export PS1="\u@\h \W# "  oracle@oradba1 ~#      

The current directory is HOME; so it shows ”~”. As you change to a different directory it changes.

Adding the current directory is a great way to remind yourself where you are and the implications of your actions. Executing rm * has a different impact on /tmp than if you were on /home/oracle, doesn’t it?

There is another symbol – \w. There is a very important difference between \w and \W. The latter produces the basename of the current directory while the former shows the full directory:

oracle@oradba1 11:59 AM db1# export PS1="\u@\h \@ \w# " oracle@oradba1 12:01 PM /opt/oracle/product/11gR2/db1#      

Note the difference? In the previous prompt, where \W was used, it showed only the directory db1, which is the basename. In the next prompt where \w was used, the full directory /opt/oracle/product/11gR2/db1 was displayed.

In many cases a full directory name in the prompt may be immensely helpful. Suppose you have three Oracle Homes. Each one will have a subdirectory called db1. How will you know where exactly you are if only ”db1” is displayed? A full directory will leave no doubts. However, a full directory also makes the prompt very long, making it a little inconvenient.

The symbol ”\@” shows the current time in hour:minute AM/PM format:

# export PS1="\u@\h \@ \W# " oracle@oradba1 11:59 AM db1#  

Here are some other symbols you can use in PS1 shell variable:

\!

The command number in the history (more on this later)

\d

The date in Weekday Month Date format

\H

The host name with the domain name. \h is the hostname without the domain

\T

The same as \@ but displaying seconds as well.

\A

The time in hour:minutes as in \@ format but 24 hours

\t

The same as \A but with the seconds as well;

 

IFS

 

This variable asks the shell to treat the shell variables as a whole or separate them. If desired to be separated, the value set to the IFS variable is used as a separator. Hence the name Input Field Separator (IFS). To demonstrate, let’s define a variable as shown below.

# pfiles=initODBA112.ora:init.ora

These are actually two files: initODBA112.ora and init.ora. Now you want to display the first line of each of these files, you will use the head -1 command.

# head -1 $pfiles head: cannot open `initODBA112.ora:init.ora' for reading: No such file or directory 

The output says it all; the shell interpreted the variable as a whole: `initODBA112.ora:init.ora’, which is not a name of any file. That’s why the head command fails. If the shell interpreted the ”:” as some sort of a separator, it would have done that job properly. So, that’s what we can do by setting IFS variable:

# export IFS=":" # head -1 $pfiles ==> initODBA112.ora  init.ora 

There you go – the shell expanded the command head -1 $pfiles to head -1 initODBA112.ora and head -1 init.ora and therefore the command executed properly.

PATH

When you use a command in Linux, it's either in a shell as you saw with the kill command in Part 4 or it's an executable file. If it's an executable, how do you know where is it located?

Take for instance the rm command, which removes some file. The command can be given from any directory. Of course the executable file rm does not exist in all the directories so how does Linux know where to look?

The variable PATH holds the locations where the shell must look for that executable. Here is an example of a PATH setting:

# echo $PATH /usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin:.     

When you issue a command such as rm, the shell looks for a file rm in these locations in this order:

/usr/kerberos/bin /usr/local/bin /bin /usr/bin /usr/X11R6/bin . (the current directory)      

If the file is not found in any of these locations, the shell returns an error message -bash: rm: command not found. If you want to add more locations to the PATH variable, do so with '':'' as a separator.

Did you note a very interesting fact above? The location ''current directory'' is set at the very end, not at the beginning. Common sense may suggest that you put it in the beginning so that the shell looks for an executable on the current directory first before looking elsewhere. Putting it at the end will instruct the shell to look in the current directory at the end of the process. But is there a better approach?

Experts recommend that you put the current directory (.) at the end of the PATH command, not the beginning. Why? This practice is for safety. Suppose you are experimenting with some ideas to enhance common shell commands and inadvertently leave that file in your home directory. When you log in, you are in the home directory and when you execute that command, you are not executing the common command but rather the executable file in your home directory.

This could be disastrous in some cases. Suppose you are using toying with a new version of the ''cp'' command and there is a file called cp in your home directory. This file may potentially do some damage. If you type ''cp somefile anotherfile'', your version of file cp will be executed, creating damage. Putting the current directory at the end executes the normal ''cp'' command and avoids such a risk.

It also prevents the risk of some hacker placing some malignant command file in the form of common commands. Some experts even suggest to remove the ''.'' from the PATH altogether, to prevent any inadvertent execution. If you have to execute something in the current directory, just use the ./ notation as in:

# ./mycommand 

This executes a file called mycommand in the present directory.

CDPATH

Very similar to PATH, this variable expands the scope of the cd command to more than the present directory. For instance when you type the cd command as shown below:

# cd dbs -bash: cd: dbs: No such file or directory

It makes sense since the dbs directory does not exist in the present directory. It's under /opt/oracle/product/11gR2/db1. That's why the cd command fails. You can of course go to the directory /opt/oracle/product/11gR2 and then execute the cd command, which will be successful. If you want to increase the scope to include /opt/oracle/product/11gR2/db1, you can issue:

# export CDPATH=/opt/oracle/product/11gR2/db1

Now if you issue the cd command from any dorectory:

# cd dbs  /opt/oracle/product/11gR2/db1/dbs # pwd /opt/oracle/product/11gR2/db1/dbs

The cd command now looks for other directories for that subdirectory.

There are several other variables; but these ones are very widely used and you should know how to master them.

SET

This command controls the behavior of the shell. It has many options and arguments but I will explain a few important ones.

A very common mistake people make while using overwriting commands such as cp and mv is to overwrite correct files inadvertently. You can prevent risk that by using ''alias'' (shown in Part 1 of this series), e.g. using mv –i instead of mv. However, how can you prevent someone or some script overwriting the files by the re-direction operator (''>'')?

Let's see an example. Suppose you have a file called very_important.txt. Someone (or some script) inadvertently used something like:

# ls -l > very_important.txt

The file immediately gets overwritten. You lose the original contents of the file. To prevent this risk, you can use the set command with the option -o noclobber as shown below:

# set -o noclobber

After this command if someone tries to overwrite the file:

# ls -l > very_important.txt -bash: very_important.txt: cannot overwrite existing file 

The shell now prevents an existing file being overwritten. What if you want to overwrite? You can use the >| operator.

# ls -l >| very_important.txt

To turn it off:

# set +o noclobber

Another very useful set command is used to use vi editor for editing commands. Later in this installment you will learn how to check the commands you have given and how they can be re-executed. One quick way to re-execute the command is to recall the commands using the vi editor. To enable it execute this command first:

# set -o vi

No suppose you are looking for a command that contains the letter ''v'' (such as vi, or vim, etc.). To search for the command, execute this keystrokes. I have shown the keys to be pressed within square brackets:

# [Escape Key][/ key][v key][ENTER Key]

This will bring up the latest command executed containing ''v''. The last command in this case was set –o vi; so that comes up at the command prompt.

# set -o vi

If that's not the command you were looking for, press the ''n'' key for the next latest command. This way you can cycle through all the command executed with the letter ''v'' in it. When you see the command, you can press [ENTER key] to execute it. The search can be as explicit as you want. Suppose you are looking for a mpstat command executed earlier. All you have to do is enter that search string ''mpstat'':

# [Escape Key][/ key]mpstat[ENTER Key]

Suppose the above command shows mpstat 5 5 and you really want to execute mpstat 10 10. Instead of retyping, you can edit the command in vi. To do so, press [Escape Key] and the [v] key, which will bring up the command in vi editor. Now you can edit the command as you want. When you save it in vi by pressing :wq, the modified command will be executed.

type

In Part 4 you learned about the kill command, which is a special one – it's both a utility (an executable in some directory) and a shell built-in. In addition, you also learned about aliases in a prior installment. Sometimes there are some commands used in shell scripts – ''do'', ''done'', ''while'' for instance, which are not really commands by themselves. They are called shell keywords.

How do you know what type of command it is? The type command shows that. Here is how we have used it to show the types of the commands mv, do, fc and oh.

# type mv do fc oh mv is /bin/mv do is a shell keyword fc is a shell builtin oh is aliased to `cd $ORACLE_HOME'

It shows very clearly that mv is a utility (along with its location), do is a keyword used inside scripts, fc is a built-in and oh is an alias (and what it aliased to).

history

When you login to the Linux system you typically execute a lot of commands at the command prompt. How do you know what commands you have executed? You may want to know that for a lot of reasons – you want to re-execute it without retyping, you want to make sure you executed the right command (e.g. removed the right file), you want to verify what commands were issued, and so on. The history command gives you a history of the commands executed.

# history   1064  cd dbs  1065  export CDPATH=/opt/oracle/product/11gR2/db1  1066  cd dbs  1067  pwd  1068  env  1069  env | grep HIST  … and so on …

Note the numbers before each command. This is the event or command number. You will learn how to use this feature later in this section. If you want to display only a few lines of history instead of all available, say the most recent five commands:

# history 5

The biggest usefulness of history command actually comes from the ability to re-execute a command without retyping. To do so, enter the ! mark followed by the event or the command number that precedes the command name in the history output. To re-execute the command cd dbs shown in number 1066, you can issue:

# !1066 cd dbs /opt/oracle/product/11gR2/db1/dbs

The command !! (two exclamation marks) executes the last command executed. You can also pass a string after the ! command, which re-executes the latest command with the pattern as the string in the starting position. The following command re-executes the most recent command starting with cd:

# !cd cd dbs /opt/oracle/product/11gR2/db1/dbs

What if you want to re-execute a command containing a string – not start with it? The ? modifier does a pattern matching in the commands. To search for a command that has network in it, issue:

# !?network? cd network /opt/oracle/product/11gR2/db1/network

You can modify the command to be re-executed as well. For instance, suppose you had given earlier a command cd /opt/oracle/product/11gR2/db1/network and want to re-execute it after adding /admin at the end, you will issue:

# !1091/admin cd network/admin /opt/oracle/product/11gR2/db1/network/admin

fc

This command is a shell built-in used to show the command history as well, like history. The most common option is  -l (the letter ''L'', not the number ''1'') which shows the 16 most recent commands:

# fc -l 1055     echo $pfiles 1056     export IFS= ... and so on ... 1064     cd dbs 1065     export CDPATH=/opt/oracle/product/11gR2/db1 1066     cd dbs

You can also ask fc to show only a few commands by giving a range of event numbers, e.g. 1060 and 1064:

# fc -l 1060 1064 1060     pwd 1061     echo CDPATH 1062     echo $CDPATH 1063     cd 1064     cd dbs

The -l option also takes two other parameters – the string to perform a pattern matching. Here is an example where you want to display the history of commands that start with the word echo all the way to the most recent command that starts with pwd.

# fc -l echo pwd 1062     echo $CDPATH 1063     cd 1064     cd dbs 1065     export CDPATH=/opt/oracle/product/11gR2/db1 1066     cd dbs 1067     pwd

If you want to re-execute the command cd dbs (command number 1066), you can simply enter that number after fc with the -s option:

# fc -s 1066 cd dbs /opt/oracle/product/11gR2/db1/dbs

Another powerful use of the fc -l command is the substitution of commands. Suppose you want to execute a command similar to the 1066 (cd dbs) but want to issue cd network, not cd dbs, you can use the substitution argument as shown below:

# fc -s dbs=network 1066 cd network /opt/oracle/product/11gR2/db1/network

If you omit the -s option, as shown below:

# fc 1066

It opens a vi file with the command cd dbs inside, which you can edit and execute.

cpio

Consider this: you want to send a set of files to someone or somewhere and do not want to risk the files getting lost, breaking the set. What can you do to make sure of that? Simple. If you could put all the files into a single file and send that single file to its destination, you can rest assured that all the files arrived safely.

The cpio command has three main options:

  • -o (create) to create an archive
  • -i (extract) to extract files from an archive
  • -p (pass through) to copy files to a different directory

Each option has its own set of sub-options. For instance the -c option is applicable in case of -i and -o but not in case of -p. So, let's see the major option groups and how they are used.

The -v option is used to display a verbose output, which may be beneficial in cases where you want a definite feedback on what's going on.

First, let see how to create an archive from a bunch of files. Here we are putting all files with the extension ''trc'' in a specific directory and putting then in a file called myfiles.cpio:

$ ls *.trc | cpio -ocv > myfiles.cpio +asm_ora_14651.trc odba112_ora_13591.trc odba112_ora_14111.trc odba112_ora_14729.trc odba112_ora_15422.trc 9 blocks

The -v option was for verbose output so cpio showed us each file as it was added to the archive. The -o option was used since we wanted to create an archive. The -c option was used to tell cpio to write the header information in ASCII, which makes it easier to move across platforms.

Another option is -O which accepts the output archive file as a parameter.

# ls *.trc | cpio -ocv -O mynewfiles.cpio

To extract the files:

$ cpio -icv 

Here the -v and –i options are used for verbose output and for extraction of files from the archives. The –c option was used to instruct the cpio to read the header information as ASCII. When cpio extracts a file and it is already present (as it was the case for odba112_ora_13591.trc), it does not overwrite the file; but simply skips it with the message. To force overwriting, use the -u option.

# cpio -icvu 

To only display the contents without actually extracting, use the –t option along with the –i (extraction):

# cpio -it 

What if you are extracting a file which already exists? You still want to extract it but perhaps to a different name. One example is that you are trying to restore a file called alert.log (which is a log file for an Oracle instance) and you don't want to overwrite the current alert.log file.

One of the very useful options is –r, which allows you to rename the files being extracted, interactively.

# cpio -ir  a.trc rename odba112_ora_13591.trc -> b.trc rename odba112_ora_14111.trc -> [ENTER] which leaves the name alone 

If you created a cpio archive of a directory and want to extract to the same directory structure, use the –d option while extracting.

While creating, you can add files to an existing archive (append) using the -A option as shown below:

# ls *.trc | cpio -ocvA -O mynewfiles.cpio

The command has many other options; but you need to know only these to effectively use them.

tar

Another mechanism for creating an archive is tar. Originally created for archiving to tape drives (hence the nam:e Tape Archiver), tar is a very popular command for its simplicity. It takes three primary options

  • -c to create an archive
  • -x to extract files from an archive
  • -t to display the files in an archive

Here is how you create a tar archive. The –f option lets you name an output file that tar will create as an archive. In this example we are creating an archive called myfiles.tar from all the files with the extension ''trc''.

# tar -cf myfiles.tar *.trc

Once created, you can list the contents of an archive by the –t option.

# tar tf myfiles.tar +asm_ora_14651.trc odba112_ora_13591.trc odba112_ora_14111.trc odba112_ora_14729.trc odba112_ora_15422.trc 

To show the details of the files, use the –v (verbose) option:

# tar tvf myfiles.tar -rw-r----- oracle/dba     1150 2008-12-30 22:06:39 +asm_ora_14651.trc -rw-r----- oracle/dba      654 2008-12-26 15:17:22 odba112_ora_13591.trc -rw-r----- oracle/dba      654 2008-12-26 15:19:29 odba112_ora_14111.trc -rw-r----- oracle/dba      654 2008-12-26 15:21:36 odba112_ora_14729.trc -rw-r----- oracle/dba      654 2008-12-26 15:24:32 odba112_ora_15422.trc

To extract files from the archive, use the –x option. Here is an example (the –v option has been used to show the verbose output):

# tar xvf myfiles.tar 

zip

Compression is a very important part of Linux administration. You may be required to compress a lot of files to make room for new ones, or to send to via email and so on.

Linux offers many compression commands; here we'll examine to most common ones: zip and gzip.

The zip command produces a single file by consolidating other files and compressing them into one zip (or compressed) file. Here is a simple example usage of the command:

# zip myzip *.aud

It produces a file called myzip.zip with all the files in the directory named with a .aud extension.

zip accepts several options. The most common is -9, which instructs zip to compress as much as possible, while sacrificing the CPU cycles (and therefore taking longer). The other option, -1, instructs just the opposite: to compress faster while not compressing as much.

You can also protect the zip file by encrypting it with a password. Without the correct password the zip file cannot be unzipped. This is provided at the runtime with the –e (encrypt) option:

# zip -e ze *.aud Enter password:  Verify password:    adding: odba112_ora_10025_1.aud (deflated 32%)   adding: odba112_ora_10093_1.aud (deflated 31%) ... and so on ...

The -P option allows a password to be given in the command line. Since this allows other users to see the password in plaintext by checking for the processes or in the command history, it's not recommended over the -e option.

# zip -P oracle zp *.aud  updating: odba112_ora_10025_1.aud (deflated 32%) updating: odba112_ora_10093_1.aud (deflated 31%) updating: odba112_ora_10187_1.aud (deflated 31%) … and so on ..

You can check the integrity of the zip files by the -T option. If the zipfile is encrypted with a password, you have to provide the password.

# zip -T ze [ze.zip] odba112_ora_10025_1.aud password:  test of ze.zip OK

Of course, when you zip, you need to unzip later. And the command is – you guessed it – unzip. Here is a simple usage of the unzip command to unzip the zip file ze.zip.

# unzip myfiles.zip

If the zip file has been encrypted with a password, you will be asked for the password. When you enter it, it will not be repeated on the screen.

# unzip ze.zip Archive:  ze.zip [ze.zip] odba112_ora_10025_1.aud password:  password incorrect--reenter:  password incorrect--reenter:  replace odba112_ora_10025_1.aud? [y]es, [n]o, [A]ll, [N]one, [r]ename: N 

In the above example you entered the password incorrectly first; so it was prompted again. After entering it correctly, unzip found that there is already a file called odba112_ora_10025_1.aud; so unzip prompted you for your action. Note the choices – you had a rename option as well, to rename the unzipped file.

Remember the zip protected by a password passed in the command line with the zip –P command? You can unzip this file by passing the command in the command line as well, using the same –P option.

# unzip -P mypass zp.zip

The -P option differs from the -p option. The -p option instructs unzip to unzip files to the standard output, which can then be redirected to another file or another program.

The attractiveness of zip comes from the fact that it's the most portable. You can zip it on Linux and unzip it on OS X or Windows. The unzip utility is available on many platforms.

Suppose you have zipped a lot of files under several subdirectories under a directory. When you unzip this file, it creates the subdirectories as needed. If you want all the files to be unzipped into the current directory instead, use the -j option.

# unzip -j myfiles.zip 

One of the most useful combinations is the use of tar to consolidate the files and compressing the resultant archive file via the zip command. Instead of a two-step process of tar and zip, you can pass the output of tar to zip as shown below:

# tar cf - . | zip myfiles -   adding: - (deflated 90%)

The special character ''-'' in zip means the name of the file. The above command tars everything and creates a zip called myfiles.zip.

Similarly, while unzipping the zipped file and extracting the files from the zip archive, you can eliminate the two step process and perform both in one shot:

# unzip -p myfiles | tar xf -

gzip

The command gzip (short for GNU zip), is another command to compress files. It is intended to replace the old UNIX compress utility.

The main practical difference between zip and gzip is that the former creates a zip file from a bunch of files while the latter creates a compressed file for each input file. Here is an example usage:

# gzip odba112_ora_10025_1.aud

Note, it did not ask for a zip file name. The gzip command takes each file (e.g. odba112_ora_10025_1.aud) and simply creates a zip file named odba112_ora_10025_1.aud.gz. Additionally, note this point carefully, it removes the original file odba112_ora_10025_1.aud. If you pass a bunch of files as parameter to the command:

# gzip *

It creates a zip file with the extension .gz for each of these files present in the directory. Initially the directory contained these files:

a.txt b.pdf c.trc

After the gzip * command, the contents of the directory will be:

a.txt.gz b.pdf.gz c.trc.gz

The same command is also used for unzip (or uncompress, or decompress). The option is, quite intuitively, -d to decompress the files compressed by gzip

To check the contents of the gzipped file and how much has been compressed, you can use the -l option. It actually doesn't compress or uncompress anything; it just shows the contents.

# gzip -l *          compressed        uncompressed  ratio uncompressed_name                 698                1150  42.5% +asm_ora_14651.trc                 464                 654  35.2% odba112_ora_13591.trc                 466                 654  34.9% odba112_ora_14111.trc                 466                 654  34.9% odba112_ora_14729.trc                 463                 654  35.3% odba112_ora_15422.trc                2557                3766  33.2% (totals)

You can compress the files in a directory as well, using the recursive option (-r). To gzip all files under the log directory, use:

# gzip -r log

To check integrity of a gzip-ed file, use the -t option:

# gzip -t myfile.gz

When you want to create a different name for the gzipped file, not the default .gz, you should use the –c option. This instructs the gzip command to write to standard output which can be directed to a file. You can use the same technique to put more than one file in the same gzipped file. Here we are compressing two files - odba112_ora_14111.trc, odba112_ora_15422.trc – in the same compressed file named 1.gz.

# gzip -c  odba112_ora_14111.trc odba112_ora_15422.trc > 1.gz 

Note when you display the contents of the compressed file:

# gzip -l 1.gz          compressed        uncompressed  ratio uncompressed_name                                     654 -35.9% 1

The compression ratio shown is for the last file in the list only (that is why it shows a lesser size for original than the compressed one). When you decompress this file, both the original files will be displayed one after the other and both will be uncompressed properly.

The -f option forces the output to overwrite the files, if present. The –v option shows the output in more verbose manner. Here is an example:

# gzip -v *.trc +asm_ora_14651.trc:      42.5% -- replaced with +asm_ora_14651.trc.gz odba112_ora_13591.trc:   35.2% -- replaced with odba112_ora_13591.trc.gz odba112_ora_14111.trc:   34.9% -- replaced with odba112_ora_14111.trc.gz odba112_ora_14729.trc:   34.9% -- replaced with odba112_ora_14729.trc.gz odba112_ora_15422.trc:   35.3% -- replaced with odba112_ora_15422.trc.gz

A related command is zcat. If you want to display the contents of the gzipped file without unzipping it first, use the zcat command:

# zcat 1.gz

The zcat command is similar to gzip -d | cat on the file; but does not actually decompress the file.

Like the zip command, gzip also accepts the options for degree of compression:

# gzip -1 myfile.txt … Least compression consuming least CPU and fastest # gzip -9 myfile.txt … Most compression consuming most CPU and slowest

The command gunzip is also available, which is equivalent to gzip -d (to decompress a gzipped file)

(Extracted from oracle technet notes author Arup Nanda)

 Comment 

mesg, wall, w, kill, killall

on October 29, 2009 at 2:56 pm
Posted In: Unix notes (Cat)

msg

The Original Instant Messenger System
With the advent of instant messaging or chat programs we seem to have conquered the ubiquitous challenge of maintaining a real time exchange of information while not getting distracted by voice communication. But are these only in the domain of the fancy programs?

The instant messaging or chat concept has been available on *nix for quite a while. In fact, you have a full fledged secure IM system built right into Linux. It allows you to securely talk to anyone connected to the system; no internet connection is required. The chat is enabled through the commands – write, mesg, wall and talk. Let’s examine each of them.

The write command can write to a user’s terminal. If the user has logged in more than one terminal, you can address a specific terminal. Here is how you write a message “Beware of the virus” to the user “oracle” logged in on terminal “pts/3”:

# write oracle pts/3
Beware of the virus
ttyl

#
The Control-D key combination ends the message, returns the shell prompt (#) to the user and sends to the user’s terminal. When the above is sent, the user “oracle” will see on terminal pts/3 the messages:

Beware of the virus
ttyl
Each line will come up as the sender presses ENTER after the lines. When the sender presses Control-D, marking the end of transmission, the receiver sees EOF on the screen. The message will be displayed regardless of the current action of the user. If the user is editing a file in vi, the message comes and the user can clear it by pressing Control-L. If the user is on SQL*Plus prompt, the message still comes but does not affect the keystrokes of the user.

What if you don’t want that slight inconvenience? You don’t want anyone to send a message to you – akin to “leave the phone off the hook”. You can do that via the mesg command. This command disables others ability to send you a message. The command without any arguments shows the ability:

# mesg
is y
It shows that others can write to you. To turn it off:

# mesg n
Now to confirm:

# mesg
is n
When you attempt to write to the users’ terminals, you may want to know which terminals have disabled this writing from others. The who -T command (described earlier in this installment) shows you that:

# who -TH
NAME       LINE          TIME         COMMENT
oracle   + pts/2        Jan 11 12:08 (10.23.32.10)
oracle   + pts/3        Jan 11 12:08 (10.23.32.10)
oracle   – pts/4        Jan 11 12:08 (10.23.32.10)
root     + pts/1        Dec 26 13:42 (:0.0)
root     ? :0           Oct 23 15:32
The + sign before the terminal name indicates that it accepts write commands from others; the “-“ sign indicates that it doesn’t. The “?” indicates that the terminal does not support writing to it, e.g. an X-window session.

What if you want to write to all the logged in users? Instead of typing to each user, use the wall command:

# wall
hello everyone
When sent, the following shows up on the terminals of all logged in users:

Broadcast message from oracle  (pts/2) (Thu Jan  8 16:37:25 2009):
hello everyone
This is very useful for root user. When you want to shutdown the system, unmount a filesystem or perform similar administrative functions you may want all users to log off. Use this command to send a message to all.

Finally, the program talk allows you to chat in real time.  Just type the following:

# talk oracle pts/2
If you want to talk to a user on a different server – prolin2 – you can use

# talk oracle@prolin2 pts/2
It brings up a chat window on the other terminal and now you can chat in real time. Is it that different from a “professional” chat program you are using now? Probably not. Oh, by the way, to make the talk work, you should make sure the talkd daemon is running, which may not have been installed.

w
Yes, it’s a command, even if it’s just one letter long! The command w is a combination of uptime and who commands given one immediately after the other, in that order. Let’s see a very common output without any arguments and options.

# w
 17:29:22 up 672 days, 18:31,   2 users,  load average: 4.52,  4.54, 4.59
USER     TTY      FROM              LOGIN@   IDLE   JCPU   PCPU WHAT
oracle   pts/1     10.14.105.139    16:43    0.00s   0.06s  0.01s w
oracle   pts/2     10.14.105.139    17:26   57.00s   3.17s  3.17s sqlplus   as sysdba
… and so  on …
The output has two distinct parts. The first part shows the output of the uptime command (described above in this installment) which shows how long the server has been up, how many users have logged in and the load average for last 1, 5 and 15 minutes. The parts of the output have been explained under the uptime command. The second part of the output shows the output of the who command with the option -H (also explained in this installment). Again, these various columns have been explained under the who command.

If you rather not display the header, use the -h option.

#  w -h
oracle   pts/1     10.14.105.139    16:43    0.00s   0.02s  0.01s w -h
This removes the header from the output. It’s useful in shell scripts where you want to read and act on the output without the additional burden of skipping the header.

The -s option produces a compact (short) version of the output, removing the login time, JPCU and PCPU times.

# w -s
 17:30:07 up 672 days, 18:32,   2 users,  load average: 5.03,  4.65, 4.63
USER     TTY      FROM               IDLE WHAT
oracle   pts/1     10.14.105.139     0.00s w -s
oracle   pts/2     10.14.105.139     1:42  sqlplus   as sysdba
You might find that the “FROM” field is really not very useful. It shows the IP address of the same server, since the logins are all local. To save the space on the output, you may want to suppress that. The -f option disables printing of the FROM field:

# w -f
 17:30:53 up 672 days, 18:33,   2 users,  load average: 4.77,  4.65, 4.63
USER     TTY        LOGIN@   IDLE    JCPU   PCPU WHAT
oracle   pts/1      16:43    0.00s  0.06s   0.00s w -f
oracle   pts/2      17:26    2:28   3.17s   3.17s sqlplus   as sysdba
The command accepts only one parameter: the name of a user. By default w shows the process and logins for all users. If you put a username, it shows the logins for that user only. For instance, to show logins for root only, issue:

# w -h root
root     pts/1    :0.0             26Dec08 13days 0.01s   0.01s bash
root     :0       -                23Oct08 ?xdm?   21:13m  1.81s  /usr/bin/gnome-session
The -h option was used to suppress displaying header.

kill
A process is running and you want the process to be terminated. What should you do? The process runs in the background so there is no going to the terminal and pressing Control-C; or, the process belongs to another user (using the same userid, such as “oracle”) and you want to terminate it. The kill command comes to rescue; it does what its name suggests – it kills the process. The most common use is:

# kill
Suppose you want to kill a process called sqlplus issued by the user oracle, you need to know its processid, or PID:

# ps -aef|grep sqlplus|grep ananda
oracle    8728 23916  0 10:36 pts/3    00:00:00 sqlplus
oracle    8768 23896  0 10:36 pts/2    00:00:00  grep sqlplus
Now, to kill the PID 8728:

# kill 8728
That’s it; the process is killed. Of course, you have to be the same user (oracle) to kill a process kicked off by oracle. To kill processes kicked off by other users you have to be super user – root.

Sometimes you may want to merely halt the process instead of killing it. You can use the option -SIGSTOP with the kill command.

# kill -SIGSTOP 9790
# ps -aef|grep sqlplus|grep oracle
oracle    9790 23916   0 10:41 pts/3    00:00:00 sqlplus   as sysdba
oracle    9885 23896  0 10:41 pts/2    00:00:00  grep sqlplus
This is good for background jobs but with the foreground processes, it merely stops the process and removes the control from the user. So, if you check for the process again after issuing the command:

# ps -aef|grep sqlplus|grep oracle
oracle    9790 23916  0 10:41 pts/3    00:00:00 sqlplus   as sysdba
oracle   10144 23896  0 10:42 pts/2    00:00:00  grep sqlplus
You see that the process is still running. It has not been terminated. To kill this process, and any stubborn processes that refuse to be terminated, you have to pass a new signal called SIGKILL. The default signal is SIGTERM.

# kill -SIGKILL 9790
# ps -aef|grep sqlplus|grep oracle
oracle   10092 23916  0 10:42 pts/3    00:00:00 sqlplus   as sysdba
oracle   10198 23896  0 10:43 pts/2    00:00:00  grep sqlplus
Note the options -SIGSTOP and -SIGKILL, which pass a specific signal (stop and kill, respectively) to the process. Likewise there are several other signals you can use. To get a listing of all the available signals, you can use the -l (that’s the letter “L”, not the numeral “1”) option:

# kill -l
 1) SIGHUP       2) SIGINT       3) SIGQUIT      4) SIGILL
 5) SIGTRAP      6) SIGABRT      7) SIGBUS       8) SIGFPE
 9) SIGKILL     10) SIGUSR1     11) SIGSEGV     12) SIGUSR2
13) SIGPIPE     14) SIGALRM     15) SIGTERM     17) SIGCHLD
18) SIGCONT     19) SIGSTOP     20) SIGTSTP     21) SIGTTIN
22) SIGTTOU     23) SIGURG      24) SIGXCPU     25) SIGXFSZ
26) SIGVTALRM   27) SIGPROF     28) SIGWINCH    29) SIGIO
30) SIGPWR      31) SIGSYS      34) SIGRTMIN    35) SIGRTMIN+1
36) SIGRTMIN+2  37) SIGRTMIN+3  38) SIGRTMIN+4  39) SIGRTMIN+5
40) SIGRTMIN+6  41) SIGRTMIN+7  42) SIGRTMIN+8  43) SIGRTMIN+9
44) SIGRTMIN+10 45) SIGRTMIN+11 46) SIGRTMIN+12 47) SIGRTMIN+13
48) SIGRTMIN+14 49) SIGRTMIN+15 50) SIGRTMAX-14 51) SIGRTMAX-13
52) SIGRTMAX-12 53) SIGRTMAX-11 54) SIGRTMAX-10 55) SIGRTMAX-9
56) SIGRTMAX-8  57) SIGRTMAX-7  58) SIGRTMAX-6  59) SIGRTMAX-5
60) SIGRTMAX-4  61) SIGRTMAX-3  62) SIGRTMAX-2  63) SIGRTMAX-1
64) SIGRTMAX
You can also use the numeral equivalent of the signal in place of the actual signal name. For instance, instead of kill -SIGKILL 9790, you can use kill -9 9790.

By the way, this is an interesting command. Remember, almost all Linux commands are usually executable files located in /bin, /sbin/, /user/bin and similar directories. The PATH executable determines where these command files can be found. Some other commands are an actually “built-in” command, i.e. they are part of the shell itself. One such example is kill. To demonstrate, give the following:

# kill -h
-bash: kill: h: invalid signal  specification
Note the output that came back from the bash shell. The usage is incorrect since the -h argument was not expected. Now use the following:

# /bin/kill -h
usage: kill [ -s signal | -p ]  [ -a ] pid …
       kill -l [ signal ]
Aha! This version of the command kill as an executable in the /bin directory accepted the option -h properly. Now you know the subtle difference between the shell built-in commands and their namesake utilities in the form of executable files.

Why is it important to know the difference? It’s important because the functionality varies significantly across these two forms. The kill built-in has lesser functionality than its utility equivalent. When you issue the command kill, you are actually invoking the built-in, not the utility. To add the other functionality, you have to use the /bin/kill utility.

The kill utility has many options and arguments. The most popular is the kill command used to kill the processes with process names, rather than PIDs. Here is an example where you want to kill all processes with the name sqlplus:

# /bin/kill sqlplus
[1]   Terminated              sqlplus
[2]   Terminated              sqlplus
[3]   Terminated              sqlplus
[4]   Terminated              sqlplus
[5]   Terminated              sqlplus
[6]   Terminated              sqlplus
[7]-  Terminated              sqlplus
[8]+  Terminated              sqlplus
Sometimes you may want to see all the process IDs kill will terminate. The -p option accomplishes that. It prints all the PIDs it would have killed, without actually killing them. It serves as a confirmation prior to action:

#  /bin/kill -p sqlplus
6798
6802
6803
6807
6808
6812
6813
6817
The output shows the PIDs of the processes it would have killed. If you reissue the command without the -p option, it will kill all those processes.

At this time you may be tempted to know which other commands are “built-in” in the shell, instead of being utilities.

# man -k builtin
. [builtins]         (1)   – bash built-in commands, see bash(1)
: [builtins]         (1)   – bash built-in commands, see bash(1)
[ [builtins]         (1)   – bash built-in commands, see bash(1)
alias [builtins]     (1)   – bash built-in commands, see bash(1)
bash [builtins]      (1)   – bash built-in commands, see bash(1)
bg [builtins]        (1)   – bash built-in commands, see bash(1)
… and so on …
Some entries seem familiar – alias, bg and so on. Some are purely built-ins, e.g. alias. There is no executable file called alias.

Usage for Oracle Users
Killing a process has many uses – mostly to kill zombie processes, processes that are in the background and others that have stopped responding to the normal shutdown commands. For instance, the Oracle database instance is not shutting down as a result of some memory issue. You have to bring it down by killing one of the key processes like pmon or smon. This should not be an activity to be performed all the time, just when you don’t have much choice.

You may want to kill all sqlplus sessions or all rman jobs using the utility kill command. Oracle Enterprise Manager processes run as perl processes; or DBCA or DBUA processes run, which you may want to kill quickly:

# /bin/kill perl rman perl dbca  dbua java
There is also a more common use of the command. When you want to terminate a user session in Oracle Database, you typically do this:

Find the SID and Serial# of the session
Kill the session using ALTER SYSTEM command
Let’s see what happens when we want to kill the session of the user SH.

SQL> select sid, serial#,  status
  2  from v$session
  3* where username = ‘SH’;
       SID    SERIAL# STATUS
———- ———- ——–
       116       5784  INACTIVE
 
SQL> alter system kill  session ‘116,5784’
  2  /
 
System altered.
 
It’s killed; but when you check the status of the session:
 
       SID    SERIAL# STATUS
———- ———- ——–
       116       5784 KILLED
It shows as KILLED, not completely gone. It happens because Oracle waits until the user SH gets to his session and attempts to do something, during which he gets the message “ORA-00028: your session has been killed”. After that time the session disappears from V$SESSION.

A faster way to kill a session is to kill the corresponding server process at the Linux level. To do so, first find the PID of the server process:

SQL> select spid
  2  from v$process
  3  where addr =
  4  (
  5     select paddr
  6     from v$session
  7     where username =  ‘SH’
  8  );
SPID
————————
30986
The SPID is the Process ID of the server process. Now kill this process:

# kill -9 30986
Now if you check the view V$SESSION, it will be gone immediately. The user will not get a message immediately; but if he attempts to perform a database query, he will get:

ERROR at line 1:
ORA-03135: connection lost  contact
Process ID: 30986
Session ID: 125 Serial number:  34528
This is a faster method to kill a session but there are some caveats. The Oracle database has to perform a session cleanup–rollback changes and so on. So this should be performed only when the sessions are idle. Otherwise you can use one of the two other ways to kill a session immediately:

alter system disconnect session  ‘125,35447’ immediate;
alter system disconnect session  ‘125,35447’ post_transaction;

killall
Unlike the dual nature of kill, killall is purely a utility, i.e. this is an executable program in the /usr/bin directory. The command is similar to kill in functionality but instead of killing a process based on its PID, it accepts the process name as an argument. For instance, to kill all sqlplus processes, issue:

# killall sqlplus
This kills all processes named sqlplus (which you have the permission to kill, of course). Unlike the kill built-in command, you don’t need to know the Process ID of the processes to be killed.

If the command does not terminate the process, or the process does not respond to a TERM signal, you can send an explicit SIGKILL signal as you saw in the kill command using the -s option.

# killall -s SIGKILL sqlplus
Like kill, you can use -9 option in lieu of -s SIGKILL. For a list of all available signals, you can use the -l option.

# killall -l
HUP INT QUIT ILL TRAP ABRT IOT  BUS FPE KILL USR1 SEGV USR2 PIPE ALRM TERM
STKFLT CHLD CONT STOP TSTP TTIN  TTOU URG XCPU XFSZ VTALRM PROF WINCH IO PWR SYS
UNUSED
To get a verbose output of the killall command, use the -v option:

# killall -v sqlplus
Killed sqlplus(26448) with signal 15
Killed sqlplus(26452) with signal 15
Killed sqlplus(26456) with signal 15
Killed sqlplus(26457) with signal 15
… and so on …
Sometimes you may want to examine the process before terminating it. The -i option allows you run it interactively. This option prompts for your input before killing it:

# killall -i sqlplus
Kill sqlplus(2537) ? (y/n) n
Kill sqlplus(2555) ? (y/n) n
Kill sqlplus(2555) ? (y/n) y
Killed sqlplus(2555) with signal 15
What happens when you pass a wrong process name?

# killall wrong_process
wrong_process: no process  killed
There is no such running process called wrong_process so nothing was killed and the output clearly showed that. To suppress this complaint “no process killed”, use the -q option. That option comes handy in shell scripts where you can’t parse the output. Rather, you want to capture the return code from the command:

# killall -q wrong_process
# echo $?
1
The return code (shown by the shell variable $?) is “1”, instead of “0”, meaning failure. You can check the return code to examine whether the killall process was successful, i.e. the return code was “0”.

One interesting thing about this command is that it does not kill itself. Of course, it kills other killall commands given elsewhere but not itself.

Usage for Oracle Users
Like the kill command, the killall command is also used to kill processes. The biggest advantage of killall is the ability to display the processid and the interactive nature. Suppose you want to kill all perl, java, sqlplus, rman and dbca processes but do it interactively; you can issue:

# killall -i -p perl sqlplus  java rman dbca
Kill sqlplus(pgid 7053) ? (y/n) n
Kill perl(pgid 31233) ? (y/n) n
… and so on …
This allows you to view the PID before you kill them, which can be very useful.

Conclusion
In this installment you learned about these commands (shown in alphabetical order)

dig             A newer version of nslookup
ifconfig       To display information on network interfaces
kill              Kill a specific process
killall            Kill a specific process, a group of processes and names matching a pattern
mesg          To turn on or off the ability of others to display something on one’s terminal.
netstat       To display statistics and other metrics on network interface usage
nslookup     To lookup a hostname for its IP address or lookup IP address for its hostname on the DNS
talk            To establish an Instant Message system between two users for realtime chat
uptime        How long the system has been up and its load average for 1, 5 and 15 minutes
w               Combination of uptime and who
wall            To display some text on the terminals of all the logged in users
who           To display the users logged into the system and what they are doing
write          To instantly display something on a specific user’s terminal session

(Extracted from oracle technet notes author Arup Nanda)

 Comment 

uptime, who

on October 29, 2009 at 2:50 pm
Posted In: Resource Management (Cat)

uptime

You just logged on to the server and see some things that were supposed to be running are not. Perhaps the processes were killed or perhaps all processes were killed by a shutdown. Instead of guessing, find out if the server was indeed rebooted with the uptime command. The command shows the length of time the server has been up since the last reboot.

# uptime
 16:43:43 up 672 days, 17:46,   45 users,  load average: 4.45,  5.18, 5.38
The output shows much useful information. The first column shows the current time when the command was executed. The second portion – up 672 days, 17:46 – shows the amount of time the server has been up. The numbers 17:46 depict the hour and minutes. So this server has been up for 672 days, 17 hours, and 46 minutes as of now.

The next item – 45 users – shows how many users are logged in to the server right now.

The last bits of the output show how much has been the load average of the server in the last 1, 5, and 15 minutes respectively. The term “load average” is a composite score that determines the load on the system based on CPU and I/O metrics. The higher the load average, the more the load on the system. It’s not based on a scale; unlike percentages it does not end at a fixed number such as 100. In addition, load averages of two systems can’t be compared. It is a number to quantify load on a system and relevant in that system alone. This output shows that the load average was 4.45 in the last 1 min, 5.18 in the 5 last mins, and so on.

The command does not have any options or accept any parameter other than -V, which shows the version of the command.

# uptime -V
procps version 3.2.3
Usage for Oracle Users
There is no clear Oracle-specific use of this command, except that you can find out the load on the system to explain some performance issues. If you see some performance issues on the database, and you trace it to high CPU or I/O load, you should immediately check the load averages using the uptime command. If you see a high load average, your next course of action is to dive down deep below the surface to find the root cause. To perform that deep dive, you have in your arsenal tools like mpstat, iostat, and sar (covered in this installment of this series).

Consider an output as shown below:

# uptime
 21:31:04 up 330 days,   7:16,  4 users,  load average: 12.90, 1.03, 1.00
It’s interesting as the load average was very high (12.90) in the last 1 minute but has been pretty low, even irrelevant, at 1.03 and 1.00 for 5 minutes and 15 minutes respectively. What does it mean? It proves that in less than 5 minutes, some process started that caused the load average to jump up for the last minute. This process was not present earlier because the previous load averages were so small. This analysis leads us to focus on the processes that kicked off during the last few minutes – speeding up the resolution process.

Of course, since it shows how long the server has been up, it also explains why the instance has been up since then.


who

Who is logged in the system right now? That’s a common question you might want to ask, especially when you are tracking down an errant user running some resource consuming commands.

The who command answers that question. Here is the simplest usage without any arguments or parameters.

# who
oracle   pts/2        Jan  8 15:57  (10.14.105.139)
oracle   pts/3        Jan  8 15:57  (10.14.105.139)
root     pts/1        Dec 26 13:42  (:0.0)
root     :0           Oct 23 15:32
The command can take several options. The -s option is the default; it produces the same output as the above.

Looking at the output, you might be straining your memory to remember what the columns are meant to be. Well, relax. You can use the -H option to display the header:

# who -H
NAME     LINE         TIME         COMMENT
oracle   pts/2        Jan  8 15:57  (10.14.105.139)
oracle   pts/3        Jan  8 15:57  (10.14.105.139)
root     pts/1        Dec 26  13:42 (:0.0)
root     :0           Oct 23  15:32
Now the meanings of the columns are clear. The column NAME shows the username of the logged in user. LINE shows the terminal name. In Linux each connection is labeled as a terminal with the naming convention pts/ where is a number starting with 1. The :0 terminal is a label for X terminal. TIME shows when they first logged in. COMMENTS shows the IP address where they logged in from.

What if you just want a list of names of users instead of all those extraneous details? The -q option accomplishes that. It displays the names of users on one line, sorted alphabetically. It also displays a count of total number of users at the end (45 in this case):

# who -q
ananda ananda jsmith klome  oracle oracle root root … and so on for  45 names
# users=45
Some users could be just logged on but actually doing nothing. You can check how long they have been idle, a command especially useful if you are the boss, by using the -u option.

# who -uH
NAME     LINE         TIME          IDLE          PID COMMENT
oracle   pts/2        Jan  8 15:57   .          18127 (10.14.105.139)
oracle   pts/3        Jan  8 15:57  00:26       18127 (10.14.105.139)
root     pts/1        Dec 26 13:42   old         6451 (:0.0)
root     :0           Oct 23 15:32    ?         24215
The new column IDLE shows how long they have been idle in hh:mm format. Note the value “old” in that column? It means that the user has been idle for more than 1 day. The PID column shows the process ID of their shell connection.

Another useful option is -b that shows when the system was rebooted.

# who -b
         system boot  Feb 15  13:31
It shows the system was booted on Feb 15th at 1:31 PM. Remember the uptime command? It also shows you how long this system has been up. You can subtract the days shown in uptime to know the day of the boot. The who -b command makes it much simpler; it directly shows you the time of the boot.

Very Important Caveat: The who -b command shows the month and date only, not the year. So if the system has been up longer than a year, the output will not reflect the correct value. Therefore uptime is always a preferred approach, even if you have to do a little calculation. Here is an example:

# uptime
 21:37:49 up 675 days, 22:40,   1 user,  load average: 3.35,  3.08, 2.86
# who -b
         system boot   Mar  7 22:58
Note the boot time shows as March 7. That’s in 2007, not 2008! The uptime shows the correct time – it has been up for 675 days. If subtractions are not your forte you can use a simple SQL to get that date 675 days ago:

SQL> select sysdate – 675  from dual;
SYSDATE-6
———
07-MAR-07
The -l option shows the logons to the system:

# who -lH
NAME     LINE         TIME         IDLE          PID COMMENT
LOGIN    tty1         Feb 15  13:32              4081 id=1
LOGIN    tty6         Feb 15  13:32              4254 id=6
To find out the user terminals that have been dead, use the -d option:

# who -dH
NAME     LINE         TIME         IDLE          PID COMMENT  EXIT
                      Feb 15  13:31               489 id=si     term=0 exit=0
                      Feb 15  13:32              2870 id=l5     term=0 exit=0
         pts/1        Oct 10  14:53             31869 id=ts/1  term=0 exit=0
         pts/4        Jan 11  00:20             22155 id=ts/4  term=0 exit=0
         pts/3        Jun 29  16:01                 0 id=/3    term=0 exit=0
         pts/2         Oct 4  22:35              8371 id=/2    term=0 exit=0
         pts/5        Dec 30  03:15              5026 id=ts/5  term=0 exit=0
         pts/4        Dec 30  22:35                 0 id=/4    term=0 exit=0
Sometimes the init process (the process that starts first when the system is booted) kicks off other processes. The -p option shows all those logins that are active.

# who -pH
NAME     LINE         TIME                PID COMMENT
                      Feb 15 13:32       4083 id=2
                      Feb 15 13:32       4090 id=3
                      Feb 15 13:32       4166 id=4
                      Feb 15 13:32       4174 id=5
                      Feb 15 13:32       4255 id=x
                      Oct  4 23:14      13754 id=h1
Later in this installment, you will learn about a command – write – that enables real time messaging. You will also learn how to disable others’ ability to write to your terminal (the mesg command). If you want to know which users do and do not allow others to write to their terminals, use the -T option:

# who -TH
NAME       LINE          TIME         COMMENT
oracle   + pts/2        Jan 11 12:08  (10.23.32.10)
oracle   + pts/3        Jan 11 12:08  (10.23.32.10)
oracle   – pts/4        Jan 11 12:08  (10.23.32.10)
root     + pts/1        Dec 26 13:42  (:0.0)
root     ? :0           Oct 23 15:32
The + sign before the terminal name means the terminal accepts write commands from others; the “-“ sign means that the terminal does not allow. The “?” in this field means the terminal does not support writing to it, e.g. an X-window session.

The current run level of the system can be obtained by the -r option:

# who -rH
NAME     LINE         TIME         IDLE          PID COMMENT
         run-level 5  Feb 15  13:31                   last=S
A more descriptive listing can be obtained by the -a (all) option. This option combines the -b -d -l -p -r -t -T -u options. So these two commands produce the same result:

# who  -bdlprtTu
# who -a
Here is a sample output (with the header, so that you can understand the columns better):

# who -aH
NAME       LINE          TIME         IDLE          PID COMMENT  EXIT
                        Feb 15 13:31               489 id=si     term=0 exit=0
           system boot  Feb 15 13:31
           run-level 5  Feb 15 13:31                   last=S
                        Feb 15 13:32              2870 id=l5     term=0 exit=0
LOGIN      tty1         Feb 15 13:32              4081 id=1
                        Feb 15 13:32              4083 id=2
                        Feb 15 13:32              4090 id=3
                        Feb 15 13:32              4166 id=4
                        Feb 15 13:32              4174 id=5
LOGIN      tty6         Feb 15 13:32              4254 id=6
                        Feb 15 13:32              4255 id=x
                        Oct  4 23:14             13754 id=h1
           pts/1        Oct 10 14:53             31869 id=ts/1  term=0 exit=0
oracle   + pts/2        Jan  8 15:57   .         18127 (10.14.105.139)
oracle   + pts/3        Jan  8 15:57  00:18      18127 (10.14.105.139)
           pts/4        Dec 30 03:15              5026 id=ts/4  term=0 exit=0
           pts/3        Jun 29 16:01                 0 id=/3    term=0 exit=0
root     + pts/1        Dec 26 13:42  old         6451 (:0.0)
           pts/2        Oct  4 22:35              8371 id=/2     term=0 exit=0
root     ? :0           Oct 23 15:32   ?         24215
           pts/5        Dec 30 03:15              5026 id=ts/5  term=0 exit=0
           pts/4        Dec 30 22:35                 0 id=/4    term=0 exit=0
To find out your own login, use the -m option:

# who -m
oracle   pts/2        Jan  8 15:57  (10.14.105.139)
Note the pts/2 value? That’s the terminal number. You can find your own terminal via the tty command:

# tty
/dev/pts/2
There is a special command structure in Linux to show your own login – who am i. It produces the same output as the -m option.

# who am i
oracle   pts/2        Jan  8 15:57  (10.14.105.139)

The only arguments allowed are “am i” and “mom likes” (yes, believe it or not!). Both produce the same output,

 
(Extracted from oracle technet notes author Arup Nanda)

 Comment 

dig, nslookup – network lookup

on October 29, 2009 at 2:48 pm
Posted In: Unix notes (Cat)

dig

The nslookup command has been deprecated. Instead, a new, more powerful command – dig (domain information groper) – should be used. On some newer Linux servers the nslookup command may not be even available.

Here is an example; to check the name resolution of the host oracle.com, you use the following command:

# dig oracle.com
; DiG 9.2.4  oracle.com
;; global options:  printcmd
;; Got answer:
;; ->>HEADER;; flags: qr rd ra; QUERY: 1,  ANSWER: 1, AUTHORITY: 8, ADDITIONAL: 8
 
;; QUESTION SECTION:
;oracle.com.                    IN      A
 
;; ANSWER SECTION:
oracle.com.             300     IN      A       141.146.8.66
 
;; AUTHORITY SECTION:
oracle.com.             3230    IN      NS      ns1.oracle.com.
oracle.com.             3230    IN      NS      ns4.oracle.com.
oracle.com.             3230    IN      NS      u-ns1.oracle.com.
oracle.com.             3230    IN      NS      u-ns2.oracle.com.
oracle.com.             3230    IN      NS      u-ns3.oracle.com.
oracle.com.             3230    IN      NS      u-ns4.oracle.com.
oracle.com.             3230    IN      NS      u-ns5.oracle.com.
oracle.com.             3230    IN      NS      u-ns6.oracle.com.
 
;; ADDITIONAL SECTION:
ns1.oracle.com.         124934  IN      A       148.87.1.20
ns4.oracle.com.         124934  IN      A       148.87.112.100
u-ns1.oracle.com.       46043   IN      A       204.74.108.1
u-ns2.oracle.com.       46043   IN      A       204.74.109.1
u-ns3.oracle.com.       46043   IN      A       199.7.68.1
u-ns4.oracle.com.       46043   IN      A       199.7.69.1
u-ns5.oracle.com.       46043   IN      A       204.74.114.1
u-ns6.oracle.com.       46043   IN      A       204.74.115.1
 
;; Query time: 97 msec
;; SERVER:  10.14.1.58#53(10.14.1.58)
;; WHEN: Mon Dec 29 22:05:56  2008
;; MSG SIZE  rcvd: 328
From the mammoth output, several things stand out. It shows that the command sent a query to the nameserver and the host got a response back from the nameserver. The name resolution was also done at some other nameservers such as ns1.oracle.com. It shows that the query took 97 milliseconds.

If the size of the output might not make it all that useful, you can use the +short option to remove all those verbose output:

# dig +short oracle.com
141.146.8.66
You can also use the IP address to reverse lookup the host name from the IP address. The -x option is used for that.

# dig -x 141.146.8.66
The +domain parameter is useful when you are looking for a host inside a domain. For instance, suppose you are searching for the host otn in the oracle.com domain, you can either use:

# dig +short otn.oracle.com
Or you can use the +domain parameter:

# dig +short +tcp  +domain=oracle.com otn
www.oracle.com.
www.oraclegha.com.
141.146.8.66

Usage for the Oracle User

The connectivity is established between the app server and the database server.
The TNSNAMES.ORA file, used by SQL*Net may look like this:

prodb3 =
  (description =
    (address_list =
      (address = (protocol = tcp)(host = prolin3)(port = 1521))
    )
    (connect_data =
      (sid = prodb3)
    )
  )

The host name prolin3 should be able to be resolved by the app server. Either this should be in the /etc/hosts file; or the host prolin3 should be defined in the DNS.

To make sure the name resolution works and works correctly to point to the right host, you can use the dig command.

With these two commands you can handle most of the tasks involved with network in a Linux environment.

nslookup

Every reachable host in a network should have an IP address, which identifies it uniquely in the network. In the internet, which is a big network anyway, IP addresses allow the connections to reach servers running Websites, e.g. www.oracle.com. So, when one host (such as a client) wants to connect to another (such as a database server) using its name and not the IP address, how does the client browser know which IP address to connect to?

The mechanism of translating the host name to IP addresses is known as name resolution. In the most rudimentary level, the host has a special file called hosts, which stores the IP Address – Hostname pairs. Here is an example file:

# cat /etc/hosts
# Do not remove the following  line, or various programs
# that require network  functionality will fail.
127.0.0.1       localhost.localdomain       localhost
192.168.1.101   prolin1.proligence.com      prolin1
192.168.1.102   prolin2.proligence.com      prolin2
This shows that the hostname prolin1.proligence.com is translated to 192.168.1.101. The special entry with the IP address 127.0.0.1 is called a loopback entry, which points back to the server itself via a special network interface called lo (which you saw earlier in the ifconfig and netstat commands).

Well, this is good, but you can’t possibly put all the IP addresses in the world in this file. There should be another mechanism to perform the name resolution. A special purpose server called a nameserver performs that role. It’s like a phonebook that your phone company provides; not your personal phonebook. There may be several nameservers available either inside or outside the private network. The host contacts one of the nameservers first, gets the IP address of the destination host it want to contact, and then attempts to connect to the IP address.

How does the host know what these nameservers are? It looks into a special file called /etc/resolv.conf to get that information. Here is a sample resolv file.

; generated by  /sbin/dhclient-script
search proligence.com
nameserver 10.14.1.58
nameserver 10.14.1.59
nameserver 10.20.223.108

How do you make sure that the name resolution is working fine for a specific host name? In other words, you want to make sure that when the Linux system tries to contact a host called oracle.com, it can find the IP address on the nameserver. The nslookup command is useful for that. Here is how you use it:

# nslookup oracle.com
Server:         10.14.1.58
Address:        10.14.1.58#53
Non-authoritative answer:
Name:   oracle.com
Address: 141.146.8.66

Let’s dissect the output. The Server output is the address of the nameserver. The name oracle.com resolves to the IP address 141.146.8.66. The name was resolved by the nameserver shown next to the word Server in the output.

If you put this IP address in a browser–http://141.146.8.66 instead of http://oracle.com–the browser will go the oracle.com site.

If you made a mistake, or looked for a wrong host:

# nslookup oracle-site.com
Server:         10.14.1.58
Address:        10.14.1.58#53
** server can’t find  oracle-site.com: NXDOMAIN

The message is quite clear: this host does not exist.

 
(Extracted from oracle technet notes author Arup Nanda)

 Comment 

netstat – network status

on October 29, 2009 at 2:46 pm
Posted In: Resource Management (Cat)

netstat
The status of the input and output through a network interface is assessed via the command netstat. This command can provide the complete information on how the network interface is performing, down to even socket level. Here is an example:

# netstat
Active Internet connections  (w/o servers)
Proto Recv-Q Send-Q Local Address Foreign Address  State     
tcp        0      0 prolin1:31027 prolin1:5500     TIME_WAIT
tcp        4      0 prolin1l:1521 applin1:40205    ESTABLISHED
tcp        0      0 prolin1l:1522 prolin1:39957    ESTABLISHED
tcp        0      0 prolin1l:3938 prolin1:31017    TIME_WAIT
tcp        0      0 prolin1l:1521 prolin1:21545    ESTABLISHED
… and so on …
The above output goes on to show all the open sockets. In very simplistic terms, a socket is akin to a connection between two processes. [Please note: strictly speaking, “sockets” and “connections” are technically different. A socket could exist without a connection. However, a discussion on sockets and connections is beyond the scope of this article. Therefore I have merely presented the concept in an easy-to-understand manner.] Naturally, a connection has to have a source and a destination, called local and remote address. The end points could be on the same server; or on different servers.

In many cases, the programs connect to the same server. For instance, if two processes communicate among each other, the local and remote addresses will be the same, as you can see in the first line – the local and remote addresses are both the sever “prolin1”. However, the processes communicate over a port, which will be different. This port is shown next to the host name after the “:” (colon) mark. The user program sends the data to be sent across the socket to a queue and the receiver reads from a queue at the remote end. Here are the columns of the output:

The leftmost column “Proto” shows the type of the connection – tcp in this case.
The column Recv-Q shows the bytes of data in the queue to be sent to the user program that established the connection. This value should be as close to 0 as possible. In busy servers this value will be more than 0 but shouldn’t be very high. A higher number may not mean much, unless you see a large number in Send-Q column, described below.
The Send-Q column denotes the bytes in the queue to be sent to the remote program, i.e. the remote program has not yet acknowledged receiving it. This should be close to 0. A large number may indicate a network bottleneck.
Local Address is source of the connection and the port number of the program.
Foreign Address is the destination host and port number. In the first line, both the source and destination are on the same host: prolin1. The connection is simply waiting. The second line shows and established connection between port 1521 of proiln1 going to the port 40205 of the host applin1. It’s most likely an Oracle connection coming from the client applin1 to the database server prolin1. The Oracle listener on prolin1 runs on port 1521; so the port of the source is 1521. In this connection, the server is sending the requested data to the client.
The column State shows the status of the connection. Here are some common values.
ESTABLISHED – that the connection has been established. It does not mean that any data is flowing between the end points; merely that the end points have talked to each other.
CLOSED – the connection has been closed, i.e. not used now.
TIME_WAIT – the connection is being closed but there are still packets in the network that are being handled.
CLOSE_WAIT – the remote end has shutdown and has asked to close the connection.
Well, from the foreign and local addresses, especially from the port numbers, you can probably guess that the connections are Oracle related, but won’t it be nice to know that for sure? Of course. The -p option shows the process information as well:

#  netstat -p
Proto  Recv-Q Send-Q Local Address Foreign Address State       PID/Program name  
tcp        0       0 prolin1:1521   prolin1:33303   ESTABLISHED  1327/oraclePROPRD1 
tcp        0       0 prolin1:1521   applin1:51324   ESTABLISHED 13827/oraclePROPRD1
tcp        0       0 prolin1:1521   prolin1:33298   ESTABLISHED  32695/tnslsnr      
tcp        0       0 prolin1:1521   prolin1:32544   ESTABLISHED  15251/oracle+ASM   
tcp        0       0 prolin1:1521   prolin1:33331   ESTABLISHED  32695/tnslsnr    
This clearly shows the process IP and the process name in the last column, which confirms it to be Oracle server processes, listener process, and ASM server processes.

The netstat command can have various options and parameters. Here are some key ones:

To find out the network statistics for various interfaces, use the -i option.

#  netstat -i
Kernel  Interface table
Iface       MTU Met    RX-OK RX-ERR RX-DRP RX-OVR    TX-OK TX-ERR TX-DRP TX-OVR Flg
eth0       1500   0  6860659      0      0      0  2055833      0      0      0 BMRU
eth8       1500   0     2345      0      0      0      833      0      0      0 BMRU
lo        16436   0 14449079      0      0      0 14449079      0      0      0 LRU
This shows the different interfaces present in the server (eth0, eth8, etc.) and the metrics associated with the interface.

RX-OK shows the number of packets successfully sent (for this interface)
RX-ERR shows number of errors
RX-DRP shows packets dropped and had to be re-sent (either successfully or not)
RX-OVR shows packets overrun
The next sets of columns (TX-OK, TX-ERR, etc.) show the corresponding stats for send data.

Flg column is a composite value of the property of the interface. Each letter indicates a specific property being present. Here is an explanation of the letters.

B – Broadcast
M – Multicast
R – Running
U – Up
O – ARP Off
P – Point to Point Connection
L – Loopback
m – Master
s – Slave

You can use the –interface (note: there are two hyphens, not one) option to display the same for a specific interface.

# netstat –interface=eth0
Kernel Interface table
Iface       MTU Met    RX-OK  RX-ERR RX-DRP RX-OVR    TX-OK TX-ERR  TX-DRP TX-OVR Flg
eth0       1500   0 277903459      0      0      0 170897632      0      0      0 BMsRU
Needless to say, the output is wide and is a little difficult to grasp at one shot. If you are comparing across interfaces, it makes sense to have a tabular output. If you want to examine the values in a more readable format, use the -e option to produce an extended output:

# netstat -i -e
Kernel Interface table
eth0      Link encap:Ethernet   HWaddr 00:13:72:CC:EB:00 
          inet addr:10.14.106.0   Bcast:10.14.107.255   Mask:255.255.252.0
          inet6 addr: fe80::213:72ff:fecc:eb00/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:6861068 errors:0 dropped:0 overruns:0 frame:0
          TX packets:2055956 errors:0 dropped:0 overruns:0  carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:3574788558 (3.3 GiB)  TX bytes:401608995 (383.0 MiB)
          Interrupt:169
Does the output seem familiar? It should; it’s the same as the output of the ifconfig.

If you’d rather see the output showing IP addresses instead of host names, use the -n option.

The -s option shows the summary statistics of each protocol, rather than showing the details of each connection. This can be combined with the protocol specific flag. For instance -u shows the stats related to the UDP protocol.

# netstat -s -u
Udp:
    12764104 packets received
    600849 packets to unknown port received.
    0 packet receive errors
    13455783 packets sent
Similarly, to see the stats for tcp, use -t and for raw, -r.

One of the really useful options is the display of the routing table, the -r option.

#  netstat -r
Kernel  IP routing table
Destination     Gateway         Genmask          Flags   MSS Window  irtt Iface
10.20.191.0     *               255.255.255.128  U         0 0          0 bond0
172.22.13.0     *               255.255.255.0    U         0 0          0 eth9
169.254.0.0     *               255.255.0.0      U         0 0          0 eth9
default         10.20.191.1     0.0.0.0          UG        0 0          0 bond0
The second column of netstat output–Gateway–shows the gateway to which the routing entry points. If no gateway is used, an asterisk is printed instead. The third column–Genmask–shows the “generality” of the route, i.e., the network mask for this route. When given an IP address to find a suitable route for, the kernel steps through each of the routing table entries, taking the bitwise AND of the address and the netmask before comparing it to the target of the route.

The fourth column, Flags, displays the following flags that describe the route:

G means the route uses a gateway.
U means the interface to be used is up (available).
H means only a single host can be reached through the route. For example, this is the case for the loopback entry 127.0.0.1.
D means this route is dynamically created.
! means the route is a reject route and data will be dropped.
The next three columns show the MSS, Window, and irtt that will be applied to TCP connections established via this route.

MSS stands for Maximum Segment Size – the size of the largest datagram for transmission via this route.
Window is the maximum amount of data the system will accept in a single burst from a remote host for this route.
irtt stands for Initial Round Trip Time. It’s a little complicated to explain. Let me explain that separately.
The TCP protocol has a built-in reliability check. If a data packet fails during transmission, it’s re-transmitted. The protocol keeps track of how long the takes for the data to reach the destination and acknowledgement to be received. If the acknowledgement does not come within that timeframe, the packet is retransmitted. The amount of time the protocol has to wait before re-transmitting is set for the interface once (which can be changed) and that value is known as initial round trip time. A value of 0 means the default value is used.

Finally, the last field displays the network interface that this route will use.

 
(Extracted from oracle technet notes author Arup Nanda)

 Comment 

ifconfig – network interfaces

on October 29, 2009 at 2:44 pm
Posted In: Resource Management (Cat)

ifconfig

The ifconfig command shows the details of the network interface(s) defined in the system.
The most common option is -a , which shows all the interfaces.

# ifconfig -a
The usual name of the primary Ethernet network interface is eth0. To find out the details of a specific interface, e.g. eth0, you can use:

# ifconfig eth0

Here are some key parts of the output:

Link encap : the type of the hardware physical medium supported by this interface (Ethernet, in this case)

HWaddr     : the unique identifier of the NIC card. Every NIC card has a unique identifier assigned by the manufacturer, called MAC or MAC address. The IP address is attached to the MAC to the server. If this IP address is changed, or this card is moved from this server to a different one, the MAC does not change.

Mask       : the netmask

inet addr  : the IP address attached to the interface

RX packets : the number of packets received by this interface

TX packets : the number of packets sent

errors     : the number of errors in sending or receiving

The command is not just used to check the settings; it’s used to configure and manage the interface as well. Here is a short list of parameters and options for this command:

up/down – enables or disables a specific interface. You can use the down parameter to shutdown an interface (or disable it):
# ifconfig eth0 down
# ifconfig eth0 up                 

media – sets the type of the Ethernet media such as 10baseT, 10 Base 2, etc. Common values for the media parameter are 10base2, 10baseT, and AUI. If you want Linux to sense the media automatically, you can specify “auto”, as shown below:
# ifconfig eth0 media auto

add – sets a specific IP address for the interface. To set an IP address of 192.168.1.101 to the interface eth0, you would issue:
# ifconfig eth0 add  192.168.1.101

netmask – sets the netmask parameter of the interface. Here is an example where you can set the netmask of the eth0 interface to 255.255.255.0
# ifconfig eth0 netmask  255.255.255.0

In an Oracle Real Application Clusters environment you have to set the netmask in a certain way, using this command.

In some advanced configurations, you can change the MAC address assigned to the network interface. The hw parameter accomplishes that. The general format is:

ifconfig hw  
The shows the type of the interface, e.g. ether, for Ethernet. Here is how the MAC address is changed for eth0 to 12.34.56.78.90.12 (Note: the MAC address shown here is fictional. If it matches any actual MAC, it’s purely coincidental.):

# ifconfig eth0 hw ether  12.34.56.78.90.12
This is useful when you add a new card (with a new MAC address) but do not want to change the Linux-related configuration such as network interfaces.

Usage for the Oracle User
The command, along with nestat described below, is one of the most widely used in managing Oracle RAC. Oracle RAC’s performance depends heavily on the interconnect used between the nodes of the cluster. If the interconnect is saturated (that is, it no longer carries any additional traffic) or is failing, you may see reduced performance. The best course of action in this case is to look at the ifconfig output to view any failures. Here is a typical example:

# ifconfig eth9
eth9      Link encap:Ethernet   HWaddr 00:1C:23:CE:6F:82 
          inet addr:10.14.104.31   Bcast:10.14.104.255   Mask:255.255.255.0
          inet6 addr: fe80::21c:23ff:fece:6f82/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST   MTU:1500  Metric:1
          RX packets:1204285416 errors:0 dropped:560923 overruns:0 frame:0
          TX packets:587443664 errors:0 dropped:623409 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:1670104239570 (1.5 TiB)  TX bytes:42726010594 (39.7 GiB)
          Interrupt:169 Memory:f8000000-f8012100

Note the text highlighted. The dropped count is extremely high; the number should ideally be 0 or close to it. A high number more than half a million sounds like a faulty interconnect that drops packets, causing the interconnect to resend packets—which should be a clue in the issue diagnosis.

 

(Extracted from oracle technet notes author Arup Nanda)

 Comment 

sar – System Activity Recorder

on October 29, 2009 at 2:39 pm
Posted In: Resource Management (Cat)

sar

From the earlier discussions, one common thread emerges: Getting real time metrics is not the only important thing; the historical trend is equally important.

Furthermore, consider this situation: how many times has someone reported a performance problem, but when you dive in to investigate, everything is back to normal? Performance issues that have occurred in the past are difficult to diagnose without any specific data as of that time. Finally, you will want to examine the performance data over the past few days to decide on some settings or to make adjustments.

The sar utility accomplishes that goal. sar stands for System Activity Recorder, which records the metrics of the key components of the Linux system—CPU, Memory, Disks, Network, etc.—in a special place: the directory /var/log/sa. The data is recorded for each day in a file named sa where is the two digit day of the month. For instance the file sa27 holds the data for the date 27th of that month. This data can be queried by the command sar.

The simplest way to use sar is to use it without any arguments or options. Here is an example:

# sar
Linux 2.6.9-55.0.9.ELlargesmp (prolin3)     12/27/2008
 
12:00:01 AM       CPU     %user     %nice   %system   %iowait     %idle
12:10:01 AM       all     14.99      0.00      1.27      2.85     80.89
12:20:01 AM       all     14.97      0.00      1.20      2.70     81.13
12:30:01 AM       all     15.80      0.00      1.39      3.00     79.81
12:40:01 AM       all     10.26      0.00      1.25      3.55     84.93
… and so on …

The output shows the CPU related metrics collected in 10 minute intervals. The columns mean:

CPU                 The CPU identifier; “all” means all the CPUs
%user              The percentage of CPU used for user processes. Oracle processes come under this category.
%nice              The %ge of CPU utilization while executing under nice priority
%system          The %age of CPU executing system processes
%iowait            The %age of CPU waiting for I/O
%idle                The %age of CPU idle waiting for work
 

From the above output, you can see that the system has been well balanced; actually severely under-utilized (as seen from the high degree of %age idle number). Going further through the output we see the following:

… continued from above …
03:00:01 AM       CPU     %user     %nice   %system   %iowait     %idle
03:10:01 AM       all     44.99      0.00      1.27      2.85     40.89
03:20:01 AM       all     44.97      0.00      1.20      2.70     41.13
03:30:01 AM       all     45.80      0.00      1.39      3.00     39.81
03:40:01 AM       all     40.26      0.00      1.25      3.55     44.93
… and so on …

This tells a different story: the system was loaded by some user processes between 3:00 and 3:40. Perhaps an expensive query was executing; or perhaps an RMAN job was running, consuming all that CPU. This is where the sar command is useful–it replays the recorded data showing the data as of a certain time, not now. This is exactly what you wanted to accomplish the three objectives outlined in the beginning of this section: getting historical data, finding usage patterns and understanding trends.

 

If you want to see a specific day’s sar data, merely open sar with that file name, using the -f option as shown below (to open the data for 26th)

# sar -f /var/log/sa/sa26

It can also display data in real time, similar to vmstat or mpstat. To get the data every 5 seconds for 10 times, use:

 

# sar 5 10

Linux 2.6.9-55.0.9.ELlargesmp (prolin3)     12/27/2008
 
01:39:16 PM       CPU     %user     %nice   %system   %iowait     %idle
01:39:21 PM       all     20.32      0.00      0.18      1.00     78.50
01:39:26 PM       all     23.28      0.00      0.20      0.45     76.08
01:39:31 PM       all     29.45      0.00      0.27      1.45     68.83
01:39:36 PM       all     16.32      0.00      0.20      1.55     81.93
… and so on 10 times …

 

Did you notice the “all” value under CPU? It means the stats were rolled up for all the CPUs. In a single processor system that is fine; but in multi-processor systems you may want to get the stats for individual CPUs as well as an aggregate one. The -P ALL option accomplishes that.

 

#sar -P ALL 2 2
Linux 2.6.9-55.0.9.ELlargesmp (prolin3)     12/27/2008
 
01:45:12 PM       CPU     %user     %nice   %system   %iowait     %idle
01:45:14 PM       all     22.31      0.00     10.19      0.69     66.81
01:45:14 PM         0      8.00      0.00     24.00      0.00     68.00
01:45:14 PM         1     99.00      0.00      1.00      0.00      0.00
01:45:14 PM         2      6.03      0.00     18.59      0.50     74.87
01:45:14 PM         3      3.50      0.00      8.50      0.00     88.00
01:45:14 PM         4      4.50      0.00     14.00      0.00     81.50
01:45:14 PM         5     54.50      0.00      6.00      0.00     39.50
01:45:14 PM         6      2.96      0.00      7.39      2.96     86.70
01:45:14 PM         7      0.50      0.00      2.00      2.00     95.50
 
01:45:14 PM       CPU     %user     %nice   %system   %iowait     %idle
01:45:16 PM       all     18.98      0.00      7.05      0.19     73.78
01:45:16 PM         0      1.00      0.00     31.00      0.00     68.00
01:45:16 PM         1     37.00      0.00      5.50      0.00     57.50
01:45:16 PM         2     13.50      0.00     19.00      0.00     67.50
01:45:16 PM         3      0.00      0.00      0.00      0.00    100.00
01:45:16 PM         4      0.00      0.00      0.50      0.00     99.50
01:45:16 PM         5     99.00      0.00      1.00      0.00      0.00
01:45:16 PM         6      0.50      0.00      0.00      0.00     99.50
01:45:16 PM         7      0.00      0.00      0.00      1.49     98.51
 
Average:          CPU     %user     %nice   %system   %iowait     %idle
Average:          all     20.64      0.00      8.62      0.44     70.30
Average:            0      4.50      0.00     27.50      0.00     68.00
Average:            1     68.00      0.00      3.25      0.00     28.75
Average:            2      9.77      0.00     18.80      0.25     71.18
Average:            3      1.75      0.00      4.25      0.00     94.00
Average:            4      2.25      0.00      7.25      0.00     90.50
Average:            5     76.81      0.00      3.49      0.00     19.70
Average:            6      1.74      0.00      3.73      1.49     93.03
Average:            7      0.25      0.00      1.00      1.75     97.01

This shows the CPU identifier (starting with 0) and the stats for each. At the very end of the output you will see the average of runs against each CPU.

 

The command sar is not only fro CPU related stats. It’s useful to get the memory related stats as well. The -r option shows the extensive memory utilization.

# sar -r
Linux 2.6.9-55.0.9.ELlargesmp (prolin3)     12/27/2008
 
12:00:01 AM kbmemfree kbmemused  %memused kbbuffers  kbcached kbswpfree kbswpused  %swpused  kbswpcad
12:10:01 AM    712264  32178920     97.83   2923884  25430452  16681300     95908      0.57       380
12:20:01 AM    659088  32232096     98.00   2923884  25430968  16681300     95908      0.57       380
12:30:01 AM    651416  32239768     98.02   2923920  25431448  16681300     95908      0.57       380
12:40:01 AM    651840  32239344     98.02   2923920  25430416  16681300     95908      0.57       380
12:50:01 AM    700696  32190488     97.87   2923920  25430416  16681300     95908      0.57       380

Let’s see what each column means:

kbmemfree                The free memory available in KB at that time
kbmemused               The memory used in KB at that time
%memused               %age of memory used
kbbuffers                   This %age of memory was used as buffers
kbcached                   This %age of memory was used as cache
kbswpfree                  The free swap space in KB at that time
kbswpused                 The swap space used in KB at that time
%swpused                 The %age of swap used at that time
kbswpcad                   The cached swap in KB at that time

At the very end of the output, you will see the average figure for time period.

 

You can also get specific memory related stats. The -B option shows the paging related activity.

# sar -B
Linux 2.6.9-55.0.9.ELlargesmp (prolin3)     12/27/2008
 
12:00:01 AM  pgpgin/s pgpgout/s   fault/s  majflt/s
12:10:01 AM    134.43    256.63   8716.33      0.00
12:20:01 AM    122.05    181.48   8652.17      0.00
12:30:01 AM    129.05    253.53   8347.93      0.00
… and so on …

The column shows metrics at that time, not currently.

pgpgin/s            The amount of paging into the memory from disk, per second
pgpgout/s          The amount of paging out to the disk from memory, per second
fault/s                 Page faults per second
majflt/s               Major page faults per second
 

To get a similar output for swapping related activity, you can use the -W option.

# sar -W
Linux 2.6.9-55.0.9.ELlargesmp (prolin3)     12/27/2008
 
12:00:01 AM  pswpin/s pswpout/s
12:10:01 AM      0.00      0.00
12:20:01 AM      0.00      0.00
12:30:01 AM      0.00      0.00
12:40:01 AM      0.00      0.00
… and so on …

The columns are probably self-explanatory; but here is the description of each anyway:

pswpin/s        Pages of memory swapped back into the memory from disk, per second
 
pswpout/s      Pages of memory swapped out to the disk from memory, per second
 

If you see a lot of swapping, you may be running low on memory. It’s not a foregone conclusion but rather something that may be a strong possibility.

To get the disk device statistics, use the -d option:

# sar -d
Linux 2.6.9-55.0.9.ELlargesmp (prolin3)     12/27/2008
 
12:00:01 AM       DEV       tps  rd_sec/s  wr_sec/s
12:10:01 AM    dev1-0      0.00      0.00      0.00
12:10:01 AM    dev1-1      5.12      0.00    219.61
12:10:01 AM    dev1-2      3.04     42.47     22.20
12:10:01 AM    dev1-3      0.18      1.68      1.41
12:10:01 AM    dev1-4      1.67     18.94     15.19
… and so on …
Average:      dev8-48      4.48    100.64     22.15
Average:      dev8-64      0.00      0.00      0.00
Average:      dev8-80      2.00     47.82      5.37
Average:      dev8-96      0.00      0.00      0.00
Average:     dev8-112      2.22     49.22     12.08

Here is the description of the columns. Again, they show the metrics at that time.

tps                         Transfers per second. Transfers are I/O operations.
                              Note: this is just number of operations; each operation may be large or small.
                              So, this, by itself, does not tell the whole story.
 
rd_sec/s                  Number of sectors read from the disk per second
 
wr_sec/s                 Number of sectors written to the disk per second
 

To get the historical network statistics, you use the -n option:

# sar -n DEV | more
Linux 2.6.9-42.0.3.ELlargesmp (prolin3)     12/27/2008
 
12:00:01 AM     IFACE   rxpck/s   txpck/s   rxbyt/s   txbyt/s   rxcmp/s   txcmp/s  rxmcst/s
12:10:01 AM        lo      4.54      4.54    782.08    782.08      0.00      0.00      0.00
12:10:01 AM      eth0      2.70      0.00    243.24      0.00      0.00      0.00      0.99
12:10:01 AM      eth1      0.00      0.00      0.00      0.00      0.00      0.00      0.00
12:10:01 AM      eth2      0.00      0.00      0.00      0.00      0.00      0.00      0.00
12:10:01 AM      eth3      0.00      0.00      0.00      0.00      0.00      0.00      0.00
12:10:01 AM      eth4    143.79    141.14  73032.72  38273.59      0.00      0.00      0.99
12:10:01 AM      eth5      0.00      0.00      0.00      0.00      0.00      0.00      0.00
12:10:01 AM      eth6      0.00      0.00      0.00      0.00      0.00      0.00      0.00
12:10:01 AM      eth7      0.00      0.00      0.00      0.00      0.00      0.00      0.00
12:10:01 AM     bond0    146.49    141.14  73275.96  38273.59      0.00      0.00      1.98
… and so on …
Average:        bond0    128.73    121.81  85529.98  27838.44      0.00      0.00      1.98
Average:         eth8      0.00      0.00      0.00      0.00      0.00      0.00      0.00
Average:         eth9      3.52      6.74    251.63  10179.83      0.00      0.00      0.00
Average:         sit0      0.00      0.00      0.00      0.00      0.00      0.00      0.00

In summary, you have these options for the sar command to get the metrics for the components:

Use this option …   … to get the stats on:
 
-P                           Specific CPU(s)
-d                           Disks
-r                            Memory
-B                           Paging
-W                          Swapping
-n                           Network

What if you want to get the all the available stats on one output? Instead of calling sar with all these options, you can use the -A option which shows all the stats stored in the sar files.

 
(Extracted from oracle technet notes author Arup Nanda)

 Comment 

iostat – i/o performance

on October 29, 2009 at 2:31 pm
Posted In: Resource Management (Cat)

iostat

A key part of the performance assessment is disk performance. The iostat command gives the performance metrics of the storage interfaces.

# iostat
Linux 2.6.9-55.0.9.ELlargesmp (prolin3)     12/27/2008
 
avg-cpu:  %user   %nice    %sys %iowait   %idle
          15.71    0.00    1.07    3.30   79.91
 
Device:            tps   Blk_read/s   Blk_wrtn/s   Blk_read   Blk_wrtn
cciss/c0d0        4.85        34.82       130.69  307949274 1155708619
cciss/c0d0p1      0.08         0.21         0.00    1897036       3659
cciss/c0d0p2     18.11        34.61       130.69  306051650 1155700792
cciss/c0d1        0.96        13.32        19.75  117780303  174676304
cciss/c0d1p1      2.67        13.32        19.75  117780007  174676288
sda               0.00         0.00         0.00        184          0
sdb               1.03         5.94        18.84   52490104  166623534
sdc               0.00         0.00         0.00        184          0
sdd               1.74        38.19        11.49  337697496  101649200
sde               0.00         0.00         0.00        184          0
sdf               1.51        34.90         6.80  308638992   60159368
sdg               0.00         0.00         0.00        184          0
… and so on …

The beginning portion of the output shows metrics such as CPU free and I/O waits as you have seen from the mpstat command.

The next part of the output shows very important metrics for each of the disk devices on the system. Let’s see what these columns mean:

Device
 The name of the device
 
tps  
 Number of transfers per second, i.e. number of I/O operations per second. Note: this is just the number of I/O operations; each operation could be huge or small.
 
Blk_read/s  
 Number of blocks read from this device per second. Blocks are usually of 512 bytes in size. This is a better value of the disk’s utilization.
 
Blk_wrtn/s  
 Number of blocks written to this device per second
 
Blk_read  
 Number of blocks read from this device so far. Be careful; this is not what is happening right now. These many blocks have already been read from the device. It’s possible that nothing is being read now. Watch this for some time to see if there is a change.
 
Blk_wrtn
 Number of blocks written to the device
 

In a system with many devices, the output might scroll through several screens—making things a little bit difficult to examine, especially if you are looking for a specific device. You can get the metrics for a specific device only by passing that device as a parameter.

# iostat sdaj  
Linux 2.6.9-55.0.9.ELlargesmp (prolin3)     12/27/2008
 
avg-cpu:  %user   %nice    %sys %iowait   %idle
          15.71    0.00    1.07    3.30   79.91
 
Device:            tps   Blk_read/s   Blk_wrtn/s   Blk_read   Blk_wrtn
sdaj              1.58        31.93        10.65  282355456   94172401

The CPU metrics shown at the beginning may not be very useful. To suppress the CPU related stats shown in the beginning of the output, use the -d option.
 
You can place optional parameters at the end to let iostat display the device stats in regular intervals. To get the stats for this device every 5 seconds for 10 times, issue the following:

# iostat -d sdaj 5 10

You can display the stats in kilobytes instead of just bytes using the -k option:

# iostat -k -d sdaj   
Linux 2.6.9-55.0.9.ELlargesmp (prolin3)     12/27/2008
 
Device:            tps    kB_read/s    kB_wrtn/s    kB_read    kB_wrtn
sdaj              1.58        15.96         5.32  141176880   47085232

While the above output can be helpful, there is lot of information not readily displayed. For instance, one of the key causes of disk issues is the disk service time, i.e. how fast the disk gets the data to the process that is asking for it. To get that level of metrics, we have to get the “extended” stats on the disk, using the -x option.

# iostat -x sdaj
Linux 2.6.9-55.0.9.ELlargesmp (prolin3)     12/27/2008
 
avg-cpu:  %user   %nice    %sys %iowait   %idle
          15.71    0.00    1.07    3.30   79.91
 
Device:    rrqm/s wrqm/s   r/s   w/s  rsec/s  wsec/s    rkB/s    wkB/s avgrq-sz avgqu-sz   await  svctm  %util
sdaj         0.00   0.00  1.07  0.51   31.93   10.65    15.96     5.32    27.01     0.01    6.26   6.00   0.95

Let’s see what the columns mean:

Device  
 The name of the device
 
rrqm/s
 The number of read requests merged per second. The disk requests are queued. Whenever possible, the kernel tries to merge several requests to one. This metric measures the merge requests for read transfers.
 
wrqm/s  
 Similar to reads, this is the number of write requests merged.
 
r/s  
 The number of read requests per second issued to this device
 
w/s 
 Likewise, the number of write requests per second
 
rsec/s 
 The number of sectors read from this device per second
 
wsec/s   
 The number of sectors written to the device per second
 
rkB/s   
 Data read per second from this device, in kilobytes per second
 
wkB/s
 Data written to this device, in kb/s
 
avgrq-sz
 Average size of the read requests, in sectors
 
avgqu-sz  
 Average length of the request queue for this device
 
await 
 Average elapsed time (in milliseconds) for the device for I/O requests. This is a sum of service time + waiting time in the queue.
 
svctm 
 Average service time (in milliseconds) of the device
 
%util
 Bandwidth utilization of the device. If this is close to 100 percent, the device is saturated.
 

Well, that’s a lot of information and may present a challenge as to how to use it effectively. The next section shows how to use the output.

How to Use It
You can use a combination of the commands to get some meaning information from the output. Remember, disks could be slow in getting the request from the processes. The amount of time the disk takes to get the data from it to the queue is called service time. If you want to find out the disks with the highest service times, you issue:

# iostat -x | sort -nrk13
sdat         0.00   0.00  0.00  0.00    0.00    0.00     0.00     0.00    18.80     0.00   64.06  64.05   0.00
sdv          0.00   0.00  0.00  0.00    0.00    0.00     0.00     0.00    17.16     0.00   18.03  17.64   0.00
sdak         0.00   0.00  0.00  0.14    0.00    1.11     0.00     0.55     8.02     0.00   17.00  17.00   0.24
sdm          0.00   0.00  0.00  0.19    0.01    1.52     0.01     0.76     8.06     0.00   16.78  16.78   0.32
… and so on …

This shows that the disk sdat has the highest service time (64.05 ms). Why is it so high? There could be many possibilities but three are most likely:

The disk gets a lot of requests so the average service time is high.
The disk is being utilized to the maximum possible bandwidth.
The disk is inherently slow.
Looking at the output we see that reads/sec and writes/sec are 0.00 (almost nothing is happening), so we can rule out #1. The utilization is also 0.00% (the last column), so we can rule out #2. That leaves #3. However, before we draw a conclusion that the disk is inherently slow, we need to observe that disk a little more closely. We can examine that disk alone every 5 seconds for 10 times.

# iostat -x sdat 5 10

If the output shows the same average service time, read rate and utilization, we can conclude that #3 is the most likely factor. If they change, then we can get further clues to understand why the service time is high for this device.

Similarly, you can sort on the read rate column to display the disk under constant read rates.

# iostat -x | sort -nrk6
sdj          0.00   0.00  1.86  0.61   56.78   12.80    28.39     6.40    28.22     0.03   10.69   9.99   2.46
sdah         0.00   0.00  1.66  0.52   50.54   10.94    25.27     5.47    28.17     0.02   10.69  10.00   2.18
sdd          0.00   0.00  1.26  0.48   38.18   11.49    19.09     5.75    28.48     0.01    3.57   3.52   0.61
… and so on …
   
The information helps you to locate a disk that is “hot”—that is, subject to a lot of reads or writes. If the disk is indeed hot, you should identify the reason for that; perhaps a filesystem defined on the disk is subject to a lot of reading. If that is the case, you should consider striping the filesystem across many disks to distribute the load, minimizing the possibility that one specific disk will be hot.

(Extracted from oracle technet notes author Arup Nanda)

 Comment 

mpstat – processor status

on October 29, 2009 at 2:28 pm
Posted In: Resource Management (Cat)

MPSTAT

Another useful command to get CPU related stats is mpstat. Here is an example output:

# mpstat -P ALL 5 2
Linux 2.6.9-67.ELsmp (oraclerac1)       12/20/2008
 
10:42:38 PM  CPU   %user   %nice %system %iowait    %irq   %soft   %idle    intr/s
10:42:43 PM  all    6.89    0.00   44.76    0.10    0.10    0.10   48.05   1121.60
10:42:43 PM    0    9.20    0.00   49.00    0.00    0.00    0.20   41.60    413.00
10:42:43 PM    1    4.60    0.00   40.60    0.00    0.20    0.20   54.60    708.40
 
10:42:43 PM  CPU   %user   %nice %system %iowait    %irq   %soft   %idle    intr/s
10:42:48 PM  all    7.60    0.00   45.30    0.30    0.00    0.10   46.70   1195.01
10:42:48 PM    0    4.19    0.00    2.20    0.40    0.00    0.00   93.21   1034.53
10:42:48 PM    1   10.78    0.00   88.22    0.40    0.00    0.00    0.20    160.48
 
Average:     CPU   %user   %nice %system %iowait    %irq   %soft   %idle    intr/s
Average:     all    7.25    0.00   45.03    0.20    0.05    0.10   47.38   1158.34
Average:       0    6.69    0.00   25.57    0.20    0.00    0.10   67.43    724.08
Average:       1    7.69    0.00   64.44    0.20    0.10    0.10   27.37    434.17

It shows the various stats for the CPUs in the system. The –P ALL options directs the command to display stats for all the CPUs, not just a specific one. The parameters 5 2 directs the command to run every 5 seconds and for 2 times. The above output shows the metrics for all the CPUs first (aggregated) and for each CPU individually. Finally, the average for all the CPUs has been shown at the end.

Let’s see what the column values mean:

 

%user
 Indicates the percentage of the processing for that CPU consumes by user processes. User processes are non-kernel processes used for applications such as an Oracle database. In this example output, the user CPU %age is very little.
 

%nice
 Indicates the percentage of CPU when a process was downgraded by nice command. The command nice has been described in an earlier installment. It brief, the command nice changes the priority of a process.
 
%system
 Indicates the CPU percentage consumed by kernel processes
 
%iowait
 Shows the percentage of CPU time consumed by waiting for an I/O to occur
 
%irq
 Indicates the %age of CPU used to handle system interrupts
 
%soft
 Indicates %age consumed for software interrupts
 
%idle
 Shows the idle time of the CPU
 
%intr/s
 Shows the total number of interrupts received by the CPU per second
 

You may be wondering about the purpose of the mpstat command when you have vmstat, described earlier.

There is a huge difference:

mpstat can show the per processor stats, whereas vmstat shows a consolidated view of all processors.

So, it’s possible that a poorly written application not using multi-threaded architecture runs on a multi-processor machine but does not use all the processors. As a result, one CPU overloads while others remain free. You can easily diagnose these sorts of issues via mpstat.

 

Usage for Oracle Users
Similar to vmstat, the mpstat command also produces CPU related stats so all the discussion related to CPU issues applies to mpstat as well. When you see a low %idle figure, you know you have CPU starvation. When you see a higher %iowait figure, you know there is some issue with the I/O subsystem under the current load. This information comes in very handy in troubleshooting Oracle database performance.

 
(Extracted from oracle technet notes author Arup Nanda)

 Comment 

vmstat – virtual memory

on October 29, 2009 at 2:25 pm
Posted In: Resource Management (Cat)

vmstat

When called, the grand-daddy of all memory and process related displays, vmstat, continuously runs and posts its information. It takes two arguments:

# vmstat
is the interval in seconds between two runs. is the number of repetitions vmstat makes. Here is a sample when we want vmstat to run every five seconds and stop after the tenth run. Every line in the output comes after five seconds and shows the stats at that time.

# vmstat 5 10

 procs ———–memory———- —swap– —–io—- –system– —-cpu—-
 r  b    swpd   free   buff  cache   si   so    bi    bo   in    cs us sy id wa
 0  0 1087032 132500  15260 622488   89   19     9     3    0     0  4 10 82  5
 0  0 1087032 132500  15284 622464    0    0   230   151 1095   858  1  0 98  1
 0  0 1087032 132484  15300 622448    0    0   317    79 1088   905  1  0 98  0
… shows up to 10 times.

The output shows a lot about the system resources. Let’s examine them in detail:

procs
 Shows the number of processes
 
r
 Processs waiting to be run. The more the load on the system, the more the number of processes waiting to get CPU cycles to run.
 
b
 Uninterruptible sleeping processes, also known as “blocked” processes. These processes are most likely waiting for I/O but could be for something else too.
 

Sometimes there is another column as well, under heading “w”, which shows the number of processes that can be run but have been swapped out to the swap area.

The numbers under “b” should be close to 0. If the number under “w” is high, you may need more memory.

The next block shows memory metrics:

swpd
 Amount of virtual memory or swapped memory (in KB)
 
free
 Amount of free physical memory (in KB)
 
buff
 Amount of memory used as buffers (in KB)
 
cache
 Kilobytes of physical memory used as cache
 

The buffer memory is used to store file metadata such as i-nodes and data from raw block devices. The cache memory is used for file data itself.

The next block shows swap activity:

si
 Rate at which the memory is swapped back from the disk to the physical RAM (in KB/sec)
 
so
 Rate at which the memory is swapped out to the disk from physical RAM (in KB/sec)
 

The next block slows I/O activity:

bi
 Rate at which the system sends data to the block devices (in blocks/sec)
 
bo
 Rate at which the system reads the data from block devices (in blocks/sec)
 

The next block shows system related activities:

in
 Number of interrupts received by the system per second
 
cs
 Rate of context switching in the process space (in number/sec)
 

The final block is probably the most used – the information on CPU load:

us
 Shows the percentage of CPU spent in user processes. The Oracle processes come in this category.
 
sy
 Percentage of CPU used by system processes, such as all root processes
 
id
 Percentage of free CPU
 
wa
 Percentage spent in “waiting for I/O”
 

Let’s see how to interpret these values. The first line of the output is an average of all the metrics since the system was restarted. So, ignore that line since it does not show the current status. The other lines show the metrics in real time.

Ideally, the number of processes waiting or blocking (under the “procs” heading) should be 0 or close to 0. If they are high, then the system either does not have enough resources like CPU, memory, or I/O. This information comes useful while diagnosing performance issues.

The data under “swap” indicates if excessive swapping is going on. If that is the case, then you may have inadequate physical memory. You should either reduce the memory demand or increase the physical RAM.

The data under “io” indicates the flow of data to and from the disks. This shows how much disk activity is going on, which does not necessarily indicate some problem. If you see some large number under “proc” and then “b” column (processes being blocked) and high I/O, the issue could be a severe I/O contention.

The most useful information comes under the “cpu” heading. The “id” column shows idle CPU. If you subtract that number from 100, you get how much percent the CPU is busy. Remember the top command described in another installment of this series? That also shows a CPU free% number. The difference is: top shows that free% for each CPU whereas vmstat shows the consolidated view for all CPUs.

The vmstat command also shows the breakdown of CPU usage: how much is used by the Linux system, how much by a user process, and how much on waiting for I/O. From this breakdown you can determine what is contributing to CPU consumption. If system CPU load is high, could there be some root process such as backup running?

The system load should be consistent over a period of time. If the system shows a high number, use the top command to identify the system process consuming CPU.

Usage for Oracle Users
Oracle processes (the background processes and server processes) and the user processes (sqlplus, apache, etc.) come under “us”. If this number is high, use top to identify the processes. If the “wa” column shows a high number, it indicates the I/O system is unable to catch up with the amount of reading or writing. This could occasionally shoot up as a result of spikes in heavy updates in the database causing log switch and a subsequent spike in archiving processes. But if it consistently shows a large number, then you may have an I/O bottleneck.

I/O blockages in an Oracle database can cause serious problems. Apart from performance issues, the slow I/O could cause controlfile writes to be slow, which may cause a process to wait to acquire a controlfile enqueue. If the wait is more that 900 seconds, and the waiter is a critical process like LGWR, it brings down the database instance.

If you see a lot of swapping, perhaps the SGA is sized too large to fit in the physical memory. You should either reduce the SGA size or increase the physical memory.

 

(Extracted from oracle technet notes author Arup Nanda) 

 Comment 

ipcrm – ipc remove

on October 29, 2009 at 2:23 pm
Posted In: Resource Management (Cat)

ipcrm

Now that you identified the shared memory and other IPC metrics, what do you do with them? You saw some usage earlier, such as identifying the shared memory used by Oracle, making sure the kernel parameter for shared memory is set, and so on. Another common application is to remove the shared memory, the IPC message queue, or the semaphore arrays.

To remove a shared memory segment, note its shmid from the ipcs command output. Then use the –m option to remove the segment. To remove segment with ID 3735562, use:

# ipcrm –m 3735562

This will remove the shared memory. You can also use this to kill semaphores and IPC message queues as well (using –s and –q parameters).

Usage for Oracle Users
Sometimes when you shutdown the database instance, the shared memory segments may not be completely cleaned up by the Linux kernel. The shared memory left behind is not useful; but it hogs the system resources making less memory available to the other processes. In that case, you can check any lingering shared memory segments owned by the “oracle” user and then remove them, if any using the ipcrm command.

 
(Extracted from oracle technet notes author Arup Nanda)

 Comment 

ipcs – inter process communication semaphores

on October 29, 2009 at 2:20 pm
Posted In: Resource Management (Cat)

When a process runs, it grabs from the “shared memory”. There could be one or many shared memory segments by this process. The processes send messages to each other (“inter-process communication”, or IPC) and use semaphores. To display information about shared memory segments, IPC message queues, and semaphores, you can use a single command: ipcs.

The –m option is very popular; it displays the shared memory segments.

# ipcs -m
 
—— Shared Memory Segments ——–
key        shmid      owner      perms      bytes      nattch     status     
0xc4145514 2031618    oracle    660        4096       0                      
0x00000000 3670019    oracle    660        8388608    108                    
0x00000000 327684     oracle    600        196608     2          dest        
0x00000000 360453     oracle    600        196608     2          dest        
0x00000000 393222     oracle    600        196608     2          dest        
0x00000000 425991     oracle    600        196608     2          dest        
0x00000000 3702792    oracle    660        926941184  108                    
0x00000000 491529     oracle    600        196608     2          dest        
0x49d1a288 3735562    oracle    660        140509184  108                    
0x00000000 557067     oracle    600        196608     2          dest        
0x00000000 1081356    oracle    600        196608     2          dest        
0x00000000 983053     oracle    600        196608     2          dest        
0x00000000 1835023    oracle    600        196608     2          dest        

This output, taken on a server running Oracle software, shows the various shared memory segments. Each one is uniquely identified by a shared memory ID, shown under the “shmid” column. (Later you will see how to use this column value.) The “owner”, of course, shows the owner of the segment, the “perms” column shows the permissions (same as unix permissions), and “bytes” shows the size in bytes.

The -u option shows a very quick summary:

# ipcs -mu

—— Shared Memory Status ——–
segments allocated 25
pages allocated 264305
pages resident  101682
pages swapped   100667
Swap performance: 0 attempts     0 successes

The –l option shows the limits (as opposed to the current values):

# ipcs -ml
 
—— Shared Memory Limits ——–
max number of segments = 4096
max seg size (kbytes) = 907290
max total shared memory (kbytes) = 13115392
min seg size (bytes) = 1

If you see the current values at or close the limit values, you should consider upping the limit.

You can get a detailed picture of a specific shared memory segment using the shmid value. The –i option accomplishes that. Here is how you will see details of the shmid 3702792:

# ipcs -m -i 3702792
 
Shared memory Segment shmid=3702792
uid=500 gid=502 cuid=500        cgid=502
mode=0660       access_perms=0660
bytes=926941184 lpid=12225      cpid=27169      nattch=113
att_time=Fri Dec 19 23:34:10 2008 
det_time=Fri Dec 19 23:34:10 2008 
change_time=Sun Dec  7 05:03:10 2008   

Later you will an example of how you to interpret the above output.

The -s shows the semaphores in the system:

# ipcs -s
 
—— Semaphore Arrays ——–
key        semid      owner      perms      nsems    
0x313f2eb8 1146880    oracle    660        104      
0x0b776504 2326529    oracle    660        154    
… and so on … 

This shows some valuable data. It shows the semaphore array with the ID 1146880 has 104 semaphores, and the other one has 154. If you add them up, the total value has to be below the maximum limit defined by the kernel parameter (semmax). While installing Oracle Database software, the pre-install checker has a check for the setting for semmax. Later, when the system attains steady state, you can check for the actual utilization and then adjust the kernel value accordingly.

Usage for Oracle Users
How can you find out the shared memory segments used by the Oracle Database instance? To get that, use the oradebug command. First connect to the database as sysdba:

# sqlplus / as sysdba

In the SQL, use the oradebug command as shown below:

SQL> oradebug setmypid
Statement processed.
SQL> oradebug ipc
Information written to trace file.

To find out the name of the trace file:

SQL> oradebug TRACEFILE_NAME
/opt/oracle/diag/rdbms/odba112/ODBA112/trace/ODBA112_ora_22544.trc

Now, if you open that trace file, you will see the shared memory IDs. Here is an excerpt from the file:

Area #0 `Fixed Size’ containing Subareas 0-0
  Total size 000000000014613c Minimum Subarea size 00000000
   Area  Subarea    Shmid      Stable Addr      Actual Addr
      0        0 17235970 0x00000020000000 0x00000020000000
                              Subarea size     Segment size
                          0000000000147000 000000002c600000
 Area #1 `Variable Size’ containing Subareas 4-4
  Total size 000000002bc00000 Minimum Subarea size 00400000
   Area  Subarea    Shmid      Stable Addr      Actual Addr
      1        4 17235970 0x00000020800000 0x00000020800000
                              Subarea size     Segment size
                          000000002bc00000 000000002c600000
 Area #2 `Redo Buffers’ containing Subareas 1-1
  Total size 0000000000522000 Minimum Subarea size 00000000
   Area  Subarea    Shmid      Stable Addr      Actual Addr
      2        1 17235970 0x00000020147000 0x00000020147000
                              Subarea size     Segment size
                          0000000000522000 000000002c600000
… and so on …

The shared memory id has been shown in bold red. You can use this shared memory ID to get the details of the shared memory:

# ipcs -m -i 17235970

Another useful observation is the value of lpid – the process ID of the process that last touched the shared memory segment. To demonstrate the value in that attribute, use SQL*Plus to connect to the instance from a different session.

# sqlplus / as sysdba

In that session, find out the PID of the server process:

SQL> select spid from v$process
  2  where addr = (select paddr from v$session
  3     where sid =
  4        (select sid from v$mystat where rownum   5  );
 
SPID
————————
13224

Now re-execute the ipcs command against the same shared memory segment:

# ipcs -m -i 17235970
 
Shared memory Segment shmid=17235970
uid=500 gid=502 cuid=500        cgid=502
mode=0660       access_perms=0660
bytes=140509184 lpid=13224      cpid=27169      nattch=113
att_time=Fri Dec 19 23:38:09 2008 
det_time=Fri Dec 19 23:38:09 2008 
change_time=Sun Dec  7 05:03:10 2008

Note the value of lpid, which was changed to 13224, from the original value 12225. The lpid shows the PID of the last process that touched the shared memory segment, and you saw how that value changes.

The command by itself provides little value. The next command – ipcrm – allows you to act based on the output, as you will see in the next section.

 
(Extracted from oracle technet notes author Arup Nanda)

 Comment 

free – free memory in megabytes

on October 29, 2009 at 2:18 pm
Posted In: Resource Management (Cat)

One common question is, “How much memory is being used by my applications and various server, user, and system processes?” Or, “How much memory is free right now?” If the memory used by the running processes is more than the available RAM, the processes are moved to swap. So an ancillary question is, “How much swap is being used?”

The free command answers all those questions. What’s more, a very useful option, –m , shows free memory in megabytes:

# free -m
             total       used       free     shared    buffers     cached
Mem:          1772       1654        117          0         18        618
-/+ buffers/cache:       1017        754
Swap:         1983       1065        918

The above output shows that the system has 1,772 MB of RAM, of which 1,654 MB is being used, leaving 117 MB of free memory.  The second line shows the buffers and cache size changes in the physical memory. The third line shows swap utilization.

To show the same in kilobytes and gigabytes, replace the -m option with -k or -g respectively. You can get down to byte level as well, using the –b option.

# free -b
             total       used       free     shared    buffers     cached
Mem:    1858129920 1724039168  134090752          0   18640896  643194880
-/+ buffers/cache: 1062203392  795926528
Swap:   2080366592 1116721152  963645440

The –t option shows the total at the bottom of the output (sum of physical memory and swap):

# free -m -t
             total       used       free     shared    buffers     cached
Mem:          1772       1644        127          0         16        613
-/+ buffers/cache:       1014        757
Swap:         1983       1065        918
Total:        3756       2709       1046

Although free does not show the percentages, we can extract and format specific parts of the output to show used memory as a percentage of the total only:

# free -m | grep Mem | awk ‘{print ($3 / $2)*100}’
98.7077

This comes handy in shell scripts where the specific numbers are important. For instance, you may want to trigger an alert when the percentage of free memory falls below a certain threshold.

Similarly, to find the percentage of swap used, you can issue:

free -m | grep -i Swap | awk ‘{print ($3 / $2)*100}’
You can use free to watch the memory load exerted by an application. For instance, check the free memory before starting the backup application and then check it immediately after starting. The difference could be attributed to the consumption by the backup application.

Usage for Oracle Users
So, how can you use this command to manage the Linux server running your Oracle environment? One of the most common causes of performance issues is the lack of memory, causing the system to “swap” memory areas into the disk temporarily. Some degree of swapping is probably inevitable but a lot of swapping is indicative of lack of free memory.

Instead, you can use free to get the free memory information now and follow it up with the sar command (shown later) to check the historical trend of the memory and swap consumption. If the swap usage is temporary, it’s probably a one-time spike; but if it’s a pronounced over a period of time, you should take notice. There are a few obvious and possible suspects of chronic memory overloads:

A large SGA that is more that memory available
Very large allocation on PGA
Some process with bugs that leaks memory
For the first case, you should make sure SGA is less that available memory. A general rule of thumb is to use about 40 percent of the physical memory for SGA, but of course you should define that parameter based on your specific situation. In the second case, you should try to reduce the large buffer allocation in queries. In the third case you should use the ps command (described in an earlier installment of this series) to identify the specific process that might be leaking memory.

(Extracted from oracle technet notes author Arup Nanda)

 Comment 

top

on October 29, 2009 at 2:14 pm
Posted In: Resource Management (Cat)

top
==

uptime
top
top -l

$ top

18:46:13  up 11 days, 21:50,  5 users,  load average: 0.11, 0.19, 0.18
151 processes: 147 sleeping, 4 running, 0 zombie, 0 stopped
CPU states:  cpu    user    nice  system    irq  softirq  iowait    idle
           total   12.5%    0.0%    6.7%   0.0%     0.0%    5.3%   75.2%
Mem:  1026912k av,  999548k used,   27364k free,       0k shrd,  116104k buff
                    758312k actv,  145904k in_d,   16192k in_c
Swap: 2041192k av,  122224k used, 1918968k free                  590140k cached
 
  PID USER     PRI  NI  SIZE  RSS SHARE STAT %CPU %MEM   TIME CPU COMMAND
  451 oracle    15   0  6044 4928  4216 S     0.1  0.4   0:20   0 tnslsnr
 8991 oracle    15   0  1248 1248   896 R     0.1  0.1   0:00   0 top
    1 root      19   0   440  400   372 S     0.0  0.0   0:04   0 init
    2 root      15   0     0    0     0 SW    0.0  0.0   0:00   0 keventd
    3 root      15   0     0    0     0 SW    0.0  0.0   0:00   0 kapmd
    4 root      34  19     0    0     0 SWN   0.0  0.0   0:00   0 ksoftirqd/0
    7 root      15   0     0    0     0 SW    0.0  0.0   0:01   0 bdflush
    5 root      15   0     0    0     0 SW    0.0  0.0   0:33   0 kswapd
    6 root      15   0     0    0     0 SW    0.0  0.0   0:14   0 kscand
    8 root      15   0     0    0     0 SW    0.0  0.0   0:00   0 kupdated
    9 root      25   0     0    0     0 SW    0.0  0.0   0:00   0 mdrecoveryd
… output snipped …

Let’s examine the different types of information produced. The first line:

18:46:13  up 11 days, 21:50,  5 users,  load average: 0.11, 0.19, 0.18

shows the current time (18:46:13), that system has been up for 11 days; that the system has been working for 21 hours 50 seconds. The load average of the system is shown (0.11, 0.19, 0.18) for the last 1, 5 and 15 minutes respectively. (By the way, you can also get this information by issuing the uptime command.)

If the load average is not required, press the letter “l” (lowercase L); it will turn it off. To turn it back on press l again. The second line:

151 processes: 147 sleeping, 4 running, 0 zombie, 0 stopped

shows the number of processes, running, sleeping, etc. The third and fourth lines:

CPU states:  cpu    user    nice  system    irq  softirq  iowait    idle
           total   12.5%    0.0%    6.7%   0.0%     0.0%    5.3%   75.2%

show the CPU utilization details. The above line shows that user processes consume 12.5% and system consumes 6.7%. The user processes include the Oracle processes. Press “t” to turn these three lines off and on. If there are more than one CPU, you will see one line per CPU.

The next two lines:

Mem:  1026912k av, 1000688k used,  26224k free,    0k shrd,  113624k buff
                    758668k actv,  146872k in_d,  14460k in_c
Swap: 2041192k av, 122476k used,   1918716k free             591776k cached

show the memory available and utilized. Total memory is “1026912k av”, approximately 1GB, of which only 26224k or 26MB is free. The swap space is 2GB; but it’s almost not used. To turn it off and on, press “m”.

The rest of the display shows the processes in a tabular format. Here is the explanation of the columns:

Column
 Description
 
PID The process ID of the process
USER
 The user running the process
PRI
 The priority of the process
NI The nice value: The higher the value, the lower the priority of the task
SIZE
 Memory used by this process (code+data+stack)
RSS
 The physical memory used by this process
SHARE
 The shared memory used by this process
STAT
 The status of this process, shown in code. Some major status codes are:
R – Running
S –Sleeping
Z – Zombie
T – Stopped

You can also see second and third characters, which indicate:
W – Swapped out process
N – positive nice value 
%CPU
 The percentage of CPU used by this process
%MEM
 The percentage of memory used by this process
TIME
 The total CPU time used by this process
CPU
 If this is a multi-processor system, this column indicates the ID of the CPU this process is running on.
COMMAND The command issued by this process

While the top is being displayed, you can press a few keys to format the display as you like. Pressing the uppercase M key sorts the output by memory usage. (Note that using lowercase m will turn the memory summary lines on or off at the top of the display.) This is very useful when you want to find out who is consuming the memory. Here is sample output:

PID USER     PRI  NI  SIZE  RSS SHARE STAT %CPU %MEM   TIME CPU COMMAND
31903 oracle    15   0 75760  72M 72508 S     0.0  7.2   0:01   0 ora_smon_PRODB2
31909 oracle    15   0 68944  66M 64572 S     0.0  6.6   0:03   0 ora_mmon_PRODB2
31897 oracle    15   0 53788  49M 48652 S     0.0  4.9   0:00   0 ora_dbw0_PRODB2

Now that you learned how to interpret the output, let’s see how to use command line parameters.

The most useful is -d, which indicates the delay between the screen refreshes. To refresh every second, use top -d 1.

The other useful option is -p. If you want to monitor only a few processes, not all, you can specify only those after the -p option. To monitor processes 13609, 13608 and 13554, issue:

top -p 13609 -p 13608 -p 13554

This will show results in the same format as the top command, but only those specific processes.

e.g.
===
20:51:14  up 11 days, 23:55,  4 users,  load average: 0.88, 0.39, 0.27
113 processes: 110 sleeping, 2 running, 1 zombie, 0 stopped
CPU states:  cpu    user    nice  system    irq  softirq  iowait    idle
           total    1.0%    0.0%    5.6%   2.2%     0.0%   91.2%    0.0%
Mem:  1026912k av, 1008832k used,   18080k free,       0k shrd,   30064k buff
                    771512k actv,  141348k in_d,   13308k in_c
Swap: 2041192k av,   66776k used, 1974416k free                  812652k cached
 
  PID USER     PRI  NI  SIZE  RSS SHARE STAT %CPU %MEM   TIME CPU COMMAND
16143 oracle    15   0 39280  32M 26608 D     4.0  3.2   0:02   0 oraclePRODB2…
    5 root      15   0     0    0     0 SW    1.6  0.0   0:33   0 kswapd
… output snipped …

Let’s analyze the output carefully. The first thing you should notice is the “idle” column under CPU states; it’s 0.0%—meaning, the CPU is completely occupied doing something. The question is, doing what? Move your attention to the column “system”, just slightly left; it shows 5.6%. So the system itself is not doing much. Go even more left to the column marked “user”, which shows 1.0%. Since user processes include Oracle as well, Oracle is not consuming the CPU cycles. So, what’s eating up all the CPU?

The answer lies in the same line, just to the right under the column “iowait”, which indicates 91.2%. This explains it all: the CPU is waiting for IO 91.2% of the time.

So why so much IO wait? The answer lies in the display. Note the PID of the highest consuming process: 16143. You can use the following query to determine what the process is doing:

select s.sid, s.username, s.program
from v$session s, v$process p
where spid = 16143
and p.addr = s.paddr
/

       SID USERNAME PROGRAM
——————- —————————–
       159 SYS      rman@prolin2 (TNS V1-V3) 

The rman process is taking up the IO waits related CPU cycles. This information helps you determine the next course of action.

 

(Extracted from oracle technet notes author Arup Nanda)

 Comment 

alias, ls, xargs, rename, find, m4, whence and which, snice, skill

on October 29, 2009 at 12:33 pm
Posted In: Unix notes (Cat)

alias
===
alias os=’echo $ORACLE_HOME’
alias rm=’rm -i’
to use rm as is normally defined use:
 ”rm a.a # two single quotes OR
 \rm
unalias rm

ls
=
ls -F          # dir1/ file1 link1@ pipe1|
ls -d or ls -1 or ls -1d
ls -h          # size
ls -1S        # largest to smallest

xargs
===
use xargcs to execute commands
wc -l `file * | grep ASCII | cut -d”:” -f1 | grep ASCII | cut -d”:” -f1`
same as
file * | grep ASCII | cut -d”:” -f1 | xargs wc -l

ls | xargs -t -i mv {} {}.bak                             # rename all files in a directory, 
                                                                  # -t=print command before executing,
                                                                  #  -i=replace {} with the item name.
file * | grep ASCII | cut -d”:” -f1 | xargs vi         # opens files one by one for editing
file * | grep ASCII | cut -d”:” -f1 | xargs -p vi     # -p confirm before rrunning each command

file * | grep SSSSS | cut -d”:” -f1 | xargs -t -r wc -l   # -r stops the command if nothing to execute
file * | grep a | cut -d”:” -f1 | xargs -t -r -n2 wc -l   # -n2 stops the command after executing with 2 inputs (even if there are > 2)

rename
====
rename .log .log.`date +%F-%H:%M:%S` *

find
===
find . -name “file*”
find . -iname “file*”                           # -i case insensitive
find . -name “orapw*” -type f             # regular files are type f

find . -name “*oraenv*” -type f -exec file {} \;

find . -name “sqlplus*” -ok {} \;

find . -name “*.trc” -ctime +3 -exec rm {} \;
find . -name “*.trc” -ctime +3 -exec rm -f {} \;
find . -name “*.trc” -ctime +3 -exec ls -l {} \;

m4
==
$cat temp
the COLOR fox jumped over the TYPE fence.
$m4 -DCOLOR=brown -DTYPE=broken temp
$cat temp
the brown fox jumped over the broken fence.

whence and which
===========
which sqlplus                                       # serches PATH for the image and prints the first path or an error
whence sqlplus                                    # serches PATH for the image and prints the first path or does nothing
which -i ls                                            # also displays alias if found
which -a sqlplus                                   # serches PATH for the image and prints all paths found

e.g.
RC=`whence myexec`
If [ $RC -ne “0” ]; then
  echo “myexec is not in the $PATH”
fi

skill snice
======
skill -STOP 16514                      # freeze the process
skill -STOP oracle                       # freeze all oracle user processes
skill -STOP rman                        # freeze all rman processes
skill -STOP -c oracle                    # freeze all commands called oracle
skill -CONT 16514                      # restart process 16514
snice +4 -u oracle                      # drop priority of processes of “oracle” by four points. (higher number, lower priority)

 Comment 

–reference, stat, file, diff, comp, cmp, md5sum

on October 29, 2009 at 12:26 pm
Posted In: Unix notes (Cat)

–reference
=======
$chmod –reference file1 file2
$chgrp  –reference file1 file2
$chown  –reference file1 file2

stat command – to find out about the extended attributes of a file
=========
$cd $ORACLE_HOME/bin
$stat oracle                 # shows size and access/modify/change dates for a file
$stat -f oracle              # shows info on the file system
$stat -t oracle              # shows filesystem info but on one line

“relink utilities” will relink all oracle utilities, saving old version with an “O” at the end of the filename.

file command – to find out about the type of file
========
$file a.a                       # tells you what the file type is
e.g.
file a.log
  a.log: ASCII text
file a.Z
 a.Z: compress’d data 16 bits
file -z a.Z
 a.Z: ASCII text (compress’d data 16 bits)
file spfile+ASM.ora.ORIGINAL
 spfile+ASM.ora.ORIGINAL: symbolic link to
 /u01/app/oracle/admin/DBA102/pfile/spfile+ASM.ora.ORIGINAL
file -L spfile+ASM.ora.ORIGINAL
 spfile+ASM.ora.ORIGINAL: data

This file checks the ASCII files, even if they are compressed, and lists them in chronological order
$file -Lz * | grep ASCII | cut -d”:” -f1 | xargs ls -ltr

diff – to see the differences between files
==
diff file1 file2                      # the output (like 1d0) is what must be done in sed to make the files the same.
diff -y file1 file2 -W 120        # -y for side by side, W 120 for use 120 char wide screen
diff -q file1 files                   # just to see if the files differ but don’t actually show the differences
diff -u file1 file2                  # gives output in a formated version
diff dir1 dir2                       # diff can be used on directories
diff -r dir1 dir2                    # diff can be used on directories, -r to go down directories
diff -r dir1 dir2 | grep -v Common

cmp – to compare two files
===
cmp -s file1 file2; echo $?     # output 0=same, 1=different
cmp sqlplus sqlplusO
 sqlplus sqlplusO differ: byte 657, line 7   # even though the files are the same size

comm – to see whats common between two files in 3 columns
====
comm file1 file2
comm -1 file1 file2               # supresses the info in file 1 only

md5sum
=====
md5sum file1
md5sum file1 file2 > f1f2
md5sum –check f1f2          # checks that file1 and file2 haven’t been changed (against the sum generated in the previos command)

 Comment 

Windows keys

on October 29, 2009 at 10:55 am
Posted In: Oracle odds and ends (Cat)

EADS – DEV Win XP PRO KYKVX-86GQG-2MDY9-F6J9M-K42BQ

PRODUCT ID 76487-OEM-0011903-00101

MS Office ENTERPRISE 2007 ?????

EADS – laptop Win XP PRO CRH4Y-9PTBQ-GXK3D-CDB7J-6BJRG

PRODUCT ID 76487-641-2798144-23851

MS Office Professional Edition 2003 (laptop) TR94J-94XQR-KW7K4-GYXW3-WG6BB

 Comment 

cifs mount command examples

on October 29, 2009 at 10:54 am
Posted In: Configuration (Cat)

ROOT

create file /etc/shells

create a line /usr/local/bin/bash

ORACLE

chsh /usr/local/bin/bash

create/edit .bash_profile to execute “eval $(/sbin/ttytype -s -a)

Change putty to send Control H for erase.

cifsclient start

/opt/cifsclient/bin/cifsclient

 

cifsmount -U Windows_server/Username -P Password //1.2.3.4/D/repo /download/repo

mount -F cifs 1.2.3.4:repo$ /download/repo

cifsmount -U “Windows_server/Username” -P Password 1.2.3.4:repo$ /download/repo

swinstall -s /download/file.depot

 Comment 

OEM – change agent timezone

on October 29, 2009 at 10:51 am
Posted In: Oracle odds and ends (Cat)

SQL> exec mgmt_target.set_agent_tzrgn(‘dev3orc01.fcdev.local:1831′,’Europe/Jersey’)

SQL> commit

 Comment 

OEM – rebuild sys_alert queue

on October 29, 2009 at 10:49 am
Posted In: Oracle odds and ends (Cat)

Subject:  How to recreate the SYS.ALERT_QUE
  Doc ID:  430146.1 Type:  HOWTO
  Modified Date :  15-MAY-2009 Status:  PUBLISHED

Applies to:
Oracle Server – Enterprise Edition – Version: 10.2.0.1.0 to 10.2.0.4.0
Information in this document applies to any platform.

Goal
The purpose of this article is to outline the steps for recreating the SYS.ALERT_QUE

The ALERT_QUE is used by the Grid Control and DB Control Management Agents to monitor server-generated alerts

 

NOTE: By running the script below, the queue tables will be recreated and the messages in the queue
will be lost

Solution
SQL> connect / as sysdba

SQL>alter system enable restricted session;

To drop server alert schema.

SQL>@$ORACLE_HOME/rdbms/admin/catnoalr.sql

To re-create tables, sequence, type and queue for server alert

SQL>@$ORACLE_HOME/rdbms/admin/dbmsslrt.sql
SQL>@$ORACLE_HOME/rdbms/admin/catalrt.sql

To recompile the invalid objects

SQL>@$ORACLE_HOME/rdbms/admin/utlrp.sql

SQL> alter system disable restricted session;

OR

SQL> connect / as sysdba

SQL>alter system enable restricted session;

To drop server alert schema.

SQL>@$ORACLE_HOME/rdbms/admin/catnoalr.sql

Rerun catproc.sql

SQL>@$ORACLE_HOME/rdbms/admin/catproc.sql

SQL> alter system disable restricted session;
 

 Comment 

Logical Volume Commands

on October 29, 2009 at 10:45 am
Posted In: Configuration (Cat)

mkfs -t ext3 -c /dev/mapper/SDAp1

mkfs -t ext3 -c /dev/mapper/SDBp1

pvcreate /dev/mapper/SDAp1

pvcreate /dev/mapper/SDBp1

vgextend VolGroup00 /dev/mapper/SDAp1

vgextend VolGroup00 /dev/mapper/SDBp1

lvcreate -l4 -nLogVol02 VolGroup00

 Comment 

ssh configuration

on October 29, 2009 at 10:19 am
Posted In: Configuration (Cat)

ON EACH HOST:
Log in as oracle

$ ssh-keygen –t rsa
$cd .ssh
$cat id_rsa.pub > authorized_keys
$chmod 600 *

Then concatenate all the authorized_keys files into one file of the same name and ensure this is on all the hosts in the .ssh directory with protection of 600.

ON EACH HOST:
Enter the following command changing the hostname to each hostname in the cluster and then changing the hostname to each fully qualified hostname in the cluster.

   $ ssh hostname date
   $ ssh hostname.domainname date

e.g.
n.b. none of these commands should request a password.

 $ssh hostname date
 $ssh hostname.domain date

 Comment 

Map asm devices using oracleasm

on October 29, 2009 at 10:17 am
Posted In: Oracle RAC (Cat)

For each of the asm volumes execute the command:
/etc/init.d/oracleasm createdisk ASMn /dev/mapper/ASMnp1

Replacing the “n” with the relevant numbers.

N.B. It is important that the mapping is made to the partion space (e.g. asm1p1) and NOT asm1 for the multipath devices as this would overwrite the volume header and remove the partition.

Perform the following on all nodes in the cluster:

# /etc/init.d/oracleasm scandisks
# /etc/init.d/oracleasm listdisks

The ASM volumes should now be listed in the directory /dev/oracleasm/disks

# ls /dev/oracleasm/disks
ASM1     ASM2    ASM3 etc

 Comment 

Device protection on reboot

on October 29, 2009 at 10:15 am
Posted In: Configuration (Cat)

Edit /etc/rc.d/rc.local 

# and insert the following lines at the end

# OCR Disks
chown root:oinstall /dev/mapper/ocr*
chmod 640 /dev/mapper/ocr*
# Voting Disks
chown oracle:oinstall /dev/mapper/vot*
chmod 660 /dev/mapper/vot*
# ASM Disks
chown oracle:oinstall /dev/mapper/asm*
chmod 660 /dev/mapper/asm*

 Comment 

Configure Multipath devices

on October 29, 2009 at 10:12 am
Posted In: Configuration (Cat)

3.15 Configure multipath devices
3.15.1 Generate device list
On each node execute the following command to retrieve the ww id’s for the scsi devices.

for i in `cat /proc/partitions | awk ‘{print $4}’ | grep sd`; do echo “### $i: `scsi_id -g -u -s /block/$i`”; done

n.b. Note the backward quotes in the command ` as these are not quotes ‘
e.g.
# for i in `cat /proc/partitions | awk ‘{print $4}’ | grep sd`; do echo “### $i: `scsi_id -g -u -s /block/$i`”; done
### sda: 360060e801530ca00000130ca00003c16
### sdb: 360060e801530ca00000130ca00003c17
### sdc: 360060e801530ca00000130ca00003c18
### sdd: 360060e801530ca00000130ca00003c19
### sde: 360060e801530ca00000130ca00003c1a
### sdf: 360060e801530ca00000130ca00003c00
### sdg: 360060e801530ca00000130ca00003c01
### sdh: 360060e801530ca00000130ca00003c38
### sdi: 360060e801530ca00000130ca00003c39
### sdj: 360060e801530ca00000130ca00003c04
### sdk: 360060e801530ca00000130ca00003c05
### sdl: 360060e801530ca00000130ca00003c06
### sdm: 360060e801530ca00000130ca00003c07
### sdn: 360060e801530ca00000130ca00003c3e
### sdo: 360060e801530ca00000130ca00003c3f
### sdp: 360060e801530ca00000130ca00003c44
### sdq: 360060e801530ca00000130ca00003d0c
### sdr: 360060e801530ca00000130ca00003d0d
### sds: 360060e801530ca00000130ca00003d0e
### sdt: 360060e801530ca00000130ca00003d0f
### sdu: 360060e801530ca00000130ca00003d10
### sdv: 360060e801530ca00000130ca00003c16
### sdw: 360060e801530ca00000130ca00003c17
### sdx: 360060e801530ca00000130ca00003c18
### sdy: 360060e801530ca00000130ca00003c19
### sdz: 360060e801530ca00000130ca00003c1a
### sdaa: 360060e801530ca00000130ca00003c00
### sdab: 360060e801530ca00000130ca00003c01
### sdac: 360060e801530ca00000130ca00003c38
### sdad: 360060e801530ca00000130ca00003c39
### sdae: 360060e801530ca00000130ca00003c04
### sdaf: 360060e801530ca00000130ca00003c05
### sdag: 360060e801530ca00000130ca00003c06
### sdah: 360060e801530ca00000130ca00003c07
### sdai: 360060e801530ca00000130ca00003c3e
### sdaj: 360060e801530ca00000130ca00003c3f
### sdak: 360060e801530ca00000130ca00003c44
### sdal: 360060e801530ca00000130ca00003d0c
### sdam: 360060e801530ca00000130ca00003d0d
### sdan: 360060e801530ca00000130ca00003d0e
### sdao: 360060e801530ca00000130ca00003d0f
### sdap: 360060e801530ca00000130ca00003d10

From this list we can see that sdv to sdap are the same devices as sda to sdu

Executing the command “cat /proc/partitions” we can determine the size of each device; e.g.

# cat /proc/partitions
major minor    #blocks  name

 104       0   71652960 cciss/c0d0
 104       1       104391 cciss/c0d0p1
 104       2   71545477 cciss/c0d0p2
     8       0     5268480 sda
     8     16     5268480 sdb
     8     32     5268480 sdc
     8     48     5268480 sdd
     8     64     5268480 sde
     8     80     5268480 sdf
     8     96     5268480 sdg
     8   112     5268480 sdh
     8   128     5268480 sdi
     8   144     5268480 sdj
     8   160     5268480 sdk
     8   176     5268480 sdl
     8   192     5268480 sdm
     8   208     5268480 sdn
     8   224     5268480 sdo
     8   240     5268480 sdp
   65       0     1053696 sdq
   65     16     1053696 sdr
   65     32     1053696 sds
   65     48     1053696 sdt
   65     64     1053696 sdu

For our purposes we know that the 1Gb volumes are the OCR and Voting disks and the 5Gb volumes are to be used for ASM.

Therefore we can map:
sda to sdp      to asm volumes 1 to 16
sdq and sdr    to ocr1 and ocr2
sds, sdt, sdu  to vote1, vote2 and vote3

3.15.2 Configure multipath.conf
Edit /etc/multipath.conf to map the scsi ids to asm disk alias’s
This is a sample multipath.conf originally from HP and modified for one of our clusters.
The points to note are that we should
• Comment out the blacklist section
• Add the multipath configuration
:
:
# The blacklist section – use this to blacklist a multipath device based on
# it’s wwid ( using wwid ) or device names ( using devnode ) or
# vendor and product id ( using device block).
blacklist {
#       wwid            26353900f02796769
##      devnode         “^(ram|raw|loop|fd|md|dm-|sr|scd|st)[0-9]*”
##      devnode         “^hd[a-z][[0-9]*]”
#       devnode         “^cciss!c[0-9]d[0-9]*”
#       device {
#               vendor “HP”
#               product “OPEN-*”
#       }
}
# The blacklist_exceptions section – to list device names to be treated
# as multipath candidates even if they are on the blacklist.
# Note: blacklist exceptions are only valid in the same class.
#       It is not possible to blacklist devices using the devnode keyword
#       and to exclude some devices of them using the wwid keyword.
#blacklist_exceptions {
#       wwid            2345234245647657
#       devnode         “sda”
#       device {
#               vendor  “HP”
#               product “OPEN-*”
#       }
#}
# The multipaths section – uncomment this section to define a per multipath
# device settings.
multipaths {
multipath {
        wwid    360060e801530ca00000130ca00003c16
        alias                   ASM1
        path_grouping_policy    multibus
        path_checker            tur
        path_selector           “round-robin 0”
}
multipath {
        wwid    360060e801530ca00000130ca00003c17
        alias                   ASM2
        path_grouping_policy    multibus
        path_checker            tur
        path_selector           “round-robin 0”
}
:
:

multipath {
        wwid    360060e801530ca00000130ca00003d0e
        alias                   OCR1
        path_grouping_policy    multibus
        path_checker            tur
        path_selector           “round-robin 0”
}
:
:
multipath {
        wwid    360060e801530ca00000130ca00003d10
        alias                   VOTE1
        path_grouping_policy    multibus
        path_checker            tur
        path_selector           “round-robin 0”
}
:
:
}
# The devices section – used to define per storage array model settings
:
#
Copy this file to /etc/multipath.conf on each of the cluster nodes.

3.15.3 Execute multipath
Execute the following commands:
# multipath -v2
# multipath –ll

The devices will now be listed in /dev/mapper

 Comment 

disk partitions

on October 29, 2009 at 10:07 am
Posted In: Configuration (Cat)

For each device (sda to sdu) enter:

$ fdisk /dev/sda
Command (m for help): u
Command (m for help): p
Command (m for help): n
Command (m for help): p
1
32768
 
 w

(Where ?? are the characters used to identify the device.)
The reason we are using 32768 as the start block for the device is because of the way scsi/san volume mapping uses the first few blocks of a device and subsequently causes excessive write I/O. This is better explained in the following link:
http://www.pythian.com/news/411/aligning-asm-disks-on-linux

e.g.
# fdisk /dev/sda
Command (m for help): u
Changing display/entry units to sectors
Command (m for help): p
Disk /dev/sda: 5394 MB, 5394923520 bytes
166 heads, 62 sectors/track, 1023 cylinders, total 10536960 sectors
Units = sectors of 1 * 512 = 512 bytes
   Device Boot      Start         End      Blocks   Id  System
Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First sector (62-10536959, default 62): 32768
Last sector or +size or +sizeM or +sizeK (32768-10536959, default 10536959):
Using default value 10536959
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
#

Reboot the system

The command “cat /proc/partitions” (should now list extra sd partitions)

e.g.
cat /proc/partitions
major minor  #blocks  name

104       0   71652960 cciss/c0d0
104       1       104391 cciss/c0d0p1
104       2   71545477 cciss/c0d0p2
    8       0     5268480 sda
    8       1     5252096 sda1
    8     16     5268480 sdb
    8     17     5252096 sdb1
    8     32     5268480 sdc
    8     33     5252096 sdc1
    8     48     5268480 sdd
    8     49     5252096 sdd1
    8     64     5268480 sde
    8     65     5252096 sde1
    8     80     5268480 sdf
    8     81     5252096 sdf1
    8     96     5268480 sdg
    8     97     5252096 sdg1
    8   112     5268480 sdh
    8   113     5252096 sdh1
    8   128     5268480 sdi
    8   129     5252096 sdi1
    8   144     5268480 sdj
    8   145     5252096 sdj1
    8   160     5268480 sdk
    8   161     5252096 sdk1
    8   176     5268480 sdl
    8   177     5252096 sdl1
Etc

# ls /dev/sd*
/dev/sda   /dev/sdah  /dev/sdb   /dev/sdf1  /dev/sdk   /dev/sdo1 /dev/sdt    /dev/sda1 /dev/sdai  /dev/sdb1 
/dev/sdg   /dev/sdk1  /dev/sdp   /dev/sdt1  /dev/sdaa /dev/sdaj  /dev/sdc    /dev/sdg1 /dev/sdl    /dev/sdp1 
/dev/sdu   /dev/sdab  /dev/sdak /dev/sdc1 /dev/sdh   /dev/sdl1  /dev/sdq    /dev/sdu1 /dev/sdac /dev/sdal 
/dev/sdd   /dev/sdh1  /dev/sdm  /dev/sdq1 /dev/sdv   /dev/sdad /dev/sdam /dev/sdd1 /dev/sdi    /dev/sdm1 

# ls /dev/mapper/
ASM1        ASM13      ASM16p1  ASM4p1   ASM8      OCR2                            VOTE2
ASM10      ASM13p1  ASM1p1    ASM5       ASM8p1  OCR2p1                        VOTE2p1
ASM10p1  ASM14      ASM2        ASM5p1   ASM9      VolGroup00-LogVol00   VOTE3

# ls /dev/mpath
ASM1        ASM12      ASM14p1  ASM1p1  ASM4      ASM6p1  ASM9      OCR2p1    VOTE3
ASM10      ASM12p1  ASM15      ASM2      ASM4p1  ASM7      ASM9p1  VOTE1      VOTE3p1
ASM10p1  ASM13      ASM15p1  ASM2p1  ASM5      ASM7p1  OCR1      VOTE1p1

edit /etc/sysconfig/oracleasm

ORACLEASM_SCANORDER=”sd”
ORACLEASM_SCANEXCLUDE=”dm”

Copy this file to each of the cluster nodes.

 Comment 

HP Blade Multipath Software for RH – install

on October 29, 2009 at 9:29 am
Posted In: Configuration (Cat)

Check HP for the correct version of the multipath software
This example is for RH EL 5.2

$gunzip HPDMmultipath-4.3.0.tar.gz

$ tar –xvf HPDMmultipath-4.3.0.tar

$ cd HPDMmultipath-4.3.0

$ ./INSTALL

Answer “1” for “Install HPDM Multipath Utilities”

And “y” to “Would you like to overwrite the existing /etc/multipath.conf file with the new multipath configuration file ?”

 Comment 

ODBC software on linux/unix

on October 29, 2009 at 9:24 am
Posted In: Oracle odds and ends (Cat)

Download the linux odbc kit from the oracle sites (in this case ODBC-2.2.14.tar.gz) to /u01/app/oracle/software and build the software.

 

# cd /u01/app/oracle/software

# gunzip /u01/app/oracle/software/unixODBC-2.2.14.tar

# tar –xvf unixODBC-2.2.14.tar

# cd unixODBC-2.2.14

# ./configure –prefix=/usr/local  –enable-gui=no

# make

# make install

 Comment 

NPT service

on October 29, 2009 at 9:23 am
Posted In: Configuration (Cat)

Edit /etc/ntp.conf and comment out the following 3 lines;

server 0.rhel.pool.ntp.org

server 1.rhel.pool.ntp.org

server 2.rhel.pool.ntp.org

add the line:

server 10.19.72.23                # temporary ntp server

 

Start the service:

service ntpd start &

 

Check the service:

ntpq –p

 

The output should be similar to the following:

     remote           refid      st t when poll reach   delay   offset  jitter

=========================================================

 z1nd01domp003.f 2.2.2.1          2 u   29   64    1    0.855    0.604   0.008

 LOCAL(0)        .LOCL.                  10  l   28   64    1    0.000    0.000   0.008

 

Enable the service at system reboot

chkconfig ntpd on

 Comment 

system parameters

on October 29, 2009 at 9:22 am
Posted In: Resource Management (Cat)


cat >> /etc/sysctl.conf

fs.file-max=6815744

kernel.sem = 250 32000 100 142

kernel.shmmni = 4096

net.core.rmem_default=262144

net.core.wmem_default=262144

net.core.rmem_max=4194304

net.core.wmem_max=1048576

net.ipv4.ip_local_port_range = 1024 65500

EOF

 

Apply the changed parameters with the command:

/sbin/sysctl –p

 

Check the parameters with the command:

/sbin/sysctl –a | grep parameter

 

 Comment 

swap space

on October 29, 2009 at 9:21 am
Posted In: Resource Management (Cat)

$grep MemTotal /proc/meminfo                        (for system memory size)

$grep SwapTotal /proc/meminfo                      (for system swap size)

$free –g                                                                                 (shows memory and swap utilization)

$cat /proc/swaps                                                  (shows swap files registered)

 

 

 Comment 

list rpms , versions and typ

on October 29, 2009 at 9:19 am
Posted In: Configuration (Cat)

rpm -q –queryformat “%{NAME} – %{VERSION} – %{RELEASE} (%{ARCH}) \n” binutils compat-libstdc++-33

 Comment 

mount cifs drive

on October 29, 2009 at 9:18 am
Posted In: Configuration (Cat)

mkdir -p /mnt/drivea

mount -t cifs “//1.2.3.4/sharename” -o username=”domain/username”, password=pwd /mnt/drivea

 Comment 

srvctl modify database -d dbname -P ‘+DATA/dbname/parameterfile/spfile.nnn.nnnnnn’

on October 29, 2009 at 8:50 am
Posted In: Oracle RAC (Cat)

Change the spfile parameter using the srvctl command

 Comment 

Truss command

on September 22, 2009 at 9:00 am
Posted In: Resource Management (Cat)

truss -o /tmp/G -f SCRIPT_NAME_HERE.sh

vi /tmp/G (error in there somewhere)

search error:

man -s 2 intro (search for error here)

 Comment 

find all files and files in a subdir

on September 22, 2009 at 9:00 am
Posted In: Unix notes (Cat)

find . -type f | xargs grep -l “VALUE”

to delete some files

find . -name “*.aud” -mtime +1 -exec rm {} \;

 Comment 

Change contents in all files in a dir

on September 22, 2009 at 8:59 am
Posted In: Unix notes (Cat)

find ./ * -type f | xargs perl -pi -e ‘s/old/new/g’

 Comment 

Search inside all files and subdirs

on September 22, 2009 at 8:57 am
Posted In: Unix notes (Cat)

find . -exec grep “string” {} /dev/null \;

 Comment 

oui, record a response file

on September 22, 2009 at 7:54 am
Posted In: Oracle oui and dbca (Cat)

./runInstaller -record -destinationFile /home/oracle/response.rsp

 Comment 

HP-UX raw disk configuration

on September 18, 2009 at 10:02 am
Posted In: Configuration (Cat)

Use xpinfo -i to get the volume information

 # ./xpinfo -i

Device File                 ALPA Tgt Lun Port  LDKC:CU:LDev Type             Serial#
====================================================================================
/dev/rdisk/disk40            ac  00  00  CL1D  0:02:d7  OPEN-V           00075515
/dev/rdisk/disk41            ac  00  01  CL1D  0:00:e7  OPEN-V           00075515
/dev/rdisk/disk42            ac  00  02  CL1D  0:02:d8  OPEN-V           00075515
/dev/rdisk/disk43            ac  00  03  CL1D  0:00:f6  OPEN-V           00075515
/dev/rdisk/disk44            ac  02  10  CL1D  0:00:e1  OPEN-V           00075515
/dev/rdisk/disk45            ac  02  11  CL1D  0:02:9d  OPEN-V           00075515
sd2vPar5:/download/utils #

USE SAM TO CHECK THE DISK PATHS

                                                    HP-UX System Management Homepage (Text User Interface)
                                                              SMH->Disks and File Systems->Disks
————————————————————————————————————————————————————–
H/W Scan: Wed Sep 16 10:40:17 2009
Path(s)           Device File(s)    Use    VG Names   Paths   Size(GB) Description
————————————————————————————————————————————————————–
64000/0xfa00/0x11    /dev/disk/disk32  LVM    vg00       1       136.73  COMPAQ  BF1468B26B
64000/0xfa00/0x12    /dev/disk/disk33  unused  -         1       0.00    Optiarc DVD RW AD-5170A
64000/0xfa00/0x1b    /dev/disk/disk40  unused  -         1       50.24   HP      OPEN-V
64000/0xfa00/0x1c    /dev/disk/disk41  unused  -         1       50.24   HP      OPEN-V
64000/0xfa00/0x1d    /dev/disk/disk42  unused  -         1       50.24   HP      OPEN-V
64000/0xfa00/0x1e    /dev/disk/disk43  unused  -         1       50.24   HP      OPEN-V
64000/0xfa00/0x1f    /dev/disk/disk44  unused  -         1       50.24   HP      OPEN-V
64000/0xfa00/0x20    /dev/disk/disk45  unused  -         1       50.24   HP      OPEN-V

USE ll TO GET THE DISK IDS

# ll /dev/rdisk/disk41
crw-r—–   1 bin        sys         13 0x00001c Sep 16 10:40 /dev/rdisk/disk41

CONFIGURE THE DISKS

mkdir /dev/oracle
mknod /dev/oracle/asmdisk1 c 13 0x00001c

chown oracle:dba /dev/oracle/*
chmod 660 /dev/oracle/*

 

 Comment 

dbca templates and issues

on September 18, 2009 at 8:27 am
Posted In: Oracle oui and dbca (Cat)


dbca -silent -responseFile /home/oracle/rsp.rsp INSTALL_TYPE=”EE” n_configurationOption=3 -ignoreSysPrereqs

DB
==
dbca -silent -createDatabase -gdbname imas -sid imas -responseFile file_name

PROBLEMS BECAUSE DBCA not recognising ASM from template:
dbca -silent -createDatabase -gdbname imas -templateName file_name -SysPassword test -SystemPassword test -storageType ASM -asmSysPassword test

To use  DBCA in silent mode and you want the database stored in the ASM +DGDATA diskgroup follow the next Correct Format for Examples:

If I already have an ASM instance/diskgroup then the following creates a single database on that diskgroup:

$ dbca -silent -createDatabase -templateName General_Purpose.dbc -gdbName ORCL -sid ORCL -SysPassword change_on_install -SystemPassword manager -emConfiguration NONE -storageType ASM -asmSysPassword change_on_install -diskGroupName DGDATA -characterSet WE8ISO8859P15 -memoryPercentage 40

$ dbca -silent -createDatabase -templateName General_Purpose.dbc -gdbName ORCL -sid ORCL -SysPassword change_on_install -SystemPassword manager -emConfiguration NONE -storageType ASM -asmSysPassword change_on_install -diskGroupName DGDATA -characterSet WE8ISO8859P15 -memoryPercentage 40

11gR1 :

Windows : 

> cd Z:\database
> setup.exe -silent -force -debug FROM_LOCATION="Z:\database\stage\products.xml" ORACLE_HOME="D:\app\oracle\product\11.1.0\db_1" ORACLE_HOME_NAME="Ora11gDb1" ORACLE_BASE="D:\app\oracle" TOPLEVEL_COMPONENT={"oracle.server","11.1.0.6.0"} INSTALL_TYPE="EE" n_configurationOption=3

Unix:

$ cd /mount/dvd/database
$ ./runInstaller -silent -force -debug \
FROM_LOCATION="/mount/dvd/database/stage/products.xml" \
ORACLE_HOME="/u01/app/oracle/product/11.1.0/db_1" \
ORACLE_HOME_NAME="Ora11gDb1" ORACLE_BASE="/u01/app/oracle" \
TOPLEVEL_COMPONENT='{"oracle.server","11.1.0.6.0"}' \
INSTALL_TYPE="EE" n_configurationOption=3

10gR2 :

Windows :

> cd Y:\database
> setup.exe -silent -force -debug FROM_LOCATION="Z:\database\stage\products.xml" ORACLE_HOME="D:\app\oracle\product\10.2.0\db_1" ORACLE_HOME_NAME="Ora10gDb1" TOPLEVEL_COMPONENT={"oracle.server","10.2.0.1.0"} INSTALL_TYPE="EE" n_configurationOption=3

Unix:

$ cd /mount/dvd/database
$ ./runInstaller -silent -force -debug \
FROM_LOCATION="/mount/dvd/database/stage/products.xml" \
ORACLE_HOME="/u01/app/oracle/product/10.2.0/db_1" \
ORACLE_HOME_NAME="Ora10gDb1" \
TOPLEVEL_COMPONENT='{"oracle.server","10.2.0.1.0"}' \
INSTALL_TYPE="EE" n_configurationOption=3

Following command can be used to deinstall Database Server Software in silent mode. Example is given for 10gR2 (10.2.0.1).

Windows:

> setup.exe -silent -debug -deinstall DEINSTALL_LIST={"oracle.server","10.2.0.1.0"} REMOVE_HOMES={"D:\app\oracle\product\10.2.0\db_1"}

Unix:

$ ./runInstaller -silent -debug -deinstall \
DEINSTALL_LIST='{"oracle.server","10.2.0.1.0"}' \
REMOVE_HOMES={"/u01/app/oracle/product/10.2.0/db_1"}

=====================================================================================

PURPOSE
——-

This bulletin lists different issues that may occur when trying to:

   * Create a database from a non-seed template (from scratch)
   * Create a non-seed template from an existing database

using the Database Configuration Assistant (DBCA)in silent mode.

To understand the definition of seed and non-seed templates provided by the
DBCA, please refer to:

    Note 148676.1 DBCA Templates

SCOPE & APPLICATION
——————-

List of possible errors and solutions.

Issues Running DBCA in Silent Mode:
===================================

Case 1
——
$ dbca -silent -createDatabase -gdbname ora9i -templateName /ora901/assistants/dbca/templates/New_Database.dbt
Look at the log file “/ora901/assistants/dbca/logs/10.log” for further details.

$ more /ora901/assistants/dbca/logs/10.log
Template /ora901/assistants/dbca/templates/New_Database.dbt does not exist
. Please specify an existing template for database creation.
$

The error occurs although /ora901/assistants/dbca/templates/New_Database.dbt
exists.

   => do not use the full path name of the template

$ dbca -silent -createDatabase -gdbname ora9i -templateName New_Database.dbt

Case 2
——
$ dbca -silent -createDatabase -gdbname ora9i -templateName New_Database.dbt
Look at the log file “/ora/ora901/assistants/dbca/logs/ora9i.log” for further
details.

$ more /ora/ora901/assistants/dbca/logs/ora9i.log
The Oracle system identifier(SID) “ora9i” already exists. Specify another SID.
$

  => you have to change the ORACLE_SID environment variable, because this
     database already exists.

Case 3
——
$ dbca -silent -createDatabase -gdbname ora9i -templateName New_Database.dbt
Look at the log file “/ora/ora901/assistants/dbca/logs/ora9i.log” for further
details.

$ more /ora/ora901/assistants/dbca/logs/ora9i.log
You do not have enough free disk space to create the database.
You need at least 998400 KB on /ora/, You have only 405504 KB available.
Do you want to continue?
$

   => edit the New_Database.dbt template to decrease the size for all datafiles
      and redo log files

   => Example:
           
     
         DRSYS
         false
         true
         0
         20480   =====> change 20480 to 2048
         true
         true
         640
         -1
      
      and so on for the other tablespaces

Case 4
——
$ dbca -silent -createDatabase -gdbname ora9i -templateName New_Database.dbt
java.lang.NullPointerException
        at oracle.sysman.assistants.dbca.backend.template.ParseManager.endElement(Compiled Code)
        at oracle.xml.parser.v2.DefaultXMLDocumentHandler.endElement(Compiled Code)
        at oracle.xml.parser.v2.NonValidatingParser.parseElement(Compiled Code)
        at oracle.xml.parser.v2.NonValidatingParser.parseRootElement(NonValidatingParser.java:270)
        at oracle.xml.parser.v2.NonValidatingParser.parseDocument(NonValidatingParser.java:235)
        at oracle.xml.parser.v2.XMLParser.parse(XMLParser.java:221)
        at oracle.sysman.assistants.dbca.backend.TemplateManager.parseTemplate(TemplateManager.java:1044)
        at oracle.sysman.assistants.dbca.backend.TemplateManager.loadTemplate(TemplateManager.java:398)
        at oracle.sysman.assistants.dbca.backend.TemplateManager.loadCurrentTemplate(TemplateManager.java:423)
        at oracle.sysman.assistants.dbca.backend.Host.startOperation(Compiled Code)
        at oracle.sysman.assistants.dbca.Dbca.execute(Dbca.java:94)
        at oracle.sysman.assistants.dbca.Dbca.main(Dbca.java:143)
$

Whenever the path given in a variable in the template file does not exist, the
java.lang.NullPointerException error will occur.

   => Edit and change all path names for control, redo log, data, and dump
      files in the template.

Case 5
——
$ dbca -silent -createDatabase -gdbname ora9i -templateName New_Database.dbt
oracle.xml.parser.v2.XMLParseException: ‘>’ Missing from end tag.
        at oracle.xml.parser.v2.XMLError.flushErrors(XMLError.java:240)
        at oracle.xml.parser.v2.NonValidatingParser.parseDocument(NonValidatingParser.java:244)
        at oracle.xml.parser.v2.XMLParser.parse(XMLParser.java:221)
        at oracle.sysman.assistants.dbca.backend.TemplateManager.parseTemplate(TemplateManager.java:1044)
        at oracle.sysman.assistants.dbca.backend.TemplateManager.loadTemplate(TemplateManager.java:398)
        at oracle.sysman.assistants.dbca.backend.TemplateManager.loadCurrentTemplate(TemplateManager.java:423)
        at oracle.sysman.assistants.dbca.backend.Host.startOperation(Compiled Code)
        at oracle.sysman.assistants.dbca.Dbca.execute(Dbca.java:94)
        at oracle.sysman.assistants.dbca.Dbca.main(Dbca.java:143)
Look at the log file “/ora/ora901/assistants/dbca/logs/ora9i1.log” for further
details.
$

$ more /ora/ora901/assistants/dbca/logs/ora9i1.log
A java pool size of at least 50MB is required for Oracle JVM.
Set “java_pool_size” initialization parameter to at least 50MB.
$

   => Edit and modify the template to set JAVA_POOL_SIZE to the appropriate
      value

   => Example:   
               changed to

Case 6
——
$ dbca -silent -createDatabase -gdbname ora9i -templateName New_Database.dbt
oracle.xml.parser.v2.XMLParseException: ‘>’ Missing from end tag.
        at oracle.xml.parser.v2.XMLError.flushErrors(XMLError.java:240)
        at oracle.xml.parser.v2.NonValidatingParser.parseDocument(NonValidatingParser.java:244)
        at oracle.xml.parser.v2.XMLParser.parse(XMLParser.java:221)
        at oracle.sysman.assistants.dbca.backend.TemplateManager.parseTemplate(TemplateManager.java:1044)
        at oracle.sysman.assistants.dbca.backend.TemplateManager.loadTemplate(TemplateManager.java:398)
        at oracle.sysman.assistants.dbca.backend.TemplateManager.loadCurrentTemplate(TemplateManager.java:423)
        at oracle.sysman.assistants.dbca.backend.Host.startOperation(Compiled Code)
        at oracle.sysman.assistants.dbca.Dbca.execute(Dbca.java:94)
        at oracle.sysman.assistants.dbca.Dbca.main(Dbca.java:143)
Look at the log file “/ora/ora901/admin/ora9i/create/ora9i.log” for further
details.
$

When the directory $ORACLE_HOME or $ORACLE_BASE/admin/ora9i/create is created,
this means that at least the instance is started and the mount phase of the
database creation process is started.

$ more /ora/ora901/admin/ora9i/create/ora9i.log
ORA-02236: invalid file name
ORA-02236: invalid file name
$

   => Read other files created in /ora/ora901/admin/ora9i/create directory
   => Read the alert.log file of the started instance

This helps to identify which step the database creation is currently at.

$ ls -l
total 4
-rw-rw-r–   1 ora901     dba            270 Nov 15 14:47 CreateDB.log
-rw-rw-r–   1 ora901     dba             58 Nov 15 14:47 ora9i.log

$ more CreateDB.log
ORACLE instance started.
Total System Global Area  235851200 bytes
Fixed Size                   437696 bytes
Variable Size             167772160 bytes
Database Buffers           67108864 bytes
Redo Buffers                 532480 bytes
CHARACTER SET US7ASCII
*
ERROR at line 8:
ORA-02236: invalid file name

or
$ more CreateDB.log
LRM-00116: syntax error at ‘protocol’ following ‘(‘
ORA-01078: failure in processing system parameters

Case 7
——
$ dbca -silent -createTemplateFromDB -sourceDB V901 \
>                                    -sysDBAUserName sys \
>                                    -sysDBAPassword manager \
>                                    -templateName copy_of_ora901.dbc
Look at the log file “/ora/ora901/assistants/dbca/logs/11.log” for further
details.
$

$ more /ora/ora901/assistants/dbca/logs/11.log
VDB-2000 : Service alias could not be resolved.

   => Use the full descriptor of the service name :

$ dbca -silent -createTemplateFromDB -sourceDB frhp11:1521:V901 \
>                                    -sysDBAUserName sys \
>                                    -sysDBAPassword manager \
>                                    -templateName copy_of_ora901.dbc

Case 8
——
$ dbca -silent -createTemplateFromDB -sourceDB frhp11:1521:V901 \
>                                    -sysDBAUserName sys \
>                                    -sysDBAPassword manager \
>                                    -templateName copy_of_ora901.dbc
Look at the log file “/ora/ora901/assistants/dbca/logs/12.log” for further
details.

$ more /ora/ora901/assistants/dbca/logs/12.log
ORA-01017: invalid username/password; logon denied

   => use a username/password able to connect to the source database AS SYSBDA

$ dbca -silent -createTemplateFromDB \
                       -sourceDB frhp11:1521:V901 \
                       -sysDBAUserName system -sysDBAPassword manager  \
                       -templateName copy_of_ora901
Look at the log file “/ora/ora901/assistants/dbca/logs/13.log” for further
details.

$ more /ora/ora901/assistants/dbca/logs/13.log
The template “copy_of_ora901.dbc” creation completed.

References:
———–

  Note 159324.1 ORA-1092 Instance Terminated When Creating A Database Via DBCA
 
Note 148676.1 DBCA Templates

======================================================================================

 

 Comment 

About Paul

on September 17, 2009 at 11:07 am
Posted In: Uncategorized

Believe it or not I started my computing experience by taking a Computing A Level in Cambridge on an IBM 1130 8K machine coding Cobol and Fortran programs on punch cards and paper tape.

That’s where I learnt all about reading and interpreting core dumps; sadly a technique that is largely redundant these days.

After taking a year out and workling for the then Pearl Assurance in Liverpool in their computing departments I attained a BSc in computing at Leeds.

I have worked for Racal Redac, Phillips TMC, Digital Equipment Corporation, Hoare Govett, the Stock Exchange, Reuters, Rover, EDS, IBM, CMC Markets, Raytheon, EADS, Centrica and BT Expedite with quite a few extensions and re-engagements from the above.

My database experience began with Ingres on DEC VAX and then Alpha. I still believe that VMS was the best operating system and Ingres one of the easiest database engines to manage.

This website was begun mainly as a place to store my photographs but I have extended it so that I can save all my Oracle notes on the net making them accessable from anywhere I am working (when you have so much trying to be stored in a memory like mine you need to have these things written down somewhere).

One day I will get these pages sorted so that they look professional but until then you’ll have to ferret around to find what you want (after all, I know where everything is).

Have fun

Paul

 Comment 

web addresses

on September 17, 2009 at 10:34 am
Posted In: Oracle sql one liners (Cat)

http://www.123people.de

http://extensions.joomla.org/ Joomla extensions, access and security, content sharing http://resources..joomla.org/directory/popular.html most popular joomla packages
phpThumb
http://BLUESOME.NET/POST/2005/08/18/50/#UPGRADE_TO_$_2 EXEC-php
http://www.jakeo.com/software/exif/index.php exif
http://www.jakeo.com/software/exif/exifer1_5.zip exif

http://mwidlake.wordpress.com
http://www.ora600.org.uk/scripts.shtml

 Comment 

dbca create asm response file

on September 16, 2009 at 3:22 pm
Posted In: Oracle oui and dbca (Cat)

To create asm on a node:

As root create th css service:
$ORACLE_HOME/bin/localconfig add

As oracle:

dbca -silent -configureASM -recoveryGroupRedundancy EXTERNAL -responseFile asm_dbca.rsp

ASM_DBCA.RSP FILE
=============
##############################################################################
##                                                                          ##
##                            DBCA response file                            ##
##                            ——————                            ##
## Copyright   1998, 2004, Oracle Corporation. All Rights Reserved.         ##
##                                                                          ##
## Specify values for the variables listed below to customize Oracle        ##
## Database Configuration installation.                                     ##
##                                                                          ##
## Each variable is associated with a comment. The comment identifies the   ##
## variable type.                                                           ##
##                                                                          ##
## Please specify the values in the following format :                      ##
##          Type       :  Example                                           ##
##          String     :  “”                                         ##
##          Boolean    :  True or False                                     ##
##          Number     :                                     ##
##          StringList :  {“”,””}                           ##
##                                                                          ##
## Examples :                                                               ##
##     1. dbca -progress_only -responseFile                  ##
##        Display a progress bar depicitng progress of database creation    ##
##        process.                                                          ##
##                                                                          ##
##     2. dbca -silent -responseFile                         ##
##        Creates database silently. No user interface is displayed.        ##
##                                                                          ##
##     3. dbca -silent -createDatabase -cloneTemplate                       ##
##                       -responseFile                       ##
##        Creates database silently with clone template. The template in    ##
##        reponsefile is a clone template.                                  ##
##                                                                          ##
##     4. dbca -silent -deleteDatabase -responseFile         ##
##        Deletes database silently.                                        ##
##############################################################################

#—————————————————————————–
# GENERAL section is required for all types of database creations.
#—————————————————————————–
[GENERAL]

#—————————————————————————–
# Name          : RESPONSEFILE_VERSION
# Datatype      : String
# Description   : Version of the database to create
# Valid values  : “10.0.0”
# Default value : None
# Mandatory     : Yes
#—————————————————————————–
RESPONSEFILE_VERSION = “10.0.0”

#—————————————————————————–
# Name          : OPERATION_TYPE
# Datatype      : String
# Description   : Type of operation
# Valid values  : “createDatabase” \ “createTemplateFromDB” \ “createCloneTemplate” \ “deleteDatabase” \ “configureDatabase” \ “configureASM” \ “addInstance” (RAC-only) \ “deleteInstance” (RAC-only)
# Default value : None
# Mandatory     : Yes
#—————————————————————————–
OPERATION_TYPE = “configureASM”

#———————–*** End of GENERAL section ***————————

#—————————————————————————–
# CONFIGUREASM section is used when OPERATION_TYPE is defined as “configureASM”.
#—————————————————————————–
[CONFIGUREASM]
#—————————————————————————–
# Name          : DISKLIST
# Datatype      : String
# Description   : Comma seperated list of OS disk paths to be used (eg. /dev/rdsk/disk1,/dev/rdsk/disk2)
# Default value : None
# Mandatory     : No (YES to create new diskgroup or add disks to existing diskgroup)
#—————————————————————————–
DISKLIST=/dev/oracle/asmdisk1,/dev/oracle/asmdisk2,/dev/oracle/asmdisk3

#—————————————————————————–
# Name          : NODELIST
# Datatype      : String
# Description   : Comma-separated list of cluster nodes
# Valid values  : Cluster node names
# Default value : None
# Mandatory     : No (YES for RAC)
#—————————————————————————–
#NODELIST=

#—————————————————————————–
# Name          : DISKGROUPNAME
# Datatype      : String
# Description   : Specifies the disk group name for the storage
# Default value : DATA
# Mandatory     : No
#—————————————————————————–
DISKGROUPNAME=DATA

#—————————————————————————–
# Name          : REDUNDANCY
# Datatype      : String
# Description   : Specifies the redundancy level for the diskgroup
# Valid values  : HIGH/NORMAL/EXTRENAL
# Default value : NORMAL
# Mandatory     : No
#—————————————————————————–
REDUNDANCY=EXTERNAL

#—————————————————————————–
# Name          : DISKSTRING
# Datatype      : String
# Description   : Specifies disk discovery path for ASM
# Default value : OS specific, eg. /dev/rdsk/* on Solaris
# Mandatory     : No
#—————————————————————————–
DISKSTRING=”/dev/oracle/asm*”

#—————————————————————————–
# Name          : ASM_SYS_PASSWORD
# Datatype      : String
# Description   : Specifies password for ASM instance to be created
# Default value : None
# Mandatory     : No
#—————————————————————————–
ASM_SYS_PASSWORD=”password”

#—————————————————————————–
# Name          : RECOVERYDISKLIST
# Datatype      : String
# Description   : Comma seperated list of OS disk paths to be used (eg. /dev/rdsk/disk1,/dev/rdsk/disk2)
# Default value : None
# Mandatory     : No
#—————————————————————————–
RECOVERYDISKLIST=/dev/oracle/asmdisk4,/dev/oracle/asmdisk5

#—————————————————————————–
# Name          : RECOVERYGROUPNAME
# Datatype      : String
# Description   : Specifies the disk group name for the recovery area
# Default value : RECOVERY
# Mandatory     : No
#—————————————————————————–
RECOVERYGROUPNAME=FLA

#—————————————————————————–
# Name          : RECOVERYREDUNDANCY
# Datatype      : String
# Description   : Specifies the redundancy level for the recovery diskgroup
# Valid values  : HIGH/NORMAL/EXTRENAL
# Default value : NORMAL
# Mandatory     : No
RECOVERYREDUNDANCY=EXTERNAL

#———————–*** End of CONFIGUREDISKGROUPS section ***————————
-bash-4.0$

 Comment 

Oracle Universal Installer

on September 15, 2009 at 9:58 am
Posted In: Oracle oui and dbca (Cat)

OUI

(ref Oracle Metalink docs 402023.1, 782919.1 and 782918.1)

To use silent install there are several undocumented options on the command line:

1 – Create a Database
2 – Configure an ASM instance
3 – Install Software Only

e.g. n_configurationOption=3

With this option you can also specify what kind of database you want to create with the n_dbType parameter.
This entry should be specified as a number. The valid values you can specify map to the following options:
1 – General Purpose Starter Database
2 – Transaction Processing Starter Database
3 – Data Warehouse Starter Database
4 – Advanced Configuration

e.g. n_dbType=4

If you want to create custom database according to your specification then you can choose Advanced
Configuration.

If you chose to perform a silent Advanced Configuration by specifying n_dbType=4 above, then you need to specify a number of additional Advanced Configuration parameters in a response file that is used by the DBCA. A template of this response file can be found on the installation media in response/dbca.rsp. Use this file to completely customize the silent database configuration, and set s_responseFileName to the location of this response file.

Example : s_responseFileName=

Prerequisite for parameter s_responseFileName is to have set these:

n_configurationOption=1
n_performUpgrade=0
n_dbType=4

 Comment 

Rolling upgrade with a physical standby

on September 10, 2009 at 10:19 am
Posted In: Oracle Data Guard Notes (Cat)

Enable flashback database

Create a guaranteed restore point,
CREATE RESTORE POINT pre_upgrade GUARANTEE FLASHBACK DATABASE;

Create a physical standby control file,
ALTER DATABASE CREATE PHYSICLA STANDBY CONTROLFILE AS ‘/tmp/ctl.phys’ REUSE;

Convert the physical standby to a logical standby
ALTER DATABASE RECOVER TO LOGICAL STANDBY KEEP IDENTITY;
Disable automatic deletion of foreign archived logs
EXECUTE DBMS_LOGSTDBY.APPLY_SET(‘LOG_AUTO_DELETE’,’FALSE’);
Start SQL apply
ALTER DATABASE START LOGICAL STANDBY APPLY IMMEDIATE;

Upgrade the logical standby as described in steps 1 to 6 in the note “rolling upgrade with a logical standby”
After these steps the original primary db will be the logical standby and the original physical standby will be the primary db with upgraded oracle software.

Flash back the original primary db to the guaranteed restore point
SHUTDOWN IMMEDIATE
STARTUP MOUNT
FLASHBACK DATABASE TO RESTORE POINT pre_upgrade;

Restore the standby controlfile on the original primary database.
SHUTDOWN IMMEDIATE
RESTORE CONTROLFILE FROM ‘/tmp/ctl.phys’;
SHUTDOWN

Switch the oracle db binary for the original primary db to use the higher version of the software.
The db_upgrade scripts are not required as this is a standby.
ALTER DATABASE MOUNT
Switch logs on the primary and ensure they are registered at the standby.
Start managed recovery
ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE DISCONNECT FROM SESSION;

Perform a switchover
Primary:
ALTER DATABASE COMMIT TPO SWITCHOVER TO PHYSICAL STANDBY WITH SESSION SHUTDOWN;
SHUTDOWN IMMEDIATE;
STARTUP MOUNT;
Standby:
ALTER DATABASE COMMIT TO SWITCHOVER TO PRIMARY;
SHUTDOWN IMMEDIATE;
STARTUP

Start the original primary db as a physical standby

 Comment 

Rolling upgrade with a logical standby

on September 10, 2009 at 10:14 am
Posted In: Oracle Data Guard Notes (Cat)

Use a logical standby db to perform a rolling upgrade.
Databases must not be part of a DG broker configuration
DG protection mode must be MAXIMUM AVAILABILITY or PERFORMANCE
The COMPATIBLE init param must match the software release before the upgrade.

Create a  new or use a current logical standby.
Use an existing physical standby in 11g only.

Identify unsupported datatypes in a logical standby.
Query DBA_LOGSTDBY_UNSUPPORTED and DBA_LOGSTDBY_SKIP
If you can not prevent changes to unsupported tables during the upgrade you may be able to use Data Pump or ecp/imp to impport the tables to the upgraded database.
Unsupported transactions are recorded in the DBA_LOGSTDBY_EVENTS table on the logical standby db.

1) SQL> ALTER DATABASE STOP LOGICAL STANDBY APPLY; on the logical standby db.
SQL> Set the COMPATIBLE parameter.
2) Upgrade the db software on the logical standby
3) Execute DBMS_LOGSTDBY pl/sql proc on the standby to capture information on unsupported transactions on the primary db. Execute the following to capture and record the info as events in the DBA_LOGSTDBY_EVENTS table.
EXEC DBMS_LOGSTDBY.APPLY_SET (‘MAX_EVENTS_RECORDED’,DBMS_LOGSTDBY.MAX_EVENTS);
EXEC DBMS_LOGSTDBY.APPLY_SET (‘RECORD_UNSUPPORTED_OPERATIONS’,’TRUE’);
4)Restart sql apply on the standby
SQL> ALTER DATABASE START LOGICAL STANDBY APPLY IMMEDIATE;
5)Query events to determine if there are any DDL or DML statements that were not applied on the logical standby.
SELECT EVENT_TIMESTAMP,  EVENT, STATUS FROM DBA_LOGSTDBY_EVENTS ORDER BY EVENT_TIMESTAMP;
6)Switchover, on primary
ALTER DATABASE COMMIT TO SWITCHOVER TO LOGICAL STANDBY;
7)Complete the switchover, on logical standby
ALTER DATABASE COMMIT TO SWITCHOVERTO LOGICAL PRIMARY;
8) Upgrade the primary database
9) Start SQL apply on the primary
ALTER DATABASE START LOGICAL STANDBY APPLY IMMEDIATE NEW PRIMARY db_link;
10) Monitor events on the new logical standby by querying DBA_LOGSTDBY_EVENTS
11) Perform a switchover to return to the original configuration
12 Raise the compatability parameter on both databases, do it on the standby before the primary.

 Comment 

Upgrade a logical standby database

on September 10, 2009 at 9:56 am
Posted In: Oracle Data Guard Notes (Cat)

Perform the preparation steps
Set the data protection to MAXIMUM PERFORMANCE
Stop all user activity on the primary
Defer the logical standby remote archive destination
Stop sql apply on the standby
Install DB software on the primary
Upgrade the primary
Install DB software on the standby
Upgrade the standby
Restart sql apply on the standby
Open the upgraded primary
Reset the data protection mode if necessary

 Comment 

Upgrade a physical standby db in a Data Guard configuration

on September 10, 2009 at 9:53 am
Posted In: Oracle Data Guard Notes (Cat)

Perform the preparation steps
Shut down primary
Shutdown standby
Install DB software on the standby
Mount the physical standby
Start redo apply on the standby
Install DB software on the primary
Upgrade the primary
Open the upgraded primary db

 Comment 

Upgrade DG Broker Configuration

on September 10, 2009 at 9:50 am
Posted In: Oracle Data Guard Notes (Cat)

DGMGRL> DISABLE CONFIGURATION;
SQL> ALTER SYSTEM SET DG_BROKER_START=FALSE;

Perform the database upgrade

SQL> ALTER SYSTEM SET DG_BROKER_START=TRUE;
DGMGRL> ENABLE CONFIGURATION;

The first time 11g broker starts it detects and upgrade the 10g broker files.

 Comment 

Data Guard client connectivity, services, triggers and role transition

on September 10, 2009 at 7:57 am
Posted In: Oracle Data Guard Notes (Cat)

TNSNAMES.ORA
PROD=(DESCRIPTION=
(ADDRESS=(PROTOCOL=TCP)(HOST=NODE1)(PORT=1521))
(ADDRESS=(PROTOCOL=TCP)(HOST=NODE2)(PORT=1521))
(CONNECT_DATA=(SERVICE_NAME=DG_PROD)))

Use DBMS_SERVICE package to manage database services.

DBMS_SERVICE.CREATE_SERVICE(
SERVICE_NAME => ‘DG_PROD’,
NETWORK_NAME => ‘DG_PROD’,
FAILOVER_METHOD => ‘BASIC’,
FAILOVER_TYPE => ‘SELECT’,
FAILOVER_RETRIES => 180,
FAILOVER_DELAY => 1);

DBMS_SERVICE.CREATE_SERVICE(
SERVICE_NAME => ‘DG_RTQ’,
NETWORK_NAME => ‘DG_RTQ’);

DBMS_SERVICE.CREATE_SERVICE(
SERVICE_NAME => ‘DG_LSBY’,
NETWORK_NAME => ‘DG_LSBY’);

DBMS_SERVICE.CREATE_SERVICE(
SERVICE_NAME => ‘DG_SNAP’,
NETWORK_NAME => ‘DG_SNAP’);

The CREATE_SERVICE procedure creates a service in the data dictionary.

Use a database event trigger to ensure clients connect to a database in the data guard configuration that is in the correct state and role.
Use the trigger to start database services
– DG_PROD Primary db
– DG_RTQ  Physical standby db in READ ONLY mode (real-time query)
– DG_SNAP snapshot standby database
– DG_LSBY Logical standby db

TRIGGER
=======
CREATE OR REPLACE TRIGGER MANAGE_SERVICES AFTER STARTUP ON DATABASE
DECLARE
ROLE VARCHAR(30);
OMODE VARCHAR(30);
BEGIN
SELECT DATABASE ROLE INTO ROLE FROM V$DFATABASE;
SELECT OPEN_MODE INTO OMODE FROM V$DATABASE;
IF ROLE = ‘PRIMARY’ THEN
DBMS_SERVICE.START_SERVICE(‘DG_PROD’);
ELSEIF ROLE = ‘PHYSICAL_STANDBY’ THEN
IF OMODE = ‘READ ONLY’ THEN
DBMS_SERVICE.START_SERVICE(‘DG_RTQ’);
END IF;
ELSEIF ROLE = ‘LOGICAL STANDBY’ THEN
DBMS_SERVICE.START_SERVICE(‘DG_LSBY’);
ELSEIF ROLE = ‘SNAPSHOT STANDBY’ THEN
DBMS_SERVICE.START_SERVICE(‘DG_SNAP’);
END IF;
END;
/

TNSNAMES.ORA
============
PROD=(DESCRIPTION=
(ADDRESS=(PROTOCOL=TCP)(HOST=NODE1)(PORT=1521))
(ADDRESS=(PROTOCOL=TCP)(HOST=NODE2)(PORT=1521))
(CONNECT_DATA=(SERVICE_NAME=DG_PROD)))

RTQ =(DESCRIPTION=
(ADDRESS=(PROTOCOL=TCP)(HOST=NODE1)(PORT=1521))
(ADDRESS=(PROTOCOL=TCP)(HOST=NODE2)(PORT=1521))
(CONNECT_DATA=(SERVICE_NAME=DG_RTQ)))

SNAP=(DESCRIPTION=
(ADDRESS=(PROTOCOL=TCP)(HOST=NODE1)(PORT=1521))
(ADDRESS=(PROTOCOL=TCP)(HOST=NODE2)(PORT=1521))
(CONNECT_DATA=(SERVICE_NAME=DG_SNAP)))

LSBY=(DESCRIPTION=
(ADDRESS=(PROTOCOL=TCP)(HOST=NODE1)(PORT=1521))
(ADDRESS=(PROTOCOL=TCP)(HOST=NODE2)(PORT=1521))
(CONNECT_DATA=(SERVICE_NAME=DG_LSBY )))

CLIENT FAILOVER – COMPONENTS
============================
1 CONNECT TIME FAILOVER:
Redirects failed connection requests to a secondary listener
2 TAF Transparent Application Failover:
Enables OCI client applications to automatically reconnect to a database if the original connection fails. TAF fails over only the session and SELECT statements.
Select statemets are automatically restarted if TAF is configured for SELECT failover.
Session customisations (e.g. ALTER SESSION) must be reexecuted by the application.
3 FAN Fast Application Notification
Provides quick notification when a resource (instance, node service etc) fails.
FAN is available to all applications by using either fast connection failover with a FAN integrated client(JDBC, OCI or OLE DB) or by using the FAN API to read FAN events directly.
4 Fast Connection Failover
by enabling you to configure FAN integrated JDBC clients to automatically subscribe to FAN high-availability events and react to service, instance and database up and down events.
5 DB_ROLE_CHANGE system event
Fired when the primary db is first opened after a dg role transition occurs. Using this system event you can write a trigger to perform post-role change actions.

CLIENT FAILOVER – BEST PRACTICES
================================
Configure OCI clients for FAN OCI
– AQ_HA_NOTIFICATIONS
Configure DBC clients for fast connection failover and FAN ONS
– ONS daemons on primary and standby clusters
– JDBC client uses remote subscription to all daemons
Implement fast ADDRESS_LIST transversal
– OCI: OUTBOUND_CONNECT_TIMEOUT
– JDBC: SQLnetDef.TCP_CONNTIMEOUT_STR

AUTOMATING FAILOVER FOR OCI CLIENTS
===================================
1 Ensure the configuration is managed by data guard broker.
2 Use DBMS_SERVICE.CREATE_SERVICE to create a db service, enable high-availability notification and configure server-side TAF settings.
3 Create a trigger on system startup to relocate db services after a role transition
4 Create an Oracle Net Service name that includes an address entry for the primary and all standby database hosts.
ON OCI CLIENTS

Use the OCI_EVENTS parameter to initialize the environment so that OCI clients receive FAN notifications.
– OCIEnvCreate(…OCI_EVENTS…)
– see the Oracle Call Interface Programmers guide for additional information

.Link the OCI client applications with the thread library libthread or libpthread
.Set the SQLNET.OUTBOUND_CONNECT_TIMEOUT in SQLNET.ORA to 3 seconds
.Register an event callback that is invoked when a high-availability event occurs.

– see the Oracle Call Interface Programmers guide for additional information

AUTOMATING FAILOVER FOR OLE DB CLIENTS
======================================
1 Ensure the configuration is managed by data guard broker.
2 Use DBMS_SERVICE.CREATE_SERVICE to create a db service, enable high-availability notification and configure server-side TAF settings.
3 Create a trigger on system startup to relocate db services after a role transition

CONFIGURE OLE DB CLIENTS FOR FAILOVER
=====================================
1 Set the DBNotifications and DBNotificationPort OraOLEDB connection string attributes
2 Set the SQLNET.OUTBOUND_CONNECT_TIMEOUT to 3 in SQLNET.ORA

AUTOMATING FAILOVER FOR JDBC CLIENTS
======================================
Because JDBC clients use FCF rather than TAF, db services for JDBC clients are not configured for AQ HA events. Instead a trigger is required to notify JDBC clients when a data guard failover occurs.
1) Use DBMS_SERVICE.CREATE_SERVICE to create the db service
2) Configure ONS in $ORACLE_HOME/opmn/conf on all hosts that may contain a primary database.
refer Oracle Database JDBC developers guide
3) Start the ONS daemon
4) Create the service trigger to relocate the db service after a role transition
5) Create a trigger on the DB_ROLE_CHANGE system event that calls a C program named the FAN ONS Publisher.
JDBC clients are notified of the primary site failure and instructed to reconnect to the new primary database.
refet to the white paper “Client Failover best practices fo Highly Available Oracle Databases: Oracle Database 10g Release 2”

CONFIGURING JDBC CLIENTS FOR FAILOVER
=====================================
1) Set “FastConnectionFailoverEnabledDatasource” property to true so the client app uses implicit JDBC connection cache on its datasource
2) Set oracle.net.ns.SQLnetDef.TCP_CONNTIMEOUT_STR to 3 seconds on the data source.
This property enables the JDBC client to quickly traverse an address list in the event of a failure.
3) Create an oracle net service name that includes an ADDRESS entry for the primary db host and all standby hosts
4) Configure an remote ONS subscription on the JDBC client so that an ONS daemon is not required on the client. The remote ONS subscription should contain all hosts that can become a primary db.
5) Enable SSL fo communications.

 Comment 

DGMGRL – Active Data Guard – enabling and using

on September 9, 2009 at 1:30 pm
Posted In: Oracle Data Guard Notes (Cat)

Seperately licensed for 11g which

  • includes the real-time query facility.
  • enables you to configure RMAN block change tracking for a physical standby database

ENABLING
========
DGMGRL> EDIT DATABASE ‘pc00sby1′ SET STATE=’apply-off’;
SQL> ALTER DATABASE OPEN;
DGMGRL> EDIT DATABASE ‘pc00sby1′ SET STATE=’apply-on’;
SQL> SHUTDOWN IMMEDIATE;
SQL> STARTUP MOUNT;

 

BLOCK CHANGE TRACKING
=====================
SQL> ALTER DATABASE ENABLE | DISABLE BLOCK CHANGE TRACKING {USING FILE ‘…’};

SQL> SELECT FILENAME, STATUS, BYTES FROM V$BLOCK_CHANGE_TRACKING;

SQL> SELECT * FROM V$BACKUP_DATAFILE;

 

 Comment 

Snapshot databases, creating and using

on September 9, 2009 at 1:22 pm
Posted In: Oracle Data Guard Notes (Cat)
  • A snapshot standby db is a fully updateable standby database created by converting a physical standby
  • Snapshot standby databases receive and archive, but not apply, redo data from the primary.
  • When a physical standby is converted an implicit guarantee resore point is created and flashback database is enabled.

CONVERTING
==========
DGMGRL> CONVERT DATABASE pc00sby1 TO SNAPSHOT DATABASE;

WARNING
=======

  • Potential data loss when there is a corrupted log file. A corrupted log file from the primary will not be detected until the db is converted back to a standby.
  • It may take a long time to convert the snapshot db back to a standby.

CAN NOT BE
==========
The only standby db in maximum protection mode
The target of a switchover
A fast-start failover target

VIEWING INFORMATION
===================
SQL> SELECT DATABASE_ROLE FROM V$DATABASE

DGMGRL> SHOW CONFIGURATION [VERBOSE];
DGMGRL> SHOW DATABASE pc00sby1;

CONVERTING BACK
===============
DGMGRL> CONVERT DATABASE pc00sby1 TO PHYSICAL STANDBY;

 Comment 

Fast-Start Failover

on September 9, 2009 at 1:09 pm
Posted In: Oracle Data Guard Notes (Cat)

fast-start failover occurs when:

1) a datafile is offline because of a write error
2) dictionary corruption of a critical database object
3) control file damaged because of a disk error
4) LGWR is unable to write to any member of the log group because of an I/O error
5) Archiver is unable to archive a redo log because the device is full or unavailable
6) primary to observer and primary to standby network failure
7) an instance crash occurs (single instance)
8) all instances of a rac crash
9) shutdown abort of primary

Must install DGMGRL on an observer computer
To install either:
1) Install complete Oracle Client Administrator (use administrator option in OUI).
2) Install a full db installation

  1. PRE-REQS Must be in max availability or max performance
  2. LogXptMode must be in sync for 10g
    LogXptMode must be in SYNC in max availability for 11g
    LogXptMode must be in ASYNC in max performance for 11g
  3. FLASHBACK database must be enabled on primary and standby
  4. tnsnames.ora must be configured on the observer
  5. A static service name must exist so the observer can automatically restart databases.

Configuring fast-start failover:

  • Specify target databases
    DGMGRL> EDIT DATABASE pc00prmy SET PROPERTY FastStartFailoverTarget = pc00sby1;
    DGMGRL> EDIT DATABASE pc00sby1 SET PROPERTY FastStartFailoverTarget = pc00prmy;
  • Set the protection mode
    DGMGRL> EDIT DATABASE pc00prmy SET PROPERTY LogXptMode=SYNC;
    DGMGRL> EDIT DATABASE pc00sby1 SET PROPERTY LogXptMode=SYNC;
    DGMGRL> EDIT CONFIGURATION SET PROTECTION MODE AS MaxAvailability;

DGMGRL> EDIT DATABASE pc00prmy SET PROPERTY LogXptMode=ASYNC;
DGMGRL> EDIT DATABASE pc00sby1 SET PROPERTY LogXptMode=ASYNC;
DGMGRL> EDIT CONFIGURATION SET PROTECTION MODE AS MaxPerformance;

In max performance mode set the FastStartFailoverLagLimit property to an acceptable limit (seconds).
If the standby db is further behind than this value fast-start failover is not allowed.

  • Set the fast-start failover threshold
    DGMGRL> EDIT CONFIGURATION SET PROPERTY FastStartFailoverThreshold = 30; (seconds, 30 is default)
    Recommended values:
    A) Single instance low latency reliable network 10 to 15
    B) Single instance high latency network over WAN 30 to 45
    C) RAC primary = (CSS misscount + reconfiguration time) + (24 to 40 seconds)
  • Set additional properties
    FastStartFailoverLagLimit (as above)
    FastStartFailoverPmyShutdown (FALSE | TRUE)
    When FALSE primary stalls awaiting diagnosis of the condition that caused the fast-start failover.
    When TRUE primary shutdowns with abort
    FastStartFailoverAutoReinstate (TRUE | FALSE)
    When TRUE the primary is restarted as a standby

Set the ObserverConnectIdentifier to specify how the observer should connect to and monitor the primary and standby databases.
DGMGRL> EDIT DATABASE pc00prmy SET PROPERTY ObserverConnectIdentifier = ‘ ‘;
Setting this property enables the observer to use the identifier to ship redo data.
The default identifier is the value of DGConnectIdentifier property
Can be specified to different valuses for primary and standby.

DGMGRL> ENABLE FAST_START FAILOVER CONDITION “value”;
DGMGRL> SHOW FAST_START FAILOVER;
e.g.
dgmgrl> enable fast_start failover condition “Datafile Offline”; *
dgmgrl> enable fast_start failover condition “Corrupted Controlfile”; *
dgmgrl> enable fast_start failover condition “Corrupted Dictionary”; *
dgmgrl> enable fast_start failover condition “Inaccessible Logfile”;
dgmgrl> enable fast_start failover condition “Stuck Archiver”;
* = default values.

DGMGRL> ENABLE FAST_START FAILOVER;
DGMGRL> START OBSERVER;
DGMGRL> SHOW CONFIGURATION VERBOSE;
DGMGRL> START OBSERVER FILE=$ORACLE_HOME/dbs/Boston.dat;
If file is not set the current working directory is searched for a file named FSFO.dat
Command is NOT returned to the user.
The DGMGRL observer must be stopped from another session with the STOP OBSERVER command.

DGMGRL> SHOW FAST_START FAILOVER;

INITIATING FAST-START FAILOVER FROM AN APPLICATION
==================================================
An application can initiate a fast_start failover using the procedure DBMS_DG.INITIATE_FS_FAILOVER
Requires SYSDBA privilege.
DBMS_DG.INITIATE_FS_FAILOVER calls DBMS_DRS.INITIATE_FS_FAILOVER.
Grant execute on DBMS_DG.INITIATE_FS_FAILOVER to the required users.

VIEWING FAST-START FAILOVER INFORMATION
=======================================
SELECT
FS_FAILOVER_STATUS AS STATUS,
FS_FAILOVER_CURRENT_TARGET AS CURR_TARGET, db_unique_name of target standby database
FS_FAILOVER_THRESHOLD AS THRESHOLD, seconds during which the observer will attempt to connect to primary before failover
FS_FAILOVER_OBSERVER_PRESENT AS OBS_PRES,
FS_FAILOVER_OBSERVER_HOST AS OBS_HOST
FROM V$DATABASE;

DETERMINING THE REASON FOR A FAST_START FAILOVER
================================================

SELECT LAST_FAILOVER_TIME, LAST_FAILOVER_REASON FROM V$FS_FAILOVER_STATUS;

MOVING THE OBSERVER
===================
STOP THE OBSERVER AND RECREATE ON A NEW HOST

 Comment 

standby switchover and failover role transitions using DGMGRL

on September 9, 2009 at 9:09 am
Posted In: Oracle Data Guard Notes (Cat)

You can enable fast start failover to fail over automatically when the primary database becomes unavailable.

DGMGRL> SWITCHOVER to ‘pc00sby1’;
DGMGRL> FAILOVER to ‘pc00sby1’ [IMMEDIATE]; If immediate is used then no attempt is made to apply any unapplied redo that has been received.

Reinstating databases.
Must have flashback on and flashback logs available.

start the db in mount mode.
DGMGRL> REINSTATE DATABASE ‘pc00prmy’;

if reinstate fails then recreate from a backup / copy
and then enable:
DGMGRL> ENABLE DATABASE pc00prmy;

 Comment 

DELETE Using flashback database after resetlogs (oracle 11g)

on September 9, 2009 at 8:58 am
Posted In: Oracle Flashback Notes (Cat)

For a physical/logical standby database it is possible that redo apply might not halt when an OPEN RESETLOGS command is encountered.

PHYSICAL STANDBY
================
If the physical standby db SCN is far enough behind the primary database SCN then the redo apply service can interpret the OPEN RESETLOGS without stopping.

N.B. Recall the “recovery through RESETLOGS” was implemented in 10g.

Use the following:

1) On primary determine an SCN at least 2 SCN’s prior to the OPEN RESETLOGS
SELECT TO_CHAR(resetlogs_change# – 2) FROM v$DATABASE;

2) On standby, obtain the current SCN
SELECT TO_CHAR(current_scn) FROM V$DATABASE;

3) On standby flashback db
FLASHBACK STANDBY DATABASE TO SCN

4) On standby restart recovery
ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT;

LOGICAL STANDBY
===============
1) On primary determine an SCN at least 2 SCN’s prior to the OPEN RESETLOGS
SELECT TO_CHAR(resetlogs_change# – 2) FROM v$DATABASE;

2) On standby, obtain the current SCN
SELECT TO_CHAR(current_scn) FROM V$DATABASE;

3) On standby flashback db
FLASHBACK STANDBY DATABASE TO SCN

4) On standby restart recovery
ALTER DATABASE START LOGICAL STANDBY APPLY IMMEDIATE;

 

 Comment 

Using flashback database after RESETLOGS

on September 9, 2009 at 8:58 am
Posted In: Oracle Data Guard Notes (Cat)

For a physical/logical standby database it is possible that redo apply might not halt when an OPEN RESETLOGS command is encountered.

PHYSICAL STANDBY
================
If the physical standby db SCN is far enough behind the primary database SCN then the redo apply service can interpret the OPEN RESETLOGS without stopping.

N.B. Recall the “recovery through RESETLOGS” was implemented in 10g.

Use the following:

1) On primary determine an SCN at least 2 SCN’s prior to the OPEN RESETLOGS
SELECT TO_CHAR(resetlogs_change# – 2) FROM v$DATABASE;

2) On standby, obtain the current SCN
SELECT TO_CHAR(current_scn) FROM V$DATABASE;

3) On standby flashback db
FLASHBACK STANDBY DATABASE TO SCN

4) On standby restart recovery
ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT;

LOGICAL STANDBY
===============
1) On primary determine an SCN at least 2 SCN’s prior to the OPEN RESETLOGS
SELECT TO_CHAR(resetlogs_change# – 2) FROM v$DATABASE;

2) On standby, obtain the current SCN
SELECT TO_CHAR(current_scn) FROM V$DATABASE;

3) On standby flashback db
FLASHBACK STANDBY DATABASE TO SCN

4) On standby restart recovery
ALTER DATABASE START LOGICAL STANDBY APPLY IMMEDIATE;

 

 Comment 

set up flashback database (Oracle 11g)

on September 9, 2009 at 8:49 am
Posted In: Oracle Flashback Notes (Cat)

Must be configured to use:
fast start failover
snapshot standby
must be in archivelog mode
Flashback database is recommended when using the broker because the broker automatically enables real-time apply.

Oracle database uses past block images to back out changes to the database.
During normal operation oracle occasionally logs these block images in flashback logs, which are written sequentially and not archived.

All files that are needed to completely recover a database from media failure are part of the flash recovery area.
(include archived redo log files, control files, rman backups, flashback logs and the change tracking file)

parameters:
ALTER SYSTEM SET DB_RECOVERY_FILE_DEST_SIZE =10G;
ALTER SYSTEM SET DB_RECOVERY_FILE_DEST = ‘+DISKn’;
– recommendation is NOT to set this to any other of the dest parameters (
db_create_file_dest
db_create_online_log_dest_n
control_files)

select estimated_flashback_size from v$flashback_database_log and then set
DB_FLASHBACK_RETENTION_TARGET

SHUTDOWN IMMEDIATE
STARTUP MOUNT;
ALTER SYSTEM SET DB_FLASHBACK_RETENTION_TARGET=2880 SCOPE=BOTH;
ALTER DATABASE FLASHBACK ON;
ALTER DATABASE OPEN;

select flashback_on from v$database;
If flashback is set to off then all existing flashback logs are deleted automatically.

Default location is $ORACLE_BASE/flash_recovery_area

e.g. alter system set log_archive_dest_n = ‘location=use_db_recovery_file_dest …’;

If DB_RECOVERY_FILE_DEST is specified and no LOG_ARCHIVE_DEST_n is specified, then LOG_ARCHIVE_DEST_10 is implicitly set to the recovery area.
You can override this behavior by setting LOG_ARCHIVE_DEST_10 to an empty string.

 

 Comment 

set up flashback database

on September 9, 2009 at 8:49 am
Posted In: Oracle Data Guard Notes (Cat)

Must be configured to use:
fast start failover
snapshot standby
must be in archivelog mode
Flashback database is recommended when using the broker because the broker automatically enables real-time apply.

Oracle database uses past block images to back out changes to the database.
During normal operation oracle occasionally logs these block images in flashback logs, which are written sequentially and not archived.

All files that are needed to completely recover a database from media failure are part of the flash recovery area.
(include archived redo log files, control files, rman backups, flashback logs and the change tracking file)

parameters:
ALTER SYSTEM SET DB_RECOVERY_FILE_DEST_SIZE =10G;
ALTER SYSTEM SET DB_RECOVERY_FILE_DEST = ‘+DISKn’;
– recommendation is NOT to set this to any other of the dest parameters (
db_create_file_dest
db_create_online_log_dest_n
control_files)

select estimated_flashback_size from v$flashback_database_log and then set
DB_FLASHBACK_RETENTION_TARGET

SHUTDOWN IMMEDIATE
STARTUP MOUNT;
ALTER SYSTEM SET DB_FLASHBACK_RETENTION_TARGET=2880 SCOPE=BOTH;
ALTER DATABASE FLASHBACK ON;
ALTER DATABASE OPEN;

select flashback_on from v$database;
If flashback is set to off then all existing flashback logs are deleted automatically.

Default location is $ORACLE_BASE/flash_recovery_area

e.g. alter system set log_archive_dest_n = ‘location=use_db_recovery_file_dest …’;

If DB_RECOVERY_FILE_DEST is specified and no LOG_ARCHIVE_DEST_n is specified, then LOG_ARCHIVE_DEST_10 is implicitly set to the recovery area.
You can override this behavior by setting LOG_ARCHIVE_DEST_10 to an empty string.

 

 Comment 

Optimizing Data Guard

on September 7, 2009 at 2:12 pm
Posted In: Oracle Data Guard Notes (Cat)

ReopenSecs : no of secs before archiver tries to access a previously failed destination
REOPEN of LOG_ARCHIVE_DEST_n
DGMGRL> EDIT DATABASE ‘pc00sby1’ SET PROPERTY ‘ReopenSecs’=600;

 

NetTimeout : no of seconds the LGWR will wait for Oracle Net Services to respond to a request
NET_TIMEOUT of LOG_ARCHIVE_DEST_n

DGMGRL> EDIT DATABASE ‘pc00sby1’ SET PROPERTY ‘NetTimeout’=20;

MaxConnections : redo transport uses all available bandwidth by allowing a single large redo log to be transferred in parallel by multiple archiver processes. (5 is the max value, default is 1).
MAX_CONNECTIONS of LOG_ARCHIVE_DEST_n
N.B. you must set LOG_ARCHIVE_MAX_PROCESSES >= value used.
DGMGRL> EDIT DATABASE ‘pc00sby1’ SET PROPERTY ‘MaxConnections’=5;

RedoCompression : enables compression of archived redo logs during gap transmission
COMPRESSION of LOG_ARCHIVE_DEST_n
DGMGRL> EDIT DATABASE ‘pc00sby1’ SET PROPERTY ‘RedoCompression’=’ENABLE’;

DelayMins : no of minutes log apply services must wait before applying redo data to the standby database
DELAY of LOG_ARCHIVE_DEST_n
DGMGRL> EDIT DATABASE ‘pc00sby1’ SET PROPERTY ‘DelayMins’=5;

LOGICAL STANDBY
===============

adjust no of processes allocated to SQL Apply
MAX_SERVERS, APPLY_SERVERS, PREPARE_SERVERS
applier processes
———————–
SELECT COUNT(*) AS IDLE_APPLIER FROM V$LOGSTDBY_PROCESS WHERE TYPE = ‘APPLIER’ AND STATUS_CODE = 16166; shows any idle appliers.
SELECT NAME, VALUE FROM V$LOGSTDBY_STATS WHERE NAME LIKE ‘transactions%’;
Returns no of transactions ready to be applied and no of transactions already applied.
If difference between the nos is > twice no of available applier processes then you can increas the no of appliers.

SQL> EXECUTE DBMS_LOGSTDBY.APPLY_SET(‘MAX_SERVERS’,26);
SQL> EXECUTE DBMS_LOGSTDBY.APPLY_SET(‘PREPARE_SERVERS’,26);

preparer processes
————————-
determine if all preparer processes are busy.
SELECT COUNT(*) AS IDLE_PREPARER FROM V$LOGSTDBY_PROCESS WHERE TYPE = ‘PREPARER’ AND STATUS_CODE = 16166;
determine if no of transactions ready to be applied is < no of APPLIER processes.
SELECT NAME, VALUE FROM V$LOGSTDBY_STATS WHERE NAME LIKE ‘transactions%’;
SELECT COUNT(*) AS APPLIER_COUNT FROM V$LOGSTDBY_PROCESS WHERE TYPE = ‘APPLIER’;
determine if there are idle applier processes
SELECT COUNT(*) AS IDLE_APPLIER FROM V$LOGSTDBY_PROCESS WHERE TYPE = ‘APPLIER’ AND STATUS_CODE = 16166;

SQL> EXECUTE DBMS_LOGSTDBY.APPLY_SET(‘MAX_SERVERS’,26);
SQL> EXECUTE DBMS_LOGSTDBY.APPLY_SET(‘PREPARE_SERVERS’,26);

 Comment 

Monitoring data guard

on September 7, 2009 at 1:51 pm
Posted In: Oracle Data Guard Notes (Cat)

DGMGRL> SHOW DATABASE ‘pc00prmy’ ‘StatusReport’;
DGMGRL> SHOW DATABASE ‘pc00prmy’ ‘LogXptStatus’;
DGMGRL> SHOW DATABASE ‘pc00prmy’ ‘InconsistentProperties’;
DGMGRL> SHOW DATABASE ‘pc00prmy’ ‘InconsistentLogXptProps’;
DGMGRL> SHOW CONFIGURATION;
DGMGRL> SHOW DATABASE ‘pc00prmy’;
DGMGRL> SHOW DATABASE verbose ‘pc00prmy’;

SQL> SELECT GROUP#, STATUS, MEMBER FROM V$LOGFILE WHERE TYPE = ‘STANDBY’;
SQL> SELECT GROUP#, DBID, ARCHIVED, STATUS FROM V$STANDBY_LOG;
if archived=yes and status=active, redo log is currently being written to.
if archived=no and status=active, redo log is waiting to be archived.
SQL> SELECT DEST_ID, VALID_TYPE, VALID_ROLE, VALID_NOW FROM V$ARCHIVE_DEST;

TRACE

ALTER SYSTEM SET LOG_ARCHIVE_TRACE=trace_level, trace is written to the DIAGNOSTIC_DEST location.
trace level:
0=disabled
1=track archiving of redo logs
2=tracks archival status per archived redo log destination
4=track archival operational phase
8=tracks archived redo log destination activity
16=tracks detailed archived redo log destination activity
32=tracks archived redo log destination parameter modifications
64=tracks ARCn process state activity
128=tracks FAL server process activity
256=reserved
512=tracks async LGWR activity
1024=tracks RFS physical client
2048=tracks ARCn or RFS heartbeat
4096=tracks real-time apply activity
8192=tracks redo apply activity (media recovery or physical standby)

SELECT PROCESS, STATUS, GROUP#, THREAD#, SEQUENCE# FROM V$MANAGED_STANDBY ORDER BY PROCESS, GROUP#, THREAD#, SEQUENCE#;

SELECT NAME, VALUE, TIME_COMPUTED FROM V$DATAGUARD_STATS;

SELECT TIMESTAMP, FACILITY, DEST_ID, MESSAGE_NUM, ERROR_CODE, MESSAGE FROM V$DATAGUARD_STATUS ORDER BY TIMESTAMP;

SELECT PRIMARY_XID, TYPE, MINIG_STATUS, APPLY_STATUS FROM V$LOGSTDBY_TRANSACTION;

 Comment 

Standby data protection modes and DGMGRL

on September 7, 2009 at 1:36 pm
Posted In: Oracle Data Guard Notes (Cat)

MAXIMUM PROTECTION ….SYNC … zero data loss, double failure protection, stall primary
MAXIMUM AVAILABILITY …SYNC … zero data loss, stall primary, switch to max perf
MAXIMUM PERFORMANCE ..ASYNC .. potential data loss, never stall

USING DGMGRL

Configure standby redo logs
Set LogXptMode(sync, sync, asyn)
Set data protection mode

DGMGRL> EDIT DATABASE ‘pc00sby1’ SET PROPERTY ‘LogXptMode’=’SYNC’;
DGMGRL> EDIT CONFIGURATION SET PROTECTION MODE AS MAXAVAILABILITY;

 Comment 

LOGICAL STANDBY CONFIGURATION

on September 7, 2009 at 1:30 pm
Posted In: Oracle Data Guard Notes (Cat)

Logical Standby

Redo information shipped  from the primary (i.e. archived redo log information) is transformed into SQL by using Log Miner technology and then applied to the database.

The reader process reads redo records from the archived redo logs.
The preparer process converts the block changes into table changes or logical change records (LCR’s)
The builder process assembles completed transactions from the LCR’s
The analyzer process examines the records possibly eliminating transactions and identifying dependencies between the dirrerent transactions.
The coordinator process (LSP)
assigns transactions
monitors dependencies between transactions and coordinates scheduling
authorizes the commitment of changes to the logical standby database.
The applier process
Applies the LCR’s to the database.
Asks the coordinator process to approve transactions with unresolved dependencies
Commits the transactions

Unsupported Objects:
Tables and sequences in the SYS schema
Tables using table compression
Tables used to support materialized views
Global temporary tables
Tables with unsupported datatypes.

Unsupported Datatypes:
BFILE, ROWID and UROWID
User-defined types
Multimedia data types (Spatial, Image, Oracle text)
Collections (VARRAYS and nested tables)
BINARY XML

SELECT * FROM DBA_LOGSTDBY_UNSUPPORTED_TABLE order by owner;

SELECT * FROM DBA_LOGSTDBY_UNSUPPORTED order by owner;

COMMANDS NOT EXECUTED ON A LOGICAL STANDBY FROM A PRIMARY DATABASE
alter database ………….EXPLAIN
alter session …………..LOCK TABLE
alter materialized view ….SET CONSTRAINTS
alter materialized view log.SET ROLE
alter system ……………SET TRANSACTION
create control file
create database
create database link
create pfile from spfile
create schema authorization
create materialized view
create materialized view log
create spfile from pfile
drop database link
drop materialized view
drop materialized view log

It is best (but not necessary) if all tables have unique keys on them.
SELECT * FROM DBA_LOGSTDBY_NOT_UNIQUE;
alter table hr.employees add primary key (id, name) rely disable;

STEPS
=====
create a physical standby database
stop redo apply on the standby
prepare primary db to support a logical standby
build a logminer dictionary in the redo data
transition to a logical standby db
open logical standby db
verify logical standby db

stop redo apply on the standby
==============================
ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;

prepare primary db to support a logical standby
==============================
ALTER SYSTEM SET LOG_ARCHIVE_DEST_2=(‘LOCATION= VALID_FOR=(STANDBY_LOGFILES, STANDBY_ROLE) DB_UNIQUE_NAME=pc00prmy’;
set UNDO_RETENTION=3600

build a logminer dictionary in the redo data
==============================
SQL> EXECUTE DBMS_LOGSTDBY.BUILD;

transition to a logical standby db (on standby)
==============================
ALTER DATABASE R£ECOVER TO LOGICAL STANDBY db_name;
SHUTDOWN IMMEDIATE;
STARTUP MOUNT;
change LOG_ARCHIVE_DEST_n parameters to ensure redo from the new database and redo from the primary are not in the same destination.

open logical standby db
==============================
ALTER DTABASE OPEN RESETLOGS;
ALTER DATBASE START LOGICAL STANDBY APPLY IMMEDIATE;

Use DGMGRL to add a logical standby to an existing data guard configuration:
DGMGRL> ADD DATABASE ‘pc00sby2’ AS CONNECT IDENTIFIER IS ‘pc00sby2’;

verify logical standby db
==============================
select sequence#, first_time, next_time, dict_begin, dict_end FROMm DBA_LOGSTDBY_LOG ORDER BY sequence#;
select name, value FROM V$LOGSTDBY_STATS WHERE name = ‘coordinator state’;
select sid, serial#, spid, type, high_scn FROM V$LOGSTDBY_PROCESS;
select applied_scn, latest_scn FROM V$LOGSTDBY_PROGRESS;

Securing the Logical standby
============================
ALTER DATABASE GUARD ALL – prevents users making any changes – DEFAULT
ALTER DATABASE GUARD STANDBY – prevents users making changes to data maintained by data guard sql apply
ALTER DATABASE GUARD NONE – normal security
SELECT GUARD_STATUS FROM V$DATABASE;
applies to all users except SYS.

Archived redo logs are automatically deleted after apply.
use LOG_AUTO_DELETE parameter (TRUE / FALSE)
LOG_AUTO_DEL_RETENTION_TARGET – only used if flash recovery area is not being used to store remote archived logs
execute DBMS_LOGSTDBY.APPLY_SET
execute DBMS_LOGSTDBY.APPLY_UNSET

MANAGING SQL APPLY FILTERING
============================
LsbyASkipCfgPr – SQL apply should ignore (skip) SQL statements as specified
LsbyDSkipCfgPr – delete
LsbyASkipErrorCfgPr – SQL apply should ignore (skip) errors as specified
LsbyDSkipErrorCfgPr – delete
LsbyASkipTxnCfgPr – SQL apply should ignore (skip) transactions as specified
LsbyDSkipTxnCfgPr – delete
SELECT ERROR, STATEMENT_OPT, NAME, USE_LIKE, ESC, PROC FROM DBA_LOGSTDBY_SKIP WHERE OWNER = ‘HR’;

DBMS_SCHEDULER ON A LOGSTDBY
============================
scheduler jobs have default local role.
Activate existing jobs by using the DATABASE_ROLE attribute of DBMS_SCHEDULER.SET_ATTRIBUTE where:
PRIMARY = job runs only when the db is in primary role
LOGICAL STANDBY = job runs only when the db is in logical standby role

 

 Comment 

DGMGRL – Data Guard Manager

on September 7, 2009 at 12:36 pm
Posted In: Oracle Data Guard Notes (Cat)

Data Guard Manager

DMON process

DGMGRL

Created the “drc” trace file in the DIAGNOSTIC_DEST location

DGMGRL> connect sys/oracle
DGMGRL> ADD – add a standby database to the broker configuration
DGMGRL> CONNECT – connect the user to the instance
DGMGRL> CREATE – create broker configurations
DGMGRL> DISABLE – disable broker control of a configuration or database
DISABLE CONFIGURATION;
DISABLE DATABASE ‘pc00sby1’;
DGMGRL> EDIT – a configuration, database or instance
DGMGRL> ENABLE – enables you to enable broker control of a configuration or database
DGMGRL> EXIT/QUIT
DGMGRL> FAILOVER – performs a db failover
DGMGRL> HELP
DGMGRL> REINSTATE – changes a disabled db into a viable standby db.
DGMGRL> REMOVE – removes a broker configuration, a standby db profile or knowledge of an instance
REMOVE DATABASE ‘pc00sby1’;
REMOVE CONFIGURATION;
DGMGRL> SHOW
DGMGRL> SHUTDOWN – shutdown the instance
DGMGRL> START – start the Fast-Start Failover Observer
DGMGRL> STARTUP – starts the instance
DGMGRL> STOP – stop the Fast-Start Failover Observer
DGMGRL> SWITCHOVER – performs a switchover

To enable Data Gurad Broker to start/stop instances a service with a specific name must be registered.
The value of GLOBAL_DBNAME must be ‘db_unique_name_DGMGRL.db_domain’.
ALTER SYSTEM SET DG_BROKER_START=TRUE;
Set DG_BROKER_CONFIG_FILEn so that all instances point to the same shared files for that database.
Must use and SPFILE
Broker log files are created in the alert log directory and are named drc.log

DGMGRL>
DGMGRL> CREATE CONFIGURATION ‘DGConfig1’ AS PRIMARY DATABASE IS pc00prmy CONNECT IDENTIFIER IS pc00prmy;
DGMGRL> ADD DATABASE pc00sby1 AS CONNECT IDENTIFIER IS pc00sby1;
( in above lines the db name must be the same as the db_unique_name)
DGMGRL> ENABLE CONFIGURATION;
DGMGRL> SHOW CONFIGURATION
To alter a database property
DGMGRL> EDIT DATABASE pc00sby1 SET PROPERTY L0gXptMode=’SYNC’;
DGMGRL> EDIT DATABASE pc00sby1 SET STATE=’APPLY-OFF’;
DGMGRL> EDIT DATABASE pc00prmy SET STATE=’TRANSPORT-OFF’;
( TRANSPORT-ON, TRANSPORT-OFF, APPLY-ON, APPLY-OFF)

DGConnectIdentifier value is used in the FAL_SERVER and FAL_CLIENT initialisation parameters,
changing this updates LOG_ARCHIVE_DEST_n and FAL_CLIENT, FAL_SERVER
LogXptMode – ASYNC (noaffirm), SYNC (Affirm)
LogShipping – ON, OFF (only used when database is in the TRANSPORT-ON state).

 

 

 Comment 
  • Page 3 of 5
  • «
  • 1
  • 2
  • 3
  • 4
  • 5
  • »

©2006-2017 isitdevops.com/databases | Powered by WordPress with ComicPress | Subscribe: RSS | Back to Top ↑