Tuesday, April 15, 2008

Cron backup on Solaris

#!/bin/sh

ORACLE_BASE=/opt/app/oracle
export ORACLE_BASE

ORACLE_HOME=$ORACLE_BASE/product/10.2.0/db_1
export ORACLE_HOME

ORACLE_SID=sunrise
export ORACLE_SID

LD_LIBRARY_PATH_64=$ORACLE_HOME/lib:$LD_LIBRARY_PATH_64
export LD_LIBRARY_PATH_64

LD_LIBRARY_PATH=$ORACLE_HOME/lib32:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH

PATH=$ORACLE_HOME/bin:$PATH
export PATH

NLS_LANG=American_America.AL32UTF8
export NLS_LANG

NLS_DATE_FORMAT='DD-Mon-YYYY HH24:MI:SS'
export NLS_DATE_FORMAT

rman target sys/pwd @/home/oracle/crons/backupinc0.rmn log /home/oracle/crons/backupinc0.log

Thursday, April 10, 2008

Move and Rename DB

1. Backup the control file of DB to trace.
alter database backup controlfile to trace

This will produce the following sql in user_dump_dest

STARTUP NOMOUNT
CREATE CONTROLFILE REUSE DATABASE "OLDDB" NORESETLOGS

2. Shutdown the DB and move the datafiles to the new location. DataFiles can be renamed but control file trace must be edited to reflect the changes.
3. Change
CREATE CONTROLFILE REUSE DATABASE "OLDDB" NORESETLOGS
to
CREATE CONTROLFILE SET DATABASE "NEWDB" NORESETLOGS

4. Remove recover database and open database statments from the control file trace.
5. If any of the *dump directories are missing create them.
6. create a pfile to start the new DB
7. Start the new DB with
startup nomount;
@control_file_trace.sql


Tuesday, April 8, 2008

Auto Start Oracle DB on Solaris

create a similar script in /etc/init.d


#!/bin/sh

user=oracle
SU=/bin/su
ORACLE_HOME=/opt/app/oracle/product/10.2.0/db_1
export ORACLE_HOME

case "$1" in
start)
$SU $user $ORACLE_HOME/bin/dbstart
;;
restart)
$SU $user $ORACLE_HOME/bin/dbshut
$SU $user $ORACLE_HOME/bin/dbstart
;;
stop)
$SU $user $ORACLE_HOME/bin/dbshut
;;
*)
echo "Usage : oracle start restart stop"
;;
esac

Edit $ORACLE_HOME/bin/dbshut and dbstart, pay attention to where oratab is. In solaris this is in /var/opt/oracle/oratab

Create softlink on rc0 rc2 and rc3 (on solaris 10)

ln -s /etc/init.d/oracle /etc/rc0.d/K01oracle

ln -s /etc/init.d/oracle /etc/rc2.d/K01oracle
ln -s /etc/init.d/oracle /etc/rc2.d/S99oracle

ln -s /etc/init.d/oracle /etc/rc3.d/K01oracle
ln -s /etc/init.d/oracle /etc/rc3.d/S99oracle


Monday, April 7, 2008

Locking User Accounts

Locking Linux user account
passwd -l {user-name}

-l : This option disables an account by changing the password to a value, which matches no possible encrypted value.

For unlocking the account use:
passwd -u {user-name}

Locking FreeBSD user account
pw lock {username}

unlocking
pw unlock {username}

Locking Solaris UNIX user account
passwd -l {username}

Locking HP-UX user account
passwd -l {username}

For unlocking the HP-UX account you need to edit /etc/passwd file using text editor
vi /etc/passwd

Finding out accounts without password.

Linux display password status
passwd -S {user-name}

Where,
-S : Display account status information. The status information consists of total seven fields. The second field indicates the status of password using following format:
L : if the user account is locked (L)
NP : Account has no password (NP)
P: Account has a usable password (P)

Solaris UNIX display password status
passwd -s {user-name}Where,
-s : Display account status information using following format:
PS : Account has a usable password
LK : User account is locked
NP : Account has no password


Friday, April 4, 2008

Solaris 10 Kernel Tuning for Oracle 10g

These steps are in addition to or unique to Solaris when compared with Linux kernel tuning procedure.

Read Metalink note 317257.1 : Running Oracle Database in Solaris 10 Containers Best Practices

Read document for bug 5237047 INCORRECT SYSTEM REQUIREMENTS FOR SOLARIS 10 on metalink. This document shows the incorrect information given in the installation guide (until it is updated with correct information in future).

If RAC is being installed them read metalink note 367442.1 for the error 'srvctl' Unable to Start Large SGA Instance ORA-27102

1. Seperate 64 bit LD_LIBRARY_PATH
export LD_LIBRARY_PATH_64=$ORACLE_HOME/lib

2. SUNWsprox package doesn't exist for Solaris 10 so it is not required.

3. add a project for oracle user
projadd -c "Oracle" user.oracle

Append the following line to the "/etc/user_attr" file.
oracle::::project=oracle

Add the following to /etc/system with suitable values.
set noexec_user_stack=1
set semsys:seminfo_semmns=1024
set semsys:seminfo_semvmx=32767

To change the kernel dynamically
prctl -n project.max-shm-memory -v 4gb -r -i project user.oracle

To make these values persist across reboots
projmod -s -K "project.max-shm-memory=(priv,4gb,deny)" user.oracle
this will add the entry to /etc/project.

Other parameters to consider
process.max-sem-nsems
process.max-sem-ops
project.max-sem-ids
project.max-shm-ids


Use projmod -rK to remove an entry.
projmod -rK "process.max-sem-nsems=(priv,256,deny)" user.oracle

To see the current value for oracle user login as oracle and type
prctl $$

To increase the UDP buffer limits add the following script to /etc/init.d

cd /etc/init.d
vi udp_ora

#!/sbin/sh
case "$1" in
'start')
ndd -set /dev/udp udp_xmit_hiwat 65536
ndd -set /dev/udp udp_recv_hiwat 65536
;;
.
'state')
ndd /dev/udp udp_xmit_hiwat
ndd /dev/udp udp_recv_hiwat
;;
.
*
echo "Usage: $0 { start state }"
exit 1
;;
esac

Then make a soft link to run the script
ln -s /etc/init.d/udp_rac /etc/rc3.d/S86udp_ora

Thursday, April 3, 2008

Solaris Tips

To find out the architecture

[root@solaris / ]# /usr/bin/isainfo -kv
64-bit amd64 kernel modules

Verifying if a patch is applied or not

/usr/sbin/patchadd -p grep patch_number(without version number)

Top like tool prstat

By default, prstat lists the processes running on a system, sorted by CPU
utilization. Number of LWPs per process appears following a "/" after the process name in the last column.

The prststat -L output shows each LWP for a multi-threaded process.

The prstat -m output includes the percentage of time a process spends in system traps, text page faults, data page faults, waiting for user locks, and waiting for CPU time.

The prstat -t output lists the CPU and memory resource usage summary for each user.

Mozilla in Solaris

/usr/sfw/bin/mozilla


Solaris network related files

/etc/resolv.conf DNS entries

/etc/hostname.interface Contains the host name or IP address associated with the network interface

/etc/nodename Host name of the local machine

/etc/defaultdomain Full qualified domain name of the administrative domain to which the local host's network belongs

/etc/defaultrouter Contain an entry for each router directly connected to the network

/etc/hosts Contains the host names and IP addresses of the primary network interface, other network interfaces attached to the machine, and any other network addresses that the machine must know about.

/etc/inet/netmasks Need to edit the netmasks database as part of network configuration only if subnetting is setup on the network.

/etc/nsswitch.conf Defines the search order of the network databases


Administer Services

svcadm command service name
svcadm enable ftp

List service status

svcs options service name
svcs -xv ftp


Shutdown the server

shutdown -y -i5 -g0