Tuesday, 24 July 2012

Configuration of FTP Server in LINUX 5.3

Ftp server is designed for uploading and downloading the files, when ftp server users log's in, they get their home folder at client side and if public/anonymous user log's in they get data stored in /var/ftp folder Steps to

Configure FTP Server in LINUX

Step:--1. Check and install required Packages

Check the packages are installed or not by rpm/yum command 
[root@server ~]# rpm -q vsftpd


Remove the packages and old data if required 
[root@server ~]# yum remove vsftpd* -y

Install the Packages

 Note: Here my file is at Desktop. So i was changing the path to Desktop.

[root@server ~]# cd /root/Desktop/
[root@server Desktop]# ls
FileZilla3 tomcat vsftpd-2.0.5-10.el5.i386.rpm

[root@server Desktop]# chmod 777 vsftpd-2.0.5-10.el5.i386.rpm

[root@server Desktop]# rpm -ivh vsftpd-2.0.5-10.el5.i386.rpm
warning: vsftpd-2.0.5-10.el5.i386.rpm:
Header V3 DSA signature: NOKEY, key ID 37017186
Preparing... ########################################### [100%]
1:vsftpd ########################################### [100%]

Step:--2. Create the resources on ftp server (file/folder & Users)


Create users and assign passwords to whom you want to allow logging through ftp


[root@server ~]# useradd vinay
[root@server ~]# useradd test

[root@server ~]# passwd test
Changing password for user test.
New UNIX password:
BAD PASSWORD:
it is too simplistic/systematic
Retype new UNIX password:
passwd: all authentication tokens updated successfully.


[root@server ~]# passwd vinay
Changing password for user vinay.
New UNIX password:
BAD PASSWORD:
it is too simplistic/systematic
 Retype new UNIX password:
passwd: all authentication tokens updated successfully.


Create or Copy some files inside /var/ftp/pub folder


[root@server ~]# cd /var/ftp/pub/ 
[root@server pub]# touch abc.txt cde.txt audio.mp3 vedio.avi
[root@server pub]# ls 
abc.txt cde.txt audio.mp3 vedio.avi




Create a Upload folder for anonymous users and give full permission for read/write.


For example 
oracle helps
[root@server pub]# mkdir /var/ftp/oracle helps 
[root@server pub]# chmod 777 /var/ftp/oracle helps
[root@server pub]#


Step:--3. Edit the Main Configuration file /etc/vsftpd/vsftpd.conf


[root@server ~]# vi /etc/vsftpd/vsftpd.conf
# FTP EXAMPLES
12 anonymous_enable=YES
15 local_enable=YES
27 anon_upload_enable=YES
83 ftpd_banner=Welcome to oracle helps
:wq!


Step:-- 4. To block the ftp server users (for Ex:-- test) write the user name in file

/etc/vsftpd/ftpusers


[root@server ~]# vi /etc/vsftpd/ftpusers

# Users that are not allowed to login via ftp
test
:wq!

Step:--5. start th ftp service


[root@server ~]# vi /etc/vsftpd/ftpusers
[root@server ~]# service vsftpd restart
Shutting down vsftpd: [FAILED]
Starting vsftpd for vsftpd: [ OK ]

[root@server ~]# service vsftpd restart
Shutting down vsftpd: [ OK ]
Starting vsftpd for vsftpd: [ OK ]

Note: Your system Firewall should be turnoff or In firewall settings ftp exception should be added.


For Checking your ftp in Client Machine, Do the following steps:



1.Open the Web Browser and give following

URL ftp://192.168.xxx.xxx/

Here replace your ftp server IP address.

To upload or Any changes use any Ftp Software like Winscp or Filzilla , etc....



Optional
User Prompting userid & password on FTP



Monitoring Table Usage & Statistics Collections


### Monitoring Table Usage for the apllication & testing purpose when the anyone table not use delete now.. how ...?see
the Scenario's rename the table and see the application break the connection & users face some problem or not when not so drop unused table.

-show parameter '%AUDIT%'
-alter system set audit_trail=db scope=spfile;
-bounce back your database;

-audit select, insert, update, delete, on scott.emp;

-perform DML on EMP table


-select username,obj_name,to_char(timestamp,'dd-mon-yy hh12:mi') event_time,
substr(ses_actions,4,1) del,
substr(ses_actions,7,1) ins,
substr(ses_actions,10,1) sel,
substr(ses_actions,11,1) upd
from dba_audit_object order by 1

-noaudit select, insert, update, delete, on scott.emp;

## Tracking objects Modifications Statistics

----Perform a quick analyze to load in base statistics
DBMS_STATS.GATHER_SCHEMA_STATS ('SCOTT', CASCADE => TRUE);


----Examine the current statistics
SELECT table_name, num_rows, blocks, avg_row_len,monitoring
FROM user_tables
WHERE table_name='EMP';

------Turn on Automatic Monitoring
Now turn on automatic monitoring for the emp table. This can be done using the alter table method.
Starting with Oracle 9i, you can also perform this at the "schema", and "entire database" level. I provide the syntax for all three methods below.
Monitor only the EMP table.

alter table emp monitoring;

-----Monitor all of the tables within Scott's schema. (Oracle 9i and higher)
BEGIN
  DBMS_STATS.alter_schema_tab_monitoring('scott', true);
END;

------Verify that monitoring is turned on.
Note: The results of the following query are from running the alter table ... statement on the emp table only.

SELECT table_name, monitoring
FROM user_tables
ORDER BY monitoring;


----- Delete some rows from the database.

SQL> DELETE FROM emp WHERE rownum < 501;

500 rows deleted.

SQL> commit;

-------Wait until the monitered data is flushed.
before analyze flush first the monitoring information for the statistics collection.
Data can be flushed in several ways.
In Oracle 8i, you can wait it out for 3 hours.
In Oracle 9i and higher, you only need to wait 15 minutes.
In either version, restart the database.
For immediate results in Oracle 9i and higher, use the DBMS_STATS.flush_database_monitoring_info package.
OK, I'm impatient...

