ITPub博客

首页 > Linux操作系统 > Linux操作系统 > How To Move Datafiles On AIX Using Raw Logical Volumes To A New Location?

How To Move Datafiles On AIX Using Raw Logical Volumes To A New Location?

原创 Linux操作系统 作者:renjixinchina 时间:2015-01-28 16:11:42 0 删除 编辑
Oracle Server - Enterprise Edition - Version: 8.1.7.0 to 11.1.0.6 - Release: 8.1.7 to 11.1
IBM AIX on POWER Systems (64-bit)
IBM AIX on POWER Systems (32-bit)
AIX5L Based Systems (64-bit)AIX Based Systems (32-bit)
AIX 4.3, 5L (5.1, 5.2, 5.3, etc.), 6.1
Database Server 8i (8.1.7), 9iR2 (9.2.0), 10gR2 (10.2.0), 11gR1 (11.1.0)

GOAL

You will be moving one or more Oracle datafiles on AIX that are located on Raw Logical Volumes (RLVs) to a new location, and would like information about the special steps needed to do this.

SOLUTION

Before discussing the steps to copy an Oracle datafile on an AIX Raw Logical Volume (RLV) to a new location, it is important to note that some RLVs have a Logical Volume Control Block (LVCB) at the beginning of the RLV.  The LVCB, if it exists, is an AIX OS structure separate from any Oracle data.  You must determine whether your RLV has a LVCB at the beginning before copying the RLV.  This must be checked on both the source and target.

You can determine whether there is an LVCB at the beginning of the RLV by checking the DEVICESUBTYPE field of the /usr/sbin/lslv output.  There are two possible values for the DEVICESUBTYPE: "DS_LV" or "DS_LVZ".  A value of DS_LV (or not having DEVICESUBTYPE field in the lslv output) means you do have an LVCB at the beginning of the RLV.  A value of DS_LVZ means you do not have an LVCB at the beginning of the RLV.  Oracle checks the DEVICESUBTYPE field, and if it finds DS_LVZ, then Oracle does not use an offset and the Oracle data starts at the beginning of the RLV, otherwise Oracle uses an offset of 4096 to leave room for the LVCB.  You can check this manually by running...

/usr/sbin/lslv

...where is the name of the logical volume for the Oracle datafile you want to move.  If you prefer, you can use the "checkoffset" shell script provided below.  To use the checkoffset script, just run...

checkoffset

...where is the raw logical volume device for the Oracle datafile you want to move.  The checkoffset script will output the Oracle offset, either 0 or 4096.  Although most do not, some Oracle RAC releases include $ORACLE_HOME/bin/offset which does basically the same thing.  If you do not have $ORACLE_HOME/bin/offset, then you can use checkoffset.

NOTE: If you have an AIX version that supports zero offset Raw Logical Volumes (RLVs), and your Oracle version is 9.2.0.3 or higher, it is strongly recommended that you use an RLV with a zero offset (by including the "-T O" option when creating the RLV with the "mklv" command).  See Metalink Note 261460.1 for more details.

If the new location is on a different system, then it is recommended that you NFS mount the directory containing the new empty RLV device on the new target system so it is accessible from the old source system.  Please contact your systems administrator and/or IBM Support if you need assistance configuring NFS.

The OS command "dd" will be used to copy the data from the old RLV to the new one.  The dd option "skip" tells dd how many blocks to skip before reading data.  The dd option "seek" tells dd how many blocks to seek before writing data.

For the command below, if the Oracle offset is 0 for the source RLV, then use "skip=0", otherwise "skip=1".  If the Oracle offset is 0 for the target RLV, then use "seek=0", otherwise "seek=1".

dd if=/path/to/source_RLV of=/path/to/target_RLV bs=4096 skip=? seek=?

If the RLV on the new system is the exact same name and directory as it was on the old source system, then this should be all that is needed to move the RLV to the new system.  If there are any changes to the RLV name or directory, then just like with regular datafiles, you must rebuild the controlfiles.  More information about rebuilding controlfiles can be found in...

Note 1012929.6  How to Recreate the Controlfile

There are no differences in the datafile structure of the same Oracle release between different AIX versions.  This means if you are moving an Oracle datafile using an RLV on AIX4 to AIX5, then no special steps are needed to deal with the OS version change.

It is recommended that you do not attempt to change the Oracle version at the same time you are moving datafiles to a new system.  If you need to move the datafiles to a new system as part of an Oracle upgrade, then either...

Upgrade the database on the old system and verify it works fine with the new Oracle version on the old system, then move the datafiles to the new system
...or...
Move the datafiles to the new system, verify the database still works fine using the old Oracle version on the new system, then upgrade to the new Oracle version.

---

Click here to download the file (save the filename as "checkoffset").

#!/bin/ksh

# input:
# string: raw character device to check

# output:
# numeric: offset in raw device where oracle data begins

# error exit codes:
# 255 - usage
# 254 - block device (instead of raw device)
# 253 - not a raw device (regular file, directory, etc.)
# 252 - LV not recognized by 'lslv' command

# notes:
# This script checks the output of the AIX 'lslv' command for a device subtype of DS_LVZ.
# Note that most implementations of 'lslv' will only output the DEVICESUBTYPE field if
# the value is something other than DS_LV. If the DEVICESUBTYPE field is not displayed,
# or displays a value other than DS_LVZ, then offset is output as 4096, otherwise 0. A
# device subtype of DS_LVZ indicates that the normal AIX Logical Volume Control Block
# (lvcb) does not occupy the first 512 bytes of the raw device file, and Oracle data
# begins at offset 0. A device subtype of DS_LV (default) indicates the first 512 bytes
# of the raw device are occupied by the AIX lvcb, and Oracle data begins at offset 4096.

# check that one, and only one, parameter was passed
if [ $# -lt 1 -o $# -gt 1 ]; then
   /usr/bin/echo "Usage: checkoffset raw_device"
   /usr/bin/echo "Example: checkoffset /dev/rASMRAW1"
   exit 255
fi

# resolve relative path to full path
dirn=`/usr/bin/dirname $1`
if [ $dirn = "." ]; then
   dirn=`/usr/bin/pwd`
fi
if [ $dirn = "/" ]; then
   dirn=""
fi
basn=`/usr/bin/basename $1`
rdev="$dirn/$basn"

# check whether the parameter passed is a block device
if [ -b $1 ];  then
   /usr/bin/echo "Error: $rdev is a block device"
   exit 254
fi

# check whether the parameter passed is a raw character device
if [ ! -c $1 ];  then
   /usr/bin/echo "Error: $rdev is not a raw character device"
   exit 253
fi

# strip the 'r' from the device name to get the LV name
lvname=`/usr/bin/echo $basn | /usr/bin/cut -c 2-`

# check whether lslv accepts the LV name as valid
lvchk=`/usr/sbin/lslv $lvname > /dev/null 2>&1 ; print $?`
if [ $lvchk != "0" ]; then
   /usr/bin/echo "Error: Command failed: /usr/sbin/lslv $lvname"
   /usr/sbin/lslv $lvname
   exit 252
fi

# check lslv output for DEVICESUBTYPE of DS_LVZ and set offset
offset=`/usr/sbin/lslv $lvname | /usr/bin/grep DEVICESUBTYPE`
offset=`echo $offset | /usr/bin/grep DS_LVZ ; print $?`
if [ $offset = "0" ]; then
   offset="0"
else
   offset="4096"
fi

# display offset and exit cleanly
echo $offset
exit 0

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/15747463/viewspace-1418381/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2011-01-30

  • 博文量
    373
  • 访问量
    2056557