RMAN备份恢复小练习

 

如果一个文件被offline了,手工备份会失败,但是rman能够成功。

如果其归档都在则需要立即回复,如果归档都不在了,只能删掉这个文件。

 

 

 

1.开发商可能会将数据文件错误地创建到了本地而非存储上,此时如果本机挂掉,应用切换到了另外一台主机上面,那么这个数据文件将不可用。我们需要及时发现问题,并将数据文件迁移到它应该在的位置。

 

create tablespace testtbs02 datafile 'c:\datafile\test02.dbf' size 10M autoextend on;

 

查看:

SQL> select name from v$datafile;

select name from v$datafile;

 

NAME

--------------------------------------------------------------------------------

/u01/app/oracle/oradata/orcl/system01.dbf

/u01/app/oracle/oradata/orcl/sysaux01.dbf

/u01/app/oracle/oradata/orcl/undotbs01.dbf

/u01/app/oracle/oradata/orcl/users01.dbf

/u01/app/oracle/oradata/orcl/example01.dbf

/u01/app/oracle/oradata/orcl/test01.dbf

/u01/app/oracle/product/11.2.0/db_1/dbs/c:datafiletest02.dbf

 

 

下面需要将其迁移到正确的位置:

 

1.先进入rman。然后进行copy命令:

 

copy datafile '/u01/app/oracle/product/11.2.0/db_1/dbs/c:datafiletest02.dbf' to '/u01/app/oracle/oradata/orcl/test02.dbf';

 

或者直接在操作系统层面cp 数据文件到正确位置(注意裸设备只能用rman

 

2.offline 当前数据文件

#alter database datafile 。。。 offline;

 

alter database datafile '/u01/app/oracle/product/11.2.0/db_1/dbs/c:datafiletest02.dbf' offline;

 

3.更新控制文件

 

#alter database rename file '' to ''

 

alter database rename file '/u01/app/oracle/product/11.2.0/db_1/dbs/c:datafiletest02.dbf' to '/u01/app/oracle/oradata/orcl/test02.dbf';   

 

 

4.恢复数据文件recover

 

#recover datafile 7;

 

recover datafile '/u01/app/oracle/oradata/orcl/test02.dbf';

 

 

5.online

 

#alter database datafile 7 online;

 

alter database datafile '/u01/app/oracle/oradata/orcl/test02.dbf' online;

 

 

 

rman 工具只能放在自己能够直接识别的包袱空间入/backup 或者磁带库。不能放在Windows上!】

 

 

Rman 备份恢复

 

全备模块:

run

{

allocate channel c1 type disk;

allocate channel c2 type disk;

backup database format '/backup/db_%d_%T_%s_%p';

}

 

 

 

压缩备份:

 

run

{

allocate channel c1 type disk;

allocate channel c2 type disk;

backup as compressed backupset database filesperset 1 format '/backup/full/comprss_%d_%T_%s_%p';

}

 

 

 

全备脚本:

 

export ORACLE_BASE=/u01/app/oracle

export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1

export ORACLE_SID=orcl

export PATH=$ORACLE_HOME/bin:$ORACLE_HOME/OPatch:$PATH

rman target / nocatalog log /backup/full.log append <<EOF

run {

allocate channel c1 type disk;

allocate channel c2 type disk;

backup filesperset 2 database format '/backup/full/full_%d_%T_%s_%p';

sql 'alter system archive log current';

sql 'alter system archive log current';

sql 'alter system archive log current';

backup archivelog all format '/backup/arch/arch_%d_%T_%s_%p';

backup current controlfile format '/backup/ctl/ctl_%d_%T_%s_%p';

}

EOF

 

 

 

归档备份脚本:

 

export ORACLE_BASE=/u01/app/oracle

export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1

export ORACLE_SID=orcl

export PATH=$ORACLE_HOME/bin:$ORACLE_HOME/OPatch:$PATH

rman target / nocatalog log /backup/arch.log append <<EOF

run

{

allocate channel c1 type disk;

allocate channel c2 type disk;

sql 'alter system archive log current';

sql 'alter system archive log current';

sql 'alter system archive log current';

backup archivelog all format '/backup/arch/arch_%d_%T_%s_%p';

backup current controlfile format '/backup/ctl/ctl_%d_%T_%s_%p';

}

EOF

 

 

 

设置计划任务:

 

$ crontab -l

2 * * * * /home/oracle/scripts/full.sh

2 * * * * /home/oracle/scripts/arch.sh

 

 

RMAN备份恢复实操:

 

1.控制文件丢失rman恢复之后,需要recover database,然后再 resetlogs 启动数据库。

 

2.系统数据文件丢失(system/sysaux/undotbs/users/test/)restore datafile 1,recover datafile 1,open...

 

3.在线修复用户数据文件:

alter database datafile 6 offline;

run{

restore datafile 6;

recover datafile 6;

}

 

alter database datafile 6 online;

 

4.临时文件损坏直接重建即可:

SQL> alter tablespace temp add tempfile '/u01/app/oracle/oradata/orcl/temp.dbf' size 50M;

 

5.日志文件损坏

--redo current 丢失:

 

只能启动到mount

SQL> startup

startup

ORACLE instance started.

 

Total System Global Area  839282688 bytes

Fixed Size                  2257880 bytes

Variable Size             545262632 bytes

Database Buffers          289406976 bytes

Redo Buffers                2355200 bytes

Database mounted.

ORA-03113: end-of-file on communication channel

Process ID: 16722

Session ID: 1 Serial number: 5

 

 

清除丢失的日志文件即可:

SQL> alter database clear logfile group 1;

若是没有归档:

SQL> alter database clear unarchived logfile group 1;

 

SQL> alter database open;

 

 

 

【猜想,alter system switch logfile ;切完变为active。日志组轮一圈之后,都会变为inactive。】

 

--redo current 丢失:

1)正常关机:

 