exec dbms_stats.flush_database_monitoring_info;

-----Check for what it has collected.
As user "scott", check USER_TAB_MODIFICATIONS to see what it was collected.

SELECT * FROM user_tab_modifications;

------Perform a quick analyze to load in base statistics
DBMS_STATS.GATHER_SCHEMA_STATS ('SCOTT', CASCADE => TRUE);


------Verify that the table is no longer listed in USER_TAB_MODIFICATIONS.
SQL> SELECT * FROM user_tab_modifications;


-----Examine some of new statistics collected.
SELECT table_name, num_rows, blocks, avg_row_len,monitoring
FROM user_tables where table_name='EMP';

Row Spaning multiple blocks (Row chaning & Migration)


SELECT 'TASK_NAME     :'||f.TASK_NAME||chr(10)||
'start run time       :'||to_char(execution_start,'dd-mon-yy hh12:mi')||chr(10)||
'SEGMENT NAME         :'||o.ATTR2 ||chr(10)||
'SEGMENT TYPE         :'||o.TYPE ||chr(10)||
'PARTITION NAME       :'||o.ATTR3 ||chr(10)||
'MESSAGE              :'||f.MESSAGE||chr(10)||
'MORE INFO            :'||f.More_INFO||chr(10)||
'----------------------------------------------'Advice
FROM dba_advisor_findings f,dba_advisor_objects o,
DBA_ADVISOR_LOG l
WHERE o.TASK_ID=f.TASK_ID
AND o.OBJECT_ID=f.OBJECT_ID
and f.task_id=l.task_id
and l.execution_start > sysdate - 1
and o.type in ('TABLE','INDEX')
order by f.task_name
/



## Move the table
alter table clientscannedimage move; //move on segemnt
select owner,index_name,status from dba_indexes where table_name='CLIENTSCANNEDIMAGE'
alter index <index_name> rebuild>;

## If the move setting is low space then use it
select table_name,pct_free from user_tables order by 1
alter table clientscannedimage move pctfree 40;

## Detect & Analyze row chaining
-utlchain.sql //create table this script
--analyze table clientscannedimage list chained rows;
---select count(*) from chained_rows where table_name='CLIENTSCANNEDIMAGE'

----analyze table ldbo.clientscannedimage compute statistics;
-----select CHAIN_CNT from user_tables where table_name='CLIENTSCANNEDIMAGE'

Solution--------
create table temp_scannedimage
as select * from clientscannedimage
where rowid(select head_rowid from chained_rows where table_name='CLIENTSCANNEDIMAGE');

delete from emp
where rowid in (select head_rowid from chained_rows where table_name='CLIENTSCANNEDIMAGE');

insert into clientscannedimage select * from temp_scannedimage

Automated Segment Advisor Advice


Run This Query then after check the output and take the action of the object--

Detect (Row spaning multiple blocks i.e row chaining ,Reclaiming space) with advice

-----Through Package

DESC DBMS_SPACE

SELECT
'SEGMENT ADVICE--------------------------------------------------'  ||chr(10)||
'SEGMENT OWNER         : '||            SEGMENT_OWNER                  ||chr(10)||
'SEGMENT NAME            : '||            SEGMENT_NAME                     ||chr(10)||
'SEGMENT TYPE              : '||            SEGMENT_TYPE                       ||chr(10)||
'TABLESPACE NAME      : '||            TABLESPACE_NAME               ||chr(10)||
'ALLOCATED SPACE       : '||            ALLOCATED_SPACE               ||chr(10)||
'RECLAIMABLE SPACE   : '||            RECLAIMABLE_SPACE           ||chr(10)||
'RECOMMENDATIONS   : '||            RECOMMENDATIONS             ||chr(10)||
'SOLUTION 1                    : '||            C1                                                ||chr(10)||
'SOLUTION 2                    : '||            C2                                                ||chr(10)||
'SOLUTION 3                    : '||            C3 ADVICE
FROM table(dbms_space.asa_recommendations('FALSE','FALSE','FALSE'))
/

Reclaimed space more than 20 MB




---Through Data Dictionary (3 Views)


SELECT * FROM DBA_ADVISOR_EXECUTIONS //11g
OR
SELECT * FROM DBA_ADVISOR_LOG // 10g

SELECT * FROM DBA_ADVISOR_FINDINGS
SELECT * FROM DBA_ADVISOR_OBJECTS




SELECT 'TASK_NAME     :'||f.TASK_NAME                                           ||chr(10)||
'start run time                        :'||to_char(execution_start,'dd-mon-yy hh12:mi')||chr(10)||
'SEGMENT NAME             :'||o.ATTR2                                                      ||chr(10)||
'SEGMENT TYPE               :'||o.TYPE                                                        ||chr(10)||
'PARTITION NAME           :'||o.ATTR3                                                     ||chr(10)||
'MESSAGE                          :'||f.MESSAGE                                                ||chr(10)||
'MORE INFO                      :'||f.More_INFO                                              ||chr(10)||
'----------------------------------------------'Advice
FROM dba_advisor_findings f,dba_advisor_objects o,
DBA_ADVISOR_LOG l
WHERE o.TASK_ID=f.TASK_ID
AND o.OBJECT_ID=f.OBJECT_ID
and f.task_id=l.task_id
and l.execution_start > sysdate - 1
and o.type in ('TABLE','INDEX')
order by f.task_name
/


## Re-organize object:


Shrink Space


alter table <table_name> enable row movement;

Note:- Mannualy,Recommend to use shrink space because after that shrink table reset the HWM they have to work of defragmentation 'i.e' requried row movement 
alter table <table_name> shrink space; //only table segment
alter table <table_name> shrink_space cascade; //table & index sgement



Shrink Space Compact
Note:- No Re-commend not defragmentation  Recover space, but don't amend the high water mark (HWM)
alter table <table_name> shrink space compact;


De-allocate Unused Space

