Wednesday, February 9, 2011

rsync command primer

rsync is used to perform the backup operation in UNIX / Linux.
rsync utility is used to synchronize the files and directories from one location to another in an effective way. Backup location could be on local server or on remote server.

Important features of rsync

  • Speed: First time, rsync replicates the whole content between the source and destination directories. Next time, rsync transfers only the changed blocks or bytes to the destination location, which makes the transfer really fast.
  • Security: rsync allows encryption of data using ssh protocol during transfer.
  • Less Bandwidth: rsync uses compression and decompression of data block by block at the sending and receiving end respectively. So the bandwidth used by rsync will be always less compared to other file transfer protocols.
  • Privileges: No special privileges are required to install and execute rsync

Syntax

$ rsync options source destination 
 
$ rsync -zvr /var/opt/installation/inventory/ /root/temp  
In the above rsync example:
  • -z is to enable compression
  • -v verbose
  • -r indicates recursive

Example 2. Preserve timestamps during Sync using rsync -a

$ rsync -azv /var/opt/installation/inventory/ /root/temp/ 

Example 3. Synchronize Only One File

$ rsync -v /var/lib/rpm/Pubkeys /root/temp/ 

Example 4. Synchronize Files From Local to Remote

$ rsync -avz /root/temp/ thegeekstuff@192.168.200.10:/home/thegeekstuff/temp/ 
 
$ rsync -avz thegeekstuff@192.168.200.10:/var/lib/rpm /root/temp 

 Example 7. Do Not Overwrite the Modified Files at the Destination

In a typical sync situation, if a file is modified at the destination, we might not want to overwrite the file with the old file from the source. Use rsync -u option to do exactly that.
 
$rsync -avzu thegeekstuff@192.168.200.10:/var/lib/rpm /root/temp 
 

Example 8. Synchronize only the Directory Tree Structure (not the files)

Use rsync -d option to synchronize only directory tree from source to the destination. The below example, synchronize only directory tree in recursive manner, not the files in the directories.
 
rsync -v -d thegeekstuff@192.168.200.10:/var/lib/ .

 

dd command primer

Example 1. Backup Entire Harddisk

# dd if=/dev/sda of=/dev/sdb
 
# dd if=/dev/sda of=/dev/sdb conv=noerror,sync
  • “if” represents inputfile, and “of” represents output file. So the exact copy of /dev/sda will be available in /dev/sdb.
  • If there are any errors, the above command will fail. If you give the parameter “conv=noerror” then it will continue to copy if there are read errors.
  • Input file and output file should be mentioned very carefully, if you mention source device in the target and vice versa, you might loss all your data.

Example 2. Create an Image of a Hard Disk

# dd if=/dev/hda of=~/hdadisk.img
 

Example 3. Restore using Hard Disk Image


# dd if=hdadisk.img of=/dev/hdb
 

 Example 6. CDROM Backup

dd if=/dev/cdrom of=tgsservice.iso bs=2048
 

 

raw device verify

Raw devices for OCR(or any voting, ASM etc), which are shared across RAC cluster nodes.  To confirm if they are same device across all nodes aka all nodes are pointing to same/similar raw device

Check OCR raw devices
./ocrcheck

dd if=/dev/emcpowera1 bs=1024000 count=100 |od -c > /tmp/dd_node1.txt

Run similar commands on all nodes on RAC cluster.

File Size and content should match on all nodes for /tmp/dd_node1.txt.

ASM Disk commands

Status
/etc/init.d/oracleasm status

To list disks
/etc/init.d/oracleasm listdisks

Check Specific Disk
/etc/init.d/oracleasm querydisk -d ASM1D0022

ASM  configuration  file
/etc/sysconfig/oracleasm

Find physical disk associated with ASM Disk

#/etc/init.d/oracleasm querydisk -d ASM1D0001
Disk "ASM1D0001" is a valid ASM disk on device [120, 129]

#ls -ltr /dev |grep 129



 brw-r-----  1 root   disk  70,   129 Jan 30 17:31 sdda1
brw-r-----  1 root   disk  67,   129 Jan 30 17:31 sdbe1
brw-r-----  1 root   disk  66,   129 Jan 30 17:31 sdao1
brw-r-----  1 root   disk   8,   129 Jan 30 17:32 sdi1
brw-r-----  1 root   disk  68,   129 Jan 30 17:32 sdbu1
brw-r-----  1 root   disk  65,   129 Jan 30 17:32 sdy1
brw-r-----  1 root   disk  69,   129 Jan 30 17:32 sdck1
brw-rw----  1 oracle dba  120,   129 Jan 30 17:32 emcpoweri1
crw-------  1 vcsa   tty    7,   129 Jan 30 17:34 vcsa1

Display EMC power path info

#sudo ./powermt display dev=/dev/emcpoweri1

# Below will display all EMC power paths
#sudo ./powermt display dev=all > /tmp/mnt_info.lis

Tuesday, December 28, 2010

Instance Hangs data gather

  • If the instance is hanging and you can't log in to any instance, please do one of these 2 options instead:
1) Use "sqlplus -prelim / as sysdba" to get into sqlplus on one instance, and run the oradebug statements 2-3 times - 1 minute apart:


SQL> oradebug setmypid
SQL> oradebug unlimit
SQL> oradebug -g all hanganalyze 3
SQL> oradebug -g all dump systemstate 267

This only needs to be done on one instance; the "-g all" will kick off collection on all the other instances.
-or-
2) Capture systemstate dumps from each node with an OS debugger (gdb):


ps -ef |grep diag
gdb $ORACLE_HOME/bin/oracle
print ksudss(266)

This must be done on each node.

RAC/CRS Troubleshooting


  • Document 339939.1 Running Cluster Verification Utility to Diagnose Install 
  • Document 316817.1 CLUSTER VERIFICATION UTILITY FAQ 
  • Document 428681.1 OCR / Vote disk Maintenance Operations: (ADD/REMOVE/REPLACE/MOVE), including moving from RAW Devices to Block Devices 
  • Document 363254.1 Applying one-off Oracle Clusterware patches in a mixed version home environment 
  • Document 332257.1 Using Oracle Clusterware with Vendor Clusterware FAQ
  • Document 759895.1 The ONS Daemon Explained In RAC/CRS environment
  • Document 783456.1 CRS Diagnostic Data Gathering: A Summary of Common tools and their Usage

Thursday, October 7, 2010

Installing ASMLIB

Install rpm for asmlib , download from oracle or metalink.



Installing using ULN
===============

#up2date -i oracleasm-support oracleasmlib oracleasm- `uname -r`

configure oracleasm

==================
Run it as root on all RAC nodes.

#/etc/init.d/oracleasm configure
This creates following tasks
1)creates /etc/sysconfig/oracleasm config file
2)creates /dev/oracleasm mount
3)loads oracleasm kernel module


Mark DISK as ASM
==================
#/etc/init.d/oracleasm createdisk ASMDISK1 /dev/hda5
After all ASM disk created, run
#/etc/init.d/oracleasm scandisks