基于存储快照快速复制一个Oracle数据库

基于存储快照快速复制一个Oracle数据库

数据库环境:oracle 11g

 

  有时候需要快速复制一个生产库作为测试用途,这个时候可以通过对生产库的存储卷做一个一致性快照,并把快照卷挂给另一台同类型操作系统的服务器来快速的安装实现。这种方式有些地方也叫做快照库。

       以下是实现步骤(快照卷已经映射到服务器):

  1.安装GI 软件(CRS_SWONLY),安装结束再以root权限运行roothas.pl脚本;  

To configure Grid Infrastructure for a Stand-Alone Server run the following command as the root user:
/u01/app/11.2.0/grid/perl/bin/perl -I/u01/app/11.2.0/grid/perl/lib -I/u01/app/11.2.0/grid/crs/install /u01/app/11.2.0/grid/crs/install/roothas.pl


To configure Grid Infrastructure for a Cluster execute the following command:
/u01/app/11.2.0/grid/crs/config/config.sh

root@snapshot_db_srv/u01/app/oraInventory>l/lib -I/u01/app/11.2.0/grid/crs/install /u01/app/11.2.0/grid/crs/install/roothas.pl <
Using configuration parameter file: /u01/app/11.2.0/grid/crs/install/crsconfig_params
Creating trace directory
User ignored Prerequisites during installation
LOCAL ADD MODE
Creating OCR keys for user 'grid', privgrp 'oinstall'..
Operation successful.
LOCAL ONLY MODE
Successfully accumulated necessary OCR keys.
Creating OCR keys for user 'root', privgrp 'system'..
Operation successful.
CRS-4664: Node snapshot_db_srv successfully pinned.
Adding Clusterware entries to inittab

snapshot_db_srv 2021/03/25 14:05:00 /u01/app/11.2.0/grid/cdata/snapshot_db_srv/backup_20210325_140500.olr
Successfully configured Oracle Grid Infrastructure for a Standalone Server

  通过crsctl start has启动GI,通过 crsctl stat res -t 查看状态:

snapshot_db_srv:/home/grid$crsctl stat res -t
--------------------------------------------------------------------------------
NAME           TARGET  STATE        SERVER                   STATE_DETAILS       
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.ons
               OFFLINE OFFLINE      snapshot_db_srv                              
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.cssd
      1        OFFLINE OFFLINE                                                   
ora.diskmon
      1        OFFLINE OFFLINE                                                   
ora.evmd
      1        ONLINE  ONLINE       snapshot_db_srv

 

  2.通过crsctl启动cssd等服务;

snapshot_db_srv:/home/grid$crsctl start resource ora.cssd
CRS-2672: Attempting to start 'ora.cssd' on 'snapshot_db_srv'
CRS-2672: Attempting to start 'ora.diskmon' on 'snapshot_db_srv'
CRS-2676: Start of 'ora.diskmon' on 'snapshot_db_srv' succeeded
CRS-2676: Start of 'ora.cssd' on 'snapshot_db_srv' succeeded

 

  3.添加ASM实例(srvctl add asm);###asm为ASM的SID名称

snapshot_db_srv:/home/grid$srvctl add asm
snapshot_db_srv:/home/grid$crsctl stat res -t
--------------------------------------------------------------------------------
NAME           TARGET  STATE        SERVER                   STATE_DETAILS       
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.asm
               OFFLINE OFFLINE      snapshot_db_srv                              
ora.ons
               OFFLINE OFFLINE      snapshot_db_srv                              
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.cssd
      1        ONLINE  ONLINE       snapshot_db_srv                              
ora.diskmon
      1        OFFLINE OFFLINE                                                   
ora.evmd
      1        ONLINE  ONLINE       snapshot_db_srv             

  再通过crsctl start resource ora.asm启动asm服务,在asm实例中mount磁盘组。

sqlplus / as sysasm

SQL> alter diskgroup crsdg mount;

Diskgroup altered.

SQL> alter diskgroup datadg mount;

Diskgroup altered.

SQL> alter diskgroup fradg mount;

Diskgroup altered.

 

  4.安装database soft only;

  安装完成后,注意检查修改$ORACLE_HOME/bin/oracle权限为6751,属组为asmadmin。

-rwsr-s--x    1 oracle     asmadmin  258650140 Jan 02 1970  oracle

  

  5.在GI中添加listener和database实例;

 

  6.从原数据库备份出pfile文件,修改后放在服务器本地目录,拉起该数据库即可。

   该过程可能需要做recover database;

   同时需要以resetlogs方式打开数据库。即通过alert database open resetlogs打开数据库。

 

  备注:单实例GI需要使用crsctl start/stop has启停GI。

 

  数据更新:

  若是需要更新该测试数据库数据的话,只需要重新快照一份生产库的磁盘卷挂载到快照库服务器替换现在使用的快照卷,执行以上第6步骤拉起即可。非常方便。

 

-- end --

 

       

posted @ 2021-04-22 12:42  曹翼宾的自留地  阅读(426)  评论(0编辑  收藏  举报