Quantcast
Channel: Sameer Shaik. B.E,M.S,M.B.A,P.M.P,C.S.M
Viewing all 191 articles
Browse latest View live

Oracle Deferred Statistics, Dynamic Sampling & Extended Statistics:

$
0
0

Deferred Statistics, Dynamic Sampling & Extended Statistics:



Lets explore how the deferred statistics works and what impact does the dynamic sampling has on the optimizer when the statistics are missing.


SQL> show user
USER is "ARCHIVE"

SQL> create table stats (c1 number,c2 number,c3 number,c4 number,c5 number,
 2  c6 number,c7 number,c8 number,c9 number);

Table created.

SQL> begin
   for a in 1..5
    loop
      for b in 1..100 loop
        insert into stats values (a,a,a,a,a,b,b,b,b);
      end loop;
   end loop;
   end;
   /

PL/SQL procedure successfully completed.

SQL> select count(*) from stats;

 COUNT(*)
----------
      500

SQL> commit;

Commit complete.

SQL> @sql.sql                 
SQL> set lines 100
SQL> set linesize 100

SQL> select table_name,last_analyzed,sample_size,num_rows from user_tables where table_name='STATS';

TABLE_NAME              LAST_ANAL SAMPLE_SIZE   NUM_ROWS
------------------------------ --------- ----------- ----------
STATS

SQL> select index_name from user_indexes where table_name='STATS';

no rows selected

SQL> desc user_tab_pending_stats
Name                              Null?    Type
----------------------------------------------------- -------- ------------------------------------
TABLE_NAME                           VARCHAR2(30)
PARTITION_NAME                        VARCHAR2(30)
SUBPARTITION_NAME                       VARCHAR2(30)
NUM_ROWS                           NUMBER
BLOCKS                            NUMBER
AVG_ROW_LEN                           NUMBER
SAMPLE_SIZE                           NUMBER
LAST_ANALYZED                           DATE

SQL> select table_name,last_analyzed,sample_size,num_rows from user_tab_pending_stats;

no rows selected

Default method_opt options doesn’t create the histograms on the columns:

SQL> exec dbms_stats.gather_table_stats('ARCHIVE','STATS');

PL/SQL procedure successfully completed.

SQL> select table_name,last_analyzed,sample_size,num_rows from user_tables where table_name='STATS';

TABLE_NAME              LAST_ANAL SAMPLE_SIZE   NUM_ROWS
------------------------------     ---------        -----------         ----------
STATS                  16-AUG-15             500            500

SQL> select table_name,column_name,last_analyzed,sample_size,histogram from user_tab_col_statistics where table_name='STATS';

TABLE_NAME              COLUMN_NAME             LAST_ANAL SAMPLE_SIZE HISTOGRAM
------------------------------ ------------------------------ --------- ----------- ---------------
STATS                  C1                 16-AUG-15     500 NONE
                 C2                 16-AUG-15     500 NONE
                 C3                 16-AUG-15     500 NONE
                 C4                 16-AUG-15     500 NONE
                 C5                 16-AUG-15     500 NONE
                 C6                 16-AUG-15     500 NONE
                 C7                 16-AUG-15     500 NONE
                 C8                 16-AUG-15     500 NONE
                 C9                 16-AUG-15     500 NONE


9 rows selected.

SQL> select table_name,column_name,last_analyzed,sample_size from user_col_pending_stats where table_name='STATS';

no rows selected


Delete the stats:
SQL> exec dbms_stats.delete_table_stats('ARCHIVE','STATS');

PL/SQL procedure successfully completed.

SQL> select table_name,column_name,last_analyzed,sample_size from user_col_pending_stats where table_name='STATS';

no rows selected

SQL> select table_name,column_name,last_analyzed,sample_size,histogram from user_tab_col_statistics where table_name='STATS';

no rows selected



SQL> select dbms_stats.get_prefs('publish','archive','stats') publish from dual;

PUBLISH
--------------------------------------------------------------------------------
TRUE

SQL> exec dbms_stats.set_table_prefs('ARCHIVE','STATS','PUBLISH','FALSE');

PL/SQL procedure successfully completed.

SQL> select dbms_stats.get_prefs('publish','archive','stats') publish from dual;

PUBLISH
--------------------------------------------------------------------------------
FALSE

SQL> exec dbms_stats.gather_table_stats('ARCHIVE','stats',method_opt=>'for all columns size 1 for columns c1 size 254 for columns c2 size 254');

PL/SQL procedure successfully completed.

SQL> select table_name,column_name,last_analyzed,sample_size,histogram from user_tab_col_statistics where table_name='STATS';

no rows selected

SQL> select table_name,column_name,last_analyzed,sample_size from user_col_pending_stats where table_name='STATS';

TABLE_NAME              COLUMN_NAME             LAST_ANAL SAMPLE_SIZE
------------------------------ ------------------------------ --------- -----------
STATS                  C1                 16-AUG-15     500
STATS                  C2                 16-AUG-15     500
STATS                  C3                 16-AUG-15     500
STATS                  C4                 16-AUG-15     500
STATS                  C5                 16-AUG-15     500
STATS                  C6                 16-AUG-15     500
STATS                  C7                 16-AUG-15     500
STATS                  C8                 16-AUG-15     500
STATS                  C9                 16-AUG-15     500

9 rows selected.

SQL> show parameter pending

NAME                    TYPE     VALUE
------------------------------------ ----------- ------------------------------
optimizer_use_pending_statistics     boolean     FALSE
SQL>


SQL> show parameter dynamic

NAME                    TYPE     VALUE
------------------------------------ ----------- ------------------------------
optimizer_dynamic_sampling         integer     2


SQL> alter session set optimizer_dynamic_sampling=0;

Session altered.

With dynamic sampling disabled and without any statistics on the table, optimizer makes a wrong guess on the number of rows.

Actual number of rows that satisfy the condition c1=1 & c2=1 are 100:

SQL> set autot on exp

SQL> select count(*) from stats where c1=1 and c2=1;

 COUNT(*)
----------
      100


Execution Plan
----------------------------------------------------------
Plan hash value: 2395854213

----------------------------------------------------------------------------
| Id  | Operation       | Name  | Rows  | Bytes | Cost (%CPU)| Time       |
----------------------------------------------------------------------------
|   0 | SELECT STATEMENT   |       |     1 |    26 |     3   (0)| 00:00:01 |
|   1 |  SORT AGGREGATE    |       |     1 |    26 |       |       |
|* 2 |   TABLE ACCESS FULL| STATS |     1 |    26 |     3   (0)| 00:00:01 |
----------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------

  2 - filter("C1"=1 AND "C2"=1)


Turn on Dynamic sampling:

Optimizer guessed the number of rows correctly when using the dynamic sampling:


SQL> alter session set optimizer_dynamic_sampling=2;

Session altered.

SQL> select count(*) from stats where c1=1 and c2=1;

 COUNT(*)
----------
      100


Execution Plan
----------------------------------------------------------
Plan hash value: 2395854213

----------------------------------------------------------------------------
| Id  | Operation       | Name  | Rows  | Bytes | Cost (%CPU)| Time       |
----------------------------------------------------------------------------
|   0 | SELECT STATEMENT   |       |     1 |    26 |     3   (0)| 00:00:01 |
|   1 |  SORT AGGREGATE    |       |     1 |    26 |       |       |
|*  2 |   TABLE ACCESS FULL| STATS |   100 |  2600 |     3   (0)| 00:00:01 |
----------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------

  2 - filter("C1"=1 AND "C2"=1)

Note
-----
  - dynamic sampling used for this statement (level=2)


Turn off dynamic sampling:
& Turn on optimizer_use_pending_statistics:
Optimizer guessed the number of rows wrong even with the pending statistics:


SQL> alter session set optimizer_dynamic_sampling=0;

Session altered.

SQL> alter session set optimizer_use_pending_statistics=true;

Session altered.




SQL> select count(*) from stats where c1=1 and c2=1;

 COUNT(*)
----------
      100


Execution Plan
----------------------------------------------------------
Plan hash value: 2395854213

----------------------------------------------------------------------------
| Id  | Operation       | Name  | Rows  | Bytes | Cost (%CPU)| Time       |
----------------------------------------------------------------------------
|   0 | SELECT STATEMENT   |       |     1 |     6 |     3   (0)| 00:00:01 |
|   1 |  SORT AGGREGATE    |       |     1 |     6 |       |       |
|*  2 |   TABLE ACCESS FULL| STATS |    20 |   120 |     3   (0)| 00:00:01 |
----------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------

  2 - filter("C1"=1 AND "C2"=1)


How the dynamic sampling affects the optimizer and its options:

Level
When Dynamic Sampling will be used
Sample size (blocks)
0
Switches off dynamic sampling
N/A
1
At least one non-partitioned table in the statement has no statistics
32
2 (default)
One or more tables in the statement have no statistics
64
3
Any statement that meets level 2 criteria and any statement that has one or more expressions used in the where clause predicates e.g. Where substr(CUSTLASTNAME,1,3) or Where a + b =5
64
4
Any statement that meets level 3 criteria and any statement that has complex predicates. An OR or AND operator between multiple predicates on the same table
64
5
Any statement that meets level 4 criteria
128
6
Any statement that meets level 4 criteria
256
7
Any statement that meets level 4 criteria
512
8
Any statement that meets level 4 criteria
1024
9
Any statement that meets level 4 criteria
4086
10
All statements
All Blocks


Create extended statistics:

We know that c1 and c2 are corelated and has the same data so lets create extended statistics on these two columns so that optimizer can guess and report the num of rows efficiently.

Extended statistics  can help the Optimizer improve the accuracy of cardinality estimates for queries that as predicates with a function(e.g. UPPER(LastName)) or multiple columns from the same table used in filter predicates,

By creating extended statistics on a group of columns, the Optimizer can determine accurate cardinality estimate when the columns are used together as the predicates.You can use DBMS_STATS.CREATE_EXTENDED_STATS to define the column group you want to have statistics gathered on as a whole. Once the group has been established Oracle will automatically maintain the statistics on that column group when statistics are gathered on the table.



SQL> SELECT dbms_stats.create_extended_stats('ARCHIVE','STATS','(C1,C2)') FROM DUAL;

DBMS_STATS.CREATE_EXTENDED_STATS('ARCHIVE','STATS','(C1,C2)')
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
SYS_STUF3GLKIOP5F4B0BTTCFTMX0W



SQL> select * from user_stat_extensions;

TABLE_NAME              EXTENSION_NAME             EXTENSION    CREATO DRO
------------------------------ ------------------------------ -------------------------------------------------------------------------------- ------ ---
STATS                  SYS_STUF3GLKIOP5F4B0BTTCFTMX0W ("C1","C2")       USER   YES

SQL> exec dbms_stats.gather_table_stats('ARCHIVE','STATS',method_opt=>'for all columns size 1 for columns(c1,c2) size 254');

PL/SQL procedure successfully completed.

SQL> select table_name,column_name,last_analyzed,sample_size,histogram from user_tab_col_statistics where table_name='STATS';

no rows selected

SQL> select table_name,column_name,last_analyzed,sample_size from user_col_pending_stats where table_name='STATS';

TABLE_NAME              COLUMN_NAME             LAST_ANAL SAMPLE_SIZE
------------------------------ ------------------------------ --------- -----------
STATS                  C2                 16-AUG-15     500
STATS                  C3                 16-AUG-15     500
STATS                  C4                 16-AUG-15     500
STATS                  C5                 16-AUG-15     500
STATS                  C6                 16-AUG-15     500
STATS                  C7                 16-AUG-15     500
STATS                  C8                 16-AUG-15     500
STATS                  C9                 16-AUG-15     500
STATS                  C1                 16-AUG-15     500
STATS                  SYS_STUF3GLKIOP5F4B0BTTCFTMX0W 16-AUG-15     500

10 rows selected.


SQL> select count(*) from stats where c1=1 and c2=1;

 COUNT(*)
----------
      100


Execution Plan
----------------------------------------------------------
Plan hash value: 2395854213

----------------------------------------------------------------------------
| Id  | Operation       | Name  | Rows  | Bytes | Cost (%CPU)| Time       |
----------------------------------------------------------------------------
|   0 | SELECT STATEMENT   |       |     1 |     6 |     3   (0)| 00:00:01 |
|   1 |  SORT AGGREGATE    |       |     1 |     6 |       |       |
|*  2 |   TABLE ACCESS FULL| STATS |   100 |   600 |     3   (0)| 00:00:01 |
----------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------

  2 - filter("C1"=1 AND "C2"=1)


Woow.. Optimizer picked up the correct cardinality now...

Let’s publish the stats:

SQL> select dbms_stats.get_prefs('publish','archive','stats') publish from dual;

PUBLISH
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
TRUE


SQL> exec dbms_stats.set_table_prefs('ARCHIVE','STATS','PUBLISH','TRUE');

PL/SQL procedure successfully completed.


SQL> select table_name,column_name,last_analyzed,sample_size,histogram from user_tab_col_statistics where table_name='STATS';

no rows selected

SQL> exec dbms_stats.gather_table_stats('ARCHIVE','STATS');

PL/SQL procedure successfully completed.

SQL> select table_name,column_name,last_analyzed,sample_size,histogram from user_tab_col_statistics where table_name='STATS';

TABLE_NAME              COLUMN_NAME             LAST_ANAL SAMPLE_SIZE HISTOGRAM
------------------------------ ------------------------------ --------- ----------- ---------------
STATS                  C1                 16-AUG-15     500 FREQUENCY
STATS                  C2                 16-AUG-15     500 FREQUENCY
STATS                  C3                 16-AUG-15     500 NONE
STATS                  C4                 16-AUG-15     500 NONE
STATS                  C5                 16-AUG-15     500 NONE
STATS                  C6                 16-AUG-15     500 NONE
STATS                  C7                 16-AUG-15     500 NONE
STATS                  C8                 16-AUG-15     500 NONE
STATS                  C9                 16-AUG-15     500 NONE
STATS                  SYS_STUF3GLKIOP5F4B0BTTCFTMX0W 16-AUG-15     500 FREQUENCY

10 rows selected.


Now the stats are published and will be picked up by the optimizer


Let’s reset the dynamic sampling value back to the default value:

SQL> alter session set optimizer_dynamic_sampling=2;

Session altered.

SQL> set autot on exp
SQL> select count(*) from stats where c1=1 and c2=1;

 COUNT(*)
----------
      100


Execution Plan
----------------------------------------------------------
Plan hash value: 2395854213

----------------------------------------------------------------------------
| Id  | Operation       | Name  | Rows  | Bytes | Cost (%CPU)| Time       |
----------------------------------------------------------------------------
|   0 | SELECT STATEMENT   |       |     1 |     6 |     3   (0)| 00:00:01 |
|   1 |  SORT AGGREGATE    |       |     1 |     6 |       |       |
|*  2 |   TABLE ACCESS FULL| STATS |   100 |   600 |     3   (0)| 00:00:01 |
----------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------

  2 - filter("C1"=1 AND "C2"=1)


Good article on method_opt:
https://blogs.oracle.com/optimizer/entry/how_does_the_method_opt



oracle: How to delete a database

$
0
0

How to delete a database in Oracle:

Set the environment variables:
[oracle@collabn1 ~]$ env | grep ORA
ORACLE_SID=SHAIKDB
ORACLE_BASE=/u01/app/oracle
ORAENV_ASK=NO
ORACLE_HOME=/u01/app/oracle/product/11.2.0.2/SHAIKPROD

oracle@collabn1 ~]$ echo $PATH
/usr/lib64/qt-3.3/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/oracle/bin:/u01/app/oracle/product/11.2.0.2/SHAIKPROD/bin

a) Using dbca -silent

[oracle@collabn1 ~]$ dbca -silent -deletedatabase -sourcedb SHAIKDB.shaiksameer -sid SHAIKDB
Connecting to database
9% complete
14% complete
19% complete
23% complete
28% complete
33% complete
38% complete
47% complete
Updating network configuration files
48% complete
52% complete
Deleting instances and datafiles
66% complete
80% complete
95% complete
100% complete
Look at the log file "/u01/app/oracle/cfgtoollogs/dbca/SHAIKDB0.log" for further details.

dbca will delete the oratab entries  too.

[oracle@collabn1 ~]$ cat /etc/oratab | grep -i SHAIKDB


b)Using SQLPLUS:

[oracle@collabn1 ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.1.0 Production on Fri Sep 4 20:19:29 2015

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


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

SHAIKDB>shut immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SHAIKDB>startup mount restrict;
ORACLE instance started.

Total System Global Area 1135747072 bytes
Fixed Size            2212656 bytes
Variable Size          318770384 bytes
Database Buffers      805306368 bytes
Redo Buffers            9457664 bytes
Database mounted.
SHAIKDB>drop database;

Database dropped.

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


Delete the oratab entry for the database manually.
vi /etc/oratab


c)Using dbca GUI

shaiks@MAC$ssh -X oracle@192.168.78.51
oracle@192.168.78.51's password:
Warning: untrusted X11 forwarding setup failed: xauth key data not generated
Warning: No xauth data; using fake authentication data for X11 forwarding.
Last login: Fri Sep  4 20:09:10 2015 from 192.168.78.2

oracle@collabn1 ~]$ dbca









Determine and set sizing parameters for database structures

$
0
0
Determine and set sizing parameters for database structures:

Play with all the parameters that has "SIZE" in their name, below are some of them that has the keyword size.
 SHAIKDB>show parameter size

NAME                     TYPE     VALUE
------------------------------------ ----------- ------------------------------
bitmap_merge_area_size             integer     1048576
client_result_cache_size         big integer 0
create_bitmap_area_size          integer     8388608
db_16k_cache_size             big integer 0
db_2k_cache_size             big integer 0
db_32k_cache_size             big integer 0
db_4k_cache_size             big integer 0
db_8k_cache_size             big integer 0
db_block_size                 integer     8192
db_cache_size                 big integer 0
db_flash_cache_size             big integer 0
db_keep_cache_size             big integer 0
db_recovery_file_dest_size         big integer 3882M
db_recycle_cache_size             big integer 0
global_context_pool_size         string
hash_area_size                 integer     131072
java_max_sessionspace_size         integer     0
java_pool_size                 big integer 0
large_pool_size              big integer 0
max_dump_file_size             string     unlimited
object_cache_max_size_percent         integer     10
object_cache_optimal_size         integer     102400
olap_page_pool_size             big integer 0
parallel_execution_message_size      integer     16384
result_cache_max_size             big integer 5600K
sga_max_size                 big integer 1088M
shared_pool_reserved_size         big integer 14260633
shared_pool_size             big integer 0
sort_area_retained_size          integer     0
sort_area_size                 integer     65536
streams_pool_size             big integer 0
workarea_size_policy             string     AUTO


 
 
