To restore the database on a new host-将数据库恢复至一个新的主机上
To restore the database on a new host:
1. Ensure that the backups of the target database are accessible on the new host.
2. Configure the ORACLE_SID on hostb.
3. Start RMAN on hostb and connect to the target database without connecting to the recovery catalog.
For example, enter the following command:
% rman NOCATALOG
RMAN> CONNECT TARGET
/
4. Set the DBID and start the database instance without mounting the database. For example, run SET DBID to set the DBID, then run STARTUP NOMOUNT:
SET DBID 1340752057;
STARTUP NOMOUNT
RMAN fails to find the server parameter file, which has not yet been restored, but starts the instance with a "dummy" file. Sample output follows:
startup failed: ORA-01078: failure in processing system parameters LRM-00109: could not open parameter file '/net/hostb/oracle/dbs/inittrgta.ora' trying to start the Oracle instance without parameter files ...
Oracle instance started
5. Restore and edit the server parameter file. --从自动备份文件中恢复参数文件
Allocate a channel to the media manager, then restore the server parameter file as a client-side parameter file and use the SET command to indicate the location of the autobackup (in this example, the autobackup is in /tmp):
RUN
{
ALLOCATE CHANNEL c1 DEVICE TYPE sbt PARMS '...';
SET CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/tmp/%F'; RESTORE SPFILE
TO PFILE '?/oradata/test/inittrgta.ora'
FROM AUTOBACKUP;
SHUTDOWN ABORT;
}
6. Edit the restored initialization parameter file. --修改已恢复的参数文件
Change any location-specific parameters, for example, those ending in _DEST, to reflect the new directory structure. For example, edit the following parameters:
- IFILE
- LOG_ARCHIVE_DEST_1
- CONTROL_FILES
7. Restart the instance with the edited initialization parameter file. --用修改好的参数文件来重新启动数据库
For example, enter the following command:
STARTUP FORCE NOMOUNT PFILE='?/oradata/test/inittrgta.ora';
8. Restore the control file from an autobackup and then mount the database. --从自动备份文件中恢复控制文件至CONTROL_FILES parameter.
For example, enter the following command:
RUN
{
ALLOCATE CHANNEL c1 DEVICE TYPE sbt PARMS '...';
RESTORE CONTROLFILE FROM AUTOBACKUP;
ALTER DATABASE MOUNT;
}
RMAN restores the control file to whatever locations you specified in the CONTROL_FILES initialization parameter.
9. Catalog the data file copies that you copied in "Restoring Disk Backups to a New Host", using their new file names or CATALOG START WITH (if you know all the files are in directories with a common prefix easily addressed with a CATALOG START WITH command). For example, run:
CATALOG START WITH '/oracle/oradata/trgt/';
If you want to specify files individually, then you can execute a CATALOG command as follows:
CATALOG DATAFILECOPY
'/oracle/oradata/trgt/system01.dbf', '/oracle/oradata/trgt/undotbs01.dbf', '/oracle/oradata/trgt/cwmlite01.dbf', '/oracle/oradata/trgt/drsys01.dbf', '/oracle/oradata/trgt/
example01.dbf', '/oracle/oradata/trgt/indx01.dbf', '/oracle/oradata/trgt/tools01.dbf', '/oracle/oradata/trgt/users01.dbf';
10. Start a SQL*Plus session on the new database and query the database file names recorded in the control file.
Because the control file is from the trgta database, the recorded file names use the original hosta file names. You can query V$ views to obtain this information.
Run the following query in SQL*Plus:
COLUMN NAME FORMAT a60
SPOOL LOG '/tmp/db_filenames.out'
SELECT FILE# AS "File/Grp#", NAME
FROM V$DATAFILE
UNION
SELECT GROUP#,MEMBER
FROM V$LOGFILE;
SPOOL OFF
EXIT
11. Write the RMAN restore and recovery script. The script must include the following steps:
a. For each data file on the destination host that is restored to a different path than it had on the source host, use a SET NEWNAME command to specify the new path on the destination host. If the file systems on the destination system are set up to have the same paths as the source host, then do not use SET NEWNAME for those files restored to the same path as on the source host.
b. For each online redo log that is to be created at a different location than it had on the source host, use SQL ALTER DATABASE RENAME FILE commands to specify the path name on the destination host. If the file systems on the destination system are set up to have the same paths as the source host, then do not use ALTER DATABASE RENAME FILE for those files restored to the same path as on the source host.
c. Perform a SET UNTIL operation to limit recovery to the end of the archived redo logs. The recovery stops with an error if no SET UNTIL command is specified.
d. Restore and recover the database.
e. Run the SWITCH DATAFILE ALL command so that the control file recognizes the new path names as the official new names of the data files.
Example 20-3 shows the RMAN script reco_test.rman that can perform the restore and recovery operation.
Example 20-3 Restoring a Database on a New Host:
RUN
{
# allocate a channel to the tape device
ALLOCATE CHANNEL c1 DEVICE TYPE sbt PARMS '...';
# rename the data files and online redo logs
SET NEWNAME FOR DATAFILE 1 TO '?/oradata/test/system01.dbf'; SET NEWNAME FOR DATAFILE 2 TO '?/oradata/test/undotbs01.dbf'; SET NEWNAME
FOR DATAFILE 3 TO '?/oradata/test/cwmlite01.dbf'; SET NEWNAME FOR DATAFILE 4 TO '?/oradata/test/drsys01.dbf'; SET NEWNAME FOR DATAFILE 5 TO
'?/oradata/test/example01.dbf'; SET NEWNAME FOR DATAFILE 6 TO '?/oradata/test/indx01.dbf'; SET NEWNAME FOR DATAFILE 7 TO '?/oradata/test/
tools01.dbf'; SET NEWNAME FOR DATAFILE 8 TO '?/oradata/test/users01.dbf'; SQL "ALTER DATABASE RENAME FILE ''/dev3/oracle/dbs/redo01.log'' TO ''?/
oradata/test/redo01.log'' ";
SQL "ALTER DATABASE RENAME FILE ''/dev3/oracle/dbs/redo02.log'' TO ''?/oradata/test/redo02.log'' ";
# Do a SET UNTIL to prevent recovery of the online logs SET UNTIL SCN 123456;
# restore the database and switch the data file names RESTORE DATABASE;
SWITCH DATAFILE ALL;
# recover the database
RECOVER DATABASE;
}
EXIT
12. Execute the script created in the previous step.
For example, start RMAN to connect to the target database and run the @ command:
% rman TARGET / NOCATALOG
RMAN> @reco_test.rman
13. Open the restored database with the RESETLOGS option. From the RMAN prompt, open the database with the RESETLOGS option:
ALTER DATABASE OPEN RESETLOGS;
Caution:
When you re-open your database in the next step, do not connect to the recovery catalog. Otherwise, the new database incarnation created is registered automatically in the recovery catalog, and the file names of the production database are replaced by the new file names specified in the script.
14. Optionally, delete the test database with all of its files.
Note:
If you used an ASM disk group, then the DROP DATABASE command is the only way to safely remove the files of the test database. If you restored to non-ASM storage then you can also use operating system commands to remove the database.
Use the DROP DATABASE command to delete all files associated with the database automatically. The following example deletes the database files:
STARTUP FORCE NOMOUNT PFILE='?/oradata/test/inittrgta.ora'; DROP DATABASE;
Because you did not perform the restore and recovery operation when connected to the recovery catalog, the recovery catalog contains no records for any of the restored files or the procedures performed during the test. Likewise, the control file of the trgta database is completely unaffected by the test.
To restore the database on a new host-将数据库恢复至一个新的主机上的更多相关文章
- 在服务器上远程链接另一台服务器的数据库的方法how to connet the database from the other host
iwangzheng.com 16:57 [root@a02.cmsapi]$ mysql -u<username> -p<password> -h10.103.xx.xx W ...
- 数据库恢复(database restore)之兵不血刃——半小时恢复客户数据库
昨天,一个客户打打来电话,说他们的数据库坏了,不能用了,需要我帮助恢复下,这马上要放假了,居然出了这事儿,自己也不太喜欢恢复数据库这类,尤其是他们的数据库是个win上的库,但心里很清楚,客户比咱着急, ...
- oracl使用DataBase Configuration Assistant创建、删除数据库
原文:oracl使用DataBase Configuration Assistant创建.删除数据库 可以使用DataBase Configuration Assistant来创建一个心得数据库.Da ...
- Backup and Restore MySQL Database using mysqlhotcopy
mysqlhotcopy is a perl script that comes with MySQL installation. This locks the table, flush the ta ...
- Restore Oracle database to another server
1. Copy or remotely mount the backupset folder from the source server to the target server 2. On the ...
- Create Oracle Enterprise Manager repository data after restore a database from another server
1. Set password for SYS in password file: orapwd file=$ORACLE_HOME/dbs/orapw<ORACLE_SID> 2. Dr ...
- oracle使用DataBase Configuration Assistant创建、删除数据库
可以使用DataBase Configuration Assistant来创建一个心得数据库.Database Configuration Assistant简称是DBCA,是创建.配置以及管理数据库 ...
- 使用alter database datafile 'XXX' offline drop 是否能够恢复(非归档模式下)
今天在群里面听到一位网友在说使用了alter database datafile 'XXX' offline drop命令是否能够恢复数据,在非归档模式下,下面是用一个实验来验证一下 ######## ...
- SQL Server ->> Database Promgramming Object Security Control(数据库编程对象安全控制)
对于SQL Server内编程对象的安全控制是今天我在思考的问题.在MSDN上找到了几篇有用的文章. 首先微软推荐了三种做法: 1)第一种做法是在SQL Server中对一个应用程序对应创建应用程序角 ...
随机推荐
- [破解] DRM-内容数据版权加密保护技术学习(上):视频文件打包实现
1. DRM介绍: DRM,英文全称Digital Rights Management, 可以翻译为:内容数字版权加密保护技术. DRM技术的工作原理是,首先建立数字节目授权中心.编码压缩后的数字节目 ...
- ASP无惧上传类不能上传中文双引号文件及ASP函数InStr存在bug
ASP无惧上传类不能上传中文双引号文件及ASP函数InStr存在bug 近日发现eWebEditor V2.8 asp 版本上传文件文件名不能包含中文双引号,发现eWebEditor使用ASP“无惧上 ...
- HTTP Digest authentication
(Digest authentication)是一个简单的认证机制,最初是为HTTP协议开发的,因而也常叫做HTTP摘要,在RFC2671中描写叙述.其身份验证机制非常easy,它採用杂凑式(hash ...
- 查看linux系统的开机时间/重启历史记录
查看linux系统的开机时间/重启历史记录1.who -b命令[root@rusky opt]# who -b ---查看最后一次(上次)系统启动的时间 system boot Dec 27 05:0 ...
- onvif规范的实现:使用gSOAP创建SOAP调用实例
预备知识 ONVIF规范中设备管理和控制部分所定义的接口均以Web Services的形式提供.ONVIF规范涵盖了完全的XML及WSDL的定义.每一个支持ONVIF规范的终端设备均须提供与功能相应的 ...
- 【SQL】大杂烩
--------------------------------- 索引 --------------------------------- 语法: CREATE [索引类型] INDEX 索引名称 ...
- Hadoop 安装(1) CENTOS 安装与配置
配置虚拟机,名字 Hadoop_Slave4,内存为1024MB,15GB. 进入安装centos. 配置Hostname: Slave4.Hadoop 配置网络,设置静态IP:192.168.1.2 ...
- OC学习中遇到的问题总结
1.不要在初始化的时候用self.方法,因为在初始化的时候self.,此时系统还没有alloc开辟空间,这样做违背了系统流程. 2.善于运用宏定义来控制程序中的变量,这样程序可修改性高. 3.obje ...
- IE10以下placeholder不兼容
做页面的时候在谷歌中是显示的,但是换了IE之后总是不显示,一个文本框还好,如果有多个的话,如图: 添加以下一段Jquery代码: <script> var JPlaceHolder = { ...
- [转载]字符编码笔记:ASCII,Unicode和UTF-8
[转载] :http://www.ruanyifeng.com/blog/2007/10/ascii_unicode_and_utf-8.html 1. ASCII码 在计算机内部,所有的信息最终都表 ...