It's Explicitly ,Deallocates unused space beginning from the end of the objects (allocated space) and moving downwards
toward the beginning of the object, continuing down until it reaches the high water mark (HWM).For indexes, "deallocate unused space"
coalesces all leaf blocks within same branch of b-tree, and quickly frees up index leaf blocks for use.

deallocate - simply deallocates unused space at the end of the segment; doesn't move any data


alter table <.......> deallocate unused space;
alter index <......> deallocate unused space;


Shrink Space Restriction
· You cannot specify this clause for a cluster, a clustered table, or any object with a LONG column.
· Segment shrink is not supported for tables with function-based indexes or bitmap join indexes. 

· This clause does not shrink mapping tables of index-organized tables, even if you specify CASCADE.
· You cannot specify this clause for a compressed table.
· You cannot shrink a table that is the master table of an ON COMMIT materialized view. Rowid materialized views must be rebuilt after the shrink operation.
· Segment shrink is not supported for tables with Domain indexes.


Monday, 23 July 2012

Backup Scenario's on (Physical Standby )



* This paper outlines RMAN procedures to setup and backup physical standby databases managed by Data Guard in an Oracle Database 10g environment.
   Note that only backups from a physical standby database can be used to recover the primary database.

The procedures outlined include:
• Configuring RMAN persistent settings on primary and standby databases.
• Creating database backups at the standby database that can be used to recover the primary or standby database.
• Recovering data files on the primary or standby database using backups that are made on the standby database.

RMAN brings rich functionality such as
• online backups.
• incremental backups.
• block media recovery.
• automation of backup management tasks.
• integration with 3rd party media management systems into the Data Guard configuration.

RMAN backups can be seamlessly offloaded to a physical standby database, allowing customers to gain more value out of
their disaster recovery investment. Backups do not impact normal Data Guard operation – they can be taken while the standby
database is in recovery or read-only mode.Backups can be used to recover either primary or standby database servers.

The following sections cover:
• RMAN and Data Guard configuration settings
• Backup procedures for primary and standby, to disk and tape
• Recovery scenarios on primary and standby
• RMAN-based instantiation of standby database


SETUP ASSUMPTIONS
The assumptions for this setup are:
Using Recovery Manager with Oracle Data Guard in Oracle Database 10g Page 5
• The standby database is a physical standby database and backups are only taken on the standby database. Refer to the Appendix for procedural
   changes if backups are taken on both primary and standby databases.
• The data file directories on the primary and standby database are identical.
  This simplifies the RMAN backup and recovery operations no matter which host is used.
• RMAN Recovery Catalog is required so that backups taken on one database server can be restored onto another database server.
   Using just the control file as the RMAN repository is not sufficient, as the primary database will have no knowledge of backups
    taken on the standby database.
The RMAN Recovery Catalog organizes backup histories and other recovery-related metadata in a centralized location.
The recovery catalog is configured in a database and maintains backup metadata. A recovery catalog does not have the space limitations
of the control file and can store more historical data about backups.
A catalog server, physically separate from the primary and standby sites, is recommended in a Data Guard configuration
as disaster striking either site will not affect the ability to recover the latest backups.

• All databases in the configuration use Oracle Database 10g Release 1 or Release 2.
• Primary database does not use Oracle Managed Files (OMF). When using OMF, standby database filenames can vary from those on the primary. Refer to the Appendix for modifications to the restore procedures when standby database filenames are different than those on the primary.
• 3rd party media management software is configured with RMAN to make backups to tape.

Note: The Appendix describes modifications to these procedures for three alternate configurations:
• Backups are made at both the primary and standby database sites due to the inability to access the backup from the originating host
• Standby database is configured as an archived log repository
• Standby database file names are different than those on the primary




Creat All database on different servers  ----that's recommended

1.PRIMAY DATABASE
2.STANDBY DATABASE
3.CATALOG DATABASE
Backup Strategy On Physical standby database scenario.

----SQL
Work some objects on primary database site
create table abc
update same table
switch  logfile 2,3 time
select * from abc;
select sequence#,applied from v$archived_log order by 1;

-----STANDBY
SQL> ALTER DATABASE [ENABLE|DISABLE] BLOCK CHANGE TRACKING
SQL> select filename, status, bytes from v$block_change_tracking;
SQL> select file#, avg(datafile_blocks) blocks,
avg(blocks_read) blocks_read,
avg(blocks_read/datafile_blocks)*100 pct_read,
avg(blocks) blocks_backed_up
from v$backup_datafile
where used_change_tracking = 'YES'
and incremental_level = 1
group by file#
order by file#;


-----Primary
connect through recovery catalog

Register Database;
configure archivelog deletion policy to shipped to all standby;
configure archivelog deletion policy to applied to standby;
configure retention policy to recovery window of 7 days;
configure db_unique_name orcl connect identifier 'orcl';
configure db_unique_name pune connect identifier 'pune';
list db_unique_name of database;



-----Standby
connect through recovery catalog

Register database;
configure archivelog deletion policy to applied to standby;
configure archivelog deletion policy to backed up 1 times on disk;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO 'D:\Backup\CTL_%F';
configure controlfile autobackup on;
configure backup optimization on;
configure channel device type disk format 'D:\Backup\%d_%u';
configure deletion policy to none;




----Backup Physical Standby
connect through recovery catalog

RECOVER COPY OF DATABASE WITH TAG 'FULL';
BACKUP  INCREMENTAL LEVEL 1 FOR RECOVER OF COPY WITH TAG 'FULL' DATABASE;
BACKUP ARCHIVELOG ALL FILESPERSET 100 TAG='ARCH';
BACKUP BACKUPSET ALL;





----SQL
Work some objects on primary database site
create table cde
update same table
select * from cde;
select sequence#,applied from v$archived_log order by 1;




----Backup Physical Standby
RECOVER COPY OF DATABASE WITH TAG 'FULL';
BACKUP  INCREMENTAL LEVEL 1 FOR RECOVER OF COPY WITH TAG 'FULL' DATABASE;
BACKUP ARCHIVELOG ALL FILESPERSET 100 TAG='ARCH';
BACKUP BACKUPSET ALL;



##When lost the datafile on PRIMARY database then Recover to Physical Standby database backup.


C:\>rman target=sys@pune

Recovery Manager: Release 11.2.0.1.0 - Production on Thu Jul 12 14:01:21 2012
Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.
connected to target database: ORCL (DBID=1313471048)

RMAN> connect auxiliary sys@orcl
connected to auxiliary database: ORCL (DBID=1313471048, not open)

RMAN> BACKUP AS COPY FORCE DATAFILE 4 AUXILIARY FORMAT 'D:\app\administrator\oradata\orcl\user01.dbf';

Starting backup at 12-JUL-12
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=37 device type=DISK
channel ORA_DISK_1: starting datafile copy
input datafile file number=00004 name=C:\PUNE\USERS01.DBF
output file name=D:\APP\ADMINISTRATOR\ORADATA\ORCL\USER01.DBF tag=TAG20120712T140233
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:55
Finished backup at 12-JUL-12


RMAN> exit
Recovery Manager complete.


C:\>rman target=sys@orcl
Recovery Manager: Release 11.2.0.1.0 - Production on Thu Jul 12 14:04:28 2012
Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.
connected to target database: ORCL (DBID=1313471048, not open)

RMAN> connect catalog rman@cat
connected to recovery catalog database

RMAN> catalog datafilecopy 'D:\app\administrator\oradata\orcl\user01.dbf';

cataloged datafile copy
datafile copy file name=D:\APP\ADMINISTRATOR\ORADATA\ORCL\USER01.DBF RECID=2 STAMP=788450751

RMAN> run{
2> sql 'alter database datafile 4 offline';
3> set newname for datafile 4 to 'D:\app\administrator\oradata\orcl\user01.dbf';
4> switch datafile 4;
5> recover datafile 4;
6> sql 'alter database datafile 4 online';
7> }

sql statement: alter database datafile 4 offline

executing command: SET NEWNAME

datafile 4 switched to datafile copy
input datafile copy RECID=2 STAMP=788450751 file name=D:\APP\ADMINISTRATOR\ORADATA\ORCL\USER01.DBF
starting full resync of recovery catalog
full resync complete

RMAN> exit
Recovery Manager complete.

C:\> sqlplus sys@orcl as sysdba
SQL> set line 32000
SQL> select * from v$datafile; //check the datafile status is online & offline mode.



========================================================================
## Resync backup Physical Standby to PRIMARY database backup catalog.


----standby database take a backup
backup database plus archivelog;


----primary get physical standby backup information
catalog start with '/u02/Backup/';




========================================================================
##Question.
My question is when i have try to take a backup with recovery catalog on standby side it's auto resync the 
backup information on primary database recover catalog or not .If yes so how we are resync or scenario. 

Friday, 20 July 2012

ROLE & PRIVILEG


---CONNECT ROLE
Alter Session
Create Session
Create Cluster
Create Synonym
Create Database Link
Create Table
Create Sequence
Create View

-----CREATE SYSOPER PRIVILEGES
RECOVER DATABASE
ALTER DATABASE BACKUP CONTROLFILE TO
ALTER DATABASE OPEN | MOUNT
SHUTDOWN
SYSOPER STARTUP
ALTER DATABASE ARCHIVELOG

-----CREATE SYSDBA PRIVILEGES
SYSDBA PRIVILEGES WITH ADMIN OPTION
CREATE DATABASE
ALTER DATABASE BEGIN/END BACKUP
RESTRICTED SESSEION
RECOVER DATABASE UNTIL


---DBA ROLE

Tuesday, 17 July 2012

Performance Tuning (Wait Event & Statistic & Classes)



Wait Event


Acollection of wait events provides information about the session that had to wait or must wait for different reasons.

It's incremented by a server process or thread to indicate that it had to wait for an event to complete before being to able to continue processing.Wait events data reveals som problem that might be affecting performanc like (latch contention,buffer contention, and I/O contention).this vies V$EVENT_VIEW to found the full list of events.

TIME_STATISTIC parameter is set TRUE.

MICRO SECOND TIMINGS

* MICRO_SECOND TO SECOND convert  (4818649763 / 10 raise to power -6)
   = 4818649763 / 1000000



*MICRO_SECOND TO CENTI-SEC (4818649763 / 10 raise to power -4)
= 4818649763 10000




*MICRO_SECOND TO MILLI-SEC (4818649763 / 10 raise to power -3)
= 4818649763 1000



MICRO_SECOND TO MINT convert  (4818649763 / 10 raise to power -6 / 60)
   = 4818649763 1000000 / 60





---Column (TIME_WAITED_MICRO)                 (CPU_TIME,ELAPSED_TIME)
v$session_wait                                                                    v$SQL
v$system_event                                                                   v$SQLAREA
v$session_event


---Column (WAIT_TIME)                                         (ACITVE_TIME)
v$LATCH                                                                      v$SQL_WORKAREA
v$LATCH_PARENT                                                     v$SQL_WORKAREA_ACTIVE
v$LATCH_CHILDREN



V$SESSION: lists session information for each current session. It lists either the event currently being waited for, or the event last waited for on each session. This view also contains information about blocking sessions, the wait state, and the wait time.



V$SESSION_WAIT: displays the events for which sessions have just completed waiting or are currently waiting.
--Column
* WAIT_TIME
                >0  The session's last wait time .i.e( how much last time  for the session)
                =0 It means session currently waiting.
               =-1 The vaule is less than 1/100 of second.
               =-2 The system cannot provide timing information.

* Second_In_wait: Number of seconds the eent wait
* State: Waiting, waiting unknown time,waited short time ( < 0.01 Second) or Waited Known time.


V$SESSION_WAIT_HISTORY: lists the last 10 wait events for each current session and the associated wait time.



Wait Class


V$SESSION_WAIT_CLASS: displays the time spent in various wait event operations on a per-session basis.

V$SYSTEM_WAIT_CLASS: displays the instance-wide time totals for each registered wait class.

V$SERVICE_WAIT_CLASS:displays aggregated wait counts and wait times for each wait statistic. An aggregation of these wait classes is used when thresholds are imported.


V$EVENT_NAME:




Wait Event Statistic


V$SYSTEM_EVENT: displays the total number of times all the sessions have waited for the events in that view.

V$SESSION_EVENT: is similar to V$SYSTEM_EVENT, but displays all waits for each session.


Select sid,event 
     from v$session_wait 
           where wait_time=0 and wait_class#=6 and event!='SQL*Net message from client';


Note:- Ignore event "SQL*Net message from client" .The wait event shown above are idel wait class events that always appear. They don't indicate a problem.There are more than 60 such idle events and belog to the "Idel" wait class (wait class number 6);




V$SERVICE_EVENT:displays the services in the database.



select service_name,event,average_wait,time_waited
                from v$service_event 
                      where time_waited > 0;


  • Wait Event Class:-

    select distinct wait_class#,wait_class from v$event_name order by 1
    select distinct name, wait_class#,wait_class from v$event_name order by 1
SOME WAIT EVENT
V$EVENT_NAME






WAIT EVENT






AREA

Buffer Busy & Waits Buffer cache,DBWR
Free Buffer Waits Buffer cache,DBWR,I/O
DB File Scattered read I/O ,SQL Tuning
DB File Sequential read I/O ,SQL Tuning
Enqueue Waits (enq:) LOCKS
Library cache waits Latches
Log buffer space Log buffer I/O
Log file sync Over Commit + rollback ,I/O


V$WAITSTAT 

The V$WAITSTAT view lists details about the block contention. This view updates the wait statistics from the buffer cache when timed statistics are enabled. This statistic can be used along with the 'buffer busy waits' wait information. To get finer details on the waits per file basis, the following query can be used.

To display buffer waits per file (run as SYS)


SELECT count, time, name

FROM v$datafile a, X$KCBFWAIT b

WHERE b.indx+1 = a.file#;

select class,count,time from v$waitstat;






  • Data Blocks - Usually occurs when there are too many modified blocks in the buffer cache; reduce contention by adding DBWR processes.
  • Free List - May occur if multiple data loading programs run simultaneously.
  • Segment Header - May occur when may full table scans execute simultaneously with data loading processes; aggravated by the parallel options. Reschedule data loading jobs to reduce contention;
  • Sort Block - Rarely seen except when the Parallel Query option is used; reduce contention by reducing the degree of parallelism or decreasing the SORT_AREA_SIZE init.ora parameter setting.
  • Undo Block - Very rarely occurs; may be caused by multiple users updating records in the same data block at a very fast rate; contention can usually be resolved by increasing the PCTFREE of the tables being modified.
  • Undo Header - May occur if there are not enough rollback segments to support the number of concurrent transactions.



  • System Statistic Classes

    STATISTIC  ID Class Name
    V$SYSSTAT 1 User
    V$SESSTAT All Session 2 Redo
    V$STATNAME 4 Enqueue
    V$MYSTAT Current Session 8 Chache
    V$SERVICE_NAME Instance Startup 16 OS
    32 RAC
    64 SQL
    128 Debug


    Eq:-Consume 30,000 bytes of PGA


    select username,name,round(value)/1024||' KB' ,class
    from v$statname n,v$session s,v$sesstat t
    where s.sid=t.sid
    and n.statistic#=t.statistic#
    and s.type='USER'
    and s.username is not null
    and n.name='session pga memory'
    and t.value > 30000
    /


    Saturday, 14 July 2012

    ORA-00261: log 5 of thread 1 is being archived or modified


    ---when create standby database Some time generate this problem .

    rman target /
    connect auxiliary sys@pune
    duplicate target database for standby from active database;
    exit

    sqlplus sys@pune as sysda

    ######
    SQL> ALTER DATABASE DROP STANDBY LOGFILE GROUP 5;
    ALTER DATABASE DROP STANDBY LOGFILE GROUP 5
    *
    ERROR at line 1:
    ORA-00261: log 5 of thread 1 is being archived or modified
    ORA-00312: online log 5 thread 1: 'C:\PUNE\ORCL_REDO05.LOG'
    ######

    --alter database clear logfile group 5;

    --alter database drop logfile group 5;

    --ALTER DATABASE ADD STANDBY LOGFILE GROUP 5  ('C:\pune\pune_REDO05.LOG') SIZE 50M;



    2.  Cancel Managed Recovery process on the standby:

    SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;

    3.  Execute the command to clear all log groups on standby for each log group (for each log group):

    SQL>alter database clear logfile group 1;

    4.  Check the v$log view to confirm the size and status.

    5.  Recreate standby redo logs on standby (only if standby Redo logs are also missing) using:

    (a) Drop the standby redo logfile group(s) (check v$standby_log)

    SQL> alter database drop standby logfile group 5;
     (b) Recreate the standby logfile group(s)

    SQL> alter database add standby logfile group 5 ('C:\pune\pune_REDO05.LOG') size 50m;

    Thursday, 12 July 2012

    User Default Setting (LINUX)

    set the default user setting

    /etc/defaults/useradd

    Disable Unnecessary Services (LINUX)


    An important security principle is “if you don’t need it, disable it”. All running services expose the system to some level of risk. Obviously, some services are much more vulnerable than others but often you don’t know what the vulnerabilities of any given service are, and some may yet to have been discovered.
    To see what services are enabled enter:
    /sbin/chkconfig –list

    To disable a service enter:
    /sbin/chkconfig -del service
    At a minimum the following should be disabled:
    /sbin/chkconfig -del bluetooth
    /sbin/chkconfig -del cups
    /sbin/chkconfig -del autofs
    /sbin/chkconfig -del isdn
    /sbin/chkconfig -del portmap
    /sbin/chkconfig -del vncserver
    /sbin/chkconfig -del mdmonitor
    /sbin/chkconfig -del winbind

    It is also a good idea to go through the /etc/xinetd.d directory and delete any unused services here. For example:
    rm /etc/xinetd.d/gssftp
    rm /etc/xinetd.d/krb5-telnet
    rm /etc/xinetd.d/tftp
    rm /etc/xinetd.d/daytime*
    rm /etc/xinetd.d/chargen*
    rm /etc/xinetd.d/ekrg5-telnet*


    Configure Password Policy (GLOBAL USERS LINUX)


    The following settings force users to change their password every 90 days and enforce passwords at least 8 characters long.
    su root
    Enter root password
    vi /etc/login.defs
    Edit the file as follows:
    PASS_MAX_DAYS 90
    PASS_MIN_DAYS 1
    PASS_MIN_LEN 8
    PASS_WARN_AGE 14
    Type ESC:x! to save and exit

    Wednesday, 11 July 2012

    samba server configuration in RHEL 5 AND RHEL 6.1 step by step


    Samba is a suite of utilities that allows your Linux Machines to share files and other resources.
    such as printers with Windows Machines.

    Before configuring Samba server in Linux you need to have the following Pre-requests.

    1. Linux System with network Configured Here i was configured My IP as 192.168.10.111 

    2. Windows System with network configured in Same network. here my System is having 192.168.10.108 

    3.Your Linux System firewall should be disabled. 

    Main Configuration:

    1. Check your linux system wheather the samba package is installed or not with the following 

    command. [root@localhost ~]# rpm -qa samba*

    2. If the packages are not installed in your system, use the following command to install from the internet. 

    [root@localhost ~]# yum install samba* 

    Note: Above command is for installing the packages from the internet only. So you should have the internet connection.

    3. After installing the Packages 
    Make sure that xinetd and Portmap service should be run. 
    For checking those services are running or not, use the following commands.

    [root@localhost ~]# /etc/init.d/xinetd status 

    [root@localhost ~]# /etc/init.d/portmap status

    For starting the above service use the following services use the following commands. 

    [root@localhost ~]# /etc/init.d/xinetd restart 

    [root@localhost ~]# /etc/init.d/portmap restart

    After that Make sure that these services to be run completely.

     For that use the following commands.
    [root@localhost ~]# chkconfig xinetd on 
    [root@localhost ~]# chkconfig portmap on 

    Check the services is running or not. These services should be running condition.

    4. Create 2 users in your linux System i.e: vinay and Test 

    [root@localhost ~]# useradd vinay 
    [root@localhost ~]# passwd vinay 
    Changing password for user vinay. 
    New password: 
    Retype new password: passwd: all authentication tokens updated successfully. 

    [root@localhost ~]# useradd Test 
    [root@localhost ~]# passwd Test 
    Changing password for user Test. 
    New password: 
    Retype new password: passwd: all authentication tokens updated successfully.


    5. Now create the share directory. i.e which directory you want to share. Here iam creating directory called 'Sambashare' in the following Path. i.e /opt and give the full Permissions to the directory.

    [root@localhost ~]# mkdir /opt/sambashare/ 
    [root@localhost ~]# chmod 777 /opt/sambashare/   (OPTIONAL #chmod -R 1777 /opt/sambshare/  it means only these users RW permission not others users)

    [root@localhost ~]# ls -l /opt/ 
    total 360 
    drwx------. 2 root root 16384 Feb 1 11:01 lost+found 
    drwxrwxrwx 3 root root 4096 Feb 6 18:12 sambashare 
    -rwxrwxrwx. 1 root root 344558 Jan 30 15:41 sysstat-10.0.3-1.i586.rpm


    6. Now enter the configuration into following file. i.e

     /etc/samba/smb.conf 
    In the above file enter the following configuration. Here iam giving permission to one user only. 
    Add the configuration at end of the file. 

    Note: Better to take the backup of the configuration file.

    [root@localhost ~]# vi /etc/samba/smb.conf 
        # My Sharing directory 
           [data] 
    comment = personal share 
    path = /opt/sambashare 
    public = no 
    writable = yes 
    Read only = no 
    printable = no 
    browseable = yes
    write list = vinay Test 

    :wq! 

    Use these to save the configuration file 

    :wq!

    7. Now add the user to the samba user's List 

    [root@localhost ~]# smbpasswd -a vinay 
    New SMB password: 
    Retype new SMB password: 
    Added user vinay.
    [root@localhost ~]#

    8. Now we did the all the configurations. so start the samba service and check its status. 

    [root@localhost ~]# chkconfig smb on 
    [root@localhost ~]# /etc/init.d/smb restart 
    Shutting down SMB services: [ OK ] 
    Starting SMB services: [ OK ] 

    [root@localhost ~]# /etc/init.d/smb status 
    smbd (pid 3686) is running...


    Client side configuration for Samba server.

    1. Check from your windows System to samba server whether Ping command is working or not. 

    Start--> run--> cmd --> Ping 192.168.10.111

    If you are getting ping with proper reply then your server is working fine or else check the network connectivity and Linux System firewall.


    2. Now access your samba server in the following way. 

    Start --> Run --> \\192.168.10.111 -->Press enter. 

    (Here IP address is your samba server IP address)

    3. It is asking for samba user's username and password.

    4. This is your samba server Main Screen.

    5. Now you can Copy or Paste your data.


    Read only permission so create sharing folder and gave read only permission on file.

    How do I set permissions to Samba shares? 
    Samba Basic permissions are as follows (configuration file is smb.conf [/etc/samba/smb.conf]): 

     read only: This parameter controls whether an user has the ability to create or modify files within a share. This is default. 

     guest ok: Uf this parameter is set to yes, the users will have access to the share without having to enter a password. This can pose security risk. 

     writeable: Specifies users should have write access to the share. You can create the share called helpfiles with read only permission. 

    [helpfiles]
    path = /usr/share/docs 
    read only = Yes


    You can create the share called salesdoc with write permission 
    [salesdoc] 
    path = /home/shared/sales 
    writeable = Yes

    You can also create a list of users to give write access to the share with write list option.
     For example allow rocky and tony to write to the share called sales: 
    [salesdoc] 
    path = /home/shared/sales 
    write list = rocky tony

    You can use following options

      read list: This option accepts a list of usernames or a group as its value. Users will be given read-only access to the share. 
     valid users: You can make a share available to specific users. Usernames or group names can be passed on as its value. 
     invalid users: Users or groups listed will be denied access to this share.



    Samba mask permission It is also possible to specify samba default file creation permission using mask. 

     create mask: This option is set using an octal value when setting permissions for files. 
     directory mask: Directories must have the execute bit for proper access. Default parameter is 0755. 
    .
    [salesdoc] 
    path = /home/shared/sales
    write list = rocky sys 
    create mask = 0775


    [root@oracle home]# smbstatus
    Samba version 3.0.33-3.7.el5

    PID Username Group Machine
    -------------------------------------------------------------------
    4614 almondz almondz hp2210-pc (192.168.11.99)
    4608 Test Test nishank (172.16.10.15)
    4611 almondz almondz nakulsharma (192.168.21.21)
    4418 almondz almondz almo (192.168.21.137)
    Service pid machine Connected at
    -------------------------------------------------------
    IPC$ 4418 almo Sun Mar 11 05:00:22 2012
    almondz 4608 nishank Sun Mar 11 05:14:48 2012
    data 4418 almo Sun Mar 11 05:00:24 2012
    IPC$ 4611 nakulsharma Sun Mar 11 05:15:01 2012
    IPC$ 4614 hp2210-pc Sun Mar 11 05:16:18 2012
    IPC$ 4608 nishank Sun Mar 11 05:14:05 2012
    No locked files



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


    RHEL 6.1

    remove rpm -e samba*

    yum install samba*

    /etc/samba/smb.conf

    -------smb.conf
            hosts allow = 127. 192.168.12. 192.168.56.  10.128.   //uncommented this line and add ip series

    [tptrc-01]
            comment = personal share
            path = /home/tptrc/tptrc-01
            writable = yes
            browseable = yes
            write list = tptrc-01
            valid users = tptrc

    ----- Hide directory directory
    [tptrc]
            comment = personal share
            path = /home/tptrc
            writable = no
            browseable = no


    useradd share
    mkdir /home/share/tptr-04 -p
    chown root:share -R tptr-04
    chmod -R 775 tptr-04


    chkconfig --levels 235 smb on
    /etc/init.d/smb restart

    smbpasswd  -a share


    password : xxxxx



    Enjoy............?

    ArchiveLog Shipping Take more time On Physical standby


    Log Shipping define the time lag.....?

    I have create one demonstration  it's work ,but i am not sure any exact solution for this problem ,if you have find the exact solution give the post on this blog.

    some time log shipped gap (delay shipped & apply on physical standby , and that's a big problem see)

    ---primary will be go
    sequence 5
    sequence 6
    sequence 7
    sequence 8
    sequence 9 log 

    ---but standby work on
    sequence 5
    sequence 6
    sequence 7
    shipped & applied 

    but not primary shipped 8,9 log on standby why ?

    my machine has been restart 2 -3 time (I have create Physical standby  on Single Machine)
    (OR network issue problem then generate this problem) 
    after the work database not properly shutdown 


    when up the database 
    1.standby
    2.primary


    NOTE:
    after few time spend
    primary generate 10,11,log 
    but standby shipped & applied on 8,9

    what the solution.?

    ##solution
    --primary
    alter system set log_archive_dest_state_2='defer';
    select max(sequence#) from v$archived_log;

    --standby
    select max(sequence#) from v$archived_log;


    OS command use CP log from primary to standby location 
    and register these logs on standby 

    --Primary & Standby both are same
    select max(sequence#) from v$archived_log;

    alter system set log_archive_dest_state_2='enable';

    ORA-27037: unable to obtain file status

    In Data guard Scenario: RMAN error



    RMAN> backup archivelog from sequence 4 until sequence 79;

    Starting backup at 10-JUL-12
    using channel ORA_DISK_1
    RMAN-00571: ===========================================================
    RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
    RMAN-00571: ===========================================================
    RMAN-03002: failure of backup command at 07/10/2012 22:48:00
    RMAN-06059: expected archived log not found, loss of archived log compromises recoverability
    ORA-19625: error identifying file /u02/pune/archivelog/ARC_1_4_787996832.dbf
    ORA-27037: unable to obtain file status
    Linux Error: 2: No such file or directory
    Additional information: 3


    RMAN> backup archivelog all;

    Starting backup at 10-JUL-12
    using channel ORA_DISK_1
    RMAN-00571: ===========================================================
    RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
    RMAN-00571: ===========================================================
    RMAN-03002: failure of backup command at 07/10/2012 22:49:22
    RMAN-06059: expected archived log not found, loss of archived log compromises recoverability
    ORA-19625: error identifying file /u02/pune/archivelog/ARC_1_4_787996832.dbf
    ORA-27037: unable to obtain file status
    Linux Error: 2: No such file or directory
    Additional information: 3

    RMAN> backup archivelog from SCN 917572 until SCN 1131578;

    Starting backup at 10-JUL-12
    using channel ORA_DISK_1
    RMAN-00571: ===========================================================
    RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
    RMAN-00571: ===========================================================
    RMAN-03002: failure of backup command at 07/10/2012 22:56:19
    RMAN-06059: expected archived log not found, loss of archived log compromises recoverability
    ORA-19625: error identifying file /u02/pune/archivelog/ARC_1_4_787996832.dbf
    ORA-27037: unable to obtain file status
    Linux Error: 2: No such file or directory
    Additional information: 3

    =======
    Solution:
    =======

    I have placed primary to standby starting 3 logfiles

    1
    2
    3

    they have been register on standby database but again check the rman show error:


    RMAN> backup archivelog all


    Starting backup at 10-JUL-12
    using channel ORA_DISK_1
    RMAN-00571: ===========================================================
    RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
    RMAN-00571: ===========================================================
    RMAN-03002: failure of backup command at 07/10/2012 22:56:19
    RMAN-06059: expected archived log not found, loss of archived log compromises recoverability
    ORA-19625: error identifying file /u02/pune/archivelog/ARC_1_4_787996832.dbf
    ORA-27037: unable to obtain file status
    Linux Error: 2: No such file or directory
    Additional information: 3


    RMAN> crosscheck archivelog all;
    RMAN> backup archivelog all;

    ORA-16006: audit_trail destination incompatible with database open mode


    Action: When the Database is opened for read-only access, the audit_trail initialization parameter can only be set to "OS" or "NONE" (FALSE).
    SQL> STARTUP MOUNT;
    ORACLE instance started.

    Database mounted.
    SQL> ALTER DATABASE OPEN READ ONLY;
    ALTER DATABASE OPEN READ ONLY
    *
    ERROR at line 1:
    ORA-16006audit_trail destination incompatible with database open mode 


    SQL> SHOW PARAMETER AUDIT_TRAIL

    ============================
    audit_trail                   string           DB

    SQL> ALTER SYSTEM SET audit_trail=none SCOPE=SPFILE;
    System altered.

    SQL> SHUTDOWN IMMEDIATE
    Database closed.
    Database dismounted.
    ORACLE instance shut down.
    SQL> STARTUP MOUNT
    ORACLE instance started.
    Database mounted.
    SQL> ALTER DATABASE OPEN READ ONLY;
    Database altered.


    Tuesday, 10 July 2012

    RMAN Password Encryption


     You want to encrypt the backups made with RMAN in order to meet your organization’s security guidelines.By default,all RMAN backups are unencrypted but you can encrypt any RMAN backup in the form of a backup set.You can encrypt sets in two ways transparent encryption and password encryption.Here I’m going to show How to configure Password encryption.


    Password Encryption :

    RMAN perform encrypted backups by using the set encryption command. This method is called password encryption of backups since the DBA must provide a password both for creating an encrypted backup and for restoring an encrypted backup.


    RMAN> set encryption on identified by vinay only;

    executing command: SET encryption

    Here I choosed one tablespace for encryption.

    RMAN> configure encryption for tablespace users on;

    tablespace USERS will be encrypted in future backup sets
    new RMAN configuration parameters are successfully stored


    RMAN> backup tablespace users;

    Starting backup at 05-JUN-10
    using channel ORA_DISK_1
    channel ORA_DISK_1: starting full datafile backupset
    channel ORA_DISK_1: specifying datafile(s) in backupset
    input datafile fno=00004 name=/home/oracle/oracle/product/10.2.0/oradata/mydb/users01.dbf
    channel ORA_DISK_1: starting piece 1 at 05-JUN-10
    channel ORA_DISK_1: finished piece 1 at 05-JUN-10
    piece handle=/home/oracle/oracle/product/10.2.0/db_1/flash_recovery_area/MYDB/backupset/2010_06_05/o1_mf_nnndf_TAG20100605T154958_60nkzpxn_.bkp tag=TAG20100605T154958 comment=NONE
    channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
    Finished backup at 05-JUN-10


    RMAN> sql ‘alter tablespace users offline’;
    sql statement: alter tablespace users offline


    RMAN> restore tablespace users;
    Starting restore at 05-JUN-10
    allocated channel: ORA_DISK_1
    channel ORA_DISK_1: sid=148 devtype=DISK

    channel ORA_DISK_1: starting datafile backupset restore
    channel ORA_DISK_1: specifying datafile(s) to restore from backup set
    restoring datafile 00004 to /home/oracle/oracle/product/10.2.0/oradata/mydb/users01.dbf
    channel ORA_DISK_1: reading from backup piece/home/oracle/oracle/product/10.2.0/db_1/flash_recovery_area/MYDB/backupset/201_06_05/o1_mf_nnndf_TAG20100605T154958_60nkzpxn_.bkp
    RMAN-00571: ===========================================================
    RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
    RMAN-00571: ===========================================================
    RMAN-03002: failure of restore command at 06/05/2010 15:55:29
    ORA-19870: error reading backup piece /home/oracle/oracle/product/10.2.0/db_1/flash_recovery_area/MYDB/backupset/2010_06_05/o1_mf_nnndf_TAG20100605T154958_60nkzpxn_.bkp
    ORA-19913: unable to decrypt backup

    So we need to set decryption.


    RMAN> set decryption identified by vinay;
    executing command: SET decryption


    RMAN> restore tablespace users;

    Starting restore at 05-JUN-10
    using channel ORA_DISK_1

    channel ORA_DISK_1: starting datafile backupset restore
    channel ORA_DISK_1: specifying datafile(s) to restore from backup set
    restoring datafile 00004 to /home/oracle/oracle/product/10.2.0/oradata/mydb/users01.dbf
    channel ORA_DISK_1: reading from backup piece /home/oracle/oracle/product/10.2.0/db_1/flash_recovery_area/MYDB/backupset/2010_06_05/o1_mf_nnndf_TAG20100605T154958_60nkzpxn_.bkp
    channel ORA_DISK_1: restored backup piece 1
    piece handle=/home/oracle/oracle/product/10.2.0/db_1/flash_recovery_area/MYDB/backupset/2010_06_05/o1_mf_nnndf_TAG20100605T154958_60nkzpxn_.bkp tag=TAG20100605T154958
    channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
    Finished restore at 05-JUN-10



    RMAN> recover tablespace users;

    Starting recover at 05-JUN-10
    using channel ORA_DISK_1

    starting media recovery
    media recovery complete, elapsed time: 00:00:02

    Finished recover at 05-JUN-10


    RMAN> sql ‘alter tablespace users online’;

    sql statement: alter tablespace users online

    RMAN>



    EXIT:-------------------- ?