CREATE SPFILE FROM MEMORY;
 
CREATE SPFILE FROM PFILE;


SHOW PARAMETERSThis SQL*Plus command displays the values of initialization parameters in effect for the current session.
SHOW SPPARAMETERSThis SQL*Plus command displays the values of initialization parameters in the server parameter file (SPFILE)
CREATE PFILEThis SQL statement creates a text initialization parameter file (PFILE) from the SPFILE or from the current in-memory settings. You can then view the PFILE with any text editor.
V$PARAMETERThis view displays the values of initialization parameters in effect for the current session.
V$PARAMETER2This view displays the values of initialization parameters in effect for the current session. It is easier to distinguish list parameter values in this view because each list parameter value appears in a separate row.
V$SYSTEM_PARAMETERThis view displays the values of initialization parameters in effect for the instance. A new session inherits parameter values from the instance-wide values.
V$SYSTEM_PARAMETER2This view displays the values of initialization parameters in effect for the instance. A new session inherits parameter values from the instance-wide values. It is easier to distinguish list parameter values in this view because each list parameter value appears in a separate row.
V$SPPARAMETERThis view displays the current contents of the SPFILE. The view returns FALSE values in the ISSPECIFIED column if an SPFILE is not being used by the instance.

SCOPE = SPFILEThe change is applied in the server parameter file only. The effect is as follows:
  • No change is made to the current instance.
  • For both dynamic and static parameters, the change is effective at the next startup and is persistent.
This is the only SCOPE specification allowed for static parameters.
SCOPE = MEMORYThe change is applied in memory only. The effect is as follows:
  • The change is made to the current instance and is effective immediately.
  • For dynamic parameters, the effect is immediate, but it is not persistent because the server parameter file is not updated.
For static parameters, this specification is not allowed.
SCOPE = BOTH





The change is applied in both the server parameter file and memory. The effect is as follows:
  • The change is made to the current instance and is effective immediately.
  • For dynamic parameters, the effect is persistent because the server parameter file is updated.
For static parameters, this specification is not allowed.

 


Oracle Memory configuration

$
0
0
Memory Configuration:

Specifying the DDL Lock Timeout

A data definition language (DDL) statement is either nonblocking or blocking, and both types of DDL statements require exclusive locks on internal structures. If these locks are unavailable when a DDL statement runs, then nonblocking and blocking DDL statements behave differently:
  • Nonblocking DDL waits until every concurrent DML transaction that references the object affected by the DDL either commits or rolls back.
  • Blocking DDL fails, though it might have succeeded if it had been executed subseconds later when the locks become available.
To enable blocking DDL statements to wait for locks, specify a DDL lock timeout—the number of seconds a DDL command waits for its required locks before failing.

To specify a DDL lock timeout, use the DDL_LOCK_TIMEOUT parameter. The permissible range of values for DDL_LOCK_TIMEOUT is 0 to 1,000,000. The default is 0. You can set DDL_LOCK_TIMEOUT at the system level, or at the session level with an ALTER SESSION statement.


Specifying the Maximum Number of Processes


The PROCESSES initialization parameter determines the maximum number of operating system processes that can be connected to Oracle Database concurrently. The value of this parameter must be a minimum of one for each background process plus one for each user process.

Specifying a Fast Recovery Area

The Fast Recovery Area is a location in which Oracle Database can store and manage files related to backup and recovery. It is distinct from the database area, which is a location for the current database files (data files, control files, and online redo logs).
You specify the Fast Recovery Area with the following initialization parameters:
  • DB_RECOVERY_FILE_DEST: Location of the Fast Recovery Area. This can be a directory, file system, or Automatic Storage Management (Oracle ASM) disk group. It cannot be a raw file system.
  • In an Oracle Real Application Clusters (Oracle RAC) environment, this location must be on a cluster file system, Oracle ASM disk group, or a shared directory configured through NFS.
  • DB_RECOVERY_FILE_DEST_SIZE: Specifies the maximum total bytes to be used by the Fast Recovery Area. This initialization parameter must be specified before DB_RECOVERY_FILE_DEST is enabled.


Nonstandard Block Sizes

Tablespaces of nonstandard block sizes can be created using the CREATE TABLESPACE statement and specifying the BLOCKSIZE clause. These nonstandard block sizes can have any of the following power-of-two values: 2K, 4K, 8K, 16K or 32K. Platform-specific restrictions regarding the maximum block size apply, so some of these sizes may not be allowed on some platforms.
To use nonstandard block sizes, you must configure subcaches within the buffer cache area of the SGA memory for all of the nonstandard block sizes that you intend to use.

RENAME THE DATABASE:
You can rename the GLOBAL_NAME of your database using the ALTER DATABASE RENAME GLOBAL_NAME statement. However, you must also shut down and restart the database after first changing the DB_NAME and DB_DOMAIN initialization parameters and re-creating the control files. Re-creating the control files is easily accomplished with the command ALTER DATABASE BACKUP CONTROLFILE TO TRACE


SELECT PROPERTY_NAME,PROPERY_VALUE FROM DATABASE_PROPERTIES;


SHAIKDB>select * from v$resource_limit;

RESOURCE_NAME              CURRENT_UTILIZATION MAX_UTILIZATION INITIAL_ALLOCATION               LIMIT_VALUE
------------------------------ ------------------- --------------- ---------------------------------------- ----------------------------------------
processes                   32       37      150                       150
sessions                   36       42      247                       247
enqueue_locks                   16       31     3030                     3030
enqueue_resources               14       37     1304                    UNLIMITED
ges_procs                   27       31      320                       320
ges_ress                    3        3       64                    UNLIMITED
ges_locks                    3        3      128                    UNLIMITED
ges_cache_ress                    0        0        0                    UNLIMITED
ges_reg_msgs                    0        0      100                    UNLIMITED
ges_big_msgs                    0        0      100                    UNLIMITED
ges_rsv_msgs                    0        0      100                       100
gcs_resources                    0        0        0                        0
gcs_shadows                    0        0        0                        0
dml_locks                    0        0     1084                    UNLIMITED
temporary_table_locks                0        3  UNLIMITED                    UNLIMITED
transactions                    0        0      271                    UNLIMITED
branches                    0        0      271                    UNLIMITED
cmtcallbk                    0        1      271                    UNLIMITED
max_rollback_segments               11       11      271                    65535
sort_segment_locks                0        2  UNLIMITED                    UNLIMITED
k2q_locks                    0        0      494                    UNLIMITED
max_shared_servers                1        1  UNLIMITED                    UNLIMITED
parallel_max_servers                0        0       20                     3600

23 rows selected.


Changing archive log mode:

SHAIKDB>archive log list;
Database log mode           No Archive Mode
Automatic archival           Disabled
Archive destination           USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence     3
Current log sequence           5


SHAIKDB>shut immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.

SHAIKDB>startup mount
ORACLE instance started.

Total System Global Area 1135747072 bytes
Fixed Size           2212656 bytes
Variable Size         318770384 bytes
Database Buffers      805306368 bytes
Redo Buffers           9457664 bytes
Database mounted.


SHAIKDB>alter database archivelog;

Database altered.

SHAIKDB>archve log list;
SP2-0734: unknown command beginning "archve log..." - rest of line ignored.
SHAIKDB>archive log list;
Database log mode           Archive Mode
Automatic archival           Enabled
Archive destination           USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence     3
Next log sequence to archive   5
Current log sequence           5
SHAIKDB>alter database open;

Database altered.

Memory Configuration:


System Global Area (SGA)
  • The SGA is a group of shared memory structures, known as SGA components, that contain data and control information for one Oracle Database instance. The SGA is shared by all server and background processes. Examples of data stored in the SGA include cached data blocks and shared SQL areas.

Program Global Area (PGA)
  • A PGA is a memory region that contains data and control information for a server process. It is nonshared memory created by Oracle Database when a server process is started. Access to the PGA is exclusive to the server process. There is one PGA for each server process. Background processes also allocate their own PGAs. The total PGA memory allocated for all background and server processes attached to an Oracle Database instance is referred to as the total instance PGA memory, and the collection of all individual PGAs is referred to as the total instance PGA, or just instance PGA.


Automatic Memory Management


The total memory that the instance uses remains relatively constant, based on the value of MEMORY_TARGET, and the instance automatically distributes memory between the system global area (SGA) and the instance program global area (instance PGA). As memory requirements change, the instance dynamically redistributes memory between the SGA and instance PGA.


MEMORY_TARGET initialization parameter is dynamic, you can change MEMORY_TARGET at any time without restarting the database.

MEMORY_MAX_TARGET, which is not dynamic, serves as an upper limit so that you cannot accidentally set MEMORY_TARGET too high, and so that enough memory is set aside for the database instance in case you do want to increase total instance memory in the future. Because certain SGA components either cannot easily shrink or must remain at a minimum size, the instance also prevents you from setting MEMORY_TARGET too low.


SHAIKDB>show parameter target

NAME                    TYPE     VALUE
------------------------------------ ----------- ------------------------------
memory_max_target            big integer 0
memory_target                big integer 0
pga_aggregate_target            big integer 360M
sga_target                big integer 1088M

SHAIKDB>


SHAIKDB>select value/1024/1024  from v$pgastat where name='maximum PGA allocated';

VALUE/1024/1024
---------------
    166.006836

SHAIKDB> select name,value from v$pgastat;

NAME                         VALUE
---------------------------------------- ----------
aggregate PGA target parameter         377487360
aggregate PGA auto target         213101568
global memory bound               75497472
total PGA inuse              140705792
total PGA allocated             162916352
maximum PGA allocated             174070784
total freeable PGA memory           8323072
process count                    36
max processes count                38
PGA memory freed back to OS           22347776
total PGA used for auto workareas         0
maximum PGA used for auto workareas         0
total PGA used for manual workareas         0
maximum PGA used for manual workareas         0
over allocation count                 0
bytes processed                47719424
extra bytes read/written             0
cache hit percentage               100
recompute count (total)            607

19 rows selected.


As a starting point:
To set the memory_target look at the value sga_target & either pga_aggregate_target or pga_max_allocated whichever is  higher.


SHAIKDB>alter system set memory_max_target=500m scope=spfile;

System altered.


SHAIKDB>alter system set memory_target=450m scope=spfile;

System altered.

SHAIKDB>shut immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SHAIKDB>startup

ORACLE instance started.

Total System Global Area  521936896 bytes
Fixed Size           2214936 bytes
Variable Size         473957352 bytes
Database Buffers       41943040 bytes
Redo Buffers           3821568 bytes
Database mounted.
Database opened.

The view V$MEMORY_TARGET_ADVICE provides tuning advice for the MEMORY_TARGET initialization parameter.


SHAIKDB>select * from v$memory_target_advice order by memory_size;

MEMORY_SIZE MEMORY_SIZE_FACTOR ESTD_DB_TIME ESTD_DB_TIME_FACTOR    VERSION
----------- ------------------ ------------ ------------------- ----------
   226           .5        11             1      0
   339           .75        11             1      0
   452            1        11             1      0
   565         1.25        11             1      0
   678           1.5        11             1      0
   791         1.75        11             1      0
   904            2        11             1      0

7 rows selected.

V$SYSSTAT
V$SESSTAT
V$PGASTAT
V$SQL_WORKAREA
V$SQL_WORKAREA_ACTIVE


To Tune SGA:

check v$sgainfo or v$sga_targte_advice

SHAIKDB>select * from v$sga_target_advice order by sga_size;

 SGA_SIZE SGA_SIZE_FACTOR ESTD_DB_TIME ESTD_DB_TIME_FACTOR ESTD_PHYSICAL_READS
---------- --------------- ------------ ------------------- -------------------
      148        1         11          1           9344
      185          1.25         11          1           8799
      222           1.5         11          1           8799
      259          1.75         11          1           8799
      296        2         11          1           8799



Use the fixed view V$BUFFER_POOL to track the sizes of the different cache components and any pending resize operations.


SHAIKDB>select * from V$BUFFER_POOL ;

   ID NAME        BLOCK_SIZE RESIZE_STA CURRENT_SIZE    BUFFERS TARGET_SIZE TARGET_BUFFERS  PREV_SIZE PREV_BUFFERS    LO_BNUM    HI_BNUM     LO_SETID   HI_SETID  SET_COUNT
---------- -------------------- ---------- ---------- ------------ ---------- ----------- -------------- ---------- ------------ ---------- ---------- ---------- ---------- ----------
    3 DEFAULT             8192 STATIC       36     4419           36        4419     40        4910      0         0       3       3          1



Memory Management Data Dictionary Views



V$SGA
Displays summary information about the system global area (SGA).
V$SGAINFO
Displays size information about the SGA, including the sizes of different SGA components, the granule size, and free memory.
V$SGASTAT
Displays detailed information about how memory is allocated within the shared pool, large pool, Java pool, and Streams pool.
V$PGASTAT
Displays PGA memory usage statistics as well as statistics about the automatic PGA memory manager when it is enabled (that is, when PGA_AGGREGATE_TARGET is set). Cumulative values in V$PGASTAT are accumulated since instance startup.
V$MEMORY_DYNAMIC_COMPONENTS
Displays information on the current size of all automatically tuned and static memory components, with the last operation (for example, grow or shrink) that occurred on each.
V$SGA_DYNAMIC_COMPONENTS
Displays the current sizes of all SGA components, and the last operation for each component.
V$SGA_DYNAMIC_FREE_MEMORY
Displays information about the amount of SGA memory available for future dynamic SGA resize operations.
V$MEMORY_CURRENT_RESIZE_OPS
Displays information about resize operations that are currently in progress. A resize operation is an enlargement or reduction of the SGA, the instance PGA, or a dynamic SGA component.
V$SGA_CURRENT_RESIZE_OPS
Displays information about dynamic SGA component resize operations that are currently in progress.
V$MEMORY_RESIZE_OPS
Displays information about the last 800 completed memory component resize operations, including automatic grow and shrink operations for SGA_TARGET and PGA_AGGREGATE_TARGET.
V$SGA_RESIZE_OPS
Displays information about the last 800 completed SGA component resize operations.
V$MEMORY_TARGET_ADVICE
Displays information that helps you tune MEMORY_TARGET if you enabled automatic memory management.
V$SGA_TARGET_ADVICE
Displays information that helps you tune SGA_TARGET.
V$PGA_TARGET_ADVICE
Displays information that helps you tune PGA_AGGREGATE_TARGET.

ADD/DROP Redo logfile groups:

$
0
0


ADD/DROP Redo logfile groups:


SHAIKDB>select group#,thread#,status from v$log;

    GROUP#    THREAD# STATUS
---------- ---------- ----------------
    1        1 INACTIVE
    2        1 CURRENT
    3        1 INACTIVE

SHAIKDB>alter database drop logfile group 1;

Database altered.

SHAIKDB>alter database drop logfile group 3;
alter database drop logfile group 3
*
ERROR at line 1:
ORA-01567: dropping log 3 would leave less than 2 log files for instance SHAIKDB (thread 1)
ORA-00312: online log 3 thread 1: '/u01/app/oracle/SHAIKDB/redo03.log'



SHAIKDB>alter database add logfile group 1('/u01/app/oracle/SHAIKDB/redo1.log','/u01/app/oracle/SHAIKDB/redo12.log') size 100m;

Database altered.

SHAIKDB>alter database drop logfile group 3;

Database altered.

SHAIKDB>alter database add logfile group 3 ('/u01/app/oracle/SHAIKDB/redo3.log','/u01/app/oracle/SHAIKDB/redo31.log') size 100m;

Database altered.

SHAIKDB>select group#,thread#,status from v$log;

    GROUP#    THREAD# STATUS
---------- ---------- ----------------
    1        1 UNUSED
    2        1 CURRENT
    3        1 UNUSED

SHAIKDB>alter system archive log current;

System altered.

SHAIKDB>select group#,thread#,status from v$log;

    GROUP#    THREAD# STATUS
---------- ---------- ----------------
    1        1 CURRENT
    2        1 ACTIVE
    3        1 UNUSED

SHAIKDB>alter system archive log current;

System altered.

SHAIKDB>select group#,thread#,status from v$log;

    GROUP#    THREAD# STATUS
---------- ---------- ----------------
    1        1 ACTIVE
    2        1 ACTIVE
    3        1 CURRENT

Duplicate controlfile to different location

$
0
0
Duplicate controlfile to different location

SHAIKDB>show parameter control_files

NAME                    TYPE    VALUE
------------------------------------ ----------- ------------------------------
control_files                string   

/u01/app/oracle/SHAIKDB/control01.ctl,/u01/app/oracle/flash_recovery_area/SHAIKDB/control02.ctl


SHAIKDB> SELECT NAME FROM V$CONTROLFILE;

NAME
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
/u01/app/oracle/SHAIKDB/control01.ctl
/u01/app/oracle/flash_recovery_area/SHAIKDB/control02.ctl

SHAIKDB>create pfile from spfile;

File created.

SHAIKDB>shut immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.

SHAIKDB>!cp /u01/app/oracle/SHAIKDB/control01.ctl /u01/app/oracle/SHAIKDB/control03.ctl

SHAIKDB>!vi $ORACLE_HOME/dbs/initSHAIKDB.ora

Add the new controlfile to the parameter file:
from
*.control_files='/u01/app/oracle/SHAIKDB/control01.ctl','/u01/app/oracle/flash_recovery_area/SHAIKDB/control02.ctl'
to:
*.control_files='/u01/app/oracle/SHAIKDB/control01.ctl','/u01/app/oracle/flash_recovery_area/SHAIKDB/control02.ctl'
*.control_files='/u01/app/oracle/SHAIKDB/control03.ctl'


SHAIKDB>startup pfile='$ORACLE_HOME/dbs/initSHAIKDB.ora';
ORACLE instance started.

Total System Global Area  521936896 bytes
Fixed Size            2214936 bytes
Variable Size         482345960 bytes
Database Buffers      33554432 bytes
Redo Buffers            3821568 bytes
Database mounted.
Database opened.
SHAIKDB>show parameter control_files

