Saturday, January 1, 2011

How to take a RMAN backup

first of all you need to switch the log files which are not currently switched. so first login to sqlplus as sys user and issue below commands:

>sqplplus / as sysdba
sql> alter system switch logfile;

Now login to rman using below command and issue below commands:

> rman target sys/sysadmin or >rman target=/

rman>run {
crosscheck archivelog all;
crosscheck backupset;
backup as copy current controlfile format 'control_%s.bak';
backup spfile;
backup as compressed backupset database;
backup as compressed backupset archivelog all;


DELETE NOPROMPT ARCHIVELOG ALL COMPLETED BEFORE 'sysdate -1';
DELETE NOPROMPT OBSOLETE REDUNDANCY = 1;
}exit;

How to automate the process for windows.

create a windows batch file named mysysbackup.bat
insert below commands and save file

sqlplus /nolog @c:\sqlpluscom.sql
rman target=/ cmdfile="c:\backupdb.sql"

now create sqlpluscom.sql and backupdb.sql files in c:\ drive

sqlpluscom.sql

connect / as sysdba
alter system switch logfile;
exit;

backupdb.sql

run {
crosscheck archivelog all;
crosscheck backupset;
backup as copy current controlfile format 'control_%s.bak';
backup spfile;
backup as compressed backupset database;
backup as compressed backupset archivelog all;


DELETE NOPROMPT ARCHIVELOG ALL COMPLETED BEFORE 'sysdate -1';
DELETE NOPROMPT OBSOLETE REDUNDANCY = 1;
}
exit;

now shedule the batch as a windows schedule task...

Oracle Apex installation on Windows

Before apex installation you should have oracle installed in your machine.(10g above)

download the Apex and unzip it in drive C:\. Then you will get a folder called apex. (C:\apex)


now set path to the apex folder

Then type below

set ORACLE_HOME=c:\oraclexe\app\oracle\product\10.2.0\server
set ORACLE_SID=XE
set PATH=%ORACLE_HOME%\bin;%PATH%


now
loging to sqlplus as sysdba
>sqlplus / as sysdba

now type below sql command
s

SQL>@apexins SYSAUX SYSAUX TEMP /i/


after installation log into sqlplus as sysdba
issue below

SQL>@apxldimg c:\ in my case it was C:\ not C:\apex XXXX


exit and relogin as sysdba and issue below to change password

SQL>@apxxepwd.sql


username ADMIN
password XXXXXX


######
This is the end of installation #######

run below to access application from client machine

login as sysdba

sql> EXEC DBMS_XDB.SETLISTENERLOCALACCESS(FALSE);

Oracle Database 11g Release 2 (11.2) Installation On Enterprise Linux 5.0

Oracle Database 11g Release 2 (11.2) Installation On Enterprise Linux 5.0

OS configuration


Login as root and make a directory in root as u01
[charith@localhost ~]$ su - root
Password:
[root@localhost ~]# mkdir /u01

Copy below file into that folder and unzip
· linux_11gR1_database.zip

Check the copied file

[root@localhost ~]# cd /u01
[root@localhost u01]# ls
linux_11gR1_database_1013.zip


Unzip it and check the u01 folder
[root@localhost u01]# unzip linux_11gR1_database_1013.zip
[root@localhost u01]# ls
database linux_11gR1_database_1013.zip
You should now have a single directory called "database" containing installation files.

Configure the host file
Get the ip address first using below command
[root@localhost /]# ifconfig

eth0 Link encap:Ethernet HWaddr 00:0C:29:85:A3:07
inet addr:192.168.174.128 Bcast:192.168.174.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fe85:a307/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:33 errors:0 dropped:0 overruns:0 frame:0
TX packets:44 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:4150 (4.0 KiB) TX bytes:8878 (8.6 KiB)
Interrupt:19 Base address:0x2000

lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:1506 errors:0 dropped:0 overruns:0 frame:0
TX packets:1506 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:75460 (73.6 KiB) TX bytes:75460 (73.6 KiB)



The /etc/hosts file must contain a fully qualified name for the server
[root@localhost /]# vim /etc/hosts
Append the below ip address as shown in the figure
192.168.100.16 localhost.localdomain localhost

ex: 192.168.10.21 racn1.hnbassurance.com racn1
Then save and exit (:wq)

How to check kernel parameters


Set kernal parameters
The following lines should be appended to the "/etc/sysctl.conf" file.
[root@localhost ~]# vim /etc/sysctl.conf

fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 2097152
kernel.shmmax = 536870912
kernel.shmmni = 4096
# semaphores: semmsl, semmns, semopm, semmni
kernel.sem = 250 32000 100 128
net.ipv4.ip_local_port_range = 9000 65500
net.core.rmem_default=4194304
net.core.rmem_max=4194304
net.core.wmem_default=262144
net.core.wmem_max=1048586

Then type below command to effect the change
[root@localhost ~]# /sbin/sysctl –p


