【ORACLE】relink oracle 10g 資料庫

楊奇龍發表於2011-08-17
通常要遷移一個資料庫,我們會使用
1 冷備份,整個資料庫遷移,
2 rman duplicate 功能進行復制到本機或者複製到異機,
前面兩種都必須先在目標庫上安裝軟體。這裡測試另外一種方法:對於單例項資料庫,複製整個oracle 10g 資料庫到另一個伺服器,relink 之後可以重新使用。。
檢視源庫資料庫庫檔案在$ORACLE_BASE 目錄下的分佈:
oracle@yangDB1:/opt/oracle>ll
總計 36
drwxrwx--- 3 oracle oinstall 4096 08-06 16:22 10.2.0
drwxr-x--- 4 oracle oinstall 4096 08-17 17:10 admin
drwxrwxr-x 3 oracle oinstall 4096 08-06 15:14 extapi
drwxr-x--- 4 oracle oinstall 4096 08-17 18:32 flash_recovery_area
drwxr-x--- 4 oracle oinstall 4096 08-17 17:10 oradata
drwxrwxr-x 6 oracle oinstall 4096 08-06 16:28 oraInventory
drwxr-xr-x 2 oracle oinstall 4096 08-17 17:49 pri_arch
drwxr-xr-x 2 oracle oinstall 4096 08-11 13:27 std_arch -standby檔案,不用
drwxr-xr-x 2 oracle oinstall 4096 08-17 18:31 yqldb_arch-上一個實驗檔案,不用
將資料庫檔案複製到目標庫:記得將目標庫設定和源庫一樣的結構,否則會報錯!
oracle@yangDB1:/opt/oracle>scp -r flash_recovery_area 10.250.7.230:/opt/oracle
oracle@yangDB1:/opt/oracle>scp -r admin               10.250.7.230:/opt/oracle
oracle@yangDB1:/opt/oracle>scp -r oraInventory        10.250.7.230:/opt/oracle
oracle@yangDB1:/opt/oracle>scp -r 10.2.0              10.250.7.230:/opt/oracle
oracle@yangDB1:/opt/oracle>scp -r oradata/orcl/       10.250.7.230:/opt/oracle/oradata/
在目標庫上:
oracle@yangDB2:/opt/oracle/10.2.0/orcl/rdbms/lib>ls
bbed        dmwdm.o       hormc.o       kciwcx.o   kprnts.o   ksnnni.o        libodm10.a      maxmem.o   s0exudrv.o  shou.o     ssbbded.o   sulmain.o   xsyeolap.o
bifile.bbd  dumpsga.o     hormd.o       kcsm.o     kprwts.o   ksnnt2.o        libperfsrv10.a  nmliblist  s0impdrv.o  sjsex.o    sskfeded.o  tg4pwd.o    zsmsdrv.o
config.c    env_rdbms.mk  horm.o        kfod.o     kpucb.o    ktd.o           libqsmashr.a    opimai.o   s0kudbv.o   skfedpt.o  sskfoded.o  tstshm.o
config.o    genezi.o      hormt.o       kgupc.o    kpudfo.o   kxmnsd.o        libskgxns.a     osh.o      s0kuzr.o    skfodpt.o  sskrmed.o   ttcoerr.o
cursize.o   genksms.o     hout.o        kgutc.o    kpundf.o   kxmwsd.o        libskgxpd.a     par.bbd    s0kvpf.o    skrmpt.o   sskrned.o   ttcsoi.o
dbfsize.o   hoaoci.o      hsxaora.o     kkpoban.o  ksms.o     kzlnlbac.o      libskgxpu.a     rfscom.o   s0udexp.o   skrnpt.o   sskrsed.o   wpspldrv.o
defopt.o    hoat.o        ins_rdbms.mk  kkxntp.o   ksnkcs.o   libdbtools10.a  libxdb.a        rfsd.o     s0udimp.o   skrspt.o   ssoraed.o   xaondy.o
dmndm.o     hoax.o        jox.o         kkxwtp.o   ksnkkpo.o  libdsga10.a     log.bbd         rfsin.o    sbbdpt.o    sllfls.o   sstrced.o   xaonsl.o
dmndmse.o   homts.o       joxoff.o      kopc.o     ksnktd.o   libknlopt.a     mapsga.o        rfsxc.o    shorm.o     srfsd.o    strcpt.o    xsnoolap.o
先執行relink oracle,然後make -f ins_rdbms.mk install
oracle@yangDB2:/opt/oracle/10.2.0/orcl/rdbms/lib>relink oracle
oracle@yangDB2:/opt/oracle/10.2.0/orcl/rdbms/lib>make -f ins_rdbms.mk install
驗證:
SQL> startup
ORACLE instance started.

