Idle sessions

Description:    Output will list out all the session that
are idle for more than 1 hr.

Command to kill those sessions is also given.
Code:
select sid,serial#,username,trunc

(last_call_et/3600,2)||' hr' 

last_call_et 

from V$session where

last_call_et > 3600 and username is not null


/


Note : last_call_et is in seconds .You can give where clause accordingly.

Ex : for 2hrs:7200 etc.

Once identified ,if you want to kill those session ,
you can use this command:


alter system kill session '<sid>,<serial#>';

VNC server configuration


VNC Server configuration
Setting up VNC server in RHEL or Fedora.
1.      up2date vnc-server (RHEL) or yum install vnc-server (Fedora) if you don't have it installed.
2.      Edit /etc/sysconfig/vncservers as root.
Uncomment the line:
VNCSERVERS="1:put_the_user_you_will_log_in_as_here"
The server will default to the resolution of the machine, so if you are going to connect to a desktop with a high resolution monitor from a laptop you will want to uncomment and set the following line also:
VNCSERVERARGS[1]="-geometry 1024x768"
3.      chkconfig vncserver on
4.      su to the user that you will be logging in as.
5.      Run vncpasswd and set the password.
6.      Now run vncserver. This will create the needed initialization files.
7.      Edit /home/user/.vnc/xstartup and uncomment the two lines there to get a normal desktop when you log in.
8.      Now kill the Xvnc task and delete the lock files in the .vnc directory
9.      service vncserver start (there might be some other lock files you need to delete; I can't remember now - check any error messages here)
10.      Unfirewall 5901 tcp to allow remote connections
11.      Connect from the remote machine using servername:1
To attach to the session that is running on the monitor of the machine - the session of currently logged in local user, use krfb (on the server) and krdc (on the client) for KDE, and vino for Gnome.
---------------------------------------------------------------------------
I am unable to execute step 7:  Edit /home/user/.vnc/xstartup and uncomment the two lines there to get a normal desktop when you log in.
If I go under /home directory - I do not see any thing their. It is blank.
How will I be able to implement step7. I am totally a windows person and newbie to Linux

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

For the newbie (as myself), here is my another 3-minute Linux guide about How to setup VNC server in Red Hat Enterprise Linux?
Though this Linux-VNC guide is tested on Redhat Enterprise Linux 4, it served the general guide of installing VNC in Linux distributions.
Locate the vnc-server-4.0-8.1.rpm package from the Red Hat Linux installation CD or download the latest free version of VNC server from Real VNC.
  
Install the rpm package of VNC server: 
rpm -Uvh vnc-server-4.0-8.1.rpm
  
VNC server is using different set of login authentication than the Linux /etc/passwd. Meaning that, you have to create VNC login password for individual Linux login accounts who are granted remote access with VNC client. 
To create VNC login password, just execute vncpasswd command and enter a valid password twice as usual.
  
Unlike VNC server for Windows, each user account can run more than one VNC servers in Linux. 
To start an instance of VNC server, just execute vncserver command, which will create the $HOME/.vnc directory with VNC default startup scripts inside (if $HOME/.vnc is not currently exists).
  
The vncserver command will startup a VNC server that open 3 next available TCP/IP port, starting from 5801, 5901, and 6001 respectively. 
Port 5801 is for VNC client connection over HTTP protocol, port 5901 is for VNC client connection over RFB protocol, and port 6001 is to allows X applications to connect to the VNC server. The lsof or netstat command will able to show the network port opened by Xvnc server.
By executing vncserver for the second time or execute the vncserver :2 command, this will startup VNC server that bind and listen to port 5802, 5902, and 6002 respectively.
To connect to Linux VNC server over HTTP protocol, just type walkernews.net:5801 (replacewalkernews.net with your VNC server IP/hostname) at any javascripts-enabled web browser, such as Mozilla Firefox, Opera, or Internet Explorer.
To connect to Linux VNC server over RFB protocol, just type walkernews.net:5901 at the VNC client.
  
To kill the VNC server in Linux, just execute vncserver -kill :1 will kill the first VNC server that bind and listen to port 5801, 5901, and 6001. The vncserver -kill :2 will kill the second VNC server, and so on. 
How to get KDE or Gnome Desktop Manager running in Linux VNC server?
Don’t worry, it’s just a 3-seconds Linux trick! Edit the default VNC server startup scripts $HOME/.vnc/xstartup and un-remark the two “critical” lines, as per the scripts suggestion:
#!/bin/sh# Uncomment the following two lines for normal desktop:unset SESSION_MANAGERexec /etc/X11/xinit/xinitrc[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresourcesxsetroot -solid greyvncconfig -iconic &xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &twm &

Common UNIX commands- RedHat, HP, AIX, Solaris

Common UNIX commands across all the platforms

RMAN - Quick Recap

General RMAN Information :
What is RMAN and How to configure it ?
Why to use RMAN ?
How RMAN works ?
What O/S and oracle user privilege required to use RMAN ? 
RMAN terminology
Q.What is RMAN and How to configure it ?
A.RMAN is an Oracle Database client that performs backup and recovery tasks on your databases and automates administration of your backup strategies. It greatly simplifies the dba jobs by managing the production database's backing up, restoring, and recovering database files.
 This tool integrates with sessions running on an Oracle database to perform a range of backup and recovery activities, including maintaining an RMAN repository of historical data about backups. There is no additional installation required for this tool. Its by default get installed with the oracle database installation. The RMAN environment consists of the utilities and databases that play a role in backing up your data.You can access RMAN through the command line or through Oracle Enterprise Manager.
Q.Why to use RMAN ?
A.RMAN gives you access to several backup and recovery techniques and features not available with user-managed backup and recovery. The most noteworthy are the following:
-- Automatic specification of files to include in a backup :  Establishes the name and locations of all files to be backed up. 
-- Maintain backup repository :  Backups are recorded in the control file, which is the main repository of RMAN metadata.  Additionally, you can store this metadata in a recovery catalog,
-- Incremental backups  : An incremental backup stores only blocks changed since a previous backup. Thus, they provide more compact backups and faster recovery, thereby reducing the need to apply redo during datafile media recovery.
-- Unused block compression  :  In unused block compression, RMAN can skip data blocks that have never been used
-- Block media recovery : You an repair a datafile with only a small number of corrupt data blocks without taking it offline or restoring it from backup.
-- Binary compression : A binary compression mechanism integrated into Oracle Database reduces the size of backups.
-- Encrypted backups : RMAN uses backup encryption capabilities integrated into Oracle Database to store backup sets in an encrypted format.
-- Corrupt block detection :  RMAN checks for the block corruption before taking its backup.

Q.How RMAN works ?
A.RMAN backup and recovery operation for a target database are managed by RMAN client. RMAN uses the target database control file to gather metadata about the target database and to store information about its own operations. The RMAN client itself does not perform backup, restore, or recovery operations. When you connect the RMAN client to a target database, RMAN allocates server sessions on the target instance and directs them to perform the operations.The work of backup and recovery is performed by server sessions running on the target database. A channel establishes a connection from the RMAN client to a target or auxiliary database instance by starting a server session on the instance.The channel reads data into memory, processes it, and writes it to the output device.
When you take a database backup using RMAN, you need to connect to the target database using RMAN Client.The RMAN client can use Oracle Net to connect to a target database, so it can be located on any host that is connected to the target host through Oracle Net. For backup you need to allocate explicit or implicit channel to the target database. An RMAN channel represents one stream of data to a device, and corresponds to one database server session. This session dynamically collect information of the files from the target database control file before taking the backup or while restoring.
  For example If you give ' Backup database ' from RMAN, it will first get all the datafiles information from the controlfile. Then it will divide all the datafiles among the allocated channels. ( roughly equal size of work as per the datafile size ). Then it takes the backup in 2 steps. In the first step the channel will read all the Blocks of the entire datafile to find out all the formatted blocks to backup. Note : RMAN do not take backup of the un formatted blocks. In the second step it take backup of the formatted blocks. This is the best advantage of using RMAN as it only take backup of the required blocks. Lets say in a datafile of 100 MB size, there may be only 10 MB of use full data and rest 90 MB is free then RMAN will only take backup of those 10 MB.
Q.What O/S and  oracle user privilege required to use RMAN ? 
A.RMAN always connect to the target or auxiliary database using the SYSDBA privilege. In fact the SYSDBA keywords are implied and cannot be explicitly specified. Its connections to a database are specified and authenticated in the same way as SQL*Plus connections to a database.
The O/S user should be part of the DBA group . For remote connection it needs the password file Authentication.Target database should have the initialization parameter REMOTE_LOGIN_PASSWORDFILE set to EXCLUSIVE or SHARED.
Q.RMAN terminology  :
A target database : An Oracle database to which RMAN is connected with the TARGET keyword. A target database is a database on which RMAN is performing backup and recovery operations. RMAN always maintains metadata about its operations on a database in the control file of the database.
A recovery Catalog : A separate database schema used to record RMAN activity against one or more target databases. A recovery catalog preserves RMAN repository metadata if the control file is lost, making it much easier to restore and recover following the loss of the control file. The database may overwrite older records in the control file, but RMAN maintains records forever in the catalog unless deleted by the user.
Backup sets : RMAN can store backup data in a logical structure called a backup set, which is the smallest unit of an RMAN backup. One backup set contains one or more datafiles a section of datafile or archivelogs.
Backup Piece : A backup set contains one or more binary files in an RMAN-specific format. This file is known as a backup piece. Each backup piece is a single output file. The size of a backup piece can be restricted; if the size is not restricted, the backup set will comprise one backup piece. Backup piece size should be restricted to no larger than the maximum file size that your filesystem will support.
Image copies : An image copy is a copy of a single file (datafile, archivelog, or controlfile). It is very similar to an O/S copy of the file. It is not a backupset or a backup piece. No compression is performed.
Snapshot Controlfile : When RMAN needs to resynchronize from a read-consistent version of the control file, it creates a temporary snapshot control file. The default name for the snapshot control file is port-specific.
Database Incarnation : Whenever you perform incomplete recovery or perform recovery using a backup control file, you must reset the online redo logs when you open the database. The new version of the reset database is called a new incarnation. The reset database command directs RMAN to create a new database incarnation record in the recovery catalog. This new incarnation record indicates the current incarnation.
RMAN Configuration :
What is RMAN Configuration and how to Configure it ?
How to check RMAN Configuration ?
How to Reset the default Configuration ?

Q.What is RMAN Configuration and how to Configure it ?
A.The RMAN backup and recovery environment is preconfigured for each target database. The configuration is persistent and applies to all subsequent operations on this target database, even if you exit and restart RMAN. RMAN configured settings can specify backup devices, configure a connection to a backup device , policies affecting backup strategy, encryption algorithm, snap shot controlfile loaion  and others.
By default there are few default configuration are set when you login to RMAN. You can customize them as per your requirement. Any time you can check the current setting by using the "Show all " command. CONFIGURE command is used to create persistent settings in the RMAN environment, which apply to all subsequent operations, even if you exit and restart RMAN.For details of the Configuration kindly refer Note <<305565.1>>

Q.How to check RMAN Configuration ?
RMAN>Show all;
Q.How to Reset to default Configuration ?
A.To reset the default configuration setting use
Connect to the target database from sqlplus and run
SQL> connect <sys/passwd as sysdba>@target_database;  
SQL> execute dbms_backup_restore.resetConfig; RMAN Catalog Database
What is Catalog database and How to Configure it ?
How Many catalog database I can have ?
Is this mandetory to use catalog database ? 
What is the advantage of catalog database ?
What is the difference between catalog database and catalog schema ?
Catalog database compatibility matrix with the target database ?
What happen if catalog database lost ?

Q. What is Catalog database and How to Configure it ?
A. This is a separate database which contains catalog schema. You can use the same target database as the catalog database but its not at all recommended. For more details on Recovery catalog kindly refer the Note 452529.1 : Recovery catalog for RMAN backup
Q. How Many catalog database I can have ?
A.  You can have multiple catalog database for the same target database . But at a time you can connect to only 1 catalog database via RMAN. Its not recommended to have multiple catalog database.
Q. Is this mandatory to use catalog database ?
A.  No ! its a optional one.
Q. What is the advantage of catalog database ?
A.  Catalog database is a secondary storage of backup metadata. Its very useful in case you lost the current controlfile, as all the backup information are there in the catalog schema. Secondly from contolfile the older backup information are aged out depending upon the control_file_record_keep_time. RMAN catalog database mainten the history of data. Kindly refer the note <<397269.1>> for more details on relation between  retention policy and control_File_record_keep_time.
Q. What is the difference between catalog database & catalog schema ?
A.  Catalog database is like any other database which contains the RMAN catalog user's schema.
Q. Catalog database compatibility matrix with the target database ?
A.  refer Note 73431.1 : RMAN Compatibility Matrix
Q. What happen if catalog database lost ?
 A.  Since catalog database is a option one there is no direct effect  of loss of catalog  database. Create  a new catalog database and register the target database with the newly createdcatalog one. All the backup information from the target database current controlfile will be updated to the catalog schema. If any backup information which is aged out from the target database then you need to manually catalog those backup pieces.
RMAN backup :
What are the database files that RMAN can backup ? 
What are the database files that RMAN can not backup ? 
Can I have archivelogs and datafile backup in a single backupset ?
Can I have datafiles and contolfile backup in a single backup set?
Can I regulate the size of backup piece and backupset ?
What is the difference between backup set backup and Image copy backup ?
What is RMAN consistent backup and Inconsistent backup ?
Can I take RMAN backup when the database is Down ? 
Do I need to place the database in begin backup mode while taking RMAN inconsistent backup ? 
Can I compress RMAN backups ?
Can I encript RMAN backup ?

Q. What are the database file's that RMAN can backup ?
A. RMAN can backup  Controlfile , Datafiles , Archive logs , standby database controfile, Spfile
Q. What are the  database file's that RMAN can not backup ? 
A.  RMAN can not take backup of the pfile, Redo logs , network configuration files, password files, external  tables and the contents of the Oracle home files
Q. Can I have archivelogs and datafile backup in a single backupset ?
A.  No . we can not put datafiles and archive logs in the same backupset.
Q. Can I have datafiles and contolfile backup in a single backup set ?
 A. Yes . If the controlfile autobackup is not ON then RMAN takes backup of controlfile along with the datafile 1, whenever you take backup of the database or System tablespace. Kindly refer ( *** create a note for controfile auto backup )
Q. Can I regulate the size of backup piece and backupset ?
A. Yes ! You can set max size of the backupset as well as the backup piece. By default one RMAN channel  creates a single backupset with one backup piece in it. You can use the MAXPIECESIZE channel parameter to set limits on the size of backup pieces. You can also use the MAXSETSIZE parameter on the BACKUP and CONFIGURE commands to set a 
limit for the size of backup sets.
Q. What is the difference between backup set backup and Image copy backup ?
A :  A backup set is an RMAN-specific proprietary format, whereas an image copy is a bit-for-bit copy of a file. By default,RMAN creates backup sets
Q. What is RMAN consistent backup and inconsistent backup ?
A. A consistent backup occurs when the database is in a consistent state. That means backup of the database taken after a shutdown immediate , shutdown normal or shutdown transactional. If the database is shutdown with  abort option then its not a consistent backup. 
A backup when when the database is Up and running is called an inconsistent backup. When a database is restored from an inconsistent backup, Oracle must perform media recovery before the database can be
opened, applying any pending changes from the redo logs. You can not take inconsistent backup when the database is in NoArchivelog mode.

Q. Can I take RMAN backup when the database is Down ?
A. No ! You can take RMAN backup only when the target database is Open or in Mount stage. Its because RMAN keep the backup metadata in controfile . Only in open or mount mode controlfile is accessible.
Q. Do I need to place the database in begin backup mode while taking RMAN inconsistent backup ?
A. RMAN does not require extra logging or backup mode because it knows the format of data blocks. RMAN is guaranteed not to back up fractured blocks.No extra redo is generated during RMAN backup.
Q. Can I compress RMAN backups ?
A. RMAN supports binary compression of backup sets. The supported algorithms are BZIP2 (default) and ZLIB.  Kindly refer Note 427581.1 for more details about different type of compressions. Its not recommend to compress  the RMAN backup using any other OS or third party utility.
Note : RMAN compressed backup with BZIP2 provides great compression but is CPU intensive. Using ZLIB compression requires the Oracle Database 11g Advanced Compression Option and is only supported with an 11g database. The feature is not backward compatible with 10g databases.
Q. Can I encrypt RMAN backup ?
A. RMAN supports backup encryption for backup sets. You can use wallet-based transparent encryption, password-based encryption, or both. You can use the CONFIGURE ENCRYPTION command to configure persistent transparent encryption. Use the SET ENCRYPTION, command at the RMAN session level to specify password-based encryption.
8.13 How to specify backup destination ?

9. Can RMAN take backup to Tape ?
Yes ! you can use RMAN for the tape backup. But RMAN can not able to write directly to tape. You need to have third party Media Management Software installed. Oracle has published an API specification which Media Management Vendor's who are members of Oracle's Backup Solutions Partner program have access to. Media Management Vendors (MMVs) then write an interface library which the Oracle server uses to write and read to 
and from tape.
9.1 Where can I get the list of supported Third party Media Management Software for tape backup ?
RMAN should not be used with that Media Manager until the MMV has certified that their software works with 
RMan. Either contact your Media Manager, or check the RMan home page for updates on which MMVs have certified their products on which platforms:
http://www.oracle.com/technology/deploy/availability/htdocs/bsp.htm
Starting from oracle 10g R2 oracle has its Own Media management software for the database backup to tape called OSB.
9.2 How RMAN Interact with Media manager ?
Before performing backup or restore to a media manager, you must allocate one or more channels or configure default channels for use with the media manager to handle the communication with the media manager. RMAN does not issue specific commands to load, label, or unload tapes. When backing up, RMAN gives the media manager a stream of bytes and associates a unique name with this stream. When RMAN needs to restore the backup, it asks the media manager to retrieve the byte stream. All details of how and where that stream is stored are handled entirely by the media manager.
9.3 What is Proxy copy backup to tape ?
Proxy copy is functionality, supported by few media manager  in which they handle the entire data movement between datafiles and the backup devices. Such products may use technologies such as high-speed connections between storage and media subsystems to reduce load on the primary database server. RMAN provides a list of files requiring backup or restore to the media manager, which in turn makes all decisions regarding how and when to move the data.
9.4 What is Oracle Secure backup ?
Oracle Secure Backup is a media manager provided by oracle that provides reliable and secure data protection through file system backup to tape. All major tape drives and tape libraries in SAN, Gigabit Ethernet, and SCSI environments are supported.