三、从文件系统迁移数据库到lv裸设备
使用备份的控制文件
1、建立对应的lv
参数文件 spfile
控制文件
日志文件
数据文件
控制文件
日志文件
数据文件
[root@haozg /]# fdisk -l
Disk /dev/sda: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000ec9c9
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000ec9c9
Device Boot Start End Blocks Id System
/dev/sda1 * 1 64 512000 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 64 2611 20458496 8e Linux LVM
/dev/sda1 * 1 64 512000 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 64 2611 20458496 8e Linux LVM
Disk /dev/sdb: 536 MB, 536870912 bytes
64 heads, 32 sectors/track, 512 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x5bbec611
64 heads, 32 sectors/track, 512 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x5bbec611
Device Boot Start End Blocks Id System
/dev/sdb1 1 512 524272 5 Extended
/dev/sdb5 1 50 51168 83 Linux
/dev/sdb6 51 99 50160 83 Linux
/dev/sdb7 100 148 50160 83 Linux
/dev/sdb8 149 512 372720 83 Linux
/dev/sdb1 1 512 524272 5 Extended
/dev/sdb5 1 50 51168 83 Linux
/dev/sdb6 51 99 50160 83 Linux
/dev/sdb7 100 148 50160 83 Linux
/dev/sdb8 149 512 372720 83 Linux
Disk /dev/sdc: 3221 MB, 3221225472 bytes
255 heads, 63 sectors/track, 391 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
255 heads, 63 sectors/track, 391 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
Disk /dev/sdc doesn't contain a valid partition table
Disk /dev/mapper/vg_haozg-lv_root: 18.8 GB, 18832424960 bytes
255 heads, 63 sectors/track, 2289 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
255 heads, 63 sectors/track, 2289 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
Disk /dev/mapper/vg_haozg-lv_root doesn't contain a valid partition table
Disk /dev/mapper/vg_haozg-lv_swap: 2113 MB, 2113929216 bytes
255 heads, 63 sectors/track, 257 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
255 heads, 63 sectors/track, 257 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
Disk /dev/mapper/vg_haozg-lv_swap doesn't contain a valid partition table
Disk /dev/mapper/vg01-lv_ocr10m: 12 MB, 12582912 bytes
255 heads, 63 sectors/track, 1 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
255 heads, 63 sectors/track, 1 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
Disk /dev/mapper/vg01-lv_ocr10m doesn't contain a valid partition table
[root@haozg /]#
[root@haozg /]#
[root@haozg /]# fdisk /dev/sdc
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0x9206bfbf.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.
[root@haozg /]#
[root@haozg /]#
[root@haozg /]# fdisk /dev/sdc
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0x9206bfbf.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
switch off the mode (command 'c') and change display units to
sectors (command 'u').
switch off the mode (command 'c') and change display units to
sectors (command 'u').
Command (m for help): m
Command action
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition
l list known partition types
m print this menu
n add a new partition
o create a new empty DOS partition table
p print the partition table
q quit without saving changes
s create a new empty Sun disklabel
t change a partition's system id
u change display/entry units
v verify the partition table
w write table to disk and exit
x extra functionality (experts only)
Command action
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition
l list known partition types
m print this menu
n add a new partition
o create a new empty DOS partition table
p print the partition table
q quit without saving changes
s create a new empty Sun disklabel
t change a partition's system id
u change display/entry units
v verify the partition table
w write table to disk and exit
x extra functionality (experts only)
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-391, default 1):
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-391, default 391):
Using default value 391
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-391, default 1):
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-391, default 391):
Using default value 391
Command (m for help): p
Disk /dev/sdc: 3221 MB, 3221225472 bytes
255 heads, 63 sectors/track, 391 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x9206bfbf
255 heads, 63 sectors/track, 391 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x9206bfbf
Device Boot Start End Blocks Id System
/dev/sdc1 1 391 3140676 83 Linux
/dev/sdc1 1 391 3140676 83 Linux
Command (m for help): w
The partition table has been altered!
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
[root@haozg /]#
[root@haozg /]#
[root@haozg /]# fdisk -;
Syncing disks.
[root@haozg /]#
[root@haozg /]#
[root@haozg /]# fdisk -;
Unable to open -
[root@haozg /]# fdisk -l
[root@haozg /]# fdisk -l
Disk /dev/sda: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000ec9c9
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000ec9c9
Device Boot Start End Blocks Id System
/dev/sda1 * 1 64 512000 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 64 2611 20458496 8e Linux LVM
/dev/sda1 * 1 64 512000 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 64 2611 20458496 8e Linux LVM
Disk /dev/sdb: 536 MB, 536870912 bytes
64 heads, 32 sectors/track, 512 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x5bbec611
64 heads, 32 sectors/track, 512 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x5bbec611
Device Boot Start End Blocks Id System
/dev/sdb1 1 512 524272 5 Extended
/dev/sdb5 1 50 51168 83 Linux
/dev/sdb6 51 99 50160 83 Linux
/dev/sdb7 100 148 50160 83 Linux
/dev/sdb8 149 512 372720 83 Linux
/dev/sdb1 1 512 524272 5 Extended
/dev/sdb5 1 50 51168 83 Linux
/dev/sdb6 51 99 50160 83 Linux
/dev/sdb7 100 148 50160 83 Linux
/dev/sdb8 149 512 372720 83 Linux
Disk /dev/sdc: 3221 MB, 3221225472 bytes
255 heads, 63 sectors/track, 391 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x9206bfbf
255 heads, 63 sectors/track, 391 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x9206bfbf
Device Boot Start End Blocks Id System
/dev/sdc1 1 391 3140676 83 Linux
/dev/sdc1 1 391 3140676 83 Linux
Disk /dev/mapper/vg_haozg-lv_root: 18.8 GB, 18832424960 bytes
255 heads, 63 sectors/track, 2289 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
255 heads, 63 sectors/track, 2289 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
Disk /dev/mapper/vg_haozg-lv_root doesn't contain a valid partition table
Disk /dev/mapper/vg_haozg-lv_swap: 2113 MB, 2113929216 bytes
255 heads, 63 sectors/track, 257 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
255 heads, 63 sectors/track, 257 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
Disk /dev/mapper/vg_haozg-lv_swap doesn't contain a valid partition table
Disk /dev/mapper/vg01-lv_ocr10m: 12 MB, 12582912 bytes
255 heads, 63 sectors/track, 1 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
255 heads, 63 sectors/track, 1 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
Disk /dev/mapper/vg01-lv_ocr10m doesn't contain a valid partition table
[root@haozg /]#
[root@haozg /]# pvcreate /dev/sdc1
Writing physical volume data to disk "/dev/sdc1"
Physical volume "/dev/sdc1" successfully created
[root@haozg /]# vgcreate oradata /dev/sdc1
Volume group "oradata" successfully created
[root@haozg /]# lvcreate -L 10m -n lv_spfile oradata
Rounding up size to full physical extent 12.00 MiB
Logical volume "lv_spfile" created
[root@haozg /]# lvcreate -L 20m -n lv_control1 oradata
Logical volume "lv_control1" created
[root@haozg /]# lvcreate -L 20m -n lv_control2 oradata
Logical volume "lv_control2" created
[root@haozg /]# lvcreate -L 100m -n lv_redo1 oradata
Logical volume "lv_redo1" created
[root@haozg /]# lvcreate -L 100m -n lv_redo2 oradata
Logical volume "lv_redo2" created
[root@haozg /]# lvcreate -L 100m -n lv_redo3 oradata
Logical volume "lv_redo3" created
[root@haozg /]# lv_create -L 1100m -n lv_system oradata
-bash: lv_create: command not found
[root@haozg /]# lvcreate -L 1100m -n lv_system oradata
Logical volume "lv_system" created
[root@haozg /]# lvcreate -L 30m -n lv_temp oradata
Rounding up size to full physical extent 32.00 MiB
Logical volume "lv_temp" created
[root@haozg /]# lvcreate -L 550m -n lv_sysaux oradata
Rounding up size to full physical extent 552.00 MiB
Logical volume "lv_sysaux" created
[root@haozg /]# lvcreate -L 320m -n lv_undo oradata
Logical volume "lv_undo" created
[root@haozg oradata]# lvcreate -L 700m -n lv_user oradata
Logical volume "lv_user" created
[root@haozg /]#
[root@haozg /]# pvcreate /dev/sdc1
Writing physical volume data to disk "/dev/sdc1"
Physical volume "/dev/sdc1" successfully created
[root@haozg /]# vgcreate oradata /dev/sdc1
Volume group "oradata" successfully created
[root@haozg /]# lvcreate -L 10m -n lv_spfile oradata
Rounding up size to full physical extent 12.00 MiB
Logical volume "lv_spfile" created
[root@haozg /]# lvcreate -L 20m -n lv_control1 oradata
Logical volume "lv_control1" created
[root@haozg /]# lvcreate -L 20m -n lv_control2 oradata
Logical volume "lv_control2" created
[root@haozg /]# lvcreate -L 100m -n lv_redo1 oradata
Logical volume "lv_redo1" created
[root@haozg /]# lvcreate -L 100m -n lv_redo2 oradata
Logical volume "lv_redo2" created
[root@haozg /]# lvcreate -L 100m -n lv_redo3 oradata
Logical volume "lv_redo3" created
[root@haozg /]# lv_create -L 1100m -n lv_system oradata
-bash: lv_create: command not found
[root@haozg /]# lvcreate -L 1100m -n lv_system oradata
Logical volume "lv_system" created
[root@haozg /]# lvcreate -L 30m -n lv_temp oradata
Rounding up size to full physical extent 32.00 MiB
Logical volume "lv_temp" created
[root@haozg /]# lvcreate -L 550m -n lv_sysaux oradata
Rounding up size to full physical extent 552.00 MiB
Logical volume "lv_sysaux" created
[root@haozg /]# lvcreate -L 320m -n lv_undo oradata
Logical volume "lv_undo" created
[root@haozg oradata]# lvcreate -L 700m -n lv_user oradata
Logical volume "lv_user" created
[root@haozg /]#
2、改变属组
[root@haozg dev]# chown -R oracle:dba /dev/oradata
[root@haozg dev]# cd oradata
[root@haozg oradata]# ls -al
total 0
drwxr-xr-x. 2 oracle dba 240 May 19 14:47 .
drwxr-xr-x. 21 root root 4280 May 19 14:47 ..
lrwxrwxrwx. 1 oracle dba 7 May 19 14:38 lv_control1 -> ../dm-4
lrwxrwxrwx. 1 oracle dba 7 May 19 14:38 lv_control2 -> ../dm-5
lrwxrwxrwx. 1 oracle dba 7 May 19 14:40 lv_redo1 -> ../dm-6
lrwxrwxrwx. 1 oracle dba 7 May 19 14:41 lv_redo2 -> ../dm-7
lrwxrwxrwx. 1 oracle dba 7 May 19 14:41 lv_redo3 -> ../dm-8
lrwxrwxrwx. 1 oracle dba 7 May 19 14:37 lv_spfile -> ../dm-3
lrwxrwxrwx. 1 oracle dba 8 May 19 14:46 lv_sysaux -> ../dm-11
lrwxrwxrwx. 1 oracle dba 7 May 19 14:44 lv_system -> ../dm-9
lrwxrwxrwx. 1 oracle dba 8 May 19 14:45 lv_temp -> ../dm-10
lrwxrwxrwx. 1 oracle dba 8 May 19 14:47 lv_undo -> ../dm-12
[root@haozg oradata]#
[root@haozg dev]# cd oradata
[root@haozg oradata]# ls -al
total 0
drwxr-xr-x. 2 oracle dba 240 May 19 14:47 .
drwxr-xr-x. 21 root root 4280 May 19 14:47 ..
lrwxrwxrwx. 1 oracle dba 7 May 19 14:38 lv_control1 -> ../dm-4
lrwxrwxrwx. 1 oracle dba 7 May 19 14:38 lv_control2 -> ../dm-5
lrwxrwxrwx. 1 oracle dba 7 May 19 14:40 lv_redo1 -> ../dm-6
lrwxrwxrwx. 1 oracle dba 7 May 19 14:41 lv_redo2 -> ../dm-7
lrwxrwxrwx. 1 oracle dba 7 May 19 14:41 lv_redo3 -> ../dm-8
lrwxrwxrwx. 1 oracle dba 7 May 19 14:37 lv_spfile -> ../dm-3
lrwxrwxrwx. 1 oracle dba 8 May 19 14:46 lv_sysaux -> ../dm-11
lrwxrwxrwx. 1 oracle dba 7 May 19 14:44 lv_system -> ../dm-9
lrwxrwxrwx. 1 oracle dba 8 May 19 14:45 lv_temp -> ../dm-10
lrwxrwxrwx. 1 oracle dba 8 May 19 14:47 lv_undo -> ../dm-12
[root@haozg oradata]#
3、RHEL5中取消了rawdevices映射文件,可以通过两种方式开机加载裸设备,一种是使用UDEV,另外一种是写入rc.local脚本,
本文使用rc.local脚本的方式开机激活裸设备。
创建一个/etc/rc.raw脚本内容如下:
[root@orcl ~]# vi /etc/rc.raw
/bin/raw /dev/raw/raw1 /dev/mapper/oradata-lv_control1
/bin/raw /dev/raw/raw2 /dev/mapper/oradata-lv_control2
/bin/raw /dev/raw/raw3 /dev/mapper/oradata-lv_redo1
/bin/raw /dev/raw/raw4 /dev/mapper/oradata-lv_redo2
/bin/raw /dev/raw/raw5 /dev/mapper/oradata-lv_redo3
/bin/raw /dev/raw/raw6 /dev/mapper/oradata-lv_spfile
/bin/raw /dev/raw/raw7 /dev/mapper/oradata-lv_sysaux
/bin/raw /dev/raw/raw8 /dev/mapper/oradata-lv_system
/bin/raw /dev/raw/raw9 /dev/mapper/oradata-lv_temp
/bin/raw /dev/raw/raw10 /dev/mapper/oradata-lv_undo
/bin/raw /dev/raw/raw11 /dev/mapper/oradata-lv_user
/bin/raw /dev/raw/raw12 /dev/mapper/oradata1-lv_user01
/bin/raw /dev/raw/raw1 /dev/mapper/oradata-lv_control1
/bin/raw /dev/raw/raw2 /dev/mapper/oradata-lv_control2
/bin/raw /dev/raw/raw3 /dev/mapper/oradata-lv_redo1
/bin/raw /dev/raw/raw4 /dev/mapper/oradata-lv_redo2
/bin/raw /dev/raw/raw5 /dev/mapper/oradata-lv_redo3
/bin/raw /dev/raw/raw6 /dev/mapper/oradata-lv_spfile
/bin/raw /dev/raw/raw7 /dev/mapper/oradata-lv_sysaux
/bin/raw /dev/raw/raw8 /dev/mapper/oradata-lv_system
/bin/raw /dev/raw/raw9 /dev/mapper/oradata-lv_temp
/bin/raw /dev/raw/raw10 /dev/mapper/oradata-lv_undo
/bin/raw /dev/raw/raw11 /dev/mapper/oradata-lv_user
/bin/raw /dev/raw/raw12 /dev/mapper/oradata1-lv_user01
/bin/chown oracle:oinstall /dev/mapper/oradata*
/bin/chown oracle:oinstall /dev/raw/*
/bin/chmod 660 /dev/raw/*
/bin/chown oracle:oinstall /dev/raw/*
/bin/chmod 660 /dev/raw/*
[root@haozg dev]# cd /etc
[root@haozg etc]# more rc.raw
/bin/raw /dev/raw/raw1 /dev/mapper/oradata-lv_control1
/bin/raw /dev/raw/raw2 /dev/mapper/oradata-lv_control2
/bin/raw /dev/raw/raw3 /dev/mapper/oradata-lv_redo1
/bin/raw /dev/raw/raw4 /dev/mapper/oradata-lv_redo2
/bin/raw /dev/raw/raw5 /dev/mapper/oradata-lv_redo3
/bin/raw /dev/raw/raw6 /dev/mapper/oradata-lv_spfile
/bin/raw /dev/raw/raw7 /dev/mapper/oradata-lv_sysaux
/bin/raw /dev/raw/raw8 /dev/mapper/oradata-lv_system
/bin/raw /dev/raw/raw9 /dev/mapper/oradata-lv_temp
/bin/raw /dev/raw/raw10 /dev/mapper/oradata-lv_undo
/bin/raw /dev/raw/raw11 /dev/mapper/oradata-lv_user
/bin/raw /dev/raw/raw12 /dev/mapper/oradata1-lv_user01
[root@haozg etc]# more rc.raw
/bin/raw /dev/raw/raw1 /dev/mapper/oradata-lv_control1
/bin/raw /dev/raw/raw2 /dev/mapper/oradata-lv_control2
/bin/raw /dev/raw/raw3 /dev/mapper/oradata-lv_redo1
/bin/raw /dev/raw/raw4 /dev/mapper/oradata-lv_redo2
/bin/raw /dev/raw/raw5 /dev/mapper/oradata-lv_redo3
/bin/raw /dev/raw/raw6 /dev/mapper/oradata-lv_spfile
/bin/raw /dev/raw/raw7 /dev/mapper/oradata-lv_sysaux
/bin/raw /dev/raw/raw8 /dev/mapper/oradata-lv_system
/bin/raw /dev/raw/raw9 /dev/mapper/oradata-lv_temp
/bin/raw /dev/raw/raw10 /dev/mapper/oradata-lv_undo
/bin/raw /dev/raw/raw11 /dev/mapper/oradata-lv_user
/bin/raw /dev/raw/raw12 /dev/mapper/oradata1-lv_user01
/bin/chown oracle:oinstall /dev/mapper/oradata*
/bin/chown oracle:oinstall /dev/raw/*
/bin/chmod 660 /dev/raw/*
[root@haozg etc]#
/bin/chown oracle:oinstall /dev/raw/*
/bin/chmod 660 /dev/raw/*
[root@haozg etc]#
重启系统查看raw
[root@haozg ~]# cd /dev/raw
[root@haozg raw]# ls -al
total 0
drwxr-xr-x. 2 root root 300 May 19 22:23 .
drwxr-xr-x. 22 root root 4400 May 19 22:23 ..
crw-rw----. 1 oracle oinstall 162, 1 May 19 22:23 raw1
crw-rw----. 1 oracle oinstall 162, 10 May 19 22:23 raw10
crw-rw----. 1 oracle oinstall 162, 11 May 19 22:23 raw11
crw-rw----. 1 oracle oinstall 162, 12 May 19 22:23 raw12
crw-rw----. 1 oracle oinstall 162, 2 May 19 22:23 raw2
crw-rw----. 1 oracle oinstall 162, 3 May 19 22:23 raw3
crw-rw----. 1 oracle oinstall 162, 4 May 19 22:23 raw4
crw-rw----. 1 oracle oinstall 162, 5 May 19 22:23 raw5
crw-rw----. 1 oracle oinstall 162, 6 May 19 22:23 raw6
crw-rw----. 1 oracle oinstall 162, 7 May 19 22:23 raw7
crw-rw----. 1 oracle oinstall 162, 8 May 19 22:23 raw8
crw-rw----. 1 oracle oinstall 162, 9 May 19 22:23 raw9
crw-rw----. 1 oracle oinstall 162, 0 May 19 22:22 rawctl
[root@haozg raw]# raw -qa
/dev/raw/raw1: bound to major 253, minor 4
/dev/raw/raw2: bound to major 253, minor 5
/dev/raw/raw3: bound to major 253, minor 6
/dev/raw/raw4: bound to major 253, minor 7
/dev/raw/raw5: bound to major 253, minor 8
/dev/raw/raw6: bound to major 253, minor 3
/dev/raw/raw7: bound to major 253, minor 11
/dev/raw/raw8: bound to major 253, minor 9
/dev/raw/raw9: bound to major 253, minor 10
/dev/raw/raw10: bound to major 253, minor 12
/dev/raw/raw11: bound to major 253, minor 13
/dev/raw/raw12: bound to major 253, minor 2
[root@haozg raw]#
[root@haozg raw]# ls -al
total 0
drwxr-xr-x. 2 root root 300 May 19 22:23 .
drwxr-xr-x. 22 root root 4400 May 19 22:23 ..
crw-rw----. 1 oracle oinstall 162, 1 May 19 22:23 raw1
crw-rw----. 1 oracle oinstall 162, 10 May 19 22:23 raw10
crw-rw----. 1 oracle oinstall 162, 11 May 19 22:23 raw11
crw-rw----. 1 oracle oinstall 162, 12 May 19 22:23 raw12
crw-rw----. 1 oracle oinstall 162, 2 May 19 22:23 raw2
crw-rw----. 1 oracle oinstall 162, 3 May 19 22:23 raw3
crw-rw----. 1 oracle oinstall 162, 4 May 19 22:23 raw4
crw-rw----. 1 oracle oinstall 162, 5 May 19 22:23 raw5
crw-rw----. 1 oracle oinstall 162, 6 May 19 22:23 raw6
crw-rw----. 1 oracle oinstall 162, 7 May 19 22:23 raw7
crw-rw----. 1 oracle oinstall 162, 8 May 19 22:23 raw8
crw-rw----. 1 oracle oinstall 162, 9 May 19 22:23 raw9
crw-rw----. 1 oracle oinstall 162, 0 May 19 22:22 rawctl
[root@haozg raw]# raw -qa
/dev/raw/raw1: bound to major 253, minor 4
/dev/raw/raw2: bound to major 253, minor 5
/dev/raw/raw3: bound to major 253, minor 6
/dev/raw/raw4: bound to major 253, minor 7
/dev/raw/raw5: bound to major 253, minor 8
/dev/raw/raw6: bound to major 253, minor 3
/dev/raw/raw7: bound to major 253, minor 11
/dev/raw/raw8: bound to major 253, minor 9
/dev/raw/raw9: bound to major 253, minor 10
/dev/raw/raw10: bound to major 253, minor 12
/dev/raw/raw11: bound to major 253, minor 13
/dev/raw/raw12: bound to major 253, minor 2
[root@haozg raw]#
----建立快键方式
ln -s /dev/raw/raw1 /u01/app/rawdevice/control1
ln -s /dev/raw/raw2 /u01/app/rawdevice/control2
ln -s /dev/raw/raw3 /u01/app/rawdevice/redo1
ln -s /dev/raw/raw4 /u01/app/rawdevice/redo2
ln -s /dev/raw/raw5 /u01/app/rawdevice/redo3
ln -s /dev/raw/raw6 /u01/app/rawdevice/spfile
ln -s /dev/raw/raw7 /u01/app/rawdevice/sysaux
ln -s /dev/raw/raw8 /u01/app/rawdevice/system
ln -s /dev/raw/raw9 /u01/app/rawdevice/temp
ln -s /dev/raw/raw10 /u01/app/rawdevice/undo
ln -s /dev/raw/raw11 /u01/app/rawdevice/user
ln -s /dev/raw/raw12 /u01/app/rawdevice/user01
4、 在rman下从文件系统复制数据文件到raw设备,在mount状态下
---复制数据文件
copy datafile '/u01/app/oradata/system01.dbf' to '/u01/app/rawdevice/system';
copy datafile '/u01/app/oradata/undo01.dbf' to '/u01/app/rawdevice/undo';
copy datafile '/u01/app/oradata/sysaux01.dbf' to '/u01/app/rawdevice/sysaux';
copy datafile '/u01/app/oradata/user01.dbf' to '/u01/app/rawdevice/user01';
--具体操作过程如下:
[oracle@haozg ~]$ rman target /
[oracle@haozg ~]$ rman target /
Recovery Manager: Release 11.2.0.1.0 - Production on Sat May 19 21:36:00 2012
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
connected to target database: ORA11G (DBID=4179426506, not open)
RMAN> copy datafile '/u01/app/oradata/system01.dbf' to '/u01/app/rawdevice/system';
Starting backup at 19-MAY-12
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=21 device type=DISK
channel ORA_DISK_1: starting datafile copy
input datafile file number=00001 name=/u01/app/oradata/system01.dbf
output file name=/u01/app/rawdevice/system tag=TAG20120519T213608 RECID=1 STAMP=783725841
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:01:15
Finished backup at 19-MAY-12
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=21 device type=DISK
channel ORA_DISK_1: starting datafile copy
input datafile file number=00001 name=/u01/app/oradata/system01.dbf
output file name=/u01/app/rawdevice/system tag=TAG20120519T213608 RECID=1 STAMP=783725841
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:01:15
Finished backup at 19-MAY-12
RMAN> copy datafile '/u01/app/oradata/undo01.dbf' to '/u01/app/rawdevice/undo';
Starting backup at 19-MAY-12
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile copy
input datafile file number=00003 name=/u01/app/oradata/undo01.dbf
output file name=/u01/app/rawdevice/undo tag=TAG20120519T213901 RECID=2 STAMP=783725955
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:15
Finished backup at 19-MAY-12
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile copy
input datafile file number=00003 name=/u01/app/oradata/undo01.dbf
output file name=/u01/app/rawdevice/undo tag=TAG20120519T213901 RECID=2 STAMP=783725955
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:15
Finished backup at 19-MAY-12
RMAN> copy datafile '/u01/app/oradata/sysaux01.dbf' to '/u01/app/rawdevice/sysaux';
Starting backup at 19-MAY-12
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile copy
input datafile file number=00002 name=/u01/app/oradata/sysaux01.dbf
output file name=/u01/app/rawdevice/sysaux tag=TAG20120519T214125 RECID=3 STAMP=783726113
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:36
Finished backup at 19-MAY-12
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile copy
input datafile file number=00002 name=/u01/app/oradata/sysaux01.dbf
output file name=/u01/app/rawdevice/sysaux tag=TAG20120519T214125 RECID=3 STAMP=783726113
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:36
Finished backup at 19-MAY-12
RMAN>
RMAN> copy datafile '/u01/app/oradata/user01.dbf' to '/u01/app/rawdevice/user01';
Starting backup at 19-MAY-12
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=18 device type=DISK
channel ORA_DISK_1: starting datafile copy
input datafile file number=00004 name=/u01/app/oradata/user01.dbf
output file name=/u01/app/rawdevice/user01 tag=TAG20120519T223532 RECID=4 STAMP=783729380
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:55
Finished backup at 19-MAY-12
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=18 device type=DISK
channel ORA_DISK_1: starting datafile copy
input datafile file number=00004 name=/u01/app/oradata/user01.dbf
output file name=/u01/app/rawdevice/user01 tag=TAG20120519T223532 RECID=4 STAMP=783729380
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:55
Finished backup at 19-MAY-12
RMAN>
5、修改数据文件在控制文件中的路径 在sqlplus下操作, 数据在mount状态下
alter database rename file '/u01/app/oradata/system01.dbf' to '/u01/app/rawdevice/system';
alter database rename file '/u01/app/oradata/sysaux01.dbf' to '/u01/app/rawdevice/sysaux';
alter database rename file '/u01/app/oradata/undo01.dbf' to '/u01/app/rawdevice/undo';
alter database rename file '/u01/app/oradata/user01.dbf' to '/u01/app/rawdevice/user01';
---具体操作过程如下:
下面的命令立刻生效
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount;
ORACLE instance started.
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount;
ORACLE instance started.
Total System Global Area 146472960 bytes
Fixed Size 1335080 bytes
Variable Size 92274904 bytes
Database Buffers 50331648 bytes
Redo Buffers 2531328 bytes
Database mounted.
SQL> alter database rename file '/u01/app/oradata/system01.dbf' to '/u01/app/rawdevice/system';
Fixed Size 1335080 bytes
Variable Size 92274904 bytes
Database Buffers 50331648 bytes
Redo Buffers 2531328 bytes
Database mounted.
SQL> alter database rename file '/u01/app/oradata/system01.dbf' to '/u01/app/rawdevice/system';
Database altered.
SQL> alter database rename file '/u01/app/oradata/sysaux01.dbf' to '/u01/app/rawdevice/sysaux';
Database altered.
SQL> alter database rename file '/u01/app/oradata/undo01.dbf' to '/u01/app/rawdevice/undo';
Database altered.
SQL> alter database rename file '/u01/app/oradata/user01.dbf' to '/u01/app/rawdevice/user01';
Database altered.
---************************截止到此时能打开数据库吗?*************************************
SQL> select name from v$datafile;
NAME
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
/u01/app/rawdevice/system
/u01/app/rawdevice/sysaux
/u01/app/rawdevice/undo
/u01/app/rawdevice/user01
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
/u01/app/rawdevice/system
/u01/app/rawdevice/sysaux
/u01/app/rawdevice/undo
/u01/app/rawdevice/user01
SQL>
6、在sqlplus 下把文件系统的日志文件改到裸设备上,修改日志文件在控制文件的路径。
SQL> select group#,status from v$log;
GROUP# STATUS
---------- ----------------
1 INACTIVE
3 CURRENT
2 INACTIVE
---------- ----------------
1 INACTIVE
3 CURRENT
2 INACTIVE
SQL>
alter database drop logfile group 2;
Alter database add logfile group 2 ('/u01/app/rawdevice/redo2') size 80m;
alter database drop logfile group 1;
Alter database add logfile group 1 ('/u01/app/rawdevice/redo1') size 80m;
alter database drop logfile group 3;
Alter database add logfile group 3 ('/u01/app/rawdevice/redo3') size 80m;
具体过程如下:
SQL> select group#,status from v$log;
GROUP# STATUS
---------- ----------------
1 INACTIVE
3 CURRENT
2 INACTIVE
---------- ----------------
1 INACTIVE
3 CURRENT
2 INACTIVE
SQL> select group#,status from v$log;
GROUP# STATUS
---------- ----------------
1 INACTIVE
3 CURRENT
2 INACTIVE
---------- ----------------
1 INACTIVE
3 CURRENT
2 INACTIVE
SQL> alter database drop logfile group 2;
Database altered.
SQL> Alter database add logfile group 2 ('/u01/app/rawdevice/redo2')size 80m;
Database altered.
SQL> alter database open;
Database altered.
SQL> select group#,status from v$log;
GROUP# STATUS
---------- ----------------
1 INACTIVE
2 CURRENT
3 INACTIVE
---------- ----------------
1 INACTIVE
2 CURRENT
3 INACTIVE
SQL> select * from v$logfiles;
select * from v$logfiles
*
ERROR at line 1:
ORA-00942: table or view does not exist
select * from v$logfiles
*
ERROR at line 1:
ORA-00942: table or view does not exist
SQL> select * from v$logfile;
GROUP# STATUS TYPE
---------- ------- -------
MEMBER
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
IS_
---
1 ONLINE
/u01/app/oradata/log01.dbf
NO
---------- ------- -------
MEMBER
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
IS_
---
1 ONLINE
/u01/app/oradata/log01.dbf
NO
2 ONLINE
/u01/app/rawdevice/redo2
NO
/u01/app/rawdevice/redo2
NO
3 ONLINE
/u01/app/oradata/log03.dbf
NO
/u01/app/oradata/log03.dbf
NO
SQL> alter database drop logfile group 1;
Database altered.
SQL> select * from v$logfile;
GROUP# STATUS TYPE
---------- ------- -------
MEMBER
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
IS_
---
2 ONLINE
/u01/app/rawdevice/redo2
NO
---------- ------- -------
MEMBER
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
IS_
---
2 ONLINE
/u01/app/rawdevice/redo2
NO
3 ONLINE
/u01/app/oradata/log03.dbf
NO
/u01/app/oradata/log03.dbf
NO
SQL> Alter database add logfile group 1 ('/u01/app/rawdevice/redo1') size 80m;
Database altered.
SQL> select group#,status from v$log;
GROUP# STATUS
---------- ----------------
1 UNUSED
2 CURRENT
3 INACTIVE
---------- ----------------
1 UNUSED
2 CURRENT
3 INACTIVE
SQL> alter system switch logfile;
System altered.
SQL> select group#,status from v$log;
GROUP# STATUS
---------- ----------------
1 CURRENT
2 ACTIVE
3 INACTIVE
---------- ----------------
1 CURRENT
2 ACTIVE
3 INACTIVE
SQL> alter database drop logfile group 3;
Database altered.
SQL> Alter database add logfile group 3 ('/u01/app/rawdevice/redo3')size 80m;
Database altered.
SQL> select group#,status from v$log;
GROUP# STATUS
---------- ----------------
1 CURRENT
2 ACTIVE
3 UNUSED
---------- ----------------
1 CURRENT
2 ACTIVE
3 UNUSED
SQL> alter system switch lofile;
alter system switch lofile
*
ERROR at line 1:
ORA-01900: LOGFILE keyword expected
alter system switch lofile
*
ERROR at line 1:
ORA-01900: LOGFILE keyword expected
SQL> alter system switch logfile;
System altered.
SQL> select group#,status from v$log;
GROUP# STATUS
---------- ----------------
1 ACTIVE
2 ACTIVE
3 CURRENT
---------- ----------------
1 ACTIVE
2 ACTIVE
3 CURRENT
SQL> select member from v$logfile;
MEMBER
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
/u01/app/rawdevice/redo1
/u01/app/rawdevice/redo2
/u01/app/rawdevice/redo3
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
/u01/app/rawdevice/redo1
/u01/app/rawdevice/redo2
/u01/app/rawdevice/redo3
SQL>
原则是保持始终有两个日志可以切换,删掉inactive状态的日志组,然后切换,把unused状态的日志改为active状态。
最后发出checkpoint。保持所有日志scn一致。
SQL> alter system checkpoint;
System altered.
7、修改spfile到raw设备上来
create pfile='/u01/app/newpfile2.ora' from spfile;
create spfile='/u01/app/rawdevice/spfile' from pfile='/u01/app/newpfile2.ora';
create spfile='/u01/app/rawdevice/spfile' from pfile='/u01/app/newpfile2.ora';
--具体操作过程如下
SQL> select status from v$instance;
SQL> select status from v$instance;
STATUS
------------
MOUNTED
------------
MOUNTED
SQL>
SQL> create pfile='/u01/app/newpfile.ora' from spfile;
SQL> create pfile='/u01/app/newpfile.ora' from spfile;
File created.
SQL> create spfile='/u01/app/rawdevice/spfile' from pfile='/u01/app/newpfile.ora';
File created.
SQL>
8、使用新的spfile文件,修改initsid.ora 文件指向新的spfile文件
[oracle@haozg dbs]$ mv initora11g.ora initora11g.ora.bak
[oracle@haozg dbs]$ mv spfileora11g.ora spfileora11g.ora.bak
[oracle@haozg dbs]$ mv spfileora11g.ora spfileora11g.ora.bak
[oracle@haozg dbs]$ vi initora11g.ora
spfile='/u01/app/rawdevice/spfile'
spfile='/u01/app/rawdevice/spfile'
[oracle@haozg dbs]$ more initora11g.ora
spfile='/u01/app/rawdevice/spfile'
然后删掉原来的spfile文件,否则还会找原来的spfile文件,现在要通过initora11g文件来找裸设备上的spfile文件
[oracle@haozg dbs]$ rm -rf spfileora11g.ora
9、在mount状态下,把内容变动后的控制文件备份到裸设备上,在sqlplus下操作
alter database backup controlfile to '/u01/app/rawdevice/control1';
alter database backup controlfile to '/u01/app/rawdevice/control2';
alter database backup controlfile to '/u01/app/rawdevice/control2';
另: 用dd方式 在关闭的数据库的情况下
dd if=/u01/app/oradata/control1.ctl f=/u01/app/rawdevice/control1
dd if=/u01/app/oradata/control2.ctl f=/u01/app/rawdevice/control2
10、修改控制文件在spfile参数文件中的位置,在nomount情况下
alter system set control_files='/u01/app/rawdevice/control1', '/u01/app/rawdevice/control2' scope=spfile;
具体过程如下
SQL> startup nomount;
ORACLE instance started.
ORACLE instance started.
Total System Global Area 146472960 bytes
Fixed Size 1335080 bytes
Variable Size 92274904 bytes
Database Buffers 50331648 bytes
Redo Buffers 2531328 bytes
SQL>
SQL>
SQL>
SQL> alter system set control_files='/u01/app/rawdevice/control1', '/u01/app/rawdevice/control2' scope=spfile;
Fixed Size 1335080 bytes
Variable Size 92274904 bytes
Database Buffers 50331648 bytes
Redo Buffers 2531328 bytes
SQL>
SQL>
SQL>
SQL> alter system set control_files='/u01/app/rawdevice/control1', '/u01/app/rawdevice/control2' scope=spfile;
System altered.
SQL> shutdown immediate;
ORA-01507: database not mounted
ORA-01507: database not mounted
ORACLE instance shut down.
SQL>
SQL>
SQL>
SQL> show parameter control
ORA-01034: ORACLE not available
Process ID: 4215
Session ID: 1 Serial number: 3
SQL> startup
ORACLE instance started.
Total System Global Area 146472960 bytes
Fixed Size 1335080 bytes
Variable Size 92274904 bytes
Database Buffers 50331648 bytes
Redo Buffers 2531328 bytes
Database mounted.
ORA-01610: recovery using the BACKUP CONTROLFILE option must be done
Fixed Size 1335080 bytes
Variable Size 92274904 bytes
Database Buffers 50331648 bytes
Redo Buffers 2531328 bytes
Database mounted.
ORA-01610: recovery using the BACKUP CONTROLFILE option must be done
---在打开数据库的时候需要做介质恢复,所以在迁移之前一定要做全库的rman备份。
--原因是控制文件在mount状态关闭库后会发生变化,当前的控制文件和备份的控制文件不一致。
--原因是控制文件在mount状态关闭库后会发生变化,当前的控制文件和备份的控制文件不一致。
SQL> recover database using backup controlfile;
ORA-00279: change 261584 generated at 05/20/2012 21:51:06 needed for thread 1
ORA-00289: suggestion : /u01/app/archivelog/1_9_783811587.dbf
ORA-00280: change 261584 for thread 1 is in sequence #9
ORA-00279: change 261584 generated at 05/20/2012 21:51:06 needed for thread 1
ORA-00289: suggestion : /u01/app/archivelog/1_9_783811587.dbf
ORA-00280: change 261584 for thread 1 is in sequence #9
Specify log: {=suggested | filename | AUTO | CANCEL}
auto
ORA-00308: cannot open archived log '/u01/app/archivelog/1_9_783811587.dbf'
ORA-27037: unable to obtain file status
Linux Error: 2: No such file or directory
Additional information: 3
ORA-00308: cannot open archived log '/u01/app/archivelog/1_9_783811587.dbf'
ORA-27037: unable to obtain file status
Linux Error: 2: No such file or directory
Additional information: 3
SQL> alter database open resetlogs;
Database altered.
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/23062014/viewspace-733254/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/23062014/viewspace-733254/