Add the following lines to the /etc/security/limits.conf file
[root@localhost /]# vim /etc/security/limits.conf

oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536

Add the following line to the /etc/pam.d/login file, if it does not already exist
[root@localhost /]# vim /etc/pam.d/login
session required pam_limits.so

Disable secure linux by editing the /etc/selinux/config file, making sure the SELINUX flag is set as follows
SELINUX=disabled

How to install required packages using yum and rpm

Setup

Install the following packages
From Linux RHEL 5 DVD
Should already be installed if you selected the recommended package groups.

# From Enterprise Linux 5 DVD
cd /media/cdrom/Server
rpm -Uvh binutils-2.*
rpm -Uvh compat-libstdc++-33*
rpm -Uvh compat-libstdc++-33*.i386.rpm
rpm -Uvh elfutils-libelf*
rpm -Uvh gcc-4.*
rpm -Uvh gcc-c++-4.*
rpm -Uvh glibc-2.*
rpm -Uvh glibc-common-2.*
rpm -Uvh glibc-devel-2.*
rpm -Uvh glibc-headers-2.*
rpm -Uvh ksh*
rpm -Uvh libaio-0.*
rpm -Uvh libaio-devel-0.*
rpm -Uvh libgomp-4.*
rpm -Uvh libgcc-4.*
rpm -Uvh libstdc++-4.*
rpm -Uvh libstdc++-devel-4.*
rpm -Uvh make-3.*
rpm -Uvh sysstat-7.*
rpm -Uvh unixODBC-2.*
rpm -Uvh unixODBC-devel-2.*
cd /
eject



If Not available on LINUX DVD, but available from standard yum repository.
Ex:-
yum install libaio libaio-devel
yum install unixODBC-devel
yum install sysstat
yum install compat-libstdc++




Create the new groups and users
groupadd oinstall
groupadd dba
groupadd oper
groupadd asmadmin

useradd -g oinstall -G dba,oper,asmadmin oracle
passwd oracle


Login as root user and issue below commands
[root@localhost /]# groupadd dba
[root@localhost /]# groupadd oinstall
[root@localhost /]# useradd -g oinstall -G dba oracle
[root@localhost /]# passwd oracle

Create the directories in which the Oracle software will be installed
mkdir -p /u01/app/oracle/product/11.2.0/db_1
chown -R oracle:oinstall /u01
chmod -R 775 /u01

Login as root and issue the following command to turn on the graphics
[root@localhost /]# xhost +

Then Create oracle home
[root@localhost /]# mkdir -p /u01/app/oracle/product/11.2.0/db_1
[root@localhost /]# chown -R oracle:oinstall /u01
[root@localhost /]# chmod -R 775 /u01
Edit the /etc/redhat-release file replacing the current release information
type below
redhat release 4

Login as the oracle user and add the following lines at the end of the .bash_profile file

[oracle@localhost ~]$ vim .bash_profile

# Oracle Settings
TMP=/tmp; export TMP
TMPDIR=$TMP; export TMPDIR

ORACLE_HOSTNAME=oel5-11gr2.localdomain; export ORACLE_HOSTNAME
ORACLE_UNQNAME=DB11G; export ORACLE_UNQNAME
ORACLE_BASE=/u01/app/oracle; export ORACLE_BASE
ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1; export ORACLE_HOME
ORACLE_SID=DB11G; export ORACLE_SID
ORACLE_TERM=xterm; export ORACLE_TERM
PATH=/usr/sbin:$PATH; export PATH
PATH=$ORACLE_HOME/bin:$PATH; export PATH

LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib; export LD_LIBRARY_PATH
CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib; export CLASSPATH

if [ $USER = "oracle" ]; then
if [ $SHELL = "/bin/ksh" ]; then
ulimit -p 16384
ulimit -n 65536
else
ulimit -u 16384 -n 65536
fi
fi


Exit from oracle and re login to effect the change

[oracle@localhost ~]$ exit
logout
[root@localhost /]# su - oracle

Then follow the below steps to run the installer
[root@localhost /]# su - oracle
[oracle@localhost ~]$ cd /u01/database
[oracle@localhost database]$ ls
doc install README runInstaller stage welcome.html
[oracle@localhost database]$ ./runInstaller

for more infomation
http://www.oracle-base.com/articles/11g/OracleDB11gR2InstallationOnEnterpriseLinux5.php


How to increase swap file

Determine the size of the new swap file and multiple by 1024 to determine the block size. For example, the block size of a 64 MB swap file is 65536.

At a shell prompt as root, type the following command with count being equal to the desired block size
dd if=/dev/zero of=/swapfile bs=1024 count=65536
Setup the swap file with the command
mkswap /swapfile
To enable the swap file immediately but not automatically at boot time
swapon /swapfile
To enable it at boot time, edit /etc/fstab to include
/swapfile swap swap defaults 0 0
The next time the system boots, it will enable the new swap file.
After adding the new swap file and enabling it, make sure it is enabled by viewing the output of the command
cat /proc/swaps or free.