归档模式下热备原理及脚本

归档模式下热备原理 :
热备是控制SCN在你备份的时候不变化 (冻结块头),但行的记录是可以变更的。
然后进行物理拷贝,
然后使scn可以变化(解冻块头)

我们可以对数据库热备,也可以对表空间热备,也可以对控制文件热备。但一般情况下对表空间热备。日志文件不需要热备。
参数文件可以相互转化,也不需要热备。

热备的命令:
alter database begin backup;      这个命令会冻结所有的块头。
alter database end backup ;      解冻所有的块头。

对单个表空间执行热备:
alter tablespace <> begin backup  ;
alter tablespace <> end backup ;
注:临时表空间是不需要热备的。


操作:
查看是否为归档模式
SQL>archive log list ;
如果不是,执行alter database archivelog 

SQL>alter system switch logfile ;
执行切换日志后,你看current log sequence 是否变化 了,
如果更新了,说明当前的归档模式是正常在工作。


SQL> select tablespace_name from dba_data_files ;
查看表空间。
SQL>select name from v$datafile ;
查看表空间的路径

SQL>alter database begin backup ;

然后做数据文件的拷贝。
SQL>select 'ho cp '||name || '/u02/horcl/' from v$datafile ;

SQL>alter database end backup ;

然后再备份控制文件
SQL> alter database backup controlfile to '/u02/horcl/control01.ctl' ;

然后备份 参数文件
SQL>create pfile='/u02/horcl/initorcl.ora' from spfile ;

日志文件不需要做备份。
临时表空间也不需要备份 ,它也oracle启动没有关系,只也排序之类的有关系。


最后,总结一下完整的热备的脚本。
spool /tmp/hot.sql
select 'ho cp ' || name  || '/u02/horcl/'  from v$datafile ;
spool off

ho sed -n /^ho cp/p' /tmp/hot.sql > /tmp/hotorcl.sql
alter database begin backup ;
start /tmp/hotorcl.sql
alter database end backup ;
alter database backup controlfile to '/u02/horcl/control01.ctl' ;
create pfile='/u02/horcl/initorcl.ora' from spfile ;

然后执行脚本
SQL>@/u02/hotbak



==================================
下面来使用备份表空间的方式来备份。
脚本:
set heading off
spool /tmp/hot.sql
select 'alter tablespace ' || tablespace_name  || ' begin backup ; '
|| chr(10) ||
' ho cp ' || file_name || ' /u02/horcl/' || chr(10)
||' alter tablespace ' || tablespace_name || ' end backup ; ' from
dba_data_files order by tablespace_name ;
spool off

start /tmp/hot.sql
alter database backup controlfile to 'u02/horcl/control01.ctl' ;
create pfile='/u02/horcl/initorcl.ora' from spfile  ;













来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/29196873/viewspace-1122061/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/29196873/viewspace-1122061/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
vrrp+mstp实现双机热备是一种常见的网络高可用方案。其中vrrp是虚拟路由冗余协议,用于实现多个路由器的冗余备份,保证网络的高可用性。而mstp是多协议生成树协议,用于在网络中选择一棵最优的生成树,实现网络的快速收敛。 在ensp中实现vrrp+mstp双机热备可以使用以下脚本: ``` sysname ENSP # interface GigabitEthernet0/0/1 port link-type access port default vlan 10 stp edged-port enable # interface GigabitEthernet0/0/2 port link-type trunk port trunk allow-pass vlan 10 stp edged-port enable # interface Vlanif10 ip address 10.0.0.1 255.255.255.0 vrrp vrid 10 virtual-ip 10.0.0.100 vrrp vrid 10 priority 100 vrrp vrid 10 preempt-mode timer delay 60 stp instance 1 vlan 10 root primary stp edged-port enable # interface Vlanif20 ip address 20.0.0.1 255.255.255.0 vrrp vrid 20 virtual-ip 20.0.0.100 vrrp vrid 20 priority 90 vrrp vrid 20 preempt-mode timer delay 60 stp instance 2 vlan 20 root secondary stp edged-port enable # interface NULL0 stp loop-protection # ``` 这个脚本中,我们通过配置GigabitEthernet0/0/1和GigabitEthernet0/0/2两个端口实现了vlan10和vlan20的网络互联,并且在Vlanif10和Vlanif20两个接口上分别启用了vrrp和mstp。其中vrrp vrid 10表示在vrrp协议中使用虚拟路由器ID为10,priority设置为100表示优先级最高,可以作为主节点提供服务,同时preempt-mode timer delay 60表示当主节点失效时,等待60秒后副节点将接管服务。而在mstp协议中,我们通过配置stp instance 1 vlan 10 root primary表示vlan10的根节点为主节点,而stp instance 2 vlan 20 root secondary则表示vlan20的根节点为副节点。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值