用sys登录
alter system set log_archive_start=true scope=spfile;(启动arch进程参数设置)
alter system set log_archive_format='ARC%S.%T' scope=spfile;(设置归档文件格式)
alter system set log_archive_dest_1='location=/u03/oracle/backup/arc';(设置归档路径)
shutdown immediate;
startup mount;
alter database archivelog;(启动归档,特别注意,在此时要关监听器,否则报ora 00265错误)
--alter database noarchvielog;(停止归档)
alter database open;(修改启动数据库)
2.创建自动备份数据库
--编辑备份文件rmanhb.sql
run {
allocate channel ch1 type disk maxpiecesize = 2G;
allocate channel ch2 type disk maxpiecesize = 2G;
backup database format '/u02/oracle/%d_DF_%T_%s_%p.bak' plus archivelog
format '/u02/oracle/%d_AF_%T_%s_%p.bak' delete input;
backup current controlfile format '/u02/oracle/%d_CTL_%T_%s_%p.bak';
release channel ch1;
release channel ch2;
}
--主机上设置Primary强制Logging(强制写日志,保证standby数据库可以正确恢复.)
startup mount;
alter database force logging;(这一步必须,不能省)
--主机上select file_name from dba_data_files;(查找数据文件路径)