首页 > 数据库 > Oracle > 用户管理方式创建复制数据库(实验)
用户管理方式创建复制数据库(实验)
//备份
[oracle@OraLinux oradata]$ export ORACLE_SID=db
[oracle@OraLinux oradata]$ sqlplus / as sysdba
SQL> alter database begin backup;
Database altered.
SQL> host cp
/oracle/app/oracle/oradata/db/system01.dbf
/oracle/app/oracle/oradata/auxdb/system01.dbf
SQL> host cp /oracle/app/oracle/oradata/db/undotbs01.dbf
/oracle/app/oracle/oradata/auxdb/undotbs01.dbf
SQL> host cp
/oracle/app/oracle/oradata/db/sysaux01.dbf
/oracle/app/oracle/oradata/auxdb/sysaux01.dbf
SQL> host cp
/oracle/app/oracle/oradata/db/users01.dbf /oracle/app/oracle/oradata/auxdb/users01.dbf
SQL> host cp
/oracle/app/oracle/oradata/db/xsspace.dbf
/oracle/app/oracle/oradata/auxdb/xsspace.dbf
SQL> alter database end backup;
Database altered.
SQL> alter system archive log current;
System altered.
SQL> alter database backup controlfile to
trace resetlogs;
Database altered.
//创建控制文件
[oracle@OraLinux udump]$ more
/oracle/app/oracle/admin/db/udump/db_ora_3542.trc
//根据具体情况拷贝以下内容准备创建控制文件的脚本
……
//注意其中的红色字,原来trace文件中的是reuse,大概原因是因为新建
//#vi /opt/ctlfile.sql
CREATE CONTROLFILE SET DATABASE "AUXDB" RESETLOGS ARCHIVELOG
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 100
MAXINSTANCES 8
MAXLOGHISTORY 292
LOGFILE
GROUP
1 '/oracle/app/oracle/oradata/auxdb/redo01.log'
SIZE 50M,
GROUP
2 '/oracle/app/oracle/oradata/ auxdb /redo02.log' SIZE 50M,
GROUP
3 '/oracle/app/oracle/oradata/ auxdb /redo03.log' SIZE 50M
-- STANDBY LOGFILE
DATAFILE
'/oracle/app/oracle/oradata/auxdb/system01.dbf',
'/oracle/app/oracle/oradata/auxdb/undotbs01.dbf',
'/oracle/app/oracle/oradata/auxdb/sysaux01.dbf',
'/oracle/app/oracle/oradata/auxdb/users01.dbf',
'/oracle/app/oracle/oradata/auxdb/xsspace.dbf'
CHARACTER SET WE8ISO8859P1;
[oracle@OraLinux opt]$ export ORACLE_SID=auxdb
[oracle@OraLinux opt]$ sqlplus / as sysdba
SQL> @/opt/ctlfile.sql
Control file created.
//恢复复制数据库
SQL> set logsource
'/oracle/app/oracle/flash_recovery_area/DB/archivelog/';
SQL> recover database using backup
controlfile until cancel;
ORA-00279: change 878159 generated at
07/14/2011 10:06:29 needed for thread 1
ORA-00289: suggestion :
/oracle/app/oracle/flash_recovery_area/DB/archivelog/1_32_747781023.dbf
ORA-00280: change 878159 for thread 1 is in
sequence #32
Specify log: {
CANCEL //手动输入
ORA-01547: warning: RECOVER succeeded but OPEN
RESETLOGS would get error below
ORA-01195: online backup of file 1 needs more
recovery to be consistent
ORA-01110: data file 1:
'/oracle/app/oracle/oradata/auxdb/system01.dbf'
ORA-01112: media recovery not started
//_allow_resetlogs_corruption是一个隐含的参数,用于强制启动数据库,设置该参数后,在数据库Open过程中,Oracle会跳过某些一致性检查,从而使数据库可能跳过不一致状态从而Open打开。
SQL> alter system set
"_allow_resetlogs_corruption"=true scope=spfile;
System altered.
SQL> shutdown immediate;
ORA-01109: database not open
Database dismounted.
ORACLE instance shut down.
SQL> startup mount;
ORACLE instance started.
Total System Global Area 239075328 bytes
Fixed Size 1218724 bytes
Variable Size 79693660 bytes
Database Buffers 155189248 bytes
Redo Buffers 2973696 bytes
Database mounted.
SQL> alter database open resetlogs;
Database altered.
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/14338195/viewspace-1052719/ ,如需转载,请注明出处,否则将追究法律责任。