分类: Oracle
2017-12-07 17:11:04
RPA,全称RecoverPoint Appliance,是EMC公司推出的基于存储级别的灾难恢复解决方案,可实时复制生产数据,同步到异地的容灾存储中。本文以RHEL 6版本上11gR2为例介绍如果在单实例上通过识别存储启动数据库,整个过程只需要同步数据盘,不需要同步仲裁和CRS磁盘组中的信息。
生产环境:物理服务器 + Redhat 6.5 + Oracle 11.2.0.4 RAC + ASM
灾备环境:VMware虚拟机 + Redhat 6.7 + Oracle 11.2.0.4 单点节 GI
生产库通过udev规则将三块挂载LUN映射为raw设备:
# vi /etc/udev/rules.d/60-raw.rules
ACTION=="add", KERNEL=="emcpowera", RUN+="/bin/raw /dev/raw/raw1 %N"
ACTION=="add", KERNEL=="emcpowerb", RUN+="/bin/raw /dev/raw/raw2 %N"
ACTION=="add", KERNEL=="emcpowerc", RUN+="/bin/raw /dev/raw/raw3 %N"
将三块LUN做成DATA磁盘组:
SQL> select group_number,path,name from v$asm_disk where group_number=1;
GROUP_NUMBER PATH NAME
------------ -------------------- ------------------------------
1 /dev/raw/raw1 DATA_0001
1 /dev/raw/raw2 DATA_0002
1 /dev/raw/raw3 DATA_0003
11g版本的数据库必须使用GI(Grid Infrastructure grid)软件来管理ASM实例,GI一般是用来管理群集(cluster)的,但我们这里仅仅是单实例,所以只需要安装软件,不需要配置cluster。具体环境参数配置及GI安装过程略。
安装完成后,执行脚本配置一个Stand-Alone Server:
[root@RPADB ~]# /grid/app/11.2.0/perl/bin/perl -I/grid/app/11.2.0/perl/lib -I/grid/app/11.2.0/crs/install /grid/app/11.2.0/crs/install/roothas.pl
检查GI状态:
[grid@RPADB ~]$ crs_stat -t
Name Type Target State Host
------------------------------------------------------------
ora.cssd ora.cssd.type ONLINE OFFLINE
ora.diskmon ora....on.type OFFLINE OFFLINE
ora.evmd ora.evm.type ONLINE ONLINE rpadb
ora.ons ora.ons.type OFFLINE OFFLINE
[grid@RPADB ~]$ crs_start -all
CRS-5702: Resource 'ora.evmd' is already running on 'rpadb'
CRS-2501: Resource 'ora.ons' is disabled
Attempting to start `ora.diskmon` on member `rpadb`
Attempting to start `ora.cssd` on member `rpadb`
Start of `ora.diskmon` on member `rpadb` succeeded.
Start of `ora.cssd` on member `rpadb` succeeded.
CRS-0223: Resource 'ora.evmd' has placement error.
CRS-2660: Resource 'ora.ons' or all of its instances are disabled
检查GI结果:
[grid@RPADB ~]$ crs_stat -t
Name Type Target State Host
------------------------------------------------------------
ora.cssd ora.cssd.type ONLINE ONLINE rpadb
ora.diskmon ora....on.type OFFLINE OFFLINE
ora.evmd ora.evm.type ONLINE ONLINE rpadb
ora.ons ora.ons.type OFFLINE OFFLINE
具体安装过程,略。
从主库复制ASM参数文件init+ASM1.ora过来放到$GRID_HOME/dbs目录下,并修改相应目录与RPA环境一致:
+ASM1.asm_diskgroups='DATA'
*.asm_diskstring='/dev/asm*'
*.asm_power_limit=1
*.diagnostic_dest='/u01/grid/app/grid'
*.instance_type='asm'
*.large_pool_size=12M
*.remote_login_passwordfile='EXCLUSIVE'
切换到grid用户,以sysasm身份进入sqlplus,启动到nomont状态:
[grid@RPADB ~]$ sqlplus / as sysasm
SQL> startup nomount;
ASM instance started
Total System Global Area 1135747072 bytes
Fixed Size 2260728 bytes
Variable Size 1108320520 bytes
ASM Cache 25165824 bytes
添加完成后,通过fdisk -l命令查看挂载的LUN:
# fdisk –l | grep sd
Disk /dev/sdb: 537.0 GB, 536952700928 bytes
Disk /dev/sdc: 537.0 GB, 536952700928 bytes
Disk /dev/sdd: 537.0 GB, 536952700928 bytes
注:如果看不到挂载的LUN,可以尝试以下命令进行扫描:
# echo ' - - - ' > /sys/class/scsi_host/host0/scan
# echo ' - - - ' > /sys/class/scsi_host/host1/scan
# echo ' - - - ' > /sys/class/scsi_host/host2/scan
# echo ' - - - ' > /sys/class/scsi_host/host3/scan
查看磁盘组UUID:
# /sbin/scsi_id --whitelisted --replace-whitespace --device=/dev/sdb
3600a0980383030535524452f6e7a5437
# /sbin/scsi_id --whitelisted --replace-whitespace --device=/dev/sdc
3600a0980383030535524452f6e7a5436
# /sbin/scsi_id --whitelisted --replace-whitespace --device=/dev/sdd
3600a0980383030535524452f6e7a5439
配置udev规则:
# cat /etc/udev/rules.d/99-oracle-asmdevices.rules
KERNEL=="sd*",SUBSYSTEM=="block",PROGRAM=="/sbin/scsi_id --whitelisted --replace-whitespace --device=/dev/$name",RESULT=="3600a0980383030535524452f6e7a5437",NAME="asm-disk1",OWNER="grid",GROUP="oinstall",MODE="0660"
KERNEL=="sd*",SUBSYSTEM=="block",PROGRAM=="/sbin/scsi_id --whitelisted --replace-whitespace --device=/dev/$name",RESULT=="3600a0980383030535524452f6e7a5436",NAME="asm-disk2",OWNER="grid",GROUP="oinstall",MODE="0660"
KERNEL=="sd*",SUBSYSTEM=="block",PROGRAM=="/sbin/scsi_id --whitelisted --replace-whitespace --device=/dev/$name",RESULT=="3600a0980383030535524452f6e7a5439",NAME="asm-disk3",OWNER="grid",GROUP="oinstall",MODE="0660"
这里我们不需要与生产环境一一对应,由于磁盘组信息是记录在磁盘头的,只要磁盘信息是一致的,ASM都可以识别得到,无所谓磁盘名称及顺序。
启动udev使规则生效:
# start_udev
Starting udev: [ OK ]
检查结果:
# ls -l /dev/asm*
brw-rw---- 1 grid oinstall 8, 64 Mar 31 23:18 /dev/asm-disk1
brw-rw---- 1 grid oinstall 8, 80 Mar 31 23:18 /dev/asm-disk2
brw-rw---- 1 grid oinstall 8, 96 Mar 31 23:17 /dev/asm-disk3
切换到grid用户,以sysasm身份进入sqlplus:
[grid@dr-rtndb ~]$ sqlplus / as sysasm
SQL> startup force
ASM instance started
Total System Global Area 1135747072 bytes
Fixed Size 2260728 bytes
Variable Size 1108320520 bytes
ASM Cache 25165824 bytes
ASM diskgroups mounted
检查挂载状态:
SQL> select name,state from v$asm_diskgroup;
NAME STATE
------------------------------ -----------
DATA MOUNTED
从主库复制实例参数文件initorcl1.ora到$ORACLE_HOME/dbs目录下,并修改为单实例参数文件(主要去掉相关cluster参数)。然后将实例启动即可:
# su – oracle
$ sqlplus / as sysdba
SQL> startup;
[oracle@RPADB ~]$ lsnrctl start
检查监听状态:
[oracle@RPADB ~]$ lsnrctl status
最后,业务连接并验证数据是否正确。
维持一个数据库启动时的必要信息,除了可以手动编辑的参数文件pfile外,主要的就是控制文件和数据文件,只要能识别到这些,数据库就可以启动起来。这部分文件都存放在ASM磁盘组中,而Oracle ASM管理及识别的灵活性,才使得通过存储层面的容灾得以实现。