这篇文章介绍了如何在一个已经安装12c rac的虚拟机上,如何建立acfs文件系统,并且利用acfs snapshot刷一个COW(Copy-On-Write)库出来做测试库。
Highlight Step:
一、给虚拟机增加asm盘,以便建立acfs文件系统
二、创建acfs文件系统
三、在节点1创建数据库在acfs文件系统上。(12c支持数据文件,控制文件,日志文件等数据库的文件放在acfs上。参考Doc ID 1369107.1中ACFS Advanced Features Platform Availability – Minimum Version)
四、在节点1上运行dml的同时,生成snapshot
五、利用上面生成的snapshot,在节点2上拉起来另外一个数据库。
一、给虚拟机增加asm盘,以便建立acfs文件系统
1.创建共享acfs盘,共3个盘,每个盘3G大小:
VBoxManage createhd --filename asm_acfs_3g_01.vdi --size 3072 --format VDI --variant Fixed
VBoxManage createhd --filename asm_acfs_3g_02.vdi --size 3072 --format VDI --variant Fixed
VBoxManage createhd --filename asm_acfs_3g_03.vdi --size 3072 --format VDI --variant Fixed
2.将创建的asm盘attach到虚拟机ol6-121-rac1上
VBoxManage storageattach ol6-121-rac1 --storagectl "SATA" --port 5 --device 0 --type hdd --medium asm_acfs_3g_01.vdi --mtype shareable
VBoxManage storageattach ol6-121-rac1 --storagectl "SATA" --port 6 --device 0 --type hdd --medium asm_acfs_3g_02.vdi --mtype shareable
VBoxManage storageattach ol6-121-rac1 --storagectl "SATA" --port 7 --device 0 --type hdd --medium asm_acfs_3g_03.vdi --mtype shareable
VBoxManage storageattach ol6-121-rac2 --storagectl "SATA" --port 5 --device 0 --type hdd --medium asm_acfs_3g_01.vdi --mtype shareable
VBoxManage storageattach ol6-121-rac2 --storagectl "SATA" --port 6 --device 0 --type hdd --medium asm_acfs_3g_02.vdi --mtype shareable
VBoxManage storageattach ol6-121-rac2 --storagectl "SATA" --port 7 --device 0 --type hdd --medium asm_acfs_3g_03.vdi --mtype shareable
3.将这些共享盘设置为可共享的:
VBoxManage modifyhd asm_acfs_3g_01.vdi --type shareable
VBoxManage modifyhd asm_acfs_3g_02.vdi --type shareable
VBoxManage modifyhd asm_acfs_3g_03.vdi --type shareable
4.进linux系统,为新加的盘进行分区
fdisk /dev/sd<n> --> n -->p -->1-->1-->w
如:
fdisk /dev/sdf --> n -->p -->1-->1-->w
fdisk /dev/sdg --> n -->p -->1-->1-->w
fdisk /dev/sdh --> n -->p -->1-->1-->w
5. 本文用到是udev的方式使用asm盘,没有使用asmlib。
/sbin/scsi_id -g -u -d /dev/sdf
/sbin/scsi_id -g -u -d /dev/sdg
/sbin/scsi_id -g -u -d /dev/sdh
如:
[root@ol6-121-rac1 dev]# /sbin/scsi_id -g -u -d /dev/sdf
1ATA_VBOX_HARDDISK_VBa36c3c6c-9da6bb20
[root@ol6-121-rac1 dev]# /sbin/scsi_id -g -u -d /dev/sdg
1ATA_VBOX_HARDDISK_VBcb790f45-de2f86fb
[root@ol6-121-rac1 dev]# /sbin/scsi_id -g -u -d /dev/sdh
1ATA_VBOX_HARDDISK_VB4489ed5a-e05a9613
[root@ol6-121-rac1 dev]#
6.获得上面的信息后,在两个节点的/etc/udev/rules.d/99-oracle-asmdevices.rules文件中,添加如下几行:
KERNEL=="sd?1", BUS=="scsi", PROGRAM=="/sbin/scsi_id -g -u -d /dev/$parent", RESULT=="1ATA_VBOX_HARDDISK_VBa36c3c6c-9da6bb20", NAME="asm_acfs_3g_01", OWNER="oracle", GROUP="dba", MODE="0660
KERNEL=="sd?1", BUS=="scsi", PROGRAM=="/sbin/scsi_id -g -u -d /dev/$parent", RESULT=="1ATA_VBOX_HARDDISK_VBcb790f45-de2f86fb", NAME="asm_acfs_3g_02", OWNER="oracle", GROUP="dba", MODE="0660
KERNEL=="sd?1", BUS=="scsi", PROGRAM=="/sbin/scsi_id -g -u -d /dev/$parent", RESULT=="1ATA_VBOX_HARDDISK_VB4489ed5a-e05a9613", NAME="asm_acfs_3g_03", OWNER="oracle", GROUP="dba", MODE="0660
7.重启两个节点的udev服务,或者直接重启两个节点:
crsctl stop crs
/sbin/udevadm control --reload-rules
/sbin/start_udev
二、创建acfs文件系统
8. 在两个节点,创建acfs文件系统的mount point
[root@ol6-121-rac1 ~]# mkdir -p /mnt/acfs
[root@ol6-121-rac1 ~]# chown oracle:oinstall /mnt/acfs
[root@ol6-121-rac2 ~]# mkdir -p /mnt/acfs
[root@ol6-121-rac2 ~]# chown oracle:oinstall /mnt/acfs
9. 先检查可以用于新建diskgroup的disk
SQL> select path, name, header_status, os_mb from v$asm_disk;
PATH NAME HEADER_STATU OS_MB
------------------------------ ------------------------------ ------------ ----------
/dev/asm_acfs_3g_03 CANDIDATE 3067
/dev/asm_acfs_3g_01 CANDIDATE 3067
/dev/asm_acfs_3g_02 CANDIDATE 3067
/dev/asm-disk1 DATA_0000 MEMBER 5114
/dev/asm-disk2 DATA_0001 MEMBER 5114
/dev/asm-disk3 DATA_0002 MEMBER 5114
/dev/asm-disk4 DATA_0003 MEMBER 5114
7 rows selected.
10. 新建diskgroup DG_ACFS
SQL> CREATE DISKGROUP DG_ACFS EXTERNAL REDUNDANCY DISK
2 '/dev/asm_acfs_3g_01' SIZE 3000M,
3 '/dev/asm_acfs_3g_02' size 3000M,
4 '/dev/asm_acfs_3g_03' size 3000M
5 ATTRIBUTE 'compatible.asm' = '12.1.0.0.0';
Diskgroup created.
SQL>
11. 设置compatible为12.1以上
SQL> alter diskgroup DG_ACFS set attribute 'compatible.advm'='12.1.0.0.0';
Diskgroup altered.
也可以:
ASMCMD> setattr -G DG_ACFS compatible.advm 12.1.0.0.0
12. 建立volumns
SQL> alter diskgroup DG_ACFS add volume VOL1 size 8000M;
Diskgroup altered.
也可以:
ASMCMD> volcreate -G DG_ACFS -s 8000M --column 1 VOL1
13. 检查设备名称:
SQL> select volume_name,volume_device from v$asm_volume
2 /
VOLUME_NAME VOLUME_DEVICE
------------------------------ ----------------------------------------
VOL1 /dev/asm/vol1-28 <<<<<<设备名称,下一步mkfs时会用
SQL>
也可以
ASMCMD> volinfo -G DG_ACFS VOL1
Diskgroup Name: DG_ACFS
Volume Name: VOL1
Volume Device: /dev/asm/vol1-28 <<<<<<设备名称,下一步mkfs时会用
State: ENABLED
Size (MB): 8000
Resize Unit (MB): 32
Redundancy: UNPROT
Stripe Columns: 4
Stripe Width (K): 128
Usage:
Mountpath:
ASMCMD>
14. 建立文件系统:
[root@ol6-121-rac1 ~]# mkfs -t acfs /dev/asm/vol1-28
mkfs.acfs: version = 12.1.0.1.0
mkfs.acfs: on-disk version = 39.0
mkfs.acfs: volume = /dev/asm/vol1-28
mkfs.acfs: volume size = 8388608000
mkfs.acfs: Format complete.
[root@ol6-121-rac1 ~]#
15. 将acfs文件系统注册到crs:
[root@ol6-121-rac1 ~]# acfsutil registry -a /dev/asm/vol1-28 /mnt/acfs
acfsutil registry: mount point /mnt/acfs successfully added to Oracle Registry
[root@ol6-121-rac1 ~]#
或者:
[root@ol6-121-rac1 ~]# srvctl add filesystem -m /mnt/acfs -d /dev/asm/vol1-28
16. 将acfs文件系统mount到mount point上:
[root@ol6-121-rac1 ~]# df -k
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/mapper/vg_ol6121rac1-lv_root
28423176 16096244 10883092 60% /
tmpfs 2560000 2038752 521248 80% /dev/shm
/dev/sda1 495844 56258 413986 12% /boot
[root@ol6-121-rac1 ~]#
[root@ol6-121-rac1 ~]# mount -t acfs /dev/asm/vol1-28 /mnt/acfs
[root@ol6-121-rac1 ~]#
[root@ol6-121-rac1 ~]# df -k
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/mapper/vg_ol6121rac1-lv_root
28423176 16096324 10883012 60% /
tmpfs 2560000 2038752 521248 80% /dev/shm
/dev/sda1 495844 56258 413986 12% /boot
/dev/asm/vol1-190 9117696 57360 9060336 1% /mnt/acfs
[root@ol6-121-rac1 ~]#
17. 检查状态:
[root@ol6-121-rac1 ~]# srvctl config filesystem -d /dev/asm/vol1-28
Volume device: /dev/asm/vol1-190
Canonical volume device: /dev/asm/vol1-190
Mountpoint path: /mnt/acfs
User:
Type: ACFS
Mount options:
Description:
Nodes:
Server pools:
Application ID:
ACFS file system is enabled
[root@ol6-121-rac1 ~]#
[root@ol6-121-rac1 ~]# srvctl status filesystem -d /dev/asm/vol1-28
ACFS file system /mnt/acfs is mounted on nodes ol6-121-rac1,ol6-121-rac2
[root@ol6-121-rac1 ~]#
三、在节点1创建数据库在acfs文件系统上。
18. 使用dbca创建一个数据库到acfs文件系统上。注意,storage type的类型要选择file system,并且选择上面建立的mount point处。
具体步骤略。
19. 检查创建好的db,我们这里测试用的db实例名叫acfsdb:
--------------------------------------------------------------------------------
Name Target State Server State details
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.ASMNET1LSNR_ASM.lsnr
ONLINE ONLINE ol6-121-rac1 STABLE
ONLINE ONLINE ol6-121-rac2 STABLE
ora.DATA.dg
ONLINE ONLINE ol6-121-rac1 STABLE
ONLINE ONLINE ol6-121-rac2 STABLE
ora.DG_ACFS.VOL1.advm
ONLINE ONLINE ol6-121-rac1 Volume device /dev/a
sm/vol1-28 is online
,STABLE
ONLINE ONLINE ol6-121-rac2 Volume device /dev/a
sm/vol1-28 is online
,STABLE
ora.DG_ACFS.dg
ONLINE ONLINE ol6-121-rac1 STABLE
ONLINE ONLINE ol6-121-rac2 STABLE
ora.LISTENER.lsnr
ONLINE ONLINE ol6-121-rac1 STABLE
ONLINE ONLINE ol6-121-rac2 STABLE
ora.dg_acfs.vol1.acfs
ONLINE ONLINE ol6-121-rac1 mounted on /mnt/acfs
,STABLE
ONLINE ONLINE ol6-121-rac2 mounted on /mnt/acfs
,STABLE
ora.net1.network
ONLINE ONLINE ol6-121-rac1 STABLE
ONLINE ONLINE ol6-121-rac2 STABLE
ora.ons
ONLINE ONLINE ol6-121-rac1 STABLE
ONLINE ONLINE ol6-121-rac2 STABLE
ora.proxy_advm
ONLINE ONLINE ol6-121-rac1 STABLE
ONLINE ONLINE ol6-121-rac2 STABLE
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.LISTENER_SCAN1.lsnr
1 ONLINE ONLINE ol6-121-rac2 STABLE
ora.LISTENER_SCAN2.lsnr
1 ONLINE ONLINE ol6-121-rac1 STABLE
ora.LISTENER_SCAN3.lsnr
1 ONLINE ONLINE ol6-121-rac1 STABLE
ora.acfsdb.db
1 ONLINE ONLINE ol6-121-rac1 Open,STABLE
ora.asm
1 ONLINE ONLINE ol6-121-rac1 STABLE
2 ONLINE ONLINE ol6-121-rac2 STABLE
3 OFFLINE OFFLINE STABLE
ora.cdbrac.db
1 OFFLINE OFFLINE Instance Shutdown,ST
ABLE
2 OFFLINE OFFLINE Instance Shutdown,ST
ABLE
ora.cvu
1 ONLINE ONLINE ol6-121-rac1 STABLE
ora.gns
1 ONLINE ONLINE ol6-121-rac1 STABLE
ora.gns.vip
1 ONLINE ONLINE ol6-121-rac1 STABLE
ora.oc4j
1 OFFLINE OFFLINE STABLE
ora.ol6-121-rac1.vip
1 ONLINE ONLINE ol6-121-rac1 STABLE
ora.ol6-121-rac2.vip
1 ONLINE ONLINE ol6-121-rac2 STABLE
ora.scan1.vip
1 ONLINE ONLINE ol6-121-rac2 STABLE
ora.scan2.vip
1 ONLINE ONLINE ol6-121-rac1 STABLE
ora.scan3.vip
1 ONLINE ONLINE ol6-121-rac1 STABLE
--------------------------------------------------------------------------------
[oracle@ol6-121-rac1 ~]$ srvctl config database -d acfsdb
Database unique name: acfsdb
Database name: acfsdb
Oracle home: /u01/app/oracle/product/12.1.0.1/db_1
Oracle user: oracle
Spfile: /u01/app/oracle/product/12.1.0.1/db_1/dbs/spfileacfsdb.ora
Password file:
Domain:
Start options: open
Stop options: immediate
Database role: PRIMARY
Management policy: AUTOMATIC
Server pools: acfsdb
Database instance: acfsdb
Disk Groups:
Mount point paths:
Services:
Type: SINGLE
Database is administrator managed
SQL> select file_name from dba_data_files;
FILE_NAME
--------------------------------------------------------------------------------
/mnt/acfs/oradata/acfsdb/system01.dbf
/mnt/acfs/oradata/acfsdb/sysaux01.dbf
/mnt/acfs/oradata/acfsdb/undotbs01.dbf
/mnt/acfs/oradata/acfsdb/users01.dbf
SQL>
SQL> select name from v$controlfile;
NAME
--------------------------------------------------------------------------------
/mnt/acfs/oradata/acfsdb/control01.ctl
/mnt/acfs/oradata/acfsdb/control02.ctl
SQL>
SQL>
SQL>
SQL> select member from v$logfile;
MEMBER
--------------------------------------------------------------------------------
/mnt/acfs/oradata/acfsdb/redo01.log
/mnt/acfs/oradata/acfsdb/redo02.log
/mnt/acfs/oradata/acfsdb/redo03.log
SQL> select file_name from dba_temp_files;
FILE_NAME
--------------------------------------------------------------------------------
/mnt/acfs/oradata/acfsdb/temp01.dbf
SQL>
四、在节点1上运行dml的同时,生成snapshot
20. 我们创建snapshot的命令是用acfsutil,我们先来看看当前是没有snapshot的:
[oracle@ol6-121-rac1 logs]$ acfsutil snap info /mnt/acfs
number of snapshots: 0
snapshot space usage: 0
[oracle@ol6-121-rac1 logs]$
21. 我们先来试试创建一个只读(Read-Only, RO)的snapshot:
[oracle@ol6-121-rac1 logs]$ date
Wed Feb 24 22:40:34 CST 2016
[oracle@ol6-121-rac1 logs]$ acfsutil snap create asfsdb_snap01 /mnt/acfs
acfsutil snap create: Snapshot operation is complete.
[oracle@ol6-121-rac1 logs]$ date
Wed Feb 24 22:40:40 CST 2016
[oracle@ol6-121-rac1 logs]$ acfsutil snap info /mnt/acfs
snapshot name: asfsdb_snap01
RO snapshot or RW snapshot: RO <<<<<<<<注意这里,类似是RO,即只读。
parent name: /mnt/acfs
snapshot creation time: Wed Feb 24 22:40:36 2016
number of snapshots: 1
snapshot space usage: 122757120
[oracle@ol6-121-rac1 logs]$
22. 注意,上述的snapshot的文件,就建立在了你的mount point下有个隐含目录 .ACFS 下:
[root@ol6-121-rac1 acfsdb]# cd /mnt/acfs/.ACFS/snaps/asfsdb_snap01/oradata/acfsdb
[root@ol6-121-rac1 acfsdb]# ls -al
total 1714424
drwxr-x---. 2 oracle oinstall 8192 Feb 24 21:27 .
drwxr-x---. 3 oracle oinstall 8192 Feb 24 21:25 ..
-rw-r-----. 1 oracle dba 10043392 Feb 24 22:40 control01.ctl
-rw-r-----. 1 oracle dba 10043392 Feb 24 22:40 control02.ctl
-rw-r-----. 1 oracle dba 52429312 Feb 24 22:03 redo01.log
-rw-r-----. 1 oracle dba 52429312 Feb 24 22:40 redo02.log
-rw-r-----. 1 oracle dba 52429312 Feb 24 22:01 redo03.log
-rw-r-----. 1 oracle dba 576724992 Feb 24 22:40 sysaux01.dbf
-rw-r-----. 1 oracle dba 734011392 Feb 24 22:39 system01.dbf
-rw-r-----. 1 oracle dba 20979712 Feb 24 22:40 temp01.dbf
-rw-r-----. 1 oracle dba 241180672 Feb 24 22:39 undotbs01.dbf
-rw-r-----. 1 oracle dba 5251072 Feb 24 22:38 users01.dbf
[root@ol6-121-rac1 acfsdb]#
23. 我们不妨再多建几个snapshot:
[oracle@ol6-121-rac1 ~]$ date
Wed Feb 24 22:52:45 CST 2016
[oracle@ol6-121-rac1 ~]$ acfsutil snap create -w asfsdb_snap02 /mnt/acfs
acfsutil snap create: Snapshot operation is complete.
[oracle@ol6-121-rac1 ~]$ date
Wed Feb 24 22:52:45 CST 2016
[oracle@ol6-121-rac1 ~]$
[oracle@ol6-121-rac1 ~]$ acfsutil snap info /mnt/acfs
snapshot name: asfsdb_snap01
RO snapshot or RW snapshot: RO
parent name: /mnt/acfs
snapshot creation time: Wed Feb 24 22:40:36 2016
snapshot name: asfsdb_snap02
RO snapshot or RW snapshot: RW
parent name: /mnt/acfs
snapshot creation time: Wed Feb 24 22:52:45 2016
number of snapshots: 2
snapshot space usage: 265420800
[oracle@ol6-121-rac1 ~]$
[oracle@ol6-121-rac1 ~]$ date
acfsutil snap create -w asfsdb_snap03 /mnt/acfs
dateThu Feb 25 15:15:08 CST 2016
[oracle@ol6-121-rac1 ~]$ acfsutil snap create -w asfsdb_snap03 /mnt/acfs
acfsutil snap create: Snapshot operation is complete.
[oracle@ol6-121-rac1 ~]$ date
Thu Feb 25 15:15:11 CST 2016
[oracle@ol6-121-rac1 ~]$
[oracle@ol6-121-rac1 ~]$
[oracle@ol6-121-rac1 ~]$
[oracle@ol6-121-rac1 ~]$
[oracle@ol6-121-rac1 ~]$ date
Thu Feb 25 15:15:33 CST 2016
[oracle@ol6-121-rac1 ~]$ acfsutil snap create -w asfsdb_snap04 /mnt/acfs
acfsutil snap create: Snapshot operation is complete.
[oracle@ol6-121-rac1 ~]$ date
Thu Feb 25 15:15:33 CST 2016
[oracle@ol6-121-rac1 ~]$
24. 可以看到已经建立了4个snapshot了。第一个是只读(RO),后面3个是读写(RW)。区别在于,用acfsutil创建的时候,是否加-w参数。否则,不加-w参数默认是只读的。
[oracle@ol6-121-rac1 ~]$ acfsutil snap info /mnt/acfs
snapshot name: asfsdb_snap01
RO snapshot or RW snapshot: RO
parent name: /mnt/acfs
snapshot creation time: Wed Feb 24 22:40:36 2016
snapshot name: asfsdb_snap02
RO snapshot or RW snapshot: RW
parent name: /mnt/acfs
snapshot creation time: Wed Feb 24 22:52:45 2016
snapshot name: asfsdb_snap03
RO snapshot or RW snapshot: RW
parent name: /mnt/acfs
snapshot creation time: Thu Feb 25 15:15:09 2016
snapshot name: asfsdb_snap04
RO snapshot or RW snapshot: RW
parent name: /mnt/acfs
snapshot creation time: Thu Feb 25 15:15:33 2016
number of snapshots: 4
snapshot space usage: 2430095360
[oracle@ol6-121-rac1 ~]$
[oracle@ol6-121-rac1 ~]$ acfsutil info fs /mnt/acfs
/mnt/acfs
ACFS Version: 12.1.0.1.0
flags: MountPoint,Available
mount time: Thu Feb 25 13:37:36 2016
volumes: 1
total size: 8388608000
total free: 3935641600
primary volume: /dev/asm/vol1-28
label:
flags: Primary,Available,ADVM
on-disk version: 43.0
allocation unit: 4096
major, minor: 251, 14337
size: 8388608000
free: 3935641600
ADVM diskgroup DG_ACFS
ADVM resize increment: 33554432
ADVM redundancy: unprotected
ADVM stripe columns: 4
ADVM stripe width: 131072
number of snapshots: 4 <<<<有4个snapshot
snapshot space usage: 2430095360 <<<<<< 4个snapshot,空间才使用2.4G。虽然一套数据文件的大小是1个多G。
replication status: DISABLED
[oracle@ol6-121-rac1 ~]$
ACFS的snapshot功能很强大,不仅可以建立只读,读写,还能把只读和读写之间进行互相convert,另外,还能建立snapshot-of-snapshot,你在acfsutil时加-p参数指定父级snapshot即可。
五、利用上面生成的snapshot,在节点2上拉起来另外一个数据库。
25. 先在节点2上创建一个pfile,可以从节点1拷贝过来,不过有些地方需要修改一下:
[oracle@ol6-121-rac2 dbs]$ cat initacfsdb.ora
*.audit_file_dest='/u01/app/oracle/admin/acfsdb/adump'
*.audit_trail='db'
*.compatible='12.1.0.0.0'
*.control_files='/mnt/acfs/.ACFS/snaps/asfsdb_snap01/oradata/acfsdb/control01.ctl','/mnt/acfs/.ACFS/snaps/asfsdb_snap01/oradata/acfsdb/control02.ctl' <<<<<<<修改这里的路径为snapshot的路径
*.db_block_size=8192
*.db_domain=''
*.db_name='acfsdb'
*.db_unique_name='cowacfs' <<<<<<<这里必须加上db_unique_name,不然由于ocssd进程会检测到存在2个一样的instance,会报错instance_number busy
*.diagnostic_dest='/u01/app/oracle'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=acfsdbXDB)'
#*.local_listener='LISTENER_ACFSDB' <<<<<<修改这里
*.memory_target=1160m
*.open_cursors=300
*.processes=300
*.remote_login_passwordfile='EXCLUSIVE'
*.undo_tablespace='UNDOTBS1'
记住,必须要加db_unique_name,不然,在一个cluster环境,即使你已经srvctl remove来database信息,但是加同样的instance的时候,还是会报错:
SQL> startup nomount
ORA-00304: requested INSTANCE_NUMBER is busy
SQL> exit
必须通过db_unique_name来解决。
26. 此时,应该是用读写(RW)的snapshot来启动的,如果是read only snapshot的话,不能启动到mount,因为文件只读。在alertlog中,你会看到如下报错:
Thu Feb 25 13:44:12 2016
alter database mount
Thu Feb 25 13:44:17 2016
Errors in file /u01/app/oracle/diag/rdbms/cowacfs/acfsdb/trace/acfsdb_ora_11237.trc:
ORA-00206: error in writing (block 1, # blocks 1) of control file
ORA-00202: control file: '/mnt/acfs/.ACFS/snaps/asfsdb_snap01/oradata/acfsdb/control01.ctl'
ORA-27041: unable to open file
Linux-x86_64 Error: 13: Permission denied
Additional information: 3
ORA-221 signalled during: alter database mount...
27. 需要用读写的那个snapshot来启动,我们这边用第四个的snapshot来在节点2上启动:
注,此时pfile中控制文件已经改好成了asfsdb_snap04的那个。
[oracle@ol6-121-rac2 dbs]$ sqlplus "/ as sysdba"
SQL*Plus: Release 12.1.0.1.0 Production on Thu Feb 25 15:18:41 2016
Copyright (c) 1982, 2013, Oracle. All rights reserved.
Connected to an idle instance.
SQL> startup nomount
ORACLE instance started.
Total System Global Area 1219260416 bytes
Fixed Size 2287768 bytes
Variable Size 855639912 bytes
Database Buffers 352321536 bytes
Redo Buffers 9011200 bytes
SQL> alter database mount
2 /
Database altered.
SQL>
28. 启动到mount后,我们将控制文件中的文件路径信息,也改成到acfsdb_snap04路径:
先检查当前路径
SQL> select name from v$datafile
2 union all
3 select name from v$tempfile
4 union all
5 select member from v$logfile;
NAME
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
/mnt/acfs/oradata/acfsdb/system01.dbf
/mnt/acfs/oradata/acfsdb/sysaux01.dbf
/mnt/acfs/oradata/acfsdb/undotbs01.dbf
/mnt/acfs/oradata/acfsdb/users01.dbf
/mnt/acfs/oradata/acfsdb/temp01.dbf
/mnt/acfs/oradata/acfsdb/redo01.log
/mnt/acfs/oradata/acfsdb/redo02.log
/mnt/acfs/oradata/acfsdb/redo03.log
8 rows selected.
生成修改脚本
select distinct 'alter database rename file '||''''||a.name||''''|| ' to '||''''||substr(c.name,1,instr(c.name,'/',-1))|| substr(a.name,instr(a.name,'/',-1)+1)||''';' from v$controlfile c, v$datafile a
union all
select distinct 'alter database rename file '||''''||b.name||''''|| ' to '||''''||substr(c.name,1,instr(c.name,'/',-1))|| substr(b.name,instr(b.name,'/',-1)+1)||''';' from v$controlfile c, v$tempfile b
union all
select distinct 'alter database rename file '||''''||d.member||''''|| ' to '||''''||substr(c.name,1,instr(c.name,'/',-1))|| substr(d.member,instr(d.member,'/',-1)+1)||''';' from v$controlfile c, v$logfile d;
执行上面修改脚本生成的语句:
alter database rename file '/mnt/acfs/oradata/acfsdb/sysaux01.dbf' to '/mnt/acfs/.ACFS/snaps/asfsdb_snap04/oradata/acfsdb/sysaux01.dbf';
alter database rename file '/mnt/acfs/oradata/acfsdb/system01.dbf' to '/mnt/acfs/.ACFS/snaps/asfsdb_snap04/oradata/acfsdb/system01.dbf';
alter database rename file '/mnt/acfs/oradata/acfsdb/undotbs01.dbf' to '/mnt/acfs/.ACFS/snaps/asfsdb_snap04/oradata/acfsdb/undotbs01.dbf';
alter database rename file '/mnt/acfs/oradata/acfsdb/users01.dbf' to '/mnt/acfs/.ACFS/snaps/asfsdb_snap04/oradata/acfsdb/users01.dbf';
alter database rename file '/mnt/acfs/oradata/acfsdb/temp01.dbf' to '/mnt/acfs/.ACFS/snaps/asfsdb_snap04/oradata/acfsdb/temp01.dbf';
alter database rename file '/mnt/acfs/oradata/acfsdb/redo01.log' to '/mnt/acfs/.ACFS/snaps/asfsdb_snap04/oradata/acfsdb/redo01.log';
alter database rename file '/mnt/acfs/oradata/acfsdb/redo02.log' to '/mnt/acfs/.ACFS/snaps/asfsdb_snap04/oradata/acfsdb/redo02.log';
alter database rename file '/mnt/acfs/oradata/acfsdb/redo03.log' to '/mnt/acfs/.ACFS/snaps/asfsdb_snap04/oradata/acfsdb/redo03.log';
Database altered.
SQL>
Database altered.
SQL>
Database altered.
SQL>
Database altered.
SQL>
Database altered.
SQL>
Database altered.
SQL>
Database altered.
SQL>
Database altered.
检查修改后的结果:
SQL> select name from v$datafile
2 union all
3 select name from v$tempfile
4 union all
5 select member from v$logfile;
NAME
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
/mnt/acfs/.ACFS/snaps/asfsdb_snap04/oradata/acfsdb/system01.dbf
/mnt/acfs/.ACFS/snaps/asfsdb_snap04/oradata/acfsdb/sysaux01.dbf
/mnt/acfs/.ACFS/snaps/asfsdb_snap04/oradata/acfsdb/undotbs01.dbf
/mnt/acfs/.ACFS/snaps/asfsdb_snap04/oradata/acfsdb/users01.dbf
/mnt/acfs/.ACFS/snaps/asfsdb_snap04/oradata/acfsdb/temp01.dbf
/mnt/acfs/.ACFS/snaps/asfsdb_snap04/oradata/acfsdb/redo01.log
/mnt/acfs/.ACFS/snaps/asfsdb_snap04/oradata/acfsdb/redo02.log
/mnt/acfs/.ACFS/snaps/asfsdb_snap04/oradata/acfsdb/redo03.log
8 rows selected.
打开数据库:
SQL> alter database open;
Database altered.
SQL>
SQL> select max(to_char(mydate,'yyyy-mm-dd hh24:mi:ss')) from t1;
MAX(TO_CHAR(MYDATE,
-------------------
2016-02-25 15:15:33
SQL>
可以看到,我在一边做snapsnot,一边做dml insert sysdate,恢复出来的t1表的最后记录是15:15:33,也是我的snapshot的创建时间:
snapshot name: asfsdb_snap04
RO snapshot or RW snapshot: RW
parent name: /mnt/acfs
snapshot creation time: Thu Feb 25 15:15:33 2016