Copyright (c) 1982, 2011, Oracle. All rights reserved.
Connected to an idle instance.
ORACLE instance started.
Database mounted.
Database opened.
[oracle@oracle11g dbs]$
cd /u01/oracle/product/dbs/
[oracle@oracle11g dbs]$
ls
hc_hbhe.dat init.ora lkHBHE orapwhbhe snapcf_orcl.f spfileorcl.ora
hc_orcl.dat
initorcl.ora lkORCL orapworcl spfilehbhe.ora
[oracle@oracle11g dbs]$
cp initorcl.ora inittest01.ora
[oracle@oracle11g dbs]$ ls
hc_hbhe.dat initorcl.ora lkORCL snapcf_orcl.f
hc_orcl.dat
inittest01.ora orapwhbhe spfilehbhe.ora
init.ora lkHBHE orapworcl spfileorcl.ora
修改inittest.ora里面的内容,将orcl改成test,修改后的文件如下:
[oracle@oracle11g dbs]$
cat inittest01.ora
[oracle@oracle11g dbs]$ cat inittest01.ora
test01.__db_cache_size=452984832
test01.__java_pool_size=16777216
test01.__large_pool_size=16777216
test01.__oracle_base='/u01/oracle'#ORACLE_BASE set from environment
test01.__pga_aggregate_target=654311424
test01.__sga_target=956301312
test01.__shared_io_pool_size=0
test01.__shared_pool_size=436207616
test01.__streams_pool_size=16777216
*.audit_file_dest='/u01/oracle/admin/test01/adump'
*.audit_trail='db'
*.compatible='11.2.0.0.0'
*.control_file_record_keep_time=14
*.control_files='/u01/oracle/oradata/test01/control01.ctl','/u01/oracle/fast_recovery_area/test01/control02.ctl'
*.db_block_size=8192
*.db_cache_size=16777216
*.db_domain=''
*.db_name='test01'
*.db_recovery_file_dest='/u01/oracle/fast_recovery_area'
*.db_recovery_file_dest_size=4322230272
*.diagnostic_dest='/u01/oracle'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=test01XDB)'
test01.log_archive_dest_1='location=/u01/oracle/test01_arch'
*.memory_target=1603272704
*.O7_DICTIONARY_ACCESSIBILITY=TRUE
*.open_cursors=300
*.processes=500
*.remote_login_passwordfile='EXCLUSIVE'
*.sessions=555
*.undo_tablespace='UNDOTBS1'
db_file_name_convert = ('/u01/oracle/oradata/orcl','/u01/oracle/oradata/test01')
log_file_name_convert = ('/u01/oracle/oradata/orcl','/u01/oracle/oradata/test01')
后面两个是后来新加的,用来转换redo log位置。
4.创建test01实例的口令文件。
[oracle@oracle11g dbs]$
cd /u01/oracle/product/bin/
[oracle@oracle11g bin]$
orapwd file=$ORACLE_HOME/dbs/orapwtest01 password=wwwwww
[oracle@oracle11g bin]$
cd $ORACLE_HOME/dbs
[oracle@oracle11g dbs]$
pwd
/u01/oracle/product/dbs
[oracle@oracle11g dbs]$
ls
hc_hbhe.dat initorcl.ora lkORCL
orapwtest01 spfileorcl.ora
hc_orcl.dat inittest01.ora orapwhbhe snapcf_orcl.f
init.ora lkHBHE orapworcl spfilehbhe.ora
windows下oracle默认的位置是$ORACLE_HOME/database目录,文件名格式是pwdSID.ora。
linux下oracle默认的位置是$ORACLE_HOME
/dbs目录,文件名格式是orapwSID。
创建完后,数据库需要重启动,新的口令文件才能生效。
5.备份数据源
[oracle@oracle11g dbs]$
mkdir -p /u02/backup/
[oracle@oracle11g backup]$
rman target /
Recovery Manager: Release 11.2.0.3.0 - Production on Sun Jul 13 00:11:43 2014
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
connected to target database: ORCL (DBID=1373722558)
RMAN>
RUN {
allocate channel c1 type disk;
allocate channel c2 type disk;
BACKUP FORMAT '/u02/backup/orcl_%U_%T' skip inaccessible filesperset 5 DATABASE TAG orcl_hot_db_bk;
sql 'alter system archive log current';
BACKUP FORMAT '/u02/backup/arch_%U_%T' skip inaccessible filesperset 5 ARCHIVELOG ALL DELETE INPUT;
backup current controlfile tag='bak_ctlfile' format='/u02/backup/ctl_file_%U_%T';
backup spfile tag='spfile' format='/u02/backup/ORCL_spfile_%U_%T';
release channel c2;
release channel c1;
}
using target database control file instead of recovery catalog
allocated channel: c1
channel c1: SID=206 device type=DISK
allocated channel: c2
channel c2: SID=399 device type=DISK
Starting backup at 13-JUL-14
channel c1: starting full datafile backup set
channel c1: specifying datafile(s) in backup set
input datafile file number=00006 name=/u01/oradata/icms.dbf
input datafile file number=00005 name=/u01/oracle/oradata/orcl/example01.dbf
input datafile file number=00007 name=/u01/oracle/oradata/orcl/rmancatalog.dbf
input datafile file number=00003 name=/u01/oracle/oradata/orcl/undotbs01.dbf
channel c1: starting piece 1 at 13-JUL-14
channel c2: starting full datafile backup set
channel c2: specifying datafile(s) in backup set
input datafile file number=00001 name=/u01/oracle/oradata/orcl/system01.dbf
input datafile file number=00002 name=/u01/oracle/oradata/orcl/sysaux01.dbf
input datafile file number=00004 name=/u01/oracle/oradata/orcl/users01.dbf
channel c2: starting piece 1 at 13-JUL-14
channel c1: finished piece 1 at 13-JUL-14
piece handle=/u02/backup/orcl_0qpd8dvf_1_1_20140713 tag=ORCL_HOT_DB_BK comment=NONE
channel c1: backup set complete, elapsed time: 00:00:55
channel c1: starting full datafile backup set
channel c1: specifying datafile(s) in backup set
including current control file in backup set
channel c1: starting piece 1 at 13-JUL-14
channel c1: finished piece 1 at 13-JUL-14
piece handle=/u02/backup/orcl_0spd8e17_1_1_20140713 tag=ORCL_HOT_DB_BK comment=NONE
channel c1: backup set complete, elapsed time: 00:00:04
channel c1: starting full datafile backup set
channel c1: specifying datafile(s) in backup set
including current SPFILE in backup set
channel c1: starting piece 1 at 13-JUL-14
channel c1: finished piece 1 at 13-JUL-14
piece handle=/u02/backup/orcl_0tpd8e1i_1_1_20140713 tag=ORCL_HOT_DB_BK comment=NONE
channel c1: backup set complete, elapsed time: 00:00:01
channel c2: finished piece 1 at 13-JUL-14
piece handle=/u02/backup/orcl_0rpd8dvg_1_1_20140713 tag=ORCL_HOT_DB_BK comment=NONE
channel c2: backup set complete, elapsed time: 00:02:42
Finished backup at 13-JUL-14
sql statement: alter system archive log current
Starting backup at 13-JUL-14
current log archived
channel c1: starting archived log backup set
channel c1: specifying archived log(s) in backup set
input archived log thread=1 sequence=54 RECID=23 STAMP=852768917
channel c1: starting piece 1 at 13-JUL-14
channel c2: starting archived log backup set
channel c2: specifying archived log(s) in backup set
input archived log thread=1 sequence=55 RECID=24 STAMP=852768917
channel c2: starting piece 1 at 13-JUL-14
channel c1: finished piece 1 at 13-JUL-14
piece handle=/u02/backup/arch_0upd8e4l_1_1_20140713 tag=TAG20140713T001517 comment=NONE
channel c1: backup set complete, elapsed time: 00:00:02
channel c1: deleting archived log(s)
archived log file name=/u01/oracle/orcl_arch/1_54_845941826.dbf RECID=23 STAMP=852768917
channel c2: finished piece 1 at 13-JUL-14
piece handle=/u02/backup/arch_0vpd8e4l_1_1_20140713 tag=TAG20140713T001517 comment=NONE
channel c2: backup set complete, elapsed time: 00:00:02
channel c2: deleting archived log(s)
archived log file name=/u01/oracle/orcl_arch/1_55_845941826.dbf RECID=24 STAMP=852768917
Finished backup at 13-JUL-14
Starting backup at 13-JUL-14
channel c1: starting full datafile backup set
channel c1: specifying datafile(s) in backup set
including current control file in backup set
channel c1: starting piece 1 at 13-JUL-14
channel c1: finished piece 1 at 13-JUL-14
piece handle=/u02/backup/ctl_file_10pd8e4n_1_1_20140713 tag=BAK_CTLFILE comment=NONE
channel c1: backup set complete, elapsed time: 00:00:01
Finished backup at 13-JUL-14
Starting backup at 13-JUL-14
channel c1: starting full datafile backup set
channel c1: specifying datafile(s) in backup set
including current SPFILE in backup set
channel c1: starting piece 1 at 13-JUL-14
channel c1: finished piece 1 at 13-JUL-14
piece handle=/u02/backup/ORCL_spfile_11pd8e4q_1_1_20140713 tag=SPFILE comment=NONE
channel c1: backup set complete, elapsed time: 00:00:01
Finished backup at 13-JUL-14
released channel: c2
released channel: c1
6.修改监听文件
[oracle@oracle11g admin]$
cd /u01/oracle/product/network/admin
[oracle@oracle11g admin]$
vi listener.ora
添加以下内容:
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME = /u01/oracle/product)
(PROGRAM = extproc)
)
(SID_DESC =
(GLOBAL_DBNAME = test01)
(ORACLE_HOME = /u01/oracle/product)
(SID_NAME = test01)
)
)
修改tnsnames.ora文件,添加下列内容
test01 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = oracle11g)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = test01)
)
)
~
7.启动要复制的数据库到nomount状态
[oracle@oracle11g admin]$
export ORACLE_SID=test01
[oracle@oracle11g admin]$
sqlplus "/as sysdba"
SQL*Plus: Release 11.2.0.3.0 Production on Sun Jul 13 00:58:40 2014
Copyright (c) 1982, 2011, Oracle. All rights reserved.
Connected to an idle instance.
SQL>
startup nomount pfile=/u01/oracle/product/dbs/inittest01.ora
ORA-00845: MEMORY_TARGET not supported on this system
如果启动过程中报错,参考http://blog.chinaunix.net/uid-25196040-id-4095303.html
SQL>
startup nomount pfile=/u01/oracle/product/dbs/inittest.ora
ORACLE instance started.
Total System Global Area 1603411968 bytes
Fixed Size 2228784 bytes
Variable Size 1140854224 bytes
Database Buffers 452984832 bytes
Redo Buffers 7344128 bytes
[oracle@oracle11g product]$
export ORACLE_SID=orcl
[oracle@oracle11g product]$
rman target /
Recovery Manager: Release 11.2.0.3.0 - Production on Sun Jul 13 00:35:42 2014
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
connected to target database: ORCL (DBID=1373722558)