3、 RMAN的启动:
连接到目标数据库
rman\>connect target user/pwd@db_name
注意:1、connect不能简写为conn
2、连接USER必须具备SYSDBA权限
3、连接的db_name必须在tnsnames.ora中有配置,且有效(即通过SQLPLUS可以连接)
4、target database 必须为archivelog 模式
5、如果是本地可以采用OS认证,如果是远程需要使用密码文件认证。
6、RMAN工具版本与目标数据库必须是同一版本。
4、 在RMAN中执行操作系统命令
Egg:
RMAN> run{host "ls -artl";}
RMAN> run{host "ifconfig";}
RMAN> run{host "pwd";}
/home/Oracle
host commandcomplete
RMAN> run{host "ls";}
Desktop sqlnet.log
host commandcomplete
RMAN> exit
5、 在RMAN中执行SQL命令对数据库进行操作
5.1 启动关闭数据库
RMAN> shutdown immediate
database closed
database dismounted
Oracle instance shut down
RMAN> startup
connected to target database (not started)
Oracle instance started
database mounted
database opened
Total System Global Area 285212672 bytes
Fixed Size 1218968 bytes
Variable Size 79693416 bytes
Database Buffers 197132288 bytes
Redo Buffers 7168000 bytes
RMAN>
5.2 在RMAN中执行SQL语句
RMAN> sql 'select * fromuser_tablespaces';
sql statement: select * fromuser_tablespaces
RMAN> sql 'alter system checkpoint';
sql statement: alter system checkpoint
RMAN>
为了解释这个问题请参看红色注释
注意:
rman is not sqlplus, rman show result of"sql" command, but not show result of 'select ....'
5.3 在RMAN中执行bak.sql脚本
RMAN> run {executescript bak.sql}
