RMAN系列(三),介质管理问题(三)
还原操作期间,SBT API 将经过一系列步骤还原磁带备份到数据库中。
还原分配磁带通道时,RMAN 会在目标数据库上创建一个服务器进程。随后通道进程调用sbtinit()来初始化介质管理软件。 这一步骤与备份操作相同,MML 文件被加载到内存中。
基于RMAN中的restore 命令的参数,RMAN 会检查RMAN目录来确定要进行还原的备份句柄名。随后,它使用sbtrestore()调用将请求的备份片句柄传递给介质管理器,该调用告诉介质管理器要为还原操作朱备好相应的磁带,即使用介质管理器目录来查找相应的磁带,如果有必要则向自动机器指令传递取磁带的命令。加载磁带后,磁带必须绕回到备份片的起始点。
为还原准备好磁带后,通道进程调用sbtread2() 函数从磁带设备读取数据并将数据流发送至ORACLE 进程。 这些数据被加载到输入缓冲区,然后被写入到输出缓冲区,最后被写入控制文件指定的数据文件位置。
在磁带上检测到备份片的结束点时,磁带通道进程调用sbtclose() 函数来断开该设备片所在的磁带,这表明Oracle 结束了对这个磁带的操作。 如果执行还原操作时需要多个备份片,通道进程会返回第二个步骤并为另一个被分片调用sbtstore()。
还原操作完成并且RMAN不再请求备份片时,通道进程调用sbtend()函数,该函数清理并释放通道资源以供其他方面使用。 然后通道进程结束,此后介质管理器就可以卸载已经请求过的磁带。
六. 使用 sbttest 和 loadsbt.exe
通常总有一些提示说明是否成功链接了MML 与Oracle,如,来自通道分配的信息说明了MML版本。不过这些指示不能保证最后的成功,在更下层的网络拓扑中(MM客户端或MM服务器)仍然可能出现故障。
Oracle 提供了一个名为sbttest的实用程序,可用它来测试以确保RMAN能够使用MM配置来执行磁带备份操作。 从命令可以调用这个实用程序,该程序执行一个完整的测试:sbttest 会向磁带写一个数据块,然后请求读取这个数据库。 通过这种方式,sbttest 运行备份操作期间执行的所有SBT API 函数,并确认这些函数能否成功。
Sbttest 的用法非常简单: 只要从命令提示符运行。 确认完成了所有的MM配置,然后进入RMAN运行环境中的命令提示符,并输入sbttest 和测试文件名。
-bash-3.2$ sbttest
Error: backup file name must be specified
Usage: sbttest backup_file_name
<-dbname database_name>
<-trace trace_file_name>
<-remove_before>
<-no_remove_after>
<-read_only>
<-no_regular_backup_restore>
<-no_proxy_backup>
<-no_proxy_restore>
<-file_type n>
<-copy_number n>
<-media_pool n>
<-os_res_size n>
<-pl_res_size n>
<-block_size block_size>
<-block_count block_count>
<-proxy_file os_file_name bk_file_name
[os_res_size pl_res_size block_size block_count]>
<-libname sbt_library_name>
Required parameters:
backup_file_name: The name of the backup file which will be created by
this program. If a BFS or Backup Piece already exists
with this name, then this program will not create a new
backup file - the existing file will be read in its
entirety and its contents will not be verified
Optional parameters:
-dbname specifies the database name which will be used by SBT
to identify the backup file. The default is "sbtdb"
-trace specifies the name of a file where the Media Management
software will write diagnostic messages.
-remove_before if specified, then the specified backup file will be
deleted before it is opened. This option is intended
for when sbttest has already been run but did not complete
successfully, leaving behind the backup file it created.
-no_remove_after The default behavior of this program is to delete the
backup file, if it was created by this program. If this
option is specified, then the file will not be
removed when this program is complete.
-read_only if -read_only is specified, then backup_file_name must already
exist. Its contents will be read. If it is determined that the
file was created by this program, then its contents is validated.
-no_regular_backup_restore skips non-proxy backup and restore.
-no_proxy_backup skips proxy copy backup session.
-no_proxy_restore skips proxy copy restore session.
-file_type specifies file type - 1, 2 or 3.
-copy_number this is the copy_number parameter to sbtpcbackup.
-media_pool this is the media_pool parameter to sbtpcbackup.
-os_res_size specifies the size in bytes of the os reserved block.
-pl_res_size specifies the size in bytes of the platform reserved block.
-bl