NAME                    TYPE    VALUE
------------------------------------ ----------- ------------------------------
control_files                string    /u01/app/oracle/SHAIKDB/contro
                        l01.ctl, /u01/app/oracle/flash
                        _recovery_area/SHAIKDB/control
                        02.ctl, /u01/app/oracle/SHAIKD
                        B/control03.ctl
SHAIKDB>create spfile from pfile;

File created.

SHAIKDB>shut immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SHAIKDB>startup
ORACLE instance started.

Total System Global Area  521936896 bytes
Fixed Size            2214936 bytes
Variable Size         482345960 bytes
Database Buffers      33554432 bytes
Redo Buffers            3821568 bytes
Database mounted.
Database opened.
SHAIKDB>



SHAIKDB> SELECT NAME FROM V$CONTROLFILE;

NAME
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
/u01/app/oracle/SHAIKDB/control01.ctl
/u01/app/oracle/flash_recovery_area/SHAIKDB/control02.ctl
/u01/app/oracle/SHAIKDB/control03.ctl



Using RMAN:


SHAIKDB>shut immediate;
ORA-01109: database not open


Database dismounted.
ORACLE instance shut down.
SHAIKDB>!vi $ORACLE_HOME/dbs/initSHAIKDB.ora

From:
*.control_files='/u01/app/oracle/SHAIKDB/control01.ctl','/u01/app/oracle/flash_recovery_area/SHAIKDB/control02.ctl'
*.control_files='/u01/app/oracle/SHAIKDB/control03.ctl'

to:
*.control_files='/u01/app/oracle/SHAIKDB/control01.ctl','/u01/app/oracle/flash_recovery_area/SHAIKDB/control02.ctl'
*.control_files='/u01/app/oracle/SHAIKDB/control03.ctl'
*.control_files='/u01/app/oracle/SHAIKDB/control_rman.ctl'


SHAIKDB>startup nomount pfile='$ORACLE_HOME/dbs/initSHAIKDB.ora';
ORACLE instance started.

Total System Global Area  521936896 bytes
Fixed Size           2214936 bytes
Variable Size         482345960 bytes
Database Buffers       33554432 bytes
Redo Buffers           3821568 bytes


[oracle@collabn1 SHAIKDB]$ rman

Recovery Manager: Release 11.2.0.1.0 - Production on Sat Sep 5 01:12:41 2015

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

RMAN> connect target /

connected to target database: SHAIKDB (DBID=1683917583)

RMAN>  restore controlfile from '/u01/app/oracle/SHAIKDB/control01.ctl' ;

Starting restore at 05-SEP-15
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=26 device type=DISK

channel ORA_DISK_1: copied control file copy
output file name=/u01/app/oracle/SHAIKDB/control01.ctl
output file name=/u01/app/oracle/flash_recovery_area/SHAIKDB/control02.ctl
output file name=/u01/app/oracle/SHAIKDB/control03.ctl
output file name=/u01/app/oracle/SHAIKDB/control_rman.ctl
Finished restore at 05-SEP-15

RMAN> sql 'alter database mount';

sql statement: alter database mount
released channel: ORA_DISK_1

RMAN> sql 'alter database open';

sql statement: alter database open

SHAIKDB>select name from v$controlfile;

NAME
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
/u01/app/oracle/SHAIKDB/control01.ctl
/u01/app/oracle/flash_recovery_area/SHAIKDB/control02.ctl
/u01/app/oracle/SHAIKDB/control03.ctl
/u01/app/oracle/SHAIKDB/control_rman.ctl

SHAIKDB>create spfile from pfile;

File created.

SHAIKDB>shut immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.

SHAIKDB>startup
ORACLE instance started.

Total System Global Area  521936896 bytes
Fixed Size           2214936 bytes
Variable Size         482345960 bytes
Database Buffers       33554432 bytes
Redo Buffers           3821568 bytes
Database mounted.
Database opened.

Convert from Dictionary Managed Tablespace to Locally Managed Tablespace:

$
0
0


Convert from Dictionary Managed Tablespace to Locally Managed Tablespace:


SHAIKDB>select tablespace_name,extent_management from dba_tablespaces;

TABLESPACE_NAME            EXTENT_MAN
------------------------------ ----------
SYSTEM                  DICTIONARY
SYSAUX                  LOCAL
UNDOTBS1                  LOCAL
TEMP1                  LOCAL
USERS                  LOCAL

Before migrating the SYSTEM tablespace, the following conditions must be met. These conditions are enforced by the TABLESPACE_MIGRATE_TO_LOCAL procedure, except for the cold backup.
  • The database must have a default temporary tablespace that is not SYSTEM.
  • Dictionary-managed tablespaces cannot have any rollback segments.
  • A locally managed tablespace must have at least one online rollback segment. If you are using automatic undo management, then an undo tablespace must be online.
  • All tablespaces—except the tablespace containing the rollback segment or the undo tablespace—must be read-only.
  • You must have a cold backup of the database.
  • The system must be in restricted mode.



SHAIKDB>shut immediate
ORA-01109: database not open


Database dismounted.
ORACLE instance shut down.
SHAIKDB>startup restrict
ORACLE instance started.

Total System Global Area  471830528 bytes
Fixed Size           2214456 bytes
Variable Size         301991368 bytes
Database Buffers      163577856 bytes
Redo Buffers           4046848 bytes
Database mounted.
Database opened.


SHAIKDB>alter tablespace sysaux offline;

Tablespace altered.

SHAIKDB>exec dbms_space_admin.tablespace_migrate_to_local('SYSTEM');

PL/SQL procedure successfully completed.

SHAIKDB>select tablespace_name,extent_management from dba_tablespaces;

TABLESPACE_NAME            EXTENT_MAN
------------------------------ ----------
SYSTEM                  LOCAL
SYSAUX                  LOCAL
UNDOTBS1                         LOCAL
TEMP1                  LOCAL
USERS                  LOCAL

SHAIKDB>
SHAIKDB>alter tablespace sysaux online;

Tablespace altered.

SHAIKDB>alter tablespace users read write;

Tablespace altered.


SHAIKDB>select open_mode from v$database;

OPEN_MODE
--------------------
READ WRITE

Create and manage temporary, permanent, and undo tablespaces

$
0
0


Tablespace Management:

initialization parameters DB_CREATE_FILE_DEST,
DB_CREATE_ONLINE_LOG_DEST_n, or
DB_RECOVERY_FILE_DEST in your initialization parameter file, you instruct Oracle Database to create and manage the underlying operating system files of your database. Oracle Database will automatically create and manage the operating system files.


SHAIKDB>show parameter db_create_file

NAME                    TYPE     VALUE
------------------------------------ ----------- ------------------------------
db_create_file_dest            string



SHAIKDB>show parameter pfile

NAME                    TYPE     VALUE
------------------------------------ ----------- ------------------------------
spfile                    string     /u01/app/oracle/product/11.2.0.2/SHAIKPROD/dbs/spfileMYDB.ora


Set Datafile destination:

SHAIKDB>alter system set db_create_file_dest='/u01/app/oracle/mydb';

System altered.

SHAIKDB>show parameter create_file_dest

NAME                    TYPE     VALUE
------------------------------------ ----------- ------------------------------
db_create_file_dest            string     /u01/app/oracle/mydb



col name for a40
select ts.name,df.name,bigfile from v$tablespace ts,v$datafile df where ts.ts#=df.ts#;



TSNAME       DFNAME                         BIG
---------- -------------------------------------------------- ---
SYSTEM       /u01/app/oracle/mydb/sys01.dbf             NO
SYSAUX       /u01/app/oracle/mydb/sysaux01.db             NO
UNDOTBS1   /u01/app/oracle/mydb/undo1.dbf             NO
USERS       /u01/app/oracle/mydb/users01.dbf             NO
f

Create tablespace and add datafiles:


SHAIKDB>create tablespace tbs1;

Tablespace created.


TSNAME       DFNAME                         BIG
---------- -------------------------------------------------- ---
SYSTEM       /u01/app/oracle/mydb/sys01.dbf             NO
SYSAUX       /u01/app/oracle/mydb/sysaux01.db             NO
UNDOTBS1   /u01/app/oracle/mydb/undo1.dbf             NO
USERS       /u01/app/oracle/mydb/users01.dbf             NO
TBS1       /u01/app/oracle/mydb/MYDB/datafile/o1_mf_tbs1_byp5 NO
      bpjk_.dbf



SHAIKDB>alter tablespace TBS1 add datafile size 100m,size 10m autoextend on maxsize unlimited;

Tablespace altered.

SHAIKDB>select ts.name TSNAME,df.name DFNAME,bigfile from v$tablespace ts,v$datafile df where ts.ts#=df.ts#;



TSNAME       DFNAME                           BIG
---------- ------------------------------------------------------------ ---
SYSTEM       /u01/app/oracle/mydb/sys01.dbf               NO
SYSAUX       /u01/app/oracle/mydb/sysaux01.db               NO
UNDOTBS1   /u01/app/oracle/mydb/undo1.dbf               NO
USERS       /u01/app/oracle/mydb/users01.dbf               NO
TBS1       /u01/app/oracle/mydb/MYDB/datafile/o1_mf_tbs1_byp5bpjk_.dbf    NO
TBS1       /u01/app/oracle/mydb/MYDB/datafile/o1_mf_tbs1_byp5p042_.dbf    NO
TBS1       /u01/app/oracle/mydb/MYDB/datafile/o1_mf_tbs1_byp5p08f_.dbf    NO

7 rows selected.


Create BIGFILE Tablespace:


SHAIKDB>drop tablespace tbs1 including contents and datafiles;

Tablespace dropped.

SHAIKDB>create bigfile tablespace BIGTBS;      

Tablespace created.

SHAIKDB>select ts.name TSNAME,df.name DFNAME,bigfile from v$tablespace ts,v$datafile df where ts.ts#=df.ts#;

TSNAME       DFNAME                           BIG
---------- ------------------------------------------------------------ ---
SYSTEM       /u01/app/oracle/mydb/sys01.dbf               NO
SYSAUX       /u01/app/oracle/mydb/sysaux01.db               NO
UNDOTBS1   /u01/app/oracle/mydb/undo1.dbf               NO
USERS       /u01/app/oracle/mydb/users01.dbf               NO
BIGTBS       /u01/app/oracle/mydb/MYDB/datafile/o1_mf_bigtbs_byp5v9f1_.db YES
      f


Rename a datafile:

SHAIKDB>alter database datafile '/u01/app/oracle/mydb/MYDB/datafile/o1_mf_bigtbs_byp5v9f1_.dbf' offline;
alter database datafile '/u01/app/oracle/mydb/MYDB/datafile/o1_mf_bigtbs_byp5v9f1_.dbf' offline
*
ERROR at line 1:
ORA-01145: offline immediate disallowed unless media recovery enabled


SHAIKDB>archive log list;
Database log mode           No Archive Mode
Automatic archival           Disabled
Archive destination           USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence     5
Current log sequence           7




SHAIKDB>alter tablespace bigtbs offline;

Tablespace altered.



SHAIKDB>!mv /u01/app/oracle/mydb/MYDB/datafile/o1_mf_bigtbs_byp5v9f1_.dbf /u01/app/oracle/mydb/MYDB/datafile/bigtbs.dbf

SHAIKDB>alter database rename file '/u01/app/oracle/mydb/MYDB/datafile/o1_mf_bigtbs_byp5v9f1_.dbf' to '/u01/app/oracle/mydb/MYDB/datafile/bigtbs.dbf';

Database altered.


SHAIKDB>alter tablespace bigtbs online;

Tablespace altered.

SHAIKDB>select ts.name TSNAME,df.name DFNAME,bigfile from v$tablespace ts,v$datafile df where ts.ts#=df.ts#;

TSNAME       DFNAME                           BIG
---------- ------------------------------------------------------------ ---
SYSTEM       /u01/app/oracle/mydb/sys01.dbf               NO
SYSAUX       /u01/app/oracle/mydb/sysaux01.db               NO
UNDOTBS1   /u01/app/oracle/mydb/undo1.dbf               NO
USERS       /u01/app/oracle/mydb/users01.dbf               NO
BIGTBS       /u01/app/oracle/mydb/MYDB/datafile/bigtbs.dbf       YES




SHAIKDB>alter tablespace users nologging;

Tablespace altered.

SHAIKDB>alter tablespace users force logging;

Tablespace altered.

SHAIKDB>alter tablespace undotbs1 retention noguarantee;

Tablespace altered.

SHAIKDB>alter tablespace undotbs1 retention guarantee;

Tablespace altered.

SHAIKDB>alter tablespace undotbs1 retention noguarantee;

Tablespace altered.

Useful views:


V$TABLESPACEName and number of all tablespaces from the control file.
V$ENCRYPTED_TABLESPACESName and encryption algorithm of all encrypted tablespaces.
DBA_TABLESPACES, USER_TABLESPACESDescriptions of all (or user accessible) tablespaces.
DBA_TABLESPACE_GROUPSDisplays the tablespace groups and the tablespaces that belong to them.
DBA_SEGMENTS, USER_SEGMENTSInformation about segments within all (or user accessible) tablespaces.
DBA_EXTENTS, USER_EXTENTSInformation about data extents within all (or user accessible) tablespaces.
DBA_FREE_SPACE, USER_FREE_SPACEInformation about free extents within all (or user accessible) tablespaces.
DBA_TEMP_FREE_SPACEDisplays the total allocated and free space in each temporary tablespace.
V$DATAFILEInformation about all data files, including tablespace number of owning tablespace.
V$TEMPFILEInformation about all temp files, including tablespace number of owning tablespace.
DBA_DATA_FILESShows files (data files) belonging to tablespaces.
DBA_TEMP_FILESShows files (temp files) belonging to temporary tablespaces.
V$TEMP_EXTENT_MAPInformation for all extents in all locally managed temporary tablespaces.
V$TEMP_EXTENT_POOLFor locally managed temporary tablespaces: the state of temporary space cached and used for by each instance.
V$TEMP_SPACE_HEADERShows space used/free for each temp file.
DBA_USERSDefault and temporary tablespaces for all users.
DBA_TS_QUOTASLists tablespace quotas for all users.
V$SORT_SEGMENTInformation about every sort segment in a given instance. The view is only updated when the tablespace is of the TEMPORARY type.
V$TEMPSEG_USAGEDescribes temporary (sort) segment usage by user for temporary or permanent tablespaces.

Convert tablespace from dictionary managed to Local extent management

