使用rman本机复制新数据库
使用rman復(fù)制數(shù)據(jù)庫
原數(shù)據(jù)庫sid orcl ?復(fù)制新的數(shù)據(jù)庫sid為 nylg
1.創(chuàng)建復(fù)制備份數(shù)據(jù)庫的參數(shù)文件
在原數(shù)據(jù)庫創(chuàng)建pfile
create pfile from spfile;
然后復(fù)制pfile參數(shù)文件
[oracle@Nagiostest dbs]$ pwd
/u01/app/oracle/product/11.2/dbs
[oracle@Nagiostest dbs]$ cp initorcl.ora initnylg.ora?
修改orcl數(shù)據(jù)庫名改為nylg
vi initnylg.ora 修改如下:
:%s/orcl/nylg/g
在這里注意,修改參數(shù)文件后,在最后行添加兩行轉(zhuǎn)換參數(shù),指定新數(shù)據(jù)文件存放路徑
db_file_name_convert = ('/u01/app/oracle/oradata/orcl','/u01/app/oracle/oradata/nylg')
log_file_name_convert = ('/u01/app/oracle/oradata/orcl','/u01/app/oracle/oradata/nylg')
2.創(chuàng)建相對應(yīng)的目錄,啟動復(fù)制數(shù)據(jù)庫的輔助實例
mkdir -p $ORACLE_BASE/admin/nylg/{a,b,c,u}dump
mkdir -p /u01/app/oracle/oradata/nylg
orapwd file=$ORACLE_HOME/dbs/orapwnylg password=yuanlei force=y
[oracle@Nagiostest ~]$ export ORACLE_SID=nylg
使用pfile啟動輔助實例到nomount
startup nomount pfile=?/dbs/initnylg.ora ??
如下:
[oracle@Nagiostest ~]$ export ORACLE_SID=nylg
[oracle@Nagiostest ~]$ sqlplus /nolog
SQL*Plus: Release 11.2.0.1.0 Production on Wed Aug 13 10:27:25 2014
Copyright (c) 1982, 2009, Oracle. ?All rights reserved.
SQL> conn / as sysdba
Connected to an idle instance.
SQL> startup nomount pfile=?/dbs/initnylg.ora
ORACLE instance started.
Total System Global Area ?413372416 bytes
Fixed Size ? ?2213896 bytes
Variable Size ?314574840 bytes
Database Buffers ? 92274688 bytes
Redo Buffers ? ?4308992 bytes
3.在新的會話中(ORACLE_SID=orcl)對原數(shù)據(jù)庫做rman全備
export ORACLE_SID=orcl
rman target /
run {
sql 'alter system archive log current';
backup database format='/u01/rmanbak/%d_%s.dbf'
plus archivelog format='/u01/rmanbak/%d_%s.arc';
sql 'alter system archive log current';
}
4.配置復(fù)制庫監(jiān)聽(就是本機的監(jiān)聽文件),服務(wù)名采用靜態(tài)注冊,啟動監(jiān)聽,這步很重要
不要有錯誤
[oracle@Nagiostest admin]$ vim listener.ora?
# listener.ora Network Configuration File: /u01/app/oracle/product/11.2/network/admin/listener.ora
# Generated by Oracle configuration tools.
SID_LIST_LISTENER =
? (SID_LIST =
? ? (SID_DESC =
? ? ? (SID_NAME = PLSExtProc)
? ? ? (ORACLE_HOME = /u01/app/oracle/product/11.2)
? ? ? (PROGRAM = extproc)
? ? )
? ? (SID_DESC =
? ? ? (SID_NAME = nylg)
? ? ? (ORACLE_HOME = /u01/app/oracle/product/11.2)
? ? ? (GLOBAL_DBNAME = NYLG)
? ? )
? )
ADR_BASE_LISTENER = /u01/app/oracle
[oracle@Nagiostest admin]$ vim tnsnames.ora?
# tnsnames.ora Network Configuration File: /u01/app/oracle/product/11.2/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.
NYLG =
? (DESCRIPTION =
? ? (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.210)(PORT = 1521))
? ? (CONNECT_DATA =
? ? ? (SERVER = DEDICATED)
? ? ? (SERVICE_NAME = nylg)
? ? )
? )
lsnrctl start
5.用rman連接到主庫實例和輔助實例,運行復(fù)制命令
[oracle@Nagiostest dbs]$ rman target /
Recovery Manager: Release 11.2.0.1.0 - Production on Wed Aug 13 11:01:56 2014
Copyright (c) 1982, 2009, Oracle and/or its affiliates. ?All rights reserved.
connected to target database: ORCL (DBID=1382226447)
RMAN> connect auxiliary sys/yuanlei@nylg
connected to auxiliary database: NYLG (not mounted)
這里如果遇到
RMAN-04006: error from auxiliary database: ORA-01031: insufficient privileges
請檢查你的監(jiān)聽配置和口令文件是否正確,一般就這兩個原因(我做的時候是把監(jiān)聽sid大寫小弄錯)
然后繼續(xù)
RMAN> duplicate target database to nylg;
其它配置沒問題話的,這里等一會就完成了
Starting Duplicate Db at 2014/08/13 11:02:38
using target database control file instead of recovery catalog
.
.
.復(fù)制過程
.
.
contents of Memory Script:
{
? ?Alter clone database open resetlogs;
}
executing Memory Script
database opened
Finished Duplicate Db at 2014/08/13 11:07:26
此時新的數(shù)據(jù)庫已經(jīng)處于open狀態(tài)了!
[oracle@Nagiostest ~]$ echo $ORACLE_SID
nylg
[oracle@Nagiostest ~]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.1.0 Production on Wed Aug 13 11:08:49 2014
Copyright (c) 1982, 2009, Oracle. ?All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> select status from v$instance;
STATUS
------------
OPEN
OK!
轉(zhuǎn)載于:https://blog.51cto.com/paopao5541/1539308
總結(jié)
以上是生活随笔為你收集整理的使用rman本机复制新数据库的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Druid使用ConfigFilter
- 下一篇: Android第十期 - 百度地图