Thursday, December 29, 2011

debug opatch xml curroption

##
##debug opatch xml curroption
##

#export OPATCH_DEBUG=TRUE

oak 11GDB ora11g $ opatch lsinventory
Invoking OPatch 11.1.0.6.2

Oracle Interim Patch Installer version 11.1.0.6.2
Copyright (c) 2007, Oracle Corporation. All rights reserved.


Oracle Home : /u01/app/ora11g/product/11.1.0/db_1
Central Inventory : /u01/app/oraInventory
from : /var/opt/oracle/oraInst.loc
OPatch version : 11.1.0.6.2
OUI version : 11.1.0.7.0
OUI location : /u01/app/ora11g/product/11.1.0/db_1/oui
Log file location : /u01/app/ora11g/product/11.1.0/db_1/cfgtoollogs/opatch/opatch2011-12-29_14-12-22PM.log

org.xml.sax.SAXParseException: : XML-20108: (Fatal Error) Start of root element expected.
at oracle.xml.parser.v2.XMLError.flushErrorHandler(XMLError.java:422)
at oracle.xml.parser.v2.XMLError.flushErrors1(XMLError.java:287)
at oracle.xml.parser.v2.NonValidatingParser.parseRootElement(NonValidatingParser.java:345)

remove oracle homes from /u01/app/oraInventory/ContentsXML/inventory.xml to find out which home cause the issue.

#One of the homes /u01/app/ora11g/product/11.1.0/db_1/inventory/ContentsXML/oraclehomeproperties.xml files corrupted

#recover the file from backup if you have one. If not, run oinstaller to fix it.


Friday, December 23, 2011

11R2 grid infrastructure gotcha

Version: Oracle Clusterware active version on the cluster is [11.2.0.1.0]

Issues with 11R2 itself
  1. ASM diskgroup shows offline after reboot.
SQL> ALTER DISKGROUP ALL ENABLE VOLUME ALL /* asm agent */
SUCCESS: ALTER DISKGROUP ALL ENABLE VOLUME ALL /* asm agent */
WARNING: failed to online diskgroup resource ora.DATADG.dg (unable to communicate with CRSD/OHASD)
WARNING: failed to online diskgroup resource ora.RECOVERYDG.dg (unable to communicate with CRSD/OHASD)


#check status
$GRID_HOME/bin/srvctl status diskgroup -g diskgroupname -a
#To start or sync diskgroup resource:
$GRID_HOME/bin/srvctl start diskgroup -g diskgroupname

upgrade gotchas
  1. try to use same user as old version RAC, do NOT try use different user. The upgrade won't success, and have to do a lot troubleshooting to bring RAC to 11R2.
  2. If you did use different users, the following are things you need look into and change.
    a. rootUpgrade.sh will fail, then you have to deconfigure it ($GRID_HOME/crs/install/rootcrs.pl -verbose -deconfig -force)
    b. restore all files belong to old RAC (Restore original /etc/init.d/initcss initcrs

    Restore /var/opt/oracle/

    Restore old version crshome

    c. run rootUpgrade.sh again
    d. this will upgrade your RAC to 11R2, but there are more things need be fixed.
    e. fix ASM by remove asm (srvctl remove asm) you need remove all database and related service first. add asm back(srvctl add asm), then add database and related service back. REF:
    ASMCA Fails When Upgrading to 11.2 due to Different ASM/CRS User or Non-default ASM Name [ID 1113073.1]

    f.fix nodeapps (mainly because the ownership not right) srvctl stat res -p > res.log
    ## workaround for nodeapps
cd $grid_home
find . -name log | xargs chmod 775
chmod g+w /u01/app/11.2.0/grid/opmn/logs/
chmod g+w /u01/app/11.2.0/grid/eons/init
chmod -R g+w /u01/app/11.2.0/grid/opmn/conf/
chmod g+w /u01/app/11.2.0/grid/network/admin
chmod g+w /u01/app/11.2.0/grid/network/admin/*
chmod -R g+w /u01/app/11.2.0/grid/ons/

h. fix TNS_ADMIN create a softlink from $GRID_HOME/network/admin to /var/opt/oracle

Friday, December 16, 2011

tar command to copy files to avoid system cache issue

This is the tar command used to copy directories:

cd fromdir; tar cf - .| (cd todir; tar xvf -)

Tuesday, December 6, 2011

showsystem in solaris

#!/bin/bash

banner=`uname -a`
kernelid=`uname -v`
machinemodel=`prtdiag -v | head -1 | sed 's/System Configuration: Sun Microsystems //'`
raminfo=`prtdiag -v | grep "Memory size"`

echo $banner
echo
echo "Kernel:$kernelid "
echo "Model:$machinemodel "
echo $raminfo
echo


nproc=`(/usr/bin/kstat -m cpu_info | grep chip_id | sort -u | wc -l | tr -d ' ')`
vproc=`(/usr/bin/kstat -m cpu_info | grep 'module: cpu_info' | sort -u | wc -l | tr -d ' ')`
#ncore=`(/usr/bin/kstat -m cpu_info | grep core_id | sort -u | wc -l | tr -d ' ')`
ncore=`(/usr/bin/kstat -m cpu_info | grep core_id | awk '{ print $2 }'| sort -u | wc -l | tr -d ' ')` #thanks to James Ervin#
speedinmhz=`(/usr/bin/kstat -m cpu_info | grep clock_MHz | awk '{ print $2 }' | sort -u)`
speedinghz=`echo "scale=2; $speedinmhz/1000" | bc`

nstrandspercore=$(($vproc/$ncore))
ncoresperproc=$(($ncore/$nproc))

echo "Total number of physical processors: $nproc"
echo "Number of virtual processors: $vproc"
echo "Total number of cores: $ncore"
echo "Number of cores per physical processor: $ncoresperproc"
echo "Number of hardware threads (strands or vCPUs) per core: $nstrandspercore"
echo "Processor speed: $speedinmhz MHz ($speedinghz GHz)"

# now derive the vcpu-to-core mapping based on above information #

echo -e "\n** Socket-Core-vCPU mapping **"
vpid=0

for ((i = 1; i <= ${nproc}; ++i ))
do
echo -e "\nPhysical Processor $i:"

for ((j = 1; j <= ${ncoresperproc}; ++j ))
do
echo -e "\tCore $j:"
echo -e "\t\tvCPU ids: $vpid-$(($vpid+$nstrandspercore-1))"
vpid=$(($vpid+$nstrandspercore))
done
done