Total System Global Area 1224736768 bytes
Fixed Size                  2020384 bytes
Variable Size             318770144 bytes
Database Buffers          889192448 bytes
Redo Buffers               14753792 bytes
Database mounted.
Database opened.
SQL> conn yang/yang
Connected.
SQL> col tname for a15
SQL> col tabtype for a10
SQL> select * from tab;
TNAME           TABTYPE     CLUSTERID
--------------- ---------- ----------
YANGB           TABLE
YANGTAB         TABLE
YANGOBJ         TABLE
YANGUSER        TABLE
OBJECTS         TABLE
A               TABLE
6 rows selected.

SQL> select instance_name from v$instance;
INSTANCE_NAME
------------------------------------
orcl
===========遇到的問題============
第一次啟動的時候遇到ORA-00205:
SQL> startup pfile='/tmp/initorcl.ora';
ORACLE instance started.

Total System Global Area 1224736768 bytes
Fixed Size                  2020384 bytes
Variable Size             318770144 bytes
Database Buffers          889192448 bytes
Redo Buffers               14753792 bytes
ORA-00205: error in identifying control file, check alert log for more info
檢查告警日誌檔案,發現如下錯誤:
Errors in file /opt/oracle/admin/orcl/udump/orcl_ora_705.trc:
ORA-00313: open failed for members of log group 1 of thread 1
ORA-00312: online log 1 thread 1: '/opt/oracle/oradata/orcl/redo01.log'
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 2: No such file or directory
Additional information: 3
Sat Aug  6 16:29:12 2011
Errors in file /opt/oracle/admin/orcl/udump/orcl_ora_705.trc:
ORA-00313: open failed for members of log group 2 of thread 1
ORA-00312: online log 2 thread 1: '/opt/oracle/oradata/orcl/redo02.log'
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 2: No such file or directory
提示沒有對應的檔案或者目錄。
檢視資料檔案,發現複製的時候是複製到/opt/oracle/ 目錄下的而不是/opt/oracle/orcl 目錄下,將資料檔案移動到orcl目錄下
oracle@yangDB2:/opt/oracle/oradata>ls
control01.ctl  control02.ctl  control03.ctl  example01.dbf  redo01.log  redo02.log  redo03.log  sysaux01.dbf  system01.dbf  temp01.dbf  undotbs01.dbf  users01.dbf
oracle@yangDB2:/opt/oracle/oradata>mkdir orcl
oracle@yangDB2:/opt/oracle/oradata>mv *.ctl orcl
oracle@yangDB2:/opt/oracle/oradata>mv *.dbf orcl
oracle@yangDB2:/opt/oracle/oradata>ls
orcl  redo01.log  redo02.log  redo03.log
oracle@yangDB2:/opt/oracle/oradata>mv *.log orcl
oracle@yangDB2:/opt/oracle/oradata>cd orcl
oracle@yangDB2:/opt/oracle/oradata>ll
oracle@yangDB2:/opt/oracle/oradata/orcl>ll
總計 1541672
-rw-r----- 1 oracle oinstall   7061504 08-17 21:40 control01.ctl
-rw-r----- 1 oracle oinstall   7061504 08-17 21:40 control02.ctl
-rw-r----- 1 oracle oinstall   7061504 08-17 21:40 control03.ctl
-rw-r----- 1 oracle oinstall 104865792 08-17 21:09 example01.dbf
-rw-r----- 1 oracle oinstall  52429312 08-17 21:09 redo01.log
-rw-r----- 1 oracle oinstall  52429312 08-17 21:40 redo02.log
-rw-r----- 1 oracle oinstall  52429312 08-17 21:09 redo03.log
-rw-r----- 1 oracle oinstall 335552512 08-17 21:38 sysaux01.dbf
-rw-r----- 1 oracle oinstall 513810432 08-17 21:39 system01.dbf
-rw-r----- 1 oracle oinstall  20979712 08-17 20:59 temp01.dbf
-rw-r----- 1 oracle oinstall  41951232 08-17 21:39 undotbs01.dbf
-rw-r----- 1 oracle oinstall 381427712 08-17 21:09 users01.dbf
再次驗證,ok!!
oracle@yangDB2:/opt/oracle/oradata/orcl>export ORCLE_SID=orcl
oracle@yangDB2:/opt/oracle/oradata/orcl>sqlplus /nolog
SQL*Plus: Release 10.2.0.1.0 - Production on Wed Aug 17 21:09:19 2011
Copyright (c) 1982, 2005, Oracle.  All rights reserved.
SQL> conn /as sysdba
Connected.
SQL> startup
ORACLE instance started.
Total System Global Area 1224736768 bytes
Fixed Size                  2020384 bytes
Variable Size             318770144 bytes
Database Buffers          889192448 bytes
Redo Buffers               14753792 bytes
Database mounted.
Database opened.
SQL> conn yang/yang
Connected.

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/22664653/viewspace-705194/,如需轉載,請註明出處,否則將追究法律責任。

相關文章