SQL> startup

。。。

Database mounted.

ORA-03113: end-of-file on communication channel

Process ID: 17141

Session ID: 1 Serial number: 5

 

清除日志文件:

SQL> alter database clear logfile group 2;

 

ERROR at line 1:

ORA-00350: log 2 of instance orcl (thread 1) needs to be archived

ORA-00312: online log 2 thread 1: '/u01/app/oracle/oradata/orcl/redo02.log'

 

日志文件还没归档:

SQL> alter database clear unarchived logfile group 2;

 

SQL> alter database open;

 

 

 

2)非正常关机:

SQL> startup force

。。。

Database mounted.

ORA-00313: open failed for members of log group 1 of thread 1

ORA-00312: online log 1 thread 1: '/u01/app/oracle/oradata/orcl/redo01.log'

ORA-27037: unable to obtain file status

Linux-x86_64 Error: 2: No such file or directory

Additional information: 3

 

此时清除日志文件无效,报错需要实例恢复:

SQL> alter database clear logfile '/u01/app/oracle/oradata/orcl/redo03.log';

alter database clear logfile '/u01/app/oracle/oradata/orcl/redo03.log';

alter database clear logfile '/u01/app/oracle/oradata/orcl/redo03.log'

*

ERROR at line 1:

ORA-01624: log 3 needed for crash recovery of instance orcl (thread 1)

ORA-00312: online log 3 thread 1: '/u01/app/oracle/oradata/orcl/redo03.log'

 

进行不完全恢复:

RMAN> restore database;

 

RMAN> recover database until scn 1245734;

或者

SQL> recover database until cancel;

 

SQL> alter database open resetlogs;

 

 

6.误删除表,闪回

 

SQL> drop table test1;                            

drop table test1;

 

Table dropped.

 

SQL> show recyclebin;                     

show recyclebin;

ORIGINAL NAME    RECYCLEBIN NAME                OBJECT TYPE  DROP TIME

---------------- ------------------------------ ------------ -------------------

TEST1            BIN$N2vvsSEwRbvgUwoUqMDN6w==$0 TABLE        2016-07-12:15:44:15

SQL> flashback table test1 to before drop;

flashback table test1 to before drop;

 

Flashback complete.

 

SQL> select count(*) from test1;

select count(*) from test1;

 

  COUNT(*)

----------

       277

 

智能网联汽车的安全员高级考试涉及多个方面的专业知识,包括但不限于自动驾驶技术原理、车辆传感器融合、网络安全防护以及法律法规等内容。以下是针对该主题的一些核心知识点解析: ### 关于智能网联车安全员高级考试的核心内容 #### 1. 自动驾驶分级标准 国际自动机工程师学会(SAE International)定义了六个级别的自动驾驶等级,从L0到L5[^1]。其中,L3及以上级别需要安全员具备更高的应急处理能力。 #### 2. 车辆感知系统的组成与功能 智能网联车通常配备多种传感器,如激光雷达、毫米波雷达、摄像头超声波传感器等。这些设备协同工作以实现环境感知、障碍物检测等功能[^2]。 #### 3. 数据通信与网络安全 智能网联车依赖V2X(Vehicle-to-Everything)技术进行数据交换,在此过程中需防范潜在的网络攻击风险,例如中间人攻击或恶意软件入侵[^3]。 #### 4. 法律法规要求 不同国家地区对于无人驾驶测试及运营有着严格的规定,考生应熟悉当地交通法典中有关自动化驾驶部分的具体条款[^4]。 ```python # 示例代码:模拟简单决策逻辑 def decide_action(sensor_data): if sensor_data['obstacle'] and not sensor_data['emergency']: return 'slow_down' elif sensor_data['pedestrian_crossing']: return 'stop_and_yield' else: return 'continue_driving' example_input = {'obstacle': True, 'emergency': False, 'pedestrian_crossing': False} action = decide_action(example_input) print(f"Action to take: {action}") ``` 需要注意的是,“橙点同学”作为特定平台上的学习资源名称,并不提供官方认证的标准答案集;建议通过正规渠道获取教材并参加培训课程来准备此类资格认证考试。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值