$
0
0
[oracle@collabn1 ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.1.0 Production on Sat Sep 5 11:51:17 2015

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


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

SHAIKDB>select tablespace_name,extent_management from dba_tablespaces;

TABLESPACE_NAME            EXTENT_MAN
------------------------------ ----------
SYSTEM                  DICTIONARY
SYSAUX                  LOCAL
UNDOTBS1              LOCAL
TEMP1                  LOCAL
USERS                  LOCAL


SHAIKDB>alter tablespace users read only;

Tablespace altered.
SHAIKDB>alter tablespace sysaux offline;

Tablespace altered.

SHAIKDB>exec dbms_space_admin.tablespace_migrate_to_local('SYSTEM');
BEGIN dbms_space_admin.tablespace_migrate_to_local('SYSTEM'); END;

*
ERROR at line 1:
ORA-10643: Database should be mounted in restricted mode and Exclusive mode
ORA-06512: at "SYS.DBMS_SPACE_ADMIN", line 227
ORA-06512: at line 1


SHAIKDB>shut immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.

SHAIKDB>startup restrict
ORACLE instance started.

Total System Global Area  471830528 bytes
Fixed Size           2214456 bytes
Variable Size         301991368 bytes
Database Buffers      163577856 bytes
Redo Buffers           4046848 bytes
Database mounted.
Database opened.

SHAIKDB>exec dbms_space_admin.tablespace_migrate_to_local('SYSTEM');

PL/SQL procedure successfully completed.

SHAIKDB>select tablespace_name,extent_management from dba_tablespaces;

TABLESPACE_NAME            EXTENT_MAN
------------------------------ ----------
SYSTEM                  LOCAL
SYSAUX                  LOCAL
UNDOTBS1              LOCAL
TEMP1                  LOCAL
USERS                  LOCAL

SHAIKDB>
SHAIKDB>alter tablespace sysaux online;

Tablespace altered.

SHAIKDB>alter tablespace users read write;

Tablespace altered.

Remember you cannot convert a tablespace from LOCAL to DICTIONARY unless the system tablespace is already in DICTIONARY managed state. ELSE you will get the below error message.


SHAIKDB>exec dbms_space_admin.tablespace_migrate_from_local('PERM');
BEGIN dbms_space_admin.tablespace_migrate_from_local('PERM'); END;

*
ERROR at line 1:
ORA-10616: Operation not allowed on this tablespace
ORA-06512: at "SYS.DBMS_SPACE_ADMIN", line 216
ORA-06512: at line 1

 

Move/Convert objects from BIGFILE To SMALLFILE Tablespace

$
0
0


Option-1:
=======
SHAIKDB>select tablespace_name,bigfile from dba_tablespaces ts;

TABLESPACE_NAME            BIG
------------------------------ ---
SYSTEM                   NO
SYSAUX                   NO
UNDOTBS1               NO
TEMP1                   NO
USERS                   NO
BIGTBS                   YES
LMTB                   NO
LMTB2                   NO

8 rows selected.

SHAIKDB>create table smalltab (col1 number) tablespace bigtbs;

Table created.

SHAIKDB>begin
  2  for i in 1..1000 loop
  3  insert into smalltab values (i);
  4  commit;
  5  end loop
  6  ;
  7  end;
  8  /

PL/SQL procedure successfully completed.

SHAIKDB>select count(*) from smalltab;

  COUNT(*)
----------
      1000



SHAIKDB>select segment_name,segment_type,tablespace_name from dba_segments where segment_name='SMALLTAB';

SEGMENT_NAME                                      SEGMENT_TYPE         TABLESPACE_NAME
--------------------------------------------------------------------------------- ------------------ ------------------------------
SMALLTAB                                      TABLE          BIGTBS


SHAIKDB>create tablespace smalltbs datafile size 10m;

Tablespace created.



SHAIKDB>alter database datafile '/u01/app/oracle/mydb/MYDB/datafile/o1_mf_smalltbs_byxm65cz_.dbf' resize 100m;

Database altered.



SHAIKDB>select tablespace_name,bigfile from dba_tablespaces ts;

TABLESPACE_NAME            BIG
------------------------------ ---
SYSTEM                   NO
SYSAUX                   NO
UNDOTBS1               NO
TEMP1                   NO
USERS                   NO
BIGTBS                   YES
SMALLTBS               NO

7 rows selected.


SHAIKDB>alter table smalltab move tablespace smalltbs;

Table altered.

SHAIKDB>select segment_name,segment_type,tablespace_name from dba_segments where segment_name='SMALLTAB';

SEGMENT_NAME                                      SEGMENT_TYPE         TABLESPACE_NAME
--------------------------------------------------------------------------------- ------------------ ------------------------------
SMALLTAB                                      TABLE          SMALLTBS


Option-2:  exp/imp using remap tablespace:
===============

SHAIKDB>create user TBS identified by tbs default tablespace bigtbs;

User created.

SHAIKDB>grant create session,create table to tbs;

Grant succeeded.

SHAIKDB>alter user tbs quota unlimited on bigtbs;

User altered.

SHAIKDB>alter user tbs quota unlimited on smalltbs;

User altered.



SHAIKDB>select username,default_tablespace from dba_users where username='TBS';

USERNAME               DEFAULT_TABLESPACE
------------------------------ ------------------------------
TBS                   BIGTBS



SHAIKDB>conn tbs/tbs;
Connected.

SHAIKDB>show user
USER is "TBS"

SHAIKDB>create table smalltab (col1 number) tablespace bigtbs;

Table created.

SHAIKDB>begin
  2  for i in 1..10000 loop
  3  insert into smalltab values(i);
  4  commit;
  5  end loop;
  6  end;
  7  /

PL/SQL procedure successfully completed.

SHAIKDB>select count(*) from smalltab;

  COUNT(*)
----------
     10000


SHAIKDB>create index smallidx on smalltab(col1) tablespace bigtbs;

Index created.


SHAIKDB>select segment_name,segment_type,tablespace_name from dba_segments where segment_name like 'SMALL%';

SEGMENT_NAME                                      SEGMENT_TYPE         TABLESPACE_NAME
--------------------------------------------------------------------------------- ------------------ ------------------------------
SMALLIDX                                      INDEX          BIGTBS
SMALLTAB                                      TABLE          BIGTBS


SHAIKDB>create directory data_dir as '/home/oracle/sshaik';

Directory created.


[oracle@collabn1 sshaik]$ expdp directory=data_dir dumpfile=move_tbs.dmp schemas=tbs

Export: Release 11.2.0.1.0 - Production on Tue Sep 8 08:17:37 2015

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

Username: system
Password:

Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, Real Application Clusters, OLAP, Data Mining
and Real Application Testing options
Starting "SYSTEM"."SYS_EXPORT_SCHEMA_01":  system/******** directory=data_dir dumpfile=move_tbs.dmp schemas=tbs
Estimate in progress using BLOCKS method...
Processing object type SCHEMA_EXPORT/TABLE/TABLE_DATA
Total estimation using BLOCKS method: 192 KB
Processing object type SCHEMA_EXPORT/USER
Processing object type SCHEMA_EXPORT/SYSTEM_GRANT
Processing object type SCHEMA_EXPORT/DEFAULT_ROLE
Processing object type SCHEMA_EXPORT/TABLESPACE_QUOTA
Processing object type SCHEMA_EXPORT/PRE_SCHEMA/PROCACT_SCHEMA
Processing object type SCHEMA_EXPORT/TABLE/TABLE
Processing object type SCHEMA_EXPORT/TABLE/INDEX/INDEX
Processing object type SCHEMA_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS
. . exported "TBS"."SMALLTAB"                            82.93 KB   10000 rows
Master table "SYSTEM"."SYS_EXPORT_SCHEMA_01" successfully loaded/unloaded
******************************************************************************
Dump file set for SYSTEM.SYS_EXPORT_SCHEMA_01 is:
  /home/oracle/sshaik/move_tbs.dmp
Job "SYSTEM"."SYS_EXPORT_SCHEMA_01" successfully completed at 08:17:58



SHAIKDB>drop user tbs cascade;

User dropped.


[oracle@collabn1 sshaik]$ impdp directory=data_dir dumpfile=move_tbs.dmp remap_tablespace=bigtbs:smalltbs

Import: Release 11.2.0.1.0 - Production on Tue Sep 8 08:19:25 2015

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

Username: system
Password:

Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, Real Application Clusters, OLAP, Data Mining
and Real Application Testing options
Master table "SYSTEM"."SYS_IMPORT_FULL_01" successfully loaded/unloaded
Starting "SYSTEM"."SYS_IMPORT_FULL_01":  system/******** directory=data_dir dumpfile=move_tbs.dmp remap_tablespace=bigtbs:smalltbs
Processing object type SCHEMA_EXPORT/USER
Processing object type SCHEMA_EXPORT/SYSTEM_GRANT
Processing object type SCHEMA_EXPORT/DEFAULT_ROLE
Processing object type SCHEMA_EXPORT/TABLESPACE_QUOTA
Processing object type SCHEMA_EXPORT/PRE_SCHEMA/PROCACT_SCHEMA
Processing object type SCHEMA_EXPORT/TABLE/TABLE
Processing object type SCHEMA_EXPORT/TABLE/TABLE_DATA
. . imported "TBS"."SMALLTAB"                            82.93 KB   10000 rows
Processing object type SCHEMA_EXPORT/TABLE/INDEX/INDEX
Processing object type SCHEMA_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS
Job "SYSTEM"."SYS_IMPORT_FULL_01" successfully completed at 08:19:32




SHAIKDB>select username,default_tablespace from dba_users where username='TBS';

USERNAME               DEFAULT_TABLESPACE
------------------------------ ------------------------------
TBS                   SMALLTBS

SHAIKDB>select segment_name,segment_type,tablespace_name from dba_segments where segment_name like 'SMALL%';

SEGMENT_NAME                                      SEGMENT_TYPE         TABLESPACE_NAME
--------------------------------------------------------------------------------- ------------------ ------------------------------
SMALLIDX                                      INDEX          SMALLTBS
SMALLTAB                                      TABLE          SMALLTBS



SHAIKDB>select index_name,status from dba_indexes where table_name='SMALLTAB';

INDEX_NAME               STATUS
------------------------------ --------
SMALLIDX               VALID

OPTION-3:dbms_redefinition:
========
options_flag
Indicates the type of redefinition method to use.
  • If dbms_redefinition.cons_use_pk, the redefinition is done using primary keys or pseudo-primary keys (unique keys with all component columns having NOTNULL constraints). The default method of redefinition is using primary keys.
  • If dbms_redefinition.cons_use_rowid, the redefinition is done using rowids.

SHAIKDB>exec dbms_redefinition.CAN_REDEF_TABLE('TBS','SMALLTAB');
BEGIN dbms_redefinition.CAN_REDEF_TABLE('TBS','SMALLTAB'); END;

*
ERROR at line 1:
ORA-12089: cannot online redefine table "TBS"."SMALLTAB" with no primary key
ORA-06512: at "SYS.DBMS_REDEFINITION", line 139
ORA-06512: at "SYS.DBMS_REDEFINITION", line 1782
ORA-06512: at line 1


SHAIKDB>exec dbms_redefinition.CAN_REDEF_TABLE('TBS','SMALLTAB',dbms_redefinition.cons_use_rowid);

PL/SQL procedure successfully completed.

If the table is not a candidate for online redefinition, an error message is raised.

SHAIKDB>select segment_name,segment_type,tablespace_name,bigfile from dba_segments a,v$tablespace b where a.tablespace_name=b.name
  2   and segment_name like 'SMALL%';

SEGMENT_NAME                                      SEGMENT_TYPE         TABLESPACE_NAME            BIG
--------------------------------------------------------------------------------- ------------------ ------------------------------ ---
SMALLIDX                                      INDEX          BIGTBS                YES
SMALLTAB                                      TABLE          BIGTBS                YES

SHAIKDB>select * from DBA_REDEFINITION_ERRORS ;

no rows selected

Create  a new interim table with the desired changes:
SHAIKDB>create table tbs.smalltab_new tablespace smalltbs as select * from tbs.smalltab where 1=2;

Table created.

SHAIKDB>select count(*) from tbs.smalltab_new;

  COUNT(*)
----------
     0

SHAIKDB>select segment_name,segment_type,tablespace_name,bigfile from dba_segments a,v$tablespace b where a.tablespace_name=b.name and segment_name like 'SMALL%';

SEGMENT_NAME                                      SEGMENT_TYPE         TABLESPACE_NAME            BIG
--------------------------------------------------------------------------------- ------------------ ------------------------------ ---
SMALLIDX                                      INDEX          BIGTBS                YES
SMALLTAB                                      TABLE          BIGTBS                YES
SMALLTAB_NEW                                      TABLE          SMALLTBS                NO



SHAIKDB>exec dbms_redefinition.start_redef_table(UNAME=>'TBS',ORIG_TABLE=>'SMALLTAB',INT_TABLE=>'SMALLTAB_NEW',OPTIONS_FLAG=>dbms_redefinition.cons_use_rowid);

PL/SQL procedure successfully completed.



SHAIKDB>select count(*) from tbs.smalltab_new;

  COUNT(*)
----------
     10000

SHAIKDB>alter index tbs.smallidx rebuild tablespace smalltbs;

SHAIKDB>EXEC DBMS_REDEFINITION.FINISH_REDEF_TABLE(UNAME=>'TBS',ORIG_TABLE=>'SMALLTAB',INT_TABLE=>'SMALLTAB_NEW');

PL/SQL procedure successfully completed.

SHAIKDB>select segment_name,segment_type,tablespace_name,bigfile from dba_segments a,v$tablespace b where a.tablespace_name=b.name and segment_name like 'SMALL%';

SEGMENT_NAME                                      SEGMENT_TYPE         TABLESPACE_NAME            BIG
--------------------------------------------------------------------------------- ------------------ ------------------------------ ---
SMALLIDX                                      INDEX          BIGTBS                YES
SMALLTAB_NEW                                      TABLE          BIGTBS                YES
SMALLTAB                                     TABLE          SMALLTBS                NO


SHAIKDB>select * from DBA_REDEFINITION_ERRORS;

no rows selected


SHAIKDB>DROP TABLE TBS.SMALLTAB_NEW;

Table dropped.



SHAIKDB>select segment_name,segment_type,tablespace_name,bigfile from dba_segments a,v$tablespace b where a.tablespace_name=b.name and segment_name like 'SMALL%';
SEGMENT_NAME                                      SEGMENT_TYPE         TABLESPACE_NAME            BIG
--------------------------------------------------------------------------------- ------------------ ------------------------------ ---
SMALLIDX                                      INDEX         SMALLTBS                NO
SMALLTAB                                      TABLE          SMALLTBS                NO


You can query the DBA_REDEFINITION_OBJECTS& DBA_REDEFINITION_ERRORS;

Stripe data files across multiple physical devices and locations

$
0
0
Stripe data files across multiple physical devices and locations

Remember -- It is “data files”, not “datafiles:

  • Controlfiles
  • Redologs
  • Tablespaces (create more than one datafile for each)

Controlfiles:
Duplicating/Moving/Adding controlfiles to a new location:

Adding redolog groups:


SHAIKDB>select group#,thread#,sequence#,members,status from v$log;

    GROUP#    THREAD#  SEQUENCE#    MEMBERS STATUS
---------- ---------- ---------- ---------- ----------------
    1        1           7      2 CURRENT
    2        1           5      2 INACTIVE
    3        1           6      2 INACTIVE

SHAIKDB>select * from v$logifle;

    GROUP# STATUS  TYPE    MEMBER                         IS_
---------- ------- ------- -------------------------------------------------- ---
    1       ONLINE  /u01/app/oracle/mydb/redo1.log             NO
    1       ONLINE  /u01/app/oracle/mydb/redo2.log             NO
    2       ONLINE  /u01/app/oracle/mydb/redo3.log             NO
    2       ONLINE  /u01/app/oracle/mydb/redo4.log             NO
    3       ONLINE  /u01/app/oracle/mydb/redo5.log             NO
    3       ONLINE  /u01/app/oracle/mydb/redo6.log             NO

6 rows selected.


SHAIKDB>alter database add logfile group 4('/u02/app/oracle/mydb/redo41.log','/u02/app/oracle/mydb/redo42.log') size 100m;

Database altered.

SHAIKDB>select * from v$logfile;

    GROUP# STATUS  TYPE    MEMBER                         IS_
---------- ------- ------- -------------------------------------------------- ---
    1       ONLINE  /u01/app/oracle/mydb/redo1.log             NO
    1       ONLINE  /u01/app/oracle/mydb/redo2.log             NO
    2       ONLINE  /u01/app/oracle/mydb/redo3.log             NO
    2       ONLINE  /u01/app/oracle/mydb/redo4.log             NO
    3       ONLINE  /u01/app/oracle/mydb/redo5.log             NO
    3       ONLINE  /u01/app/oracle/mydb/redo6.log             NO
    4       ONLINE  /u02/app/oracle/mydb/redo41.log             NO
    4       ONLINE  /u02/app/oracle/mydb/redo42.log             NO

8 rows selected.



Striping tablespace :

SHAIKDB>select ts.name tsname,df.name dfname,df.status from v$datafile df,v$tablespace ts where ts.ts#=df.ts#;

TSNAME                    DFNAME                  STATUS
---------------------------------------- ---------------------------------------- -------
SYSTEM                    /u01/app/oracle/mydb/sys01.dbf       SYSTEM
SYSAUX                    /u01/app/oracle/mydb/sysaux01.db      ONLINE
UNDOTBS1                /u01/app/oracle/mydb/undo1.dbf       ONLINE
USERS                    /u01/app/oracle/mydb/users01.dbf      ONLINE
BIGTBS                    /u01/app/oracle/mydb/MYDB/datafile/bigtb ONLINE
                   s.dbf


SHAIKDB>alter tablespace users add datafile '/u02/app/oracle/mydb/users02.dbf' size 10m;

Tablespace altered.

SHAIKDB>select ts.name tsname,df.name dfname,df.status from v$datafile df,v$tablespace ts where ts.ts#=df.ts#;

TSNAME                    DFNAME                  STATUS
---------------------------------------- ---------------------------------------- -------
SYSTEM                    /u01/app/oracle/mydb/sys01.dbf           SYSTEM
SYSAUX                    /u01/app/oracle/mydb/sysaux01.db          ONLINE
UNDOTBS1                /u01/app/oracle/mydb/undo1.dbf              ONLINE
USERS                    /u01/app/oracle/mydb/users01.dbf          ONLINE
BIGTBS                    /u01/app/oracle/mydb/MYDB/datafile/bigtbs.dbf ONLINE
USERS                    /u02/app/oracle/mydb/users02.dbf         ONLINE

6 rows selected.

SHAIKDB>select ts.name tsname,df.name dfname,df.status from v$datafile df,v$tablespace ts where ts.ts#=df.ts# order by 1;

TSNAME                    DFNAME                  STATUS
---------------------------------------- ---------------------------------------- -------
BIGTBS                    /u01/app/oracle/mydb/MYDB/datafile/bigtbs.dbf ONLINE
SYSAUX                    /u01/app/oracle/mydb/sysaux01.db      ONLINE
SYSTEM                    /u01/app/oracle/mydb/sys01.dbf           SYSTEM
UNDOTBS1                /u01/app/oracle/mydb/undo1.dbf               ONLINE
USERS                    /u02/app/oracle/mydb/users02.dbf      ONLINE
USERS                    /u01/app/oracle/mydb/users01.dbf      ONLINE

6 rows selected.

Configure the database environment to support optimal data access performance:

$
0
0

Configure the database environment to support optimal data access performance:

BEGIN
DBMS_WORKLOAD_REPOSITORY.MODIFY_SNAPSHOT_SETTINGS( retention => 43200, interval => 30, topnsql => 100, dbid => 3310949047);
END;
/

In this example, the retention period is specified as 43200 minutes (30 days), the interval between each snapshot is specified as 30 minutes, and the number of Top SQL to flush for each SQL criteria as 100. If NULL is specified, the existing value is preserved. The optional database identifier is 3310949047. If you do not specify a value for dbid, the local database identifier is used as the default value. You can check the current settings for your database instance with the DBA_HIST_WR_CONTROL view



ORA-00847: MEMORY_TARGET/MEMORY_MAX_TARGET and LOCK_SGA cannot be set together

You cannot configure lock_sga if you have configured AMM i.e memory_target for your database.

SHAIKDB>show parameter memory

NAME                    TYPE    VALUE
------------------------------------ ----------- ------------------------------
memory_max_target            big integer 452M
memory_target                big integer 452M



SHAIKDB>show parameter sga

NAME                    TYPE    VALUE
------------------------------------ ----------- ------------------------------
lock_sga                boolean    FALSE
pre_page_sga                boolean    FALSE
sga_max_size                big integer 452M
sga_target                big integer 0


SHAIKDB>alter system set lock_sga=true scope=spfile;

System altered.

SHAIKDB>shut immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.

SHAIKDB>startup
ORA-00847: MEMORY_TARGET/MEMORY_MAX_TARGET and LOCK_SGA cannot be set together


Either set lock_sga=false or memory_target=0


OPTIMIZER_DYNAMIC_SAMPLING:
In 11.2.0.4
optimizer automatically decides whether to gather dynamic statistics during table scans, index access, joins, and GROUP BY operations. The enhanced behavior is enabled only when the OPTIMIZER_DYNAMIC_SAMPLING initialization parameter is set to the new value of 11


In-Memory Parallel Execution When using parallel query, you can configure the database to use the database buffer cache instead of performing direct reads into the PGA for a SQL statement. This configuration may be appropriate when database servers have a large amount of memory. Also, an Oracle Real Applications Cluster (Oracle RAC) database can aggregate the size of the buffer cache of all nodes, thereby caching larger objects and caching more queries.

Performance Tuning Guide:


The optimal size can be obtained by querying the OPTIMAL_LOGFILE_SIZE column from the V$INSTANCE_RECOVERY

SHAIKDB>alter system set fast_start_mttr_target=900;

System altered.



SHAIKDB>alter system archive log current;

System altered.

SHAIKDB>select optimal_logfile_size from v$instance_recovery;

OPTIMAL_LOGFILE_SIZE
--------------------
        1467


You should monitor temporary tablespace activity to check how many extents the database allocates for the temporary segment. If an application extensively uses temporary tables, as in a situation when many users are concurrently using temporary tables, then the extent size could be set smaller, such as 256K, because every usage requires at least one extent. The EXTENT MANAGEMENT LOCAL clause is optional for temporary tablespaces because all temporary tablespaces are created with locally managed extents of a uniform size. The default for SIZE is 1M.


V$DISPATCHER and V$DISPATCHER_RATE

If the current and average rates are significantly less than the maximums, then consider reducing the number of dispatchers. Conversely, if current and average rates are close to the maximums, then you might need to add more dispatchers. A general rule is to examine V$DISPATCHER_RATE statistics during both light and heavy system use periods

Steadily increasing wait times in the requests queue indicate contention for shared servers. To examine wait time data, use the dynamic performance view V$QUEUE


SHAIKDB>select * from v$queue;

PADDR        TYPE        QUEUED        WAIT     TOTALQ
---------------- ---------- ---------- ---------- ----------
00        COMMON         0        0      0
000000007B88F0D0 DISPATCHER        0        0      0

or

SHAIKDB>SELECT DECODE(TOTALQ, 0, 'No Requests',
WAIT/TOTALQ || ' HUNDREDTHS OF SECONDS') "AVERAGE WAIT TIME PER REQUESTS"
FROM V$QUEUE
WHERE TYPE = 'COMMON';  2    3    4

AVERAGE WAIT TIME PER REQUESTS
--------------------------------------------------------------
No Requests


You can also determine how many shared servers are currently running by issuing the following query:

SHAIKDB>SELECT COUNT(*) "Shared Server Processes" FROM V$SHARED_SERVER WHERE STATUS != 'QUIT';

Shared Server Processes
-----------------------
             1

SHAIKDB>show parameter shared_servers

NAME                    TYPE    VALUE
------------------------------------ ----------- ------------------------------
max_shared_servers            integer
shared_servers                integer    1


Chapter-7 In Performance Guide:

Configuring and Using Memory:

Oracle Memory Caches The main Oracle Database memory caches that affect performance are:
■ Shared pool
■ Large pool
■ Java pool
■ Buffer cache
■ Streams pool size
■ Log buffer
■ Process-private memory, such as memory used for sorting and hash joins


Memory for the shared pool, large pool, java pool, and buffer cache is allocated in units of granules. The granule size is 4MB if the SGA size is less than 1GB. If the SGA size is greater than 1GB, the granule size changes to 16MB. The granule size is calculated and fixed when the instance starts up. The size does not change during the lifetime of the instance


SHAIKDB>col component for a30

SHAIKDB>show parameter target;

archive_lag_target            integer    0
db_flashback_retention_target        integer    1440
fast_start_io_target            integer    0
fast_start_mttr_target            integer    900
memory_max_target            big integer 452M
memory_target                big integer 300M
parallel_servers_target         integer    8
pga_aggregate_target            big integer 50M
sga_target                big integer 148M


SHAIKDB>select * from v$sga_dynamic_components;

COMPONENT              CURRENT_SIZE   MIN_SIZE    MAX_SIZE USER_SPECIFIED_SIZE OPER_COUNT LAST_OPER_TYP LAST_OPER LAST_OPER GRANULE_SIZE
------------------------------ ------------ ---------- ---------- ------------------- ---------- ------------- --------- --------- ------------
shared pool             113246208  113246208    113246208            0          0 STATIC                 4194304
large pool                4194304    4194304     4194304            0          0 STATIC                 4194304
java pool                4194304    4194304     4194304            0          0 STATIC                 4194304
streams pool                 0        0        0            0          0 STATIC                 4194304
DEFAULT buffer cache          67108864   67108864    138412032            0           1 SHRINK        DEFERRED  10-SEP-15    4194304
KEEP buffer cache             0        0        0            0          0 STATIC                 4194304
RECYCLE buffer cache             0        0        0            0          0 STATIC                 4194304
DEFAULT 2K buffer cache          0        0        0            0          0 STATIC                 4194304
DEFAULT 4K buffer cache          0        0        0            0          0 STATIC                 4194304
DEFAULT 8K buffer cache          0        0        0            0          0 STATIC                 4194304
DEFAULT 16K buffer cache         0        0        0            0          0 STATIC                 4194304
DEFAULT 32K buffer cache         0        0        0            0          0 STATIC                 4194304
Shared IO Pool                 0        0        0            0          0 STATIC                 4194304
ASM Buffer Cache             0        0        0            0          0 STATIC                 4194304

14 rows selected.

You must then divide the resulting memory between the SGA and the PGA.

For OLTP systems, the PGA memory typically accounts for a small fraction of the total memory available (for example, 20%), leaving 80% for the SGA.

For DSS systems running large, memory-intensive queries, PGA memory can typically use up to 70% of that total (up to 2.2 GB in this example).
Good initial values for the parameter PGA_AGGREGATE_TARGET might be:
For OLTP: PGA_AGGREGATE_TARGET = (total_mem * 80%) * 20%

For DSS: PGA_AGGREGATE_TARGET = (total_mem * 80%) * 50%


V$DB_CACHE_ADVICE, the parameter DB_CACHE_ADVICE should be set to ON, and a representative workload should be running on the instance. Allow the workload to stabilize before querying the V$DB_CACHE_ADVICE view.



COLUMN size_for_estimate FORMAT 999,999,999,999 heading 'Cache Size (MB)'
COLUMN buffers_for_estimate FORMAT 999,999,999 heading 'Buffers'
COLUMN estd_physical_read_factor FORMAT 999.90 heading 'Estd Phys|Read Factor'
COLUMN estd_physical_reads FORMAT 999,999,999 heading 'Estd Phys| Reads'

SELECT size_for_estimate, buffers_for_estimate, estd_physical_read_factor, estd_ physical_reads FROM V$DB_CACHE_ADVICE WHERE name = 'DEFAULT' AND block_size = (SELECT value FROM V$PARAMETER WHERE name = 'db_block_ size') AND advice_status = 'ON';



The buffer pool hit ratio can be determined using the following formula

SHAIKDB>SELECT NAME, PHYSICAL_READS, DB_BLOCK_GETS, CONSISTENT_GETS,
1 - (PHYSICAL_READS / (DB_BLOCK_GETS + CONSISTENT_GETS)) "Hit Ratio"
FROM V$BUFFER_POOL_STATISTICS;  

NAME            PHYSICAL_READS DB_BLOCK_GETS CONSISTENT_GETS  Hit Ratio
-------------------- -------------- ------------- --------------- ----------
DEFAULT              15138       121525       767633 .982974904


Determining Which Segments Have Many Buffers in the Pool

The V$BH view shows the data object ID of all blocks that currently reside in the SGA. To determine which segments have many buffers in the pool, you can use


SHAIKDB>
COLUMN OBJECT_NAME FORMAT A40
COLUMN NUMBER_OF_BLOCKS FORMAT 999,999,999,999

SELECT o.OBJECT_NAME, COUNT(*) NUMBER_OF_BLOCKS
FROM DBA_OBJECTS o, V$BH bh
WHERE o.DATA_OBJECT_ID = bh.OBJD
AND o.OWNER != 'SYS'
GROUP BY o.OBJECT_NAME
ORDER BY COUNT(*);

OBJECT_NAME                NUMBER_OF_BLOCKS
---------------------------------------- ----------------
BSLN_TIMEGROUPS_PK                   1
BSLN_BASELINES_PK2                   1
BSLN_BASELINES                       6


KEEP_POOL:

If there are certain segments in your application that are referenced frequently, then store the blocks from those segments in a separate cache called the KEEP buffer pool. Memory is allocated to the KEEP buffer pool by setting the parameter DB_KEEP_CACHE_ SIZE to the required size. The memory for the KEEP pool is not a subset of the default pool. Typical segments that can be kept are small reference tables that are used frequently

RECYCLE_POOL:
It is possible to configure a RECYCLE buffer pool for blocks belonging to those segments that you do not want to remain in memory. The RECYCLE pool is good for segments that are scanned rarely or are not referenced frequently.Memory is allocated to the RECYCLE buffer pool by setting the parameter DB_RECYCLE_ CACHE_SIZE to the required size. This memory for the RECYCLE buffer pool is not a subset of the default pool.

SHARED_POOL;
The main components of the shared pool are the library cache, the dictionary cache, and, depending on your configuration, the server result cache. The library cache stores the executable (parsed or compiled) form of recently referenced SQL and PL/SQL code. The dictionary cache stores data referenced from the data dictionary. The server result cache stores the results of queries and PL/SQL function results.

A cache miss on the data dictionary cache or library cache is more expensive than a miss on the buffer cache. For this reason, the shared pool should be sized to ensure that frequently used data is cached

Dictionary Cache
Information stored in the data dictionary cache includes usernames, segment information, profile data, tablespace information, and sequence numbers. The dictionary cache also stores descriptive information, or metadata, about schema objects. Oracle Database uses this metadata when parsing SQL cursors or during the compilation of PL/SQL programs.


Library Cache
The library cache holds executable forms of SQL cursors, PL/SQL programs, and Java classes. This section focuses on tuning as it relates to cursors, PL/SQL programs, and Java classes. These are collectively referred to as application code


Shared Cursors
Reuse of shared SQL for multiple users running the same application, avoids hard parsing. Soft parses provide a significant reduction in the use of resources such as the shared pool and library cache latches

V$LIBRARYCACHE
These statistics reflect all library cache activity after the most recent instance startup.

SHAIKDB>SELECT NAMESPACE, PINS, PINHITS, RELOADS, INVALIDATIONS
FROM V$LIBRARYCACHE
ORDER BY NAMESPACE;  2    3  

NAMESPACE                                  PINS    PINHITS      RELOADS INVALIDATIONS
---------------------------------------------------------------- ---------- ---------- ---------- -------------
BODY                                      1847      1620           16          0
CLUSTER                                   1447      1413       0          0
DBINSTANCE                                 0         0       0          0
DBLINK                                     0         0       0          0
DIRECTORY                                 2         0       0          0
EDITION                                143       117       0          0
INDEX                                      2057      1469           23          0
OBJECT ID                                 0         0       0          0
QUEUE                                     6         2       0          0
RULESET                                  3         2       0          0
SCHEMA                                     0         0       0          0
SQL AREA                                224818    204558         2303        426
SUBSCRIPTION                                 1         0       0          0
TABLE/PROCEDURE                              49248     35009         2887          0
TEMPORARY INDEX                            190         0           20          0
TEMPORARY TABLE                            533         0          389          0

16 rows selected.

To calculate the library cache hit ratio, use the following formula:
Library Cache Hit Ratio = sum(pinhits) / sum(pins)       
               
                   
Cache Recovery (Rolling Forward)
                   
During the cache recovery step, Oracle Database applies all committed and uncommitted changes in the redo log files to the affected data blocks. The work required for cache recovery processing is proportional to the rate of change to the database (update transactions each second) and the time between checkpoints.
                   
Transaction Recovery (Rolling Back)
                   
To make the database consistent, the changes that were not committed at the time of the crash must be undone (in other words, rolled back). During the transaction recovery step, Oracle Database applies the rollback segments to undo the uncommitted changes.       
                   
FAST_START_MTTR_TARGET (cache recovery)           
The Fast-Start Fault Recovery feature reduces the time required for cache recovery, and makes the recovery bounded and predictable by limiting the number of dirty buffers and the number of redo records generated between the most recent redo record and the last checkpoint

With the Fast-Start Fault Recovery feature, the FAST_START_MTTR_TARGET initialization parameter simplifies the configuration of recovery time from instance or system failure. FAST_START_MTTR_TARGET specifies a target for the expected mean time to recover (MTTR), that is, the time (in seconds) that it should take to start up the instance and perform cache recovery. After FAST_START_MTTR_TARGET is set, the database manages incremental checkpoint writes in an attempt to meet that target. If you have chosen a practical value for FAST_START_MTTR_TARGET, you can expect your database to recover, on average, in approximately the number of seconds you have chosen.   
               
You must disable or remove the FAST_START_IO_TARGET, LOG_CHECKPOINT_INTERVAL, and LOG_CHECKPOINT_TIMEOUT initialization parameters when using FAST_START_MTTR_TARGET. Setting these parameters interferes with the mechanisms used to manage cache recovery time to meet FAST_START_MTTR_TARGET
                                   
The maximum value for FAST_START_MTTR_TARGET is 3600 seconds (one hour). If you set the value to more than 3600, then Oracle Database rounds it to 3600.
                                   
           
               
                   
Reducing Checkpoint Frequency to Optimize Run-Time Performance
                   
To reduce the checkpoint frequency and optimize run-time performance, you can do the following:
               
                           
  • Set the value of FAST_START_MTTR_TARGET to 3600. This enables Fast-Start checkpointing and the Fast-Start Fault Recovery feature, but minimizes its effect on run-time performance while avoiding the need for performance tuning of FAST_START_MTTR_TARGET.                       
           
  • Size your online redo log files according to the amount of redo your system generates. Try to switch logs at most every twenty minutes. Having your log files too small can increase checkpoint activity and reduce performance. Also note that all redo log files should be the same size.       
                                   
  • As part of the ongoing monitoring of your database, you can periodically compare V$INSTANCE_RECOVERY.TARGET_MTTR to your FAST_START_MTTR_TARGET. The two values should generally be the same if the FAST_START_MTTR_TARGET value is in the practical range. If TARGET_MTTR is consistently longer than FAST_START_MTTR_TARGET, then set FAST_START_MTTR_TARGET to a value no less than TARGET_MTTR. If TARGET_MTTR is consistently shorter, then set FAST_START_MTTR_TARGET to a value no greater than TARGET_MTTR.
  •                        
           
       
   
SHAIKDB>SELECT TARGET_MTTR, ESTIMATED_MTTR FROM V$INSTANCE_RECOVERY;

TARGET_MTTR ESTIMATED_MTTR
----------- --------------
    36        9


SHAIKDB>select * from V$MTTR_TARGET_ADVICE;

MTTR_TARGET_FOR_ESTIMATE ADVIC DIRTY_LIMIT ESTD_CACHE_WRITES ESTD_CACHE_WRITE_FACTOR ESTD_TOTAL_WRITES ESTD_TOTAL_WRITE_FACTOR ESTD_TOTAL_IOS ESTD_TOTAL_IO_FACTOR
------------------------ ----- ----------- ----------------- ----------------------- ----------------- ----------------------- -------------- --------------------
            29 ON          9528           14969               1        16125                1       47074            1
            35 ON         12518           14969               1        16125                1       47074            1
            11 ON          1098           17167             1.1468        18323           1.1363       49272           1.0467
            17 ON          3947           14969               1        16125                1       47074            1
            23 ON          6738           14969               1        16125                1       47074            1

Download the complete Oracle 11g documentation

$
0
0
Before you start the journey for OCM, download the complete documentation so that you can view it offline rather than searching it ONLINE.

1) go edelivery.oracle.com
2) Search for the version
3) Download the documentation pack. ~330 MB.



4) Extract the .zip archive


5) Click on the index.html




From here you should be able to browse through all the documents.



Create and manage database configuration files

$
0
0
Create and manage database configuration files

Database configuration files that are needed are those stored under the respective $ORACLE_HOME/dbs directory:

  1. The relevant files are, for example, the pfile/spfile and the passwordfile.
  2. Other files that may have to be studied could be /etc/oratab, the Oracle Net configuration files in $ORACLE_HOME/network/admin


[oracle@collabn1 ~]$ cd $ORACLE_HOME/dbs

[oracle@collabn1 dbs]$ ls -lrt

total 9632
-rw-r--r-- 1 oracle oinstall    2851 May 15  2009    init.ora
-rw-r----- 1 oracle oinstall    1536 Aug  1 18:18     orapwSHAIKPRD1
-rw-r--r-- 1 oracle oinstall      66 Aug  3 13:16           initSHAIKPRD1.ora



Views available to determine the parameters:

SHAIKDB>select table_name from dict where table_name like '%PARAMETER%';

TABLE_NAME
------------------------------
ALL_APPLY_PARAMETERS
ALL_CAPTURE_PARAMETERS
DBA_ADVISOR_DEF_PARAMETERS
DBA_ADVISOR_EXEC_PARAMETERS
DBA_ADVISOR_PARAMETERS
DBA_ADVISOR_PARAMETERS_PROJ
DBA_ADVISOR_SQLW_PARAMETERS
DBA_APPLY_PARAMETERS
USER_ADVISOR_EXEC_PARAMETERS
USER_ADVISOR_PARAMETERS
USER_ADVISOR_SQLW_PARAMETERS
DBA_REPPARAMETER_COLUMN
USER_REPPARAMETER_COLUMN
ALL_REPPARAMETER_COLUMN
DBA_HIST_PARAMETER
DBA_HIST_PARAMETER_NAME
DBA_LOGSTDBY_PARAMETERS
DBA_CAPTURE_PARAMETERS
NLS_DATABASE_PARAMETERS
NLS_INSTANCE_PARAMETERS
NLS_SESSION_PARAMETERS
V$NLS_PARAMETERS
V$OBSOLETE_PARAMETER
V$PARAMETER
V$PARAMETER2
V$PARAMETER_VALID_VALUES
V$SPPARAMETER
V$SYSTEM_PARAMETER
V$SYSTEM_PARAMETER2
GV$HS_PARAMETER
GV$SPPARAMETER
V$HS_PARAMETER
V$LOGMNR_PARAMETERS
GV$LOGMNR_PARAMETERS
GV$NLS_PARAMETERS
GV$OBSOLETE_PARAMETER
GV$PARAMETER
GV$PARAMETER2
GV$PARAMETER_VALID_VALUES
GV$SYSTEM_PARAMETER
GV$SYSTEM_PARAMETER2

41 rows selected.



SHOW PARAMETERS
This SQL*Plus command displays the values of initialization parameters in effect for the current session.
SHOW SPPARAMETERS
This SQL*Plus command displays the values of initialization parameters in the server parameter file (SPFILE).
CREATE PFILE
This SQL statement creates a text initialization parameter file (PFILE) from the SPFILE or from the current in-memory settings. You can then view the PFILE with any text editor.
V$PARAMETER
This view displays the values of initialization parameters in effect for the current session.
V$PARAMETER2
This view displays the values of initialization parameters in effect for the current session. It is easier to distinguish list parameter values in this view because each list parameter value appears in a separate row.
V$SYSTEM_PARAMETER
This view displays the values of initialization parameters in effect for the instance. A new session inherits parameter values from the instance-wide values.
V$SYSTEM_PARAMETER2
This view displays the values of initialization parameters in effect for the instance. A new session inherits parameter values from the instance-wide values. It is easier to distinguish list parameter values in this view because each list parameter value appears in a separate row.
V$SPPARAMETER
This view displays the current contents of the SPFILE. The view returns FALSE values in the ISSPECIFIED column if an SPFILE is not being used by the instance.


SHAIKDB>desc v$parameter
Name                              Null?    Type
----------------------------------------------------- -------- ------------------------------------
NUM                               NUMBER
NAME                               VARCHAR2(80)
TYPE                               NUMBER
VALUE                               VARCHAR2(4000)
DISPLAY_VALUE                           VARCHAR2(4000)
ISDEFAULT                           VARCHAR2(9)
ISSES_MODIFIABLE                       VARCHAR2(5)
ISSYS_MODIFIABLE                       VARCHAR2(9)
ISINSTANCE_MODIFIABLE                       VARCHAR2(5)
ISMODIFIED                           VARCHAR2(10)
ISADJUSTED                           VARCHAR2(5)
ISDEPRECATED                           VARCHAR2(5)
ISBASIC                           VARCHAR2(5)
DESCRIPTION                           VARCHAR2(255)
UPDATE_COMMENT                        VARCHAR2(255)
HASH                               NUMBER

SHAIKDB>desc v$parameter2
Name                              Null?    Type
----------------------------------------------------- -------- ------------------------------------
NUM                               NUMBER
NAME                               VARCHAR2(80)
TYPE                               NUMBER
VALUE                               VARCHAR2(4000)
DISPLAY_VALUE                           VARCHAR2(4000)
ISDEFAULT                           VARCHAR2(6)
ISSES_MODIFIABLE                       VARCHAR2(5)
ISSYS_MODIFIABLE                       VARCHAR2(9)
ISINSTANCE_MODIFIABLE                       VARCHAR2(5)
ISMODIFIED                           VARCHAR2(10)
ISADJUSTED                           VARCHAR2(5)
ISDEPRECATED                           VARCHAR2(5)
ISBASIC                           VARCHAR2(5)
DESCRIPTION                           VARCHAR2(255)
ORDINAL                           NUMBER
UPDATE_COMMENT                        VARCHAR2(255)


SHAIKDB>col value for a40
SHAIKDB>col name for a40
SHAIKDB>select name,value from v$parameter2 where upper(name) like '%PFILE%';



NAME                  VALUE
------------------------------ ----------------------------------------
spfile                  /u01/app/oracle/product/11.2.0.2/SHAIKPR
                 OD/dbs/spfileMYDB.ora


SHAIKDB>create pfile from spfile;

File created.

SHAIKDB>!ls -lrt $ORACLE_HOME/dbs/*MYDB*.ora
-rw-r----- 1 oracle dba 3584 Sep 10 21:25 /u01/app/oracle/product/11.2.0.2/SHAIKPROD/dbs/spfileMYDB.ora
-rw-r--r-- 1 oracle dba  977 Sep 12 12:37 /u01/app/oracle/product/11.2.0.2/SHAIKPROD/dbs/initMYDB.ora

SHAIKDB>select sysdate from dual;

SYSDATE
---------
12-SEP-15


SHAIKDB>create pfile='/home/oracle/sshaik/mydb.ora' from spfile;

File created.

SHAIKDB>!ls -lrt /home/oracle/sshaik/mydb.ora
-rw-r--r-- 1 oracle dba 977 Sep 12 12:38 /home/oracle/sshaik/mydb.ora

SHAIKDB>



SHAIKDB>shut immediate
Database closed.
Database dismounted.
ORACLE instance shut down.

SHAIKDB>startup pfile='/home/oracle/sshaik/mydb.ora';
ORACLE instance started.

Total System Global Area  208769024 bytes
Fixed Size           2211928 bytes
Variable Size         159387560 bytes
Database Buffers       41943040 bytes
Redo Buffers           5226496 bytes
Database mounted.
Database opened.
SHAIKDB>select name,value from v$parameter2 where upper(name) like '%PFILE%';

NAME                  VALUE
------------------------------ ----------------------------------------
spfile

SHAIKDB>create spfile from pfile;

File created.

SHAIKDB>!ls -lrt $ORACLE_HOME/dbs/*MYDB*.ora
-rw-r--r-- 1 oracle dba  977 Sep 12 12:37 /u01/app/oracle/product/11.2.0.2/SHAIKPROD/dbs/initMYDB.ora
-rw-r----- 1 oracle dba 3584 Sep 12 12:39 /u01/app/oracle/product/11.2.0.2/SHAIKPROD/dbs/spfileMYDB.ora

SHAIKDB>shut immediate
Database closed.
Database dismounted.
ORACLE instance shut down.


SHAIKDB>startup
ORACLE instance started.

Total System Global Area  208769024 bytes
Fixed Size           2211928 bytes
Variable Size         159387560 bytes
Database Buffers       41943040 bytes
Redo Buffers           5226496 bytes
Database mounted.
Database opened.

SHAIKDB>select name,value from v$parameter2 where upper(name) like '%PFILE%';

NAME                  VALUE
------------------------------ ----------------------------------------
spfile                  /u01/app/oracle/product/11.2.0.2/SHAIKPR
                 OD/dbs/spfileMYDB.ora


If the instance is running, issue the following command to re-create the SPFILE from the current values of initialization parameters in memory:

SHAIKDB>CREATE SPFILE FROM MEMORY;
Changing parameter values:


SCOPE = SPFILE
The change is applied in the server parameter file only. The effect is as follows: No change is made to the current instance. For both dynamic and static parameters, the change is effective at the next startup and is persistent. This is the only SCOPE specification allowed for static parameters.
SCOPE = MEMORY
The change is applied in memory only. The effect is as follows: The change is made to the current instance and is effective immediately. For dynamic parameters, the effect is immediate, but it is not persistent because the server parameter file is not updated. For static parameters, this specification is not allowed.
SCOPE = BOTH
The change is applied in both the server parameter file and memory. The effect is as follows: The change is made to the current instance and is effective immediately. For dynamic parameters, the effect is persistent because the server parameter file is updated. For static parameters, this specification is not allowed.


Clearing Initialization Parameter Values

You can use the ALTER SYSTEM RESET command to clear (remove) the setting of any initialization parameter in the SPFILE that was used to start the instance. Neither SCOPE=MEMORY nor SCOPE=BOTH are allowed. The SCOPE = SPFILE clause is not required, but can be included.

[oracle@collabn1 dbs]$ orapwd --help
Usage: orapwd file=<fname> entries=<users> force=<y/n> ignorecase=<y/n> nosysdba=<y/n>

 where
    file - name of password file (required),
    password - password for SYS will be prompted if not specified at command line,
    entries - maximum number of distinct DBA (optional),
    force - whether to overwrite existing file (optional),
    ignorecase - passwords are case-insensitive (optional),
    nosysdba - whether to shut out the SYSDBA logon (optional Database Vault only).
   
 There must be no spaces around the equal-to (=) character.

[oracle@collabn1 dbs]$ orapwd file=orapwMYDB password=test123 entries=5 ignorecase=yes

[oracle@collabn1 dbs]$ ls -lrt orapwMYDB
-rw-r----- 1 oracle oinstall 2048 Sep 12 13:58 orapwMYDB

Create BIGFILE tablespace

$
0
0

Bigfile Tablespaces 


A bigfile tablespace is a tablespace with a single, but very large (up to 4G blocks) datafile. Traditional smallfile tablespaces, in contrast, can contain multiple datafiles, but the files cannot be as large. The benefits of bigfile tablespaces are the following:
  • A bigfile tablespace with 8K blocks can contain a 32 terabyte datafile. A bigfile tablespace with 32K blocks can contain a 128 terabyte datafile. The maximum number of datafiles in an Oracle Database is limited (usually to 64K files). Therefore, bigfile tablespaces can significantly enhance the storage capacity of an Oracle Database.
  • Bigfile tablespaces can reduce the number of datafiles needed for a database. An additional benefit is that the DB_FILES initialization parameter and MAXDATAFILES parameter of the CREATE DATABASE and CREATE CONTROLFILE statements can be adjusted to reduce the amount of SGA space required for datafile information and the size of the control file.
  • Bigfile tablespaces simplify database management by providing datafile transparency. SQL syntax for the ALTER TABLESPACE statement lets you perform operations on tablespaces, rather than the underlying individual datafiles.
Bigfile tablespaces are supported only for locally managed tablespaces with automatic segment space management, with three exceptions: locally managed undo tablespaces, temporary tablespaces, and the SYSTEM tablespace.

Set Datafile destination:

SHAIKDB>alter system set db_create_file_dest='/u01/app/oracle/mydb';

System altered.

SHAIKDB>show parameter create_file_dest

NAME                    TYPE     VALUE
------------------------------------ ----------- ------------------------------
db_create_file_dest            string     /u01/app/oracle/mydb

SHAIKDB>create bigfile tablespace BIGTBS;      

Tablespace created.

SHAIKDB>select ts.name TSNAME,df.name DFNAME,bigfile from v$tablespace ts,v$datafile df where ts.ts#=df.ts#;

TSNAME       DFNAME                                   BIG
---------- ------------------------------------------------------------                 ---
SYSTEM       /u01/app/oracle/mydb/sys01.dbf                       NO
SYSAUX       /u01/app/oracle/mydb/sysaux01.db                       NO
UNDOTBS1   /u01/app/oracle/mydb/undo1.dbf                       NO
USERS       /u01/app/oracle/mydb/users01.dbf                       NO
BIGTBS       /u01/app/oracle/mydb/MYDB/datafile/o1_mf_bigtbs_byp5v9f1_.dbf YES


You can also identify a bigfile tablespace by the relative file number of its single datafile. That number is 1024 on most platforms, but 4096 on OS/390.


SHAIKDB>col tsname for a10
SHAIKDB>col dfname for a50

SHAIKDB>select ts.name TSNAME,df.name DFNAME,file#,rfile#,bigfile BIGFILE  from v$tablespace ts,v$datafile df where ts.ts#=df.ts#;
TSNAME       DFNAME                           FILE#     RFILE# BIG
---------- -------------------------------------------------- ---------- ---------- ---
SYSTEM       /u01/app/oracle/mydb/sys01.dbf                  1      1 NO
SYSAUX       /u01/app/oracle/mydb/sysaux01.db                  2      2 NO
UNDOTBS1   /u01/app/oracle/mydb/undo1.dbf                  3      3 NO
USERS       /u01/app/oracle/mydb/users01.dbf                  4      4 NO
BIGTBS       /u01/app/oracle/mydb/MYDB/datafile/bigtbs.dbf  5   1024 YES
USERS       /u02/app/oracle/mydb/users02.dbf                  6      6 NO

6 rows selected.




if the default tablespace type was set to BIGFILE at database creation, you need not specify the keyword BIGFILE in the CREATE TABLESPACE statement. A bigfile tablespace is created by default.

CREATE DATABASE MYDB
    USER SYS IDENTIFIED BY test123
    USER SYSTEM IDENTIFIED BY test123
    SET DEFAULT BIGFILE TABLESPACE
    UNDO TABLESPACE undotbs
    DEFAULT TEMPORARY TABLESPACE tempts1;

Create a new local NFS mount

$
0
0

Below I will creating a new NFS file system named /nfs


[oracle@collabn1 ~]$ df -Ph
Filesystem                       Size  Used Avail Use% Mounted on
/dev/mapper/vg_collabn1-lv_root   31G   20G   11G  66% /
tmpfs                            1.8G  758M  1.1G  43% /dev/shm
/dev/sda1                        477M   66M  382M  15% /boot
stage                            465G  280G  186G  61% /media/sf_stage
/dev/asm/shared-162              1.0G   79M  946M   8% /shared


[root@collabn1 ~]# cd /


[root@collabn1 /]# mkdir localfs nfs


Add the below lines in the fstab

[root@collabn1 ~]# vi /etc/fstab

# create an NFS mount on nfs which points back to localfs
localhost:/localfs /nfs nfs rw,bg,hard,nointr,rsize=32768,wsize=32768,tcp,vers=3,timeo=600,noac

Add the below line to the exports file

[root@collabn1 ~]# cat /etc/exports
/nfs *(rw,no_root_squash,sync)

stop/start the nfs service:

[root@collabn1 /]# chkconfig nfs on

[root@collabn1 /]# service nfs stop
Shutting down NFS daemon:                                  [  OK  ]
Shutting down NFS mountd:                                  [  OK  ]
Shutting down NFS quotas:                                  [  OK  ]
Shutting down NFS services:                                [  OK  ]
Shutting down RPC idmapd:                                  [  OK  ]

[root@collabn1 /]# service nfs start
Starting NFS services:                                     [  OK  ]
Starting NFS quotas:                                       [  OK  ]
Starting NFS mountd:                                       [  OK  ]
Starting NFS daemon:                                       [  OK  ]
Starting RPC idmapd:                                       [  OK  ]


[root@collabn1 /]# mount /nfs

[root@collabn1 /]# df -Ph
Filesystem                       Size  Used Avail Use% Mounted on
/dev/mapper/vg_collabn1-lv_root   31G   20G   11G  66% /
tmpfs                            1.8G  758M  1.1G  43% /dev/shm
/dev/sda1                        477M   66M  382M  15% /boot
stage                            465G  280G  186G  61% /media/sf_stage
/dev/asm/shared-162              1.0G   79M  946M   8% /shared
localhost:/localfs                31G   20G   11G  66% /nfs

huray….. /nfs is mounted and available for use.

 [root@collabn1 /]# ls -ld /nfs
drwxr-xr-x 2 root root 4096 Sep 12 18:49 /nfs
 
[root@collabn1 /]# chown oracle:dba /nfs
 
[root@collabn1 /]# ls -ld /nfs
drwxr-xr-x 2 oracle dba 4096 Sep 12 18:49 /nfs


[oracle@collabn1 nfs]$ pwd
/nfs
 
[oracle@collabn1 nfs]$ mkdir test
 
[oracle@collabn1 nfs]$ ls -lrt
total 4
drwxr-xr-x 2 oracle oinstall 4096 Sep 12 18:59 test

 

Create and Manage a tablespace that uses NFS mounted file system file

$
0
0

Below we will discuss
1) How to create NFS filesystem and use it for Database files:
2) Configure DNFS client filesystem and use it for Database files bypassing Kernel NFS system.

1) How to create NFS filesystem client and use it for Database files:

Create a new NFS filesystem

Below I will creating a new NFS file system named /nfs

[oracle@collabn1 ~]$ df -Ph
Filesystem                       Size  Used Avail Use% Mounted on
/dev/mapper/vg_collabn1-lv_root   31G   20G   11G  66% /
tmpfs                            1.8G  758M  1.1G  43% /dev/shm
/dev/sda1                        477M   66M  382M  15% /boot
stage                            465G  280G  186G  61% /media/sf_stage
/dev/asm/shared-162              1.0G   79M  946M   8% /shared


[root@collabn1 ~]# cd /


[root@collabn1 /]# mkdir localfs nfs


Add the below lines in the fstab

[root@collabn1 ~]# vi /etc/fstab

# create an NFS mount on nfs which points back to localfs
localhost:/localfs /nfs nfs rw,bg,hard,nointr,rsize=32768,wsize=32768,tcp,vers=3,timeo=600,noac

Add the below line to the exports file

[root@collabn1 ~]# cat /etc/exports
/nfs *(rw,no_root_squash,sync)

stop/start the nfs service:

[root@collabn1 /]# chkconfig nfs on

[root@collabn1 /]# service nfs stop
Shutting down NFS daemon:                                  [  OK  ]
Shutting down NFS mountd:                                  [  OK  ]
Shutting down NFS quotas:                                  [  OK  ]
Shutting down NFS services:                                [  OK  ]
Shutting down RPC idmapd:                                  [  OK  ]

[root@collabn1 /]# service nfs start
Starting NFS services:                                     [  OK  ]
Starting NFS quotas:                                       [  OK  ]
Starting NFS mountd:                                       [  OK  ]
Starting NFS daemon:                                       [  OK  ]
Starting RPC idmapd:                                       [  OK  ]


[root@collabn1 /]# mount /nfs

[root@collabn1 /]# df -Ph
Filesystem                       Size  Used Avail Use% Mounted on
/dev/mapper/vg_collabn1-lv_root   31G   20G   11G  66% /
tmpfs                            1.8G  758M  1.1G  43% /dev/shm
/dev/sda1                        477M   66M  382M  15% /boot
stage                            465G  280G  186G  61% /media/sf_stage
/dev/asm/shared-162              1.0G   79M  946M   8% /shared
localhost:/localfs                31G   20G   11G  66% /nfs

huray….. /nfs is mounted and available for use.



Create and Manage a tablespace that uses NFS mounted file system file

[root@collabn1 /]# cat /etc/fstab | grep nfs
localhost:/localfs /nfs nfs rw,bg,hard,nointr,rsize=32768,wsize=32768,tcp,vers=3,timeo=600,noac

SHAIKDB>create tablespace nfstbs datafile '/nfs/nfstbs01.dbf' size 100m;       

Tablespace created.

SHAIKDB>


SHAIKDB>!ls -lrt /nfs

total 102412
-rw-r----- 1 oracle dba      104865792 Sep 12 19:56 nfstbs01.dbf


2) Configure DNFS client filesystem and use it for Database files bypassing Kernel NFS system.


With Oracle Database 11g release 2 (11.2), instead of using the operating system kernel NFS client, you can configure Oracle Database to access NFS V3 servers directly using an Oracle internal Direct NFS client.

To enable Oracle Database to use Direct NFS, the NFS file systems must be mounted and available over regular NFS mounts before you start installation. Direct NFS manages settings after installation. You should still set the kernel mount options as a backup, but for normal operation, Direct NFS will manage NFS mounts.

WARNING:
The DNFS Guide says to enable the init.ora param filesystemio_options to enable direct I/O support.
Doing this, all DB access to all files will be via DIO.
There is no way to only enable direct IO for certain files and exclude others.
Configure Direct NFS Client (DNFS)

SHAIKDB>select * from v$dnfs_servers;

no rows selected

SHAIKDB>show parameter filesystem

NAME                     TYPE     VALUE
------------------------------------ ----------- ------------------------------
filesystemio_options             string     none

i) Configure oranfstab file
Direct NFS Client can use a new configuration file or the mount tab file (/etc/mtab on Linux) to determine the mount point settings for NFS storage devices.

When the oranfstab file is placed in $ORACLE_HOME/dbs, the entries in the file are specific to a single database. When the oranfstab file is placed in /etc, then it is globally available to all Oracle databases

Direct NFS searches for mount entries in the following order:
1. $ORACLE_HOME/dbs/oranfstab
2. /etc/oranfstab
3. /etc/mtab

Here I will let Oracle use the /etc/mtab instead of using oranfstab file:

Enable the Direct NFS Client ODM Library


[root@collabn1 /]# cat /etc/mtab | grep nfs
sunrpc /var/lib/nfs/rpc_pipefs rpc_pipefs rw 0 0
nfsd /proc/fs/nfsd nfsd rw 0 0
localhost:/localfs /nfs nfs rw,bg,hard,nointr,rsize=32768,wsize=32768,tcp,vers=3,timeo=600,noac,addr=127.0.0.1 0 0


cd $ORACLE_HOME/lib

mv libodm11.so libodm11.so_bak

ln -s libnfsodm11.so libodm11.so

[oracle@collabn1 lib]$ ls -lrt libodm11.*
-rw-r--r-- 1 oracle oinstall 7442 Aug 14  2009 libodm11.a
lrwxrwxrwx 1 oracle oinstall   12 Aug  1 17:53 libodm11.so_bak -> libodmd11.so
lrwxrwxrwx 1 oracle oinstall   14 Sep 12 21:12 libodm11.so -> libnfsodm11.so

On 11.2 you can enable it with the following make command

[oracle@collabn1 lib]$ cd $ORACLE_HOME/rdbms/lib

[oracle@collabn1 lib]$ make -f ins_rdbms.mk dnfs_on
rm -f /u01/app/oracle/product/11.2.0.2/SHAIKPROD/lib/libodm11.so; cp /u01/app/oracle/product/11.2.0.2/SHAIKPROD/lib/libnfsodm11.so /u01/app/oracle/product/11.2.0.2/SHAIKPROD/lib/libodm11.so


Re-start the Database instance.

SHAIKDB>shut abort
ORACLE instance shut down.
SHAIKDB>startup
ORACLE instance started.

Total System Global Area  521936896 bytes
Fixed Size           2214936 bytes
Variable Size         494928872 bytes
Database Buffers       20971520 bytes
Redo Buffers           3821568 bytes
Database mounted.
Database opened.


View the alert_log:
[oracle@collabn1 trace]$ tail -f alert_SHAIKDB.log

Oracle instance running with ODM: Oracle Direct NFS ODM Library Version 2.0
Sat Sep 12 21:17:46 2015
-
-
--
ALTER DATABASE OPEN
Direct NFS: attempting to mount /localfs on filer localhost defined in mtab
Direct NFS: channel config is:
    channel id [0] local [] path [localhost]
Direct NFS: mount complete dir /localfs on localhost mntport 34962 nfsport 2049
Direct NFS: NFS3ERR 1 Not owner. path localhost mntport 34962 nfsport 2049
Direct NFS: NFS3ERR 1 Not owner. path localhost mntport 34962 nfsport 2049


SHAIKDB>select ts.name tsname,df.name dfname,bigfile,status from v$tablespace ts,v$datafile df where df.ts#=ts.ts#;

TSNAME       DFNAME                   BIG STATUS
---------- ---------------------------------------- --- -------
SYSTEM       /u01/app/oracle/SHAIKDB/system01.dbf     NO    SYSTEM
SYSAUX       /u01/app/oracle/SHAIKDB/sysaux01.dbf     NO    ONLINE
UNDOTBS1   /u01/app/oracle/SHAIKDB/undotbs01.dbf    NO    ONLINE
USERS       /u01/app/oracle/SHAIKDB/users01.dbf        NO    ONLINE
NFSTBS       /nfs/nfstbs01.dbf               NO    ONLINE




SHAIKDB>col svrname for a10
SHAIKDB>col dirname for a10

SHAIKDB>select * from v$dnfs_servers;

    ID SVRNAME    DIRNAME        MNTPORT    NFSPORT        WTMAX      RTMAX
---------- ---------- ---------- ---------- ---------- ---------- ----------
    1 localhost  /localfs          34962      2049       0       0


SHAIKDB>select * from v$dnfs_files;

no rows selected

SHAIKDB>create tablespace DNFS datafile '/localfs/dnfs01.dbf' size 100m;

Tablespace created.

SHAIKDB>select * from v$dnfs_files;

no rows selected

SHAIKDB>create table dnfs (col1 number) tablespace dnfs;

Table created.



SHAIKDB>begin
 2  for i in 1..10000 loop
 3   insert into dnfs values (i);
 4   commit;
 5  end loop;
 6  end;
 7  /

PL/SQL procedure successfully completed.


SHAIKDB>select count(*) from dnfs;

 COUNT(*)
----------
    10000

SHAIKDB>select ts.name tsname,df.name dfname,bigfile,status from v$tablespace ts,v$datafile df where df.ts#=ts.ts#;

TSNAME       DFNAME                   BIG STATUS
---------- ---------------------------------------- --- -------
SYSTEM       /u01/app/oracle/SHAIKDB/system01.dbf     NO    SYSTEM
SYSAUX       /u01/app/oracle/SHAIKDB/sysaux01.dbf     NO    ONLINE
UNDOTBS1   /u01/app/oracle/SHAIKDB/undotbs01.dbf    NO    ONLINE
USERS       /u01/app/oracle/SHAIKDB/users01.dbf        NO    ONLINE
NFSTBS       /nfs/nfstbs01.dbf                   NO    ONLINE
DNFS       /localfs/dnfs01.dbf                   NO    ONLINE

6 rows selected.

More info DNFS:
Step by Step - Configure Direct NFS Client (DNFS) on Linux (11g) (Doc ID 762374.1)
http://docs.oracle.com/cd/E11882_01/install.112/e22489/storage.htm#CWLIN276 

Create and manage multiple network configuration files

$
0
0

Below we will address:

  1. How to setup listener.ora
  2. How to setup tnsnames.ora
  3. How to setup sqlnet.ora
  4. How to change the listener port/Listener oracle home
  5. How to setup multiple listeners in listener.ora
  6. tcp_invited_nodes feature
  7. What is a connection manager and How to set it up.

  1. set up the .ora files:

[oracle@collabn1 admin]$ env | grep TNS_ADMIN;cd $TNS_ADMIN
TNS_ADMIN=/u01/app/oracle/product/11.2.0.2/SHAIKPROD/network/admin

copy the .ora files from $TNS_ADMIN/samples to the $TNS_ADMIN/

[oracle@collabn1 admin]$ cp samples/*.ora .

[oracle@collabn1 admin]$ ls -lrt
total 24
-rw-r--r-- 1 oracle oinstall  187 May  7  2007 shrept.lst
drwxr-xr-x 2 oracle oinstall 4096 Aug  1 17:51 samples
-rw-r--r-- 1 oracle oinstall  106 Sep 13 16:41 sqlnet.ora
-rw-r--r-- 1 oracle oinstall 1051 Sep 13 12:19 listener.ora
-rw-r----- 1 oracle oinstall 1970 Sep 13 12:20 tnsnames.ora

Modify the .ora file to your environment or as shown in the below example under  4. (b):

4) (a) How to change the listener port/Listener home:

Current Listener port is :1521
Current Listener Home is : Grid Home → /u01/app/oracle/product/12.1.0/grid/network/admin/listener.ora

[oracle@collabn1 lib]$ tnsping shaikdb

TNS Ping Utility for Linux: Version 11.2.0.1.0 - Production on 12-SEP-2015 22:40:35

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

Used parameter files:
/u01/app/oracle/product/11.2.0.2/SHAIKPROD/network/admin/sqlnet.ora


Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = collabn1.shaiksameer)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = SHAIKDB.shaikmeer)))
OK (10 msec)


[oracle@collabn1 lib]$ lsnrctl status shaikdb

LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 12-SEP-2015 22:40:49

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

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=collabn1.shaiksameer)(PORT=1521))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=SHAIKDB.shaikmeer)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 12.1.0.2.0 - Production
Start Date                03-SEP-2015 17:19:09
Uptime                    9 days 5 hr. 21 min. 39 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/oracle/product/12.1.0/grid/network/admin/listener.ora
Listener Log File         /u01/app/ora_base/diag/tnslsnr/collabn1/listener/alert/log.xml
Listening Endpoints Summary...
 (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=LISTENER)))
 (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.78.61)(PORT=1521)))
 (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.78.51)(PORT=1521)))
Services Summary...
Service "+ASM" has 1 instance(s).
 Instance "+ASM1", status READY, has 1 handler(s) for this service...
Service "SHAIKDB.shaikmeer" has 1 instance(s).
 Instance "SHAIKDB", status READY, has 1 handler(s) for this service...
Service "SHAIKDBXDB.shaikmeer" has 1 instance(s).
 Instance "SHAIKDB", status READY, has 1 handler(s) for this service...
The command completed successfully


[oracle@collabn1 lib]$cat tnsnames.ora

SHAIKDB =
 (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = collabn1.shaiksameer)(PORT = 1521))
    (CONNECT_DATA =
     (SERVER = DEDICATED)
     (SERVICE_NAME = SHAIKDB.shaikmeer)
    )
 )

SHAIKDB>show parameter service

NAME                    TYPE     VALUE
------------------------------------ ----------- ------------------------------
service_names                string     SHAIKDB.shaikmeer
SHAIKDB>show parameter listener

NAME                    TYPE     VALUE
------------------------------------ ----------- ------------------------------
listener_networks            string
local_listener                string      (ADDRESS=(PROTOCOL=TCP)(HOST=
                       192.168.78.61)(PORT=1521))
remote_listener             string      collabn-cluster-scan.shaiksam
                       eer:1521
SHAIKDB>


Lets remove the SHAIKDB entry from the default listener


shaiks@MAC$ssh -X oracle@192.168.78.51

oracle@192.168.78.51's password:
Warning: untrusted X11 forwarding setup failed: xauth key data not generated
Warning: No xauth data; using fake authentication data for X11 forwarding.
Last login: Sat Sep 12 20:06:27 2015 from 192.168.78.2


[oracle@collabn1 ~]$ . ./SHAIKDB.env

[oracle@collabn1 ~]$ netca































Oracle Net Services Configuration:
 The net service name SHAIKDB was deleted.
Oracle Net Services configuration successful. The exit code is 0


[oracle@collabn1 ~]$ tnsping shaikdb

TNS Ping Utility for Linux: Version 11.2.0.1.0 - Production on 13-SEP-2015 12:06:05

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

Used parameter files:
/u01/app/oracle/product/11.2.0.2/SHAIKPROD/network/admin/sqlnet.ora

TNS-03505: Failed to resolve name
[oracle@collabn1 ~]$ lsnrctl status shaikdb

LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 13-SEP-2015 12:06:14

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

TNS-01101: Could not find service name shaikdb

SHAIKDB>show parameter service

NAME                    TYPE     VALUE
------------------------------------ ----------- ------------------------------
service_names                string     SHAIKDB.shaikmeer

SHAIKDB>show parameter listener

NAME                    TYPE     VALUE
------------------------------------ ----------- ------------------------------
listener_networks            string
local_listener                string      (ADDRESS=(PROTOCOL=TCP)(HOST=
                       192.168.78.61)(PORT=1521))
remote_listener             string      collabn-cluster-scan.shaiksam
                       eer:1521


4. (b)    Now lets add the SHAIKDB  listener manually:

[oracle@collabn1 ~]$ cd $TNS_ADMIN
[oracle@collabn1 admin]$ pwd
/u01/app/oracle/product/11.2.0.2/SHAIKPROD/network/admin


[oracle@collabn1 admin]$ vi listener.ora

SHAIKDB =
 (DESCRIPTION_LIST =
    (DESCRIPTION =
     (ADDRESS = (PROTOCOL = TCP)(HOST = collabn1.shaiksameer)(PORT = 1522))
    )
 )

SID_LIST_SHAIKDB=
  (SID_LIST=
       (SID_DESC=
         (GLOBAL_DBNAME=SHAIKDB.shaiksameer)
         (SID_NAME=SHAIKDB)
         (ORACLE_HOME=/u01/app/oracle/product/11.2.0.2/SHAIKPROD)
        )
     )

[oracle@collabn1 admin]$ lsnrctl start shaikdb

LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 13-SEP-2015 12:19:29

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

Starting /u01/app/oracle/product/11.2.0.2/SHAIKPROD/bin/tnslsnr: please wait...

TNSLSNR for Linux: Version 11.2.0.1.0 - Production
System parameter file is /u01/app/oracle/product/11.2.0.2/SHAIKPROD/network/admin/listener.ora
Log messages written to /u01/app/oracle/diag/tnslsnr/collabn1/shaikdb/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=collabn1.shaiksameer)(PORT=1522)))

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=collabn1.shaiksameer)(PORT=1522)))
STATUS of the LISTENER
------------------------
Alias                     shaikdb
Version                   TNSLSNR for Linux: Version 11.2.0.1.0 - Production
Start Date                13-SEP-2015 12:19:29
Uptime                    0 days 0 hr. 0 min. 0 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/oracle/product/11.2.0.2/SHAIKPROD/network/admin/listener.ora
Listener Log File         /u01/app/oracle/diag/tnslsnr/collabn1/shaikdb/alert/log.xml
Listening Endpoints Summary...
 (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=collabn1.shaiksameer)(PORT=1522)))
Services Summary...
Service "SHAIKDB.shaiksameer" has 1 instance(s).
 Instance "SHAIKDB", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully


[oracle@collabn1 admin]$ vi tnsnames.ora

SHAIKDB =
 (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = collabn1.shaiksameer)(PORT = 1522))
    (CONNECT_DATA =
     (SERVER = DEDICATED)
     (SERVICE_NAME = SHAIKDB.shaiksameer)
    )
 )

[oracle@collabn1 admin]$ tnsping shaikdb

TNS Ping Utility for Linux: Version 11.2.0.1.0 - Production on 13-SEP-2015 12:20:31

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

Used parameter files:
/u01/app/oracle/product/11.2.0.2/SHAIKPROD/network/admin/sqlnet.ora


Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = collabn1.shaiksameer)(PORT = 1522)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = SHAIKDB.shaiksameer)))
OK (0 msec)

[oracle@collabn1 admin]$ sqlplus system@shaikdb

SQL*Plus: Release 11.2.0.1.0 Production on Sun Sep 13 12:23:29 2015

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

Enter password:

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

SHAIKDB>select name from v$database;

NAME
---------
SHAIKDB


6 . How to setup multiple listeners in listener.ora


[oracle@collabn1 admin]$ env | grep TNS_ADMIN;cd $TNS_ADMIN
TNS_ADMIN=/u01/app/oracle/product/11.2.0.2/SHAIKPROD/network/admin

[oracle@collabn1 admin]$ ls -lrt
total 24
-rw-r--r-- 1 oracle oinstall  187 May  7  2007 shrept.lst
drwxr-xr-x 2 oracle oinstall 4096 Aug  1 17:51 samples
-rw-r--r-- 1 oracle oinstall  106 Aug 23 16:41 sqlnet.ora
-rw-r--r-- 1 oracle oinstall 1051 Sep 13 12:19 listener.ora
-rw-r----- 1 oracle oinstall 1970 Sep 13 12:20 tnsnames.ora

Below we will create a default listener named “LISTENER” with port 1621 and register databases “MYDB” & “ORCL”

[oracle@collabn1 admin]$ vi listener.ora

LISTENER =
 (DESCRIPTION_LIST =
    (DESCRIPTION =
     (ADDRESS = (PROTOCOL = TCP)(HOST = collabn1.shaiksameer)(PORT = 1621))
    )
 )

SHAIKDB =
 (DESCRIPTION_LIST =
    (DESCRIPTION =
     (ADDRESS = (PROTOCOL = TCP)(HOST = collabn1.shaiksameer)(PORT = 1522))
    )
 )

SID_LIST_LISTENER=
  (SID_LIST=
       (SID_DESC=
         (GLOBAL_DBNAME=orcl_dgmgrl.shaiksameer)
         (SID_NAME=orcl)
         (ORACLE_HOME=/u01/app/oracle/product/11.2.0.2/SHAIKPROD)
        )
       (SID_DESC=
         (GLOBAL_DBNAME=MYDB)
         (SID_NAME=MYDB)
         (ORACLE_HOME=/u01/app/oracle/product/11.2.0.2/SHAIKPROD)
        )
  )

SID_LIST_SHAIKDB=
  (SID_LIST=
       (SID_DESC=
         (GLOBAL_DBNAME=SHAIKDB.shaiksameer)
         (SID_NAME=SHAIKDB)
         (ORACLE_HOME=/u01/app/oracle/product/11.2.0.2/SHAIKPROD)
        )
    )
ADR_BASE_LISTENER = /u01/app/oracle

[oracle@collabn1 admin]$ lsnrctl start LISTENER

LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 13-SEP-2015 14:17:31

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

Starting /u01/app/oracle/product/11.2.0.2/SHAIKPROD/bin/tnslsnr: please wait...

TNSLSNR for Linux: Version 11.2.0.1.0 - Production
System parameter file is /u01/app/oracle/product/11.2.0.2/SHAIKPROD/network/admin/listener.ora
Log messages written to /u01/app/oracle/diag/tnslsnr/collabn1/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=collabn1.shaiksameer)(PORT=1621)))

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=collabn1.shaiksameer)(PORT=1621)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 11.2.0.1.0 - Production
Start Date                13-SEP-2015 14:17:31
Uptime                    0 days 0 hr. 0 min. 0 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/oracle/product/11.2.0.2/SHAIKPROD/network/admin/listener.ora
Listener Log File         /u01/app/oracle/diag/tnslsnr/collabn1/listener/alert/log.xml
Listening Endpoints Summary...
 (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=collabn1.shaiksameer)(PORT=1621)))
Services Summary...
Service "MYDB" has 1 instance(s).
 Instance "MYDB", status UNKNOWN, has 1 handler(s) for this service...
Service "orcl_dgmgrl.shaiksameer" has 1 instance(s).
 Instance "orcl", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully


[oracle@collabn1 admin]$ vi tnsnames.ora

MYDB =
 (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = collabn1.shaiksameer)(PORT = 1621))
    (CONNECT_DATA =
     (SERVER = DEDICATED)
     (SERVICE_NAME = MYDB)
    )
 )


[oracle@collabn1 admin]$ tnsping mydb

TNS Ping Utility for Linux: Version 11.2.0.1.0 - Production on 13-SEP-2015 14:20:14

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

Used parameter files:
/u01/app/oracle/product/11.2.0.2/SHAIKPROD/network/admin/sqlnet.ora


Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = collabn1.shaiksameer)(PORT = 1621)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = MYDB)))
OK (0 msec)

[oracle@collabn1 admin]$ tnsping shaikdb

TNS Ping Utility for Linux: Version 11.2.0.1.0 - Production on 13-SEP-2015 14:20:32

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

Used parameter files:
/u01/app/oracle/product/11.2.0.2/SHAIKPROD/network/admin/sqlnet.ora


Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = collabn1.shaiksameer)(PORT = 1522)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = SHAIKDB.shaiksameer)))
OK (10 msec)

TCP.INVITED_NODES


To specify which clients are allowed access to the database.

[oracle@collabn1 admin]$ vi sqlnet.ora
ENCRYPTION_WALLET_LOCATION= (SOURCE=(METHOD=FILE)(METHOD_DATA= (DIRECTORY=/u01/app/oracle/admin/wallet)))
TCP.INVITED_NODES=(collabn1.shaiksameer,collabn2.shaiksameer)

[oracle@collabn1 admin]$ ping collabn1.shaiksameer
PING collabn1.shaiksameer (192.168.78.51) 56(84) bytes of data.
64 bytes from collabn1.shaiksameer (192.168.78.51): icmp_seq=1 ttl=64 time=0.010 ms
64 bytes from collabn1.shaiksameer (192.168.78.51): icmp_seq=2 ttl=64 time=0.036 ms
^C
--- collabn1.shaiksameer ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1077ms
rtt min/avg/max/mdev = 0.010/0.023/0.036/0.013 ms


[oracle@collabn1 admin]$ ping collabn2.shaiksameer
PING collabn2.shaiksameer (192.168.78.52) 56(84) bytes of data.
64 bytes from collabn1.shaiksameer (192.168.78.52): icmp_seq=1 ttl=64 time=0.010 ms
64 bytes from collabn1.shaiksameer (192.168.78.52): icmp_seq=2 ttl=64 time=0.036 ms




more info:

Oracle® Database Net Services Reference
11g Release 2 (11.2)
Part Number E10835-01

Deploy and Configure 11gR2 Connection Manager - CMAN

$
0
0

 Part 7 of the series:
Create and manage multiple network configuration files

  1. How to setup listener.ora
  2. How to setup tnsnames.ora
  3. How to setup sqlnet.ora
  4. How to change the listener port/Listener oracle home
  5. How to setup multiple listeners in listener.ora
  6. tcp_invited_nodes feature
  7. What is a connection manager and How to set it up.

7. Below I will show you how to install and deploy CMAN and configure the DB client to use CMAN to connect to the database.


What is Connection Manager:

A router through which a client connection request may be sent either to its next hop or directly to the database server. Clients who route their connection requests through an Oracle Connection Manager can take advantage of the session multiplexing, access control, or protocol conversion features configured for that Oracle Connection Manager.

Oracle Connection Manager Control utility (cmctl)
A utility included with Oracle Net Services to control various functions, such as starting, stopping, and getting the status of the Oracle Connection Manager.


commands available via cmctl:

[oracle@collabn1 admin]$ cmctl

CMCTL for Linux: Version 11.2.0.1.0 - Production on 13-SEP-2015 22:38:54

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

Welcome to CMCTL, type "help" for information.

CMCTL> help
The following operations are available
An asterisk (*) denotes a modifier or extended command:

administer      close*          exit            quit           
reload          resume*         save_passwd     set*           
show*           shutdown        sleep           startup        
suspend*       


Lets do the demo:
 Below I will install the Oracle Client Software including the Oracle Net Listener:


shaiks@MAC$ssh -X oracle@192.168.78.51

oracle@192.168.78.51's password:
Warning: untrusted X11 forwarding setup failed: xauth key data not generated
Warning: No xauth data; using fake authentication data for X11 forwarding.
Last login: Sun Sep 13 20:00:04 2015 from 192.168.78.2

[oracle@collabn1 ~]$ls -lrt
-rwxrwx--- 1 root vboxsf  706187979 Sep 13 19:07 linux.x64_11gR2_client.zip


[oracle@collabn1 ~]$unzip linux.x64_11gR2_client.zip

[oracle@collabn1 ~]$ cd /media/sf_stage/client/

[oracle@collabn1 client]$ ls
doc  install  response  runInstaller  stage  welcome.html

Start the Install
[oracle@collabn1 client]$ ./runInstaller
Starting Oracle Universal Installer...

Checking Temp space: must be greater than 120 MB.   Actual 10153 MB    Passed
Checking swap space: must be greater than 150 MB.   Actual 2934 MB    Passed
Checking monitor: must be configured to display at least 256 colors.    Actual 16777216    Passed
Preparing to launch Oracle Universal Installer from /tmp/OraInstall2015-09-13_08-01-09PM. Please wait ...[oracle@collabn1 client]$ You can find the log of this install session at:
/u01/app/oraInventory/logs/installActions2015-09-13_08-01-09PM.log

[oracle@collabn1 client]$
























[root@collabn1 CLIENT]# ./root.sh
Running Oracle 11g root.sh script...

The following environment variables are set as:
    ORACLE_OWNER= oracle
    ORACLE_HOME=  /u01/app/oracle/product/11.2.0.2/CLIENT

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

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

[root@collabn1 CLIENT]#

[oracle@collabn1 admin]$
[oracle@collabn1 admin]$cat i listener.ora
CMAN =
 (DESCRIPTION_LIST =
    (DESCRIPTION =
     (ADDRESS = (PROTOCOL = TCP)(HOST = collabn1.shaiksameer)(PORT = 1523))
    )
 )

ADR_BASE_CMAN = /u01/app/oracle


[oracle@collabn1 admin]$ lsnrctl status cman

LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 13-SEP-2015 20:18:07

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

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=collabn1.shaiksameer)(PORT=1523)))
STATUS of the LISTENER
------------------------
Alias                     cman
Version                   TNSLSNR for Linux: Version 11.2.0.1.0 - Production
Start Date                13-SEP-2015 20:18:02
Uptime                    0 days 0 hr. 0 min. 5 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/oracle/product/11.2.0.2/CLIENT/network/admin/listener.ora
Listener Log File         /u01/app/oracle/diag/tnslsnr/collabn1/cman/alert/log.xml
Listening Endpoints Summary...
 (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=collabn1.shaiksameer)(PORT=1523)))
The listener supports no services
The command completed successfully

Stop the Traditional Listener:


[oracle@collabn1 admin]$ lsnrctl stop cman

LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 13-SEP-2015 20:27:11

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

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=collabn1.shaiksameer)(PORT=1523)))
The command completed successfully


Let’s use Connection Manager instead of traditional Listener configurations:

Create the cman configuration files cman.ora & tnsnames.ora

[oracle@collabn1 admin]$ cp samples/cman.ora .
[oracle@collabn1 admin]$ vi cman.ora

[oracle@collabn1 admin]$ vi cman.ora

# CMAN Alias
cman_collabn1 =
(configuration=
 # Listening address of the cman
 (address=(protocol=tcp)(host=collabn1.shaiksameer)(port=1523))
 (parameter_list =
    (aso_authentication_filter=off)
    (connection_statistics=yes)
    (log_directory=/u01/app/oracle/product/11.2.0.2/CLIENT/log/)
    (log_level=off)
    (max_connections=6)
    (idle_timeout=0)
    (inbound_connect_timeout=0)
    (session_timeout=0)
    (outbound_connect_timeout=0)
    (max_gateway_processes=16)
    (min_gateway_processes=2)
    (remote_admin=on)
    (trace_directory=/u01/app/oracle/product/11.2.0.2/CLIENT/log/)
    (trace_level=off)
    (max_cmctl_sessions=4)
    (event_group=init_and_term,memory_ops)
 )

 (rule_list=
    (rule=
      (src=*)(dst=*)(srv=*)(act=accept)
      (action_list=(aut=off)(moct=0)(mct=0)(mit=0)(conn_stats=on))
    )
 )
)

[oracle@collabn1 admin]$ cp samples/tnsnames.ora .
[oracle@collabn1 admin]$ vi tnsnames.ora
cman_collabn1=(DESCRIPTION_LIST =
         (DESCRIPTION=
            (ADDRESS_LIST=
             (ADDRESS=
               (PROTOCOL=tcp)
               (HOST=collabn1.shaiksameer)
               (PORT=1523)
             )
          )
       )
 )

[oracle@collabn1 admin]$ cmctl

CMCTL for Linux: Version 11.2.0.1.0 - Production on 13-SEP-2015 20:30:11

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

Welcome to CMCTL, type "help" for information.

CMCTL> administer cman_collabn1
Current instance cman_collabn1 is not yet started
Connections refer to (address=(protocol=tcp)(host=collabn1.shaiksameer)(port=1523)).
The command completed successfully.



CMCTL:cman_collabn1> startup
Starting Oracle Connection Manager instance cman_collabn1. Please wait...
TNS-04077: WARNING: No password set for the Oracle Connection Manager instance.
CMAN for Linux: Version 11.2.0.1.0 - Production
Status of the Instance
----------------------
Instance name             cman_collabn1
Version                   CMAN for Linux: Version 11.2.0.1.0 - Production
Start date                13-SEP-2015 20:30:37
Uptime                    0 days 0 hr. 0 min. 9 sec
Num of gateways started   2
Average Load level        0
Log Level                 OFF
Trace Level               OFF
Instance Config file      /u01/app/oracle/product/11.2.0.2/CLIENT/network/admin/cman.ora
Instance Log directory    /u01/app/oracle/diag/netcman/collabn1/cman_collabn1/alert
Instance Trace directory  /u01/app/oracle/diag/netcman/collabn1/cman_collabn1/trace
The command completed successfully.


CMCTL:cman_collabn1> show services
Services Summary...
Proxy service "cmgw" has 1 instance(s).
 Instance "cman", status READY, has 2 handler(s) for this service...
    Handler(s):
     "cmgw001" established:0 refused:0 current:0 max:6 state:ready
        <machine: ::1, pid: 22904>
        (ADDRESS=(PROTOCOL=tcp)(HOST=::1)(PORT=32895))
     "cmgw000" established:0 refused:0 current:0 max:6 state:ready
        <machine: ::1, pid: 22902>
        (ADDRESS=(PROTOCOL=tcp)(HOST=::1)(PORT=32304))
Service "cmon" has 1 instance(s).
 Instance "cman", status READY, has 1 handler(s) for this service...
    Handler(s):
     "cmon" established:1 refused:0 current:1 max:4 state:ready
        <machine: ::1, pid: 22893>
        (ADDRESS=(PROTOCOL=tcp)(HOST=::1)(PORT=19041))
The command completed successfully.

[oracle@collabn1 admin]$ ps -aef| grep CLIENT
oracle    6936  8617  0 21:21 pts/1    00:00:00 grep CLIENT
oracle   22893     1  0 20:52 ?        00:00:00 /u01/app/oracle/product/11.2.0.2/CLIENT/bin/cmadmin cman_collabn1 -inherit
oracle   22897     1  0 20:52 ?        00:00:00 /u01/app/oracle/product/11.2.0.2/CLIENT/bin/tnslsnr ifile=/u01/app/oracle/product/11.2.0.2/CLIENT/network/admin/cman.ora cman_collabn1 -inherit -mode proxy
oracle   22902     1  0 20:52 ?        00:00:00 /u01/app/oracle/product/11.2.0.2/CLIENT/bin/cmgw cmgw0 0 16 cman_collabn1 SNLSM:0e9a4000
oracle   22904     1  0 20:52 ?        00:00:00 /u01/app/oracle/product/11.2.0.2/CLIENT/bin/cmgw cmgw1 1 16 cman_collabn1 SNLSM:0e9a4000

Register the cman on the Database to listen for connections:


SHAIKDB>alter system set remote_listener="(address=(protocol=tcp)(host=collabn1.shaiksameer)(port=1523))";

System altered.

SHAIKDB>alter system register;

System altered.

SHAIKDB>!

Verify the registration:


CMCTL> administer cman_collabn1
TNS-04077: WARNING: No password set for the Oracle Connection Manager instance.
Current instance cman_collabn1 is already started
Connections refer to (address=(protocol=tcp)(host=collabn1.shaiksameer)(port=1523)).
The command completed successfully.

CMCTL:cman_collabn1> show services
Services Summary...
Proxy service "cmgw" has 1 instance(s).
 Instance "cman", status READY, has 2 handler(s) for this service...
    Handler(s):
     "cmgw001" established:0 refused:0 current:0 max:6 state:ready
        <machine: ::1, pid: 22904>
        (ADDRESS=(PROTOCOL=tcp)(HOST=::1)(PORT=32895))
     "cmgw000" established:0 refused:0 current:0 max:6 state:ready
        <machine: ::1, pid: 22902>
        (ADDRESS=(PROTOCOL=tcp)(HOST=::1)(PORT=32304))
Service "SHAIKDB.shaikmeer" has 1 instance(s).
 Instance "SHAIKDB", status READY, has 1 handler(s) for this service...
    Handler(s):
     "DEDICATED" established:0 refused:0 state:ready
        REMOTE SERVER
        (ADDRESS=(PROTOCOL=TCP)(HOST=collabn1.shaiksameer)(PORT=1521))
Service "SHAIKDBXDB.shaikmeer" has 1 instance(s).
 Instance "SHAIKDB", status READY, has 1 handler(s) for this service...
    Handler(s):
     "D000" established:0 refused:0 current:0 max:1022 state:ready
        DISPATCHER <machine: collabn1.shaiksameer, pid: 26756>
        (ADDRESS=(PROTOCOL=tcp)(HOST=collabn1.shaiksameer)(PORT=47765))
Service "cmon" has 1 instance(s).
 Instance "cman", status READY, has 1 handler(s) for this service...
    Handler(s):
     "cmon" established:2 refused:0 current:0 max:4 state:ready
        <machine: ::1, pid: 22893>
        (ADDRESS=(PROTOCOL=tcp)(HOST=::1)(PORT=19041))
The command completed successfully.



Configure the client tnsnames.ora:


[oracle@collabn1 sf_stage]$ vi $TNS_ADMIN/tnsnames.ora

cman =
 (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = collabn1.shaiksameer)(PORT = 1521))
    (CONNECT_DATA =
     (SERVER = DEDICATED)
     (SERVICE_NAME = collabn1.shaikmeer)
    )
 )

[oracle@collabn1 sf_stage]$ tnsping cman

TNS Ping Utility for Linux: Version 11.2.0.1.0 - Production on 13-SEP-2015 22:26:53

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

Used parameter files:
/u01/app/oracle/product/11.2.0.2/SHAIKPROD/network/admin/sqlnet.ora

Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = collabn1.shaiksameer)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = SHAIKDB.shaikmeer)))
OK (0 msec)


[oracle@collabn1 sf_stage]$ sqlplus system@cman

SQL*Plus: Release 11.2.0.1.0 Production on Sun Sep 13 22:26:56 2015

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

Enter password:

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

SHAIKDB>select name from v$database;

NAME
---------
SHAIKDB

Create and configure a listener

$
0
0

[oracle@collabn1 client]  netca

[oracle@collabn1 client]$






























[oracle@collabn1 admin]$
[oracle@collabn1 admin]$cat listener.ora

CMAN =
 (DESCRIPTION_LIST =
    (DESCRIPTION =
     (ADDRESS = (PROTOCOL = TCP)(HOST = collabn1.shaiksameer)(PORT = 1523))
    )
 )


SID_LIST_CMAN =
  (SID_LIST =
    (SID_DESC =
      (GLOBAL_DBNAME = SHAIKDB.shaiksameer)
      (SID_NAME = SHAIKDB)
      (ORACLE_HOME = /u01/app/oracle/product/11.2.0.2/SHAIKPROD)
    )
  )

ADR_BASE_CMAN = /u01/app/oracle


[oracle@collabn1 admin]$ lsnrctl status cman

LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 13-SEP-2015 20:18:07

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

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=collabn1.shaiksameer)(PORT=1523)))
STATUS of the LISTENER
------------------------
Alias                     cman
Version                   TNSLSNR for Linux: Version 11.2.0.1.0 - Production
Start Date                13-SEP-2015 20:18:02
Uptime                    0 days 0 hr. 0 min. 5 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/oracle/product/11.2.0.2/CLIENT/network/admin/listener.ora
Listener Log File         /u01/app/oracle/diag/tnslsnr/collabn1/cman/alert/log.xml
Listening Endpoints Summary...
 (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=collabn1.shaiksameer)(PORT=1523)))
Services Summary...
Service "SHAIKDB.shaiksameer" has 1 instance(s).
  Instance "SHAIKDB", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully

[oracle@collabn1 sf_stage]$ vi $TNS_ADMIN/tnsnames.ora
cman =
  (DESCRIPTION =
  (ADDRESS = (PROTOCOL = TCP)(HOST = collabn1.shaiksameer)(PORT = 1523))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = SHAIKDB.shaikmeer)
    )
  )


[oracle@collabn1 sf_stage]$ tnsping cman

TNS Ping Utility for Linux: Version 11.2.0.1.0 - Production on 13-SEP-2015 23:16:07

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

Used parameter files:
/u01/app/oracle/product/11.2.0.2/SHAIKPROD/network/admin/sqlnet.ora


Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = collabn1.shaiksameer)(PORT = 1523)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = SHAIKDB.shaiksameer)))
OK (0 msec)


Test the listener:


[oracle@collabn1 sf_stage]$ sqlplus system@cman

SQL*Plus: Release 11.2.0.1.0 Production on Sun Sep 13 22:26:56 2015

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

Enter password:

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

SHAIKDB>select name from v$database;

NAME
---------
SHAIKDB

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

Stop the Traditional Listener:


[oracle@collabn1 admin]$ lsnrctl stop cman

LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 13-SEP-2015 20:27:11

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

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=collabn1.shaiksameer)(PORT=1523)))
The command completed successfully


Delete Listener Configuration:









 
Viewing all 191 articles
Browse latest View live