ITPub博客

首页 > 数据库 > Oracle > 利用存储级的复制技术将一个ASM数据库快速clone到目标环境

利用存储级的复制技术将一个ASM数据库快速clone到目标环境

原创 Oracle 作者:oliseh 时间:2015-07-22 20:44:03 0 删除 编辑

生产库是建在ASM上的两节点RAC,测试库是单节点的安装了Oracle restart,版本和生产一样同为11.2.0.3
现使用存储级的复制软件将生产库的所有DG拷贝到测试库所在的磁阵,以快速构建出一个测试环境
以下记录了存储复制完成后,测试库搭建的全过程:

如果我们安装Oracle Restart环境时选择的是"Install Oracle Grid Infrastructure for a Standalone software only",那么安装完后还要进行如下配置,如果已经配置好了ASM那么直接进入"2、启动ASM实例,Mount磁盘组"

/////////////////

// 1、oracle restart安装后的配置
///////////////// 

###root用户执行,其中ORACLE_HOME是grid用户下的变量

export DISPLAY=10.10.176.140:0.0
export ORACLE_HOME=/oracle/app/grid
$ORACLE_HOME/perl/bin/perl -I $ORACLE_HOME/perl/lib -I $ORACLE_HOME/crs/install $ORACLE_HOME/crs/install/roothas.pl

Using configuration parameter file: /oracle/app/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 qc26702a successfully pinned.
Adding Clusterware entries to inittab

qc26702a     2015/07/22 16:35:26     /oracle/app/grid/cdata/qc26702a/backup_20150722_163526.olr
Successfully configured Oracle Grid Infrastructure for a Standalone Server


###可以看到基础资源已经注册到了oracle restart环境

grid@qc26702a:/home/grid>crsctl status res -t
--------------------------------------------------------------------------------
NAME           TARGET  STATE        SERVER                   STATE_DETAILS      
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.ons
               OFFLINE OFFLINE      qc26702a                                    
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.cssd
      1        OFFLINE OFFLINE                                                  
ora.diskmon
      1        OFFLINE OFFLINE                                                  
ora.evmd
      1        ONLINE  ONLINE       qc26702a 
     
###继续进行配置,这步主要是更新oracle Inventory,以Grid用户执行
su - grid
export DISPLAY=10.10.176.140:0.0  
$ORACLE_HOME/oui/bin/runInstaller -updateNodeList ORACLE_HOME=$ORACLE_HOME -defaultHomeName CLUSTER_NODES= CRS=TRUE     
Starting Oracle Universal Installer...

Starting Oracle Universal Installer...

Checking swap space: must be greater than 500 MB.   Actual 16384 MB    Passed
The inventory pointer is located at /etc/oraInst.loc
The inventory is located at /oracle/app/oraInventory
'UpdateNodeList' was successful.

###使用asmca配置ASM实例,并启动ASM instance
创建过程中必须指定一块盘创建dg用于存放spfile,注意这块磁盘不能是BCV的目标磁盘,否则下次同步时信息会丢失


###ASM实例创建后检查ora.SPDG.dg(包含spfile的diskgroup)、ora.asm、ora.cssd、ora.evmd四个资源应该处于online

grid@qc26702a:/home/grid>crsctl status res -t
--------------------------------------------------------------------------------
NAME           TARGET  STATE        SERVER                   STATE_DETAILS      
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.SPDG.dg
               ONLINE  ONLINE       qc26702a                                       
ora.asm
               ONLINE  ONLINE       qc26702a                 Started            
ora.ons
               OFFLINE OFFLINE      qc26702a                                    
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.cssd
      1        ONLINE  ONLINE       qc26702a                                    
ora.diskmon
      1        OFFLINE OFFLINE                                                  
ora.evmd
      1        ONLINE  ONLINE       qc26702a
     
/////////////////
// 2、启动ASM实例,Mount磁盘组
/////////////////    
  

###连接ASM实例,使用asmcmd的lsdg命令能看到刚才创建的存放spfile的DG
grid@qc26702a:/home/grid>export ORACLE_SID=+ASM
grid@qc26702a:/home/grid>asmcmd
ASMCMD> lsdg
State    Type    Rebal  Sector  Block       AU  Total_MB  Free_MB  Req_mir_free_MB  Usable_file_MB  Offline_disks  Voting_files  Name
MOUNTED  EXTERN  N         512   4096  1048576     46477    46418                0           46418              0             N  SPDG/

###调整ASM初始化参数重启ASM instance
alter system set asm_diskstring='/dev/rhdiskpower*' scope=both;

srvctl stop asm -o immediate
srvctl start asm    
     
###修改磁盘权限
chown oracle:dba /dev/rhdiskpower*
chmod 660 /dev/rhdiskpower*


###使用kfod确认这磁盘信息都能被oracle或者grid用户准确读到

grid@qc26702a:/home/grid>kfod asm_diskstring='/dev/rhdiskpower*' disks=all
--------------------------------------------------------------------------------
 Disk          Size Path                                     User     Group  
================================================================================
   1:      46477 Mb /dev/rhdiskpower0                        oracle   dba    
   2:      46477 Mb /dev/rhdiskpower1                        oracle   dba    
   3:      46477 Mb /dev/rhdiskpower10                       oracle   dba    
   4:      46477 Mb /dev/rhdiskpower11                       oracle   dba    
   5:      46477 Mb /dev/rhdiskpower12                       oracle   dba    
   6:      46477 Mb /dev/rhdiskpower13                       oracle   dba    
   7:      46477 Mb /dev/rhdiskpower14                       oracle   dba    
   8:      46477 Mb /dev/rhdiskpower15                       oracle   dba    
   9:      46477 Mb /dev/rhdiskpower16                       oracle   dba    
  10:      46477 Mb /dev/rhdiskpower17                       oracle   dba    
  11:      46477 Mb /dev/rhdiskpower18                       oracle   dba    
  12:      46477 Mb /dev/rhdiskpower19                       oracle   dba    
  13:      46477 Mb /dev/rhdiskpower2                        oracle   dba    
  14:      46477 Mb /dev/rhdiskpower20                       oracle   dba    
  15:      46477 Mb /dev/rhdiskpower21                       oracle   dba    
  16:      46477 Mb /dev/rhdiskpower22                       oracle   dba    
  17:      46477 Mb /dev/rhdiskpower23                       oracle   dba    
  18:      46477 Mb /dev/rhdiskpower24                       oracle   dba    
  19:      46477 Mb /dev/rhdiskpower25                       oracle   dba    
  20:      46477 Mb /dev/rhdiskpower26                       oracle   dba    
  21:      46477 Mb /dev/rhdiskpower27                       oracle   dba    
  22:      46477 Mb /dev/rhdiskpower28                       oracle   dba    
  23:      46477 Mb /dev/rhdiskpower29                       oracle   dba    
  24:      46477 Mb /dev/rhdiskpower3                        oracle   dba    
  25:      46477 Mb /dev/rhdiskpower30                       oracle   dba    
  26:      46477 Mb /dev/rhdiskpower31                       oracle   dba    
  27:      46477 Mb /dev/rhdiskpower32                       oracle   dba    
  28:      46477 Mb /dev/rhdiskpower33                       oracle   dba    
  29:      46477 Mb /dev/rhdiskpower34                       oracle   dba    
  30:      46477 Mb /dev/rhdiskpower35                       oracle   dba    
  31:      46477 Mb /dev/rhdiskpower36                       oracle   dba    
  32:      46477 Mb /dev/rhdiskpower37                       oracle   dba    
  33:      46477 Mb /dev/rhdiskpower38                       oracle   dba    
  34:      46477 Mb /dev/rhdiskpower39                       oracle   dba    
  35:      46477 Mb /dev/rhdiskpower4                        oracle   dba    
  36:      46477 Mb /dev/rhdiskpower40                       oracle   dba    
  37:      46477 Mb /dev/rhdiskpower41                       oracle   dba    
  38:      46477 Mb /dev/rhdiskpower42                       oracle   dba    
  39:      46477 Mb /dev/rhdiskpower43                       oracle   dba    
  40:      46477 Mb /dev/rhdiskpower5                        oracle   dba    
  41:      46477 Mb /dev/rhdiskpower6                        oracle   dba    
  42:      46477 Mb /dev/rhdiskpower7                        oracle   dba    
  43:      46477 Mb /dev/rhdiskpower8                        oracle   dba    
  44:      46477 Mb /dev/rhdiskpower9                        oracle   dba    
--------------------------------------------------------------------------------
ORACLE_SID ORACLE_HOME                                                         
================================================================================
      +ASM /oracle/app/grid           
                                        

###连接ASM instance,mount diskgroup
export ORACLE_SID=+ASM
sqlplus '/as sysasm'
alter diskgroup AJXDG1 mount;
alter diskgroup AJXDG2 mount;

注:dg名称可以通过kfed命令得到:
grid@qc26702a:/home/grid>kfed read /dev/rhdiskpower21 | grep grpname
kfdhdb.grpname:                  AJXDG1 ; 0x048: length=6


###检查diskgroup & disk状态

set linesize 200 pagesize 80
column path format a45
column name format a20
column failgroup format a15
select group_number, disk_number, mount_status, header_status, state, failgroup, name, path from v$asm_disk_stat;
GROUP_NUMBER DISK_NUMBER MOUNT_S HEADER_STATU STATE    FAILGROUP       NAME                 PATH
------------ ----------- ------- ------------ -------- --------------- -------------------- ---------------------------------------------
           1           0 CACHED  MEMBER       NORMAL   SPDG_0000       SPDG_0000            /dev/rhdiskpower0
           2           0 CACHED  MEMBER       NORMAL   AJXDG1_0000     AJXDG1_0000          /dev/rhdiskpower12
           2           1 CACHED  MEMBER       NORMAL   AJXDG1_0001     AJXDG1_0001          /dev/rhdiskpower13
           2           2 CACHED  MEMBER       NORMAL   AJXDG1_0002     AJXDG1_0002          /dev/rhdiskpower14
           2           3 CACHED  MEMBER       NORMAL   AJXDG1_0003     AJXDG1_0003          /dev/rhdiskpower15
           2           4 CACHED  MEMBER       NORMAL   AJXDG1_0004     AJXDG1_0004          /dev/rhdiskpower16
           2           5 CACHED  MEMBER       NORMAL   AJXDG1_0005     AJXDG1_0005          /dev/rhdiskpower17
           2           6 CACHED  MEMBER       NORMAL   AJXDG1_0006     AJXDG1_0006          /dev/rhdiskpower18
           2           7 CACHED  MEMBER       NORMAL   AJXDG1_0007     AJXDG1_0007          /dev/rhdiskpower19
           2           8 CACHED  MEMBER       NORMAL   AJXDG1_0008     AJXDG1_0008          /dev/rhdiskpower20
           2           9 CACHED  MEMBER       NORMAL   AJXDG1_0009     AJXDG1_0009          /dev/rhdiskpower21
           2          10 CACHED  MEMBER       NORMAL   AJXDG1_0010     AJXDG1_0010          /dev/rhdiskpower22
           2          11 CACHED  MEMBER       NORMAL   AJXDG1_0011     AJXDG1_0011          /dev/rhdiskpower23
           2          12 CACHED  MEMBER       NORMAL   AJXDG1_0012     AJXDG1_0012          /dev/rhdiskpower24
           2          13 CACHED  MEMBER       NORMAL   AJXDG1_0013     AJXDG1_0013          /dev/rhdiskpower25
           2          14 CACHED  MEMBER       NORMAL   AJXDG1_0014     AJXDG1_0014          /dev/rhdiskpower26
           2          15 CACHED  MEMBER       NORMAL   AJXDG1_0015     AJXDG1_0015          /dev/rhdiskpower27
           3           0 CACHED  MEMBER       NORMAL   AJXDG2_0000     AJXDG2_0000          /dev/rhdiskpower28
           3           1 CACHED  MEMBER       NORMAL   AJXDG2_0001     AJXDG2_0001          /dev/rhdiskpower29
           3           2 CACHED  MEMBER       NORMAL   AJXDG2_0002     AJXDG2_0002          /dev/rhdiskpower30
           3           3 CACHED  MEMBER       NORMAL   AJXDG2_0003     AJXDG2_0003          /dev/rhdiskpower31
           3           4 CACHED  MEMBER       NORMAL   AJXDG2_0004     AJXDG2_0004          /dev/rhdiskpower32
           3           5 CACHED  MEMBER       NORMAL   AJXDG2_0005     AJXDG2_0005          /dev/rhdiskpower33
           3           6 CACHED  MEMBER       NORMAL   AJXDG2_0006     AJXDG2_0006          /dev/rhdiskpower34
           3           7 CACHED  MEMBER       NORMAL   AJXDG2_0007     AJXDG2_0007          /dev/rhdiskpower35
           3           8 CACHED  MEMBER       NORMAL   AJXDG2_0008     AJXDG2_0008          /dev/rhdiskpower36
           3           9 CACHED  MEMBER       NORMAL   AJXDG2_0009     AJXDG2_0009          /dev/rhdiskpower37
           3          10 CACHED  MEMBER       NORMAL   AJXDG2_0010     AJXDG2_0010          /dev/rhdiskpower38
           3          11 CACHED  MEMBER       NORMAL   AJXDG2_0011     AJXDG2_0011          /dev/rhdiskpower39
           3          12 CACHED  MEMBER       NORMAL   AJXDG2_0012     AJXDG2_0012          /dev/rhdiskpower40
           3          13 CACHED  MEMBER       NORMAL   AJXDG2_0013     AJXDG2_0013          /dev/rhdiskpower41
           3          14 CACHED  MEMBER       NORMAL   AJXDG2_0014     AJXDG2_0014          /dev/rhdiskpower42
           3          15 CACHED  MEMBER       NORMAL   AJXDG2_0015     AJXDG2_0015          /dev/rhdiskpower43

SQL> select group_number, name, state, type, total_mb, free_mb from v$asm_diskgroup_stat;

GROUP_NUMBER NAME                 STATE       TYPE     TOTAL_MB    FREE_MB
------------ -------------------- ----------- ------ ---------- ----------
           1 SPDG                 MOUNTED     EXTERN      46477      46418
           2 AJXDG1               MOUNTED     EXTERN     743632     350106
           3 AJXDG2               MOUNTED     EXTERN     743632     354227
          
###检查CRS资源组状态
crsctl status res -t
--------------------------------------------------------------------------------
NAME           TARGET  STATE        SERVER                   STATE_DETAILS      
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.AJXDG1.dg
               ONLINE  ONLINE       qc26702a                                    
ora.AJXDG2.dg
               ONLINE  ONLINE       qc26702a                                    
ora.SPDG.dg
               ONLINE  ONLINE       qc26702a                                    
ora.asm
               ONLINE  ONLINE       qc26702a                 Started            
ora.ons
               OFFLINE OFFLINE      qc26702a                                    
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.cssd
      1        ONLINE  ONLINE       qc26702a                                    
ora.diskmon
      1        OFFLINE OFFLINE                                                  
ora.evmd
      1        ONLINE  ONLINE       qc26702a    
 

/////////////////
// 3、启动数据库实例
/////////////////
###将参数文件创建到dg的spfile
***initajxbcv1.ora内容
sga_target=500M
db_block_size=8192
db_name=shajx
instance_name=ajxbcv1
control_files='+AJXDG1/sys/control01.ctl','+AJXDG2/sys/control02.ctl'
cluster_database=FALSE

***create spfile from pfile
sqlplus '/as sysdba'
startup mount;
create spfile='+SPDG' from pfile='$ORACLE_HOME/dbs/initajxbcv1.ora'


###找到spfile的存放路径,将此路径放到初始化参数文件

ASMCMD> pwd
+spdg/SHAJX/PARAMETERFILE
ASMCMD> ls -l
Type           Redund  Striped  Time             Sys  Name
PARAMETERFILE  UNPROT  COARSE   JUL 22 19:00:00  Y    spfile.257.885757443

###初始化参数文件initajxbcv1.ora调整为只包含如下内容
spfile='+spdg/SHAJX/PARAMETERFILE/spfile.257.885757443'


###将数据库资源添加到oracle restart环境,启动数据库

srvctl add database -d shajx -o $ORACLE_HOME -i ajxbcv1 

srvctl start database -d shajx

###检查db资源已经online
grid@qc26702a:/home/grid>crsctl status res -t
--------------------------------------------------------------------------------
NAME           TARGET  STATE        SERVER                   STATE_DETAILS      
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.AJXDG1.dg
               ONLINE  ONLINE       qc26702a                                    
ora.AJXDG2.dg
               ONLINE  ONLINE       qc26702a                                    
ora.SPDG.dg
               ONLINE  ONLINE       qc26702a                                    
ora.asm
               ONLINE  ONLINE       qc26702a                 Started            
ora.ons
               OFFLINE OFFLINE      qc26702a                                    
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.cssd
      1        ONLINE  ONLINE       qc26702a                                    
ora.diskmon
      1        OFFLINE OFFLINE                                                  
ora.evmd
      1        ONLINE  ONLINE       qc26702a                                    
ora.shajx.db
      1        ONLINE  ONLINE       qc26702a                 Open               

 

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

请登录后发表评论 登录
全部评论
不仅仅专注Oracle database技术, member of SHOUG

注册时间:2014-04-06

  • 博文量
    128
  • 访问量
    1616865