利用儲存級的複製技術將一個ASM資料庫快速clone到目標環境

oliseh發表於2015-07-22

生產庫是建在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/,如需轉載,請註明出處,否則將追究法律責任。

相關文章