当前位置: 首页 > news >正文

Oracle 数据库 control file的备份

自动备份

间接的是指,如果启用了CONTROLFILE AUTOBACKUP,那么备份时,也会把control file带上:

RMAN> CONFIGURE CONTROLFILE AUTOBACKUP OFF;new RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP OFF;
new RMAN configuration parameters are successfully storedRMAN> backup spfile;Starting backup at 15-DEC-23
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=264 device type=DISK
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current SPFILE in backup set
channel ORA_DISK_1: starting piece 1 at 15-DEC-23
channel ORA_DISK_1: finished piece 1 at 15-DEC-23
piece handle=/opt/oracle/product/19c/dbhome_1/dbs/012e36jf_1_1 tag=TAG20231215T095703 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 15-DEC-23RMAN> CONFIGURE CONTROLFILE AUTOBACKUP CLEAR;old RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP OFF;
RMAN configuration parameters are successfully reset to default valueRMAN> backup spfile;Starting backup at 15-DEC-23
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current SPFILE in backup set
channel ORA_DISK_1: starting piece 1 at 15-DEC-23
channel ORA_DISK_1: finished piece 1 at 15-DEC-23
piece handle=/opt/oracle/product/19c/dbhome_1/dbs/022e36k3_1_1 tag=TAG20231215T095723 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 15-DEC-23Starting Control File and SPFILE Autobackup at 15-DEC-23
piece handle=/opt/oracle/product/19c/dbhome_1/dbs/c-2920819444-20231215-00 comment=NONE
Finished Control File and SPFILE Autobackup at 15-DEC-23

手动备份

手动备份可通过RMAN或SQL命令。

RMAN 手动备份

RMAN> backup current controlfile;Starting backup at 15-DEC-23
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current control file in backup set
channel ORA_DISK_1: starting piece 1 at 15-DEC-23
channel ORA_DISK_1: finished piece 1 at 15-DEC-23
piece handle=/opt/oracle/product/19c/dbhome_1/dbs/042e370v_1_1 tag=TAG20231215T100415 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 15-DEC-23Starting Control File and SPFILE Autobackup at 15-DEC-23
piece handle=/opt/oracle/product/19c/dbhome_1/dbs/c-2920819444-20231215-01 comment=NONE
Finished Control File and SPFILE Autobackup at 15-DEC-23

很神奇,spfile也自动备份了。

SQL 手动备份

ALTER DATABASE BACKUP CONTROLFILE TO TRACE

在alert log中可以找到trace file的位置:

alert_ORCLCDB.log:Backup controlfile written to trace file 

输出的SQL脚本:

/opt/oracle/diag/rdbms/orclcdb/ORCLCDB/trace/ORCLCDB_ora_3449.trc
$ cat /opt/oracle/diag/rdbms/orclcdb/ORCLCDB/trace/ORCLCDB_ora_3449.trc
Trace file /opt/oracle/diag/rdbms/orclcdb/ORCLCDB/trace/ORCLCDB_ora_3449.trc
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0
Build label:    RDBMS_19.3.0.0.0DBRU_LINUX.X64_190417
ORACLE_HOME:    /opt/oracle/product/19c/dbhome_1
System name:    Linux
Node name:      oracle-19c-vagrant
Release:        5.4.17-2136.323.8.2.el7uek.x86_64
Version:        #2 SMP Wed Sep 20 00:06:39 PDT 2023
Machine:        x86_64
Instance name: ORCLCDB
Redo thread mounted by this instance: 1
Oracle process number: 35
Unix process pid: 3449, image: oracle@oracle-19c-vagrant (TNS V1-V3)*** 2023-12-15T09:52:20.683367+08:00 (CDB$ROOT(1))
*** SESSION ID:(268.60469) 2023-12-15T09:52:20.683403+08:00
*** CLIENT ID:() 2023-12-15T09:52:20.683411+08:00
*** SERVICE NAME:(SYS$USERS) 2023-12-15T09:52:20.683416+08:00
*** MODULE NAME:(sqlplus@oracle-19c-vagrant (TNS V1-V3)) 2023-12-15T09:52:20.683423+08:00
*** ACTION NAME:() 2023-12-15T09:52:20.683428+08:00
*** CLIENT DRIVER:(SQL*PLUS) 2023-12-15T09:52:20.683432+08:00
*** CONTAINER ID:(1) 2023-12-15T09:52:20.683438+08:00-- The following are current System-scope REDO Log Archival related
-- parameters and can be included in the database initialization file.
--
-- LOG_ARCHIVE_DEST=''
-- LOG_ARCHIVE_DUPLEX_DEST=''
--
-- LOG_ARCHIVE_FORMAT=%t_%s_%r.dbf
--
-- DB_UNIQUE_NAME="ORCLCDB"
--
-- LOG_ARCHIVE_CONFIG='SEND, RECEIVE, NODG_CONFIG'
-- LOG_ARCHIVE_MAX_PROCESSES=4
-- STANDBY_FILE_MANAGEMENT=MANUAL
-- FAL_CLIENT=''
-- FAL_SERVER=''
--
-- LOG_ARCHIVE_DEST_1='LOCATION=/opt/oracle/product/19c/dbhome_1/dbs/arch'
-- LOG_ARCHIVE_DEST_1='MANDATORY REOPEN=300 NODELAY'
-- LOG_ARCHIVE_DEST_1='ARCH NOAFFIRM NOVERIFY SYNC'
-- LOG_ARCHIVE_DEST_1='NOREGISTER'
-- LOG_ARCHIVE_DEST_1='NOALTERNATE'
-- LOG_ARCHIVE_DEST_1='NODEPENDENCY'
-- LOG_ARCHIVE_DEST_1='NOMAX_FAILURE NOQUOTA_SIZE NOQUOTA_USED NODB_UNIQUE_NAME'
-- LOG_ARCHIVE_DEST_1='VALID_FOR=(PRIMARY_ROLE,ONLINE_LOGFILES)'
-- LOG_ARCHIVE_DEST_STATE_1=ENABLE
--
-- Below are two sets of SQL statements, each of which creates a new
-- control file and uses it to open the database. The first set opens
-- the database with the NORESETLOGS option and should be used only if
-- the current versions of all online logs are available. The second
-- set opens the database with the RESETLOGS option and should be used
-- if online logs are unavailable.
-- The appropriate set of statements can be copied from the trace into
-- a script file, edited as necessary, and executed when there is a
-- need to re-create the control file.
--
--     Set #1. NORESETLOGS case
--
-- The following commands will create a new control file and use it
-- to open the database.
-- Data used by Recovery Manager will be lost.
-- Additional logs may be required for media recovery of offline
-- Use this only if the current versions of all online logs are
-- available.
-- After mounting the created controlfile, the following SQL
-- statement will place the database in the appropriate
-- protection mode:
--  ALTER DATABASE SET STANDBY DATABASE TO MAXIMIZE PERFORMANCE
STARTUP NOMOUNT
CREATE CONTROLFILE REUSE DATABASE "ORCLCDB" NORESETLOGS  NOARCHIVELOGMAXLOGFILES 16MAXLOGMEMBERS 3MAXDATAFILES 1024MAXINSTANCES 8MAXLOGHISTORY 292
LOGFILEGROUP 1 '/opt/oracle/oradata/ORCLCDB/redo01.log'  SIZE 200M BLOCKSIZE 512,GROUP 2 '/opt/oracle/oradata/ORCLCDB/redo02.log'  SIZE 200M BLOCKSIZE 512,GROUP 3 '/opt/oracle/oradata/ORCLCDB/redo03.log'  SIZE 200M BLOCKSIZE 512
-- STANDBY LOGFILE
DATAFILE'/opt/oracle/oradata/ORCLCDB/system01.dbf','/opt/oracle/oradata/ORCLCDB/sysaux01.dbf','/opt/oracle/oradata/ORCLCDB/undotbs01.dbf','/opt/oracle/oradata/ORCLCDB/pdbseed/system01.dbf','/opt/oracle/oradata/ORCLCDB/pdbseed/sysaux01.dbf','/opt/oracle/oradata/ORCLCDB/users01.dbf','/opt/oracle/oradata/ORCLCDB/pdbseed/undotbs01.dbf','/opt/oracle/oradata/ORCLCDB/ORCLPDB1/system01.dbf','/opt/oracle/oradata/ORCLCDB/ORCLPDB1/sysaux01.dbf','/opt/oracle/oradata/ORCLCDB/ORCLPDB1/undotbs01.dbf','/opt/oracle/oradata/ORCLCDB/ORCLPDB1/users01.dbf','/u02/oradata/ORCLCDB/07AB4734637A6E5DE0630101007F8538/datafile/o1_mf_system_llnsto42_.dbf','/u02/oradata/ORCLCDB/07AB4734637A6E5DE0630101007F8538/datafile/o1_mf_sysaux_llnsto4j_.dbf','/u02/oradata/ORCLCDB/07AB4734637A6E5DE0630101007F8538/datafile/o1_mf_undotbs1_llnsto4o_.dbf','/u02/oradata/ORCLCDB/07AB4734637A6E5DE0630101007F8538/datafile/o1_mf_users_llnsto4z_.dbf'
CHARACTER SET AL32UTF8
;
-- Commands to re-create incarnation table
-- Below log names MUST be changed to existing filenames on
-- disk. Any one log file from each branch can be used to
-- re-create incarnation records.
-- ALTER DATABASE REGISTER LOGFILE '/opt/oracle/product/19c/dbhome_1/dbs/arch1_1_1005785759.dbf';
-- ALTER DATABASE REGISTER LOGFILE '/opt/oracle/product/19c/dbhome_1/dbs/arch1_1_1149758071.dbf';
-- Recovery is required if any of the datafiles are restored backups,
-- or if the last shutdown was not normal or immediate.
RECOVER DATABASE
-- Database can now be opened normally.
ALTER DATABASE OPEN;
-- Open all the PDBs.
ALTER PLUGGABLE DATABASE ALL OPEN;
-- Commands to add tempfiles to temporary tablespaces.
-- Online tempfiles have complete space information.
-- Other tempfiles may require adjustment.
ALTER TABLESPACE TEMP ADD TEMPFILE '/opt/oracle/oradata/ORCLCDB/temp01.dbf'SIZE 135266304  REUSE AUTOEXTEND ON NEXT 655360  MAXSIZE 32767M;
ALTER SESSION SET CONTAINER = "PDB$SEED";
ALTER TABLESPACE TEMP ADD TEMPFILE '/opt/oracle/oradata/ORCLCDB/pdbseed/temp012023-10-09_09-26-58-555-AM.dbf'SIZE 37748736  REUSE AUTOEXTEND ON NEXT 655360  MAXSIZE 32767M;
ALTER SESSION SET CONTAINER = "ORCLPDB1";
ALTER TABLESPACE TEMP ADD TEMPFILE '/opt/oracle/oradata/ORCLCDB/ORCLPDB1/temp01.dbf'SIZE 37748736  REUSE AUTOEXTEND ON NEXT 655360  MAXSIZE 32767M;
ALTER SESSION SET CONTAINER = "ORCLPDB2";
ALTER TABLESPACE TEMP ADD TEMPFILE '/u02/oradata/ORCLCDB/07AB4734637A6E5DE0630101007F8538/datafile/o1_mf_temp_llnsto4t_.dbf' REUSE;
ALTER SESSION SET CONTAINER = "CDB$ROOT";
-- End of tempfile additions.
--
--     Set #2. RESETLOGS case
--
-- The following commands will create a new control file and use it
-- to open the database.
-- Data used by Recovery Manager will be lost.
-- The contents of online logs will be lost and all backups will
-- be invalidated. Use this only if online logs are damaged.
-- After mounting the created controlfile, the following SQL
-- statement will place the database in the appropriate
-- protection mode:
--  ALTER DATABASE SET STANDBY DATABASE TO MAXIMIZE PERFORMANCE
STARTUP NOMOUNT
CREATE CONTROLFILE REUSE DATABASE "ORCLCDB" RESETLOGS  NOARCHIVELOGMAXLOGFILES 16MAXLOGMEMBERS 3MAXDATAFILES 1024MAXINSTANCES 8MAXLOGHISTORY 292
LOGFILEGROUP 1 '/opt/oracle/oradata/ORCLCDB/redo01.log'  SIZE 200M BLOCKSIZE 512,GROUP 2 '/opt/oracle/oradata/ORCLCDB/redo02.log'  SIZE 200M BLOCKSIZE 512,GROUP 3 '/opt/oracle/oradata/ORCLCDB/redo03.log'  SIZE 200M BLOCKSIZE 512
-- STANDBY LOGFILE
DATAFILE'/opt/oracle/oradata/ORCLCDB/system01.dbf','/opt/oracle/oradata/ORCLCDB/sysaux01.dbf','/opt/oracle/oradata/ORCLCDB/undotbs01.dbf','/opt/oracle/oradata/ORCLCDB/pdbseed/system01.dbf','/opt/oracle/oradata/ORCLCDB/pdbseed/sysaux01.dbf','/opt/oracle/oradata/ORCLCDB/users01.dbf','/opt/oracle/oradata/ORCLCDB/pdbseed/undotbs01.dbf','/opt/oracle/oradata/ORCLCDB/ORCLPDB1/system01.dbf','/opt/oracle/oradata/ORCLCDB/ORCLPDB1/sysaux01.dbf','/opt/oracle/oradata/ORCLCDB/ORCLPDB1/undotbs01.dbf','/opt/oracle/oradata/ORCLCDB/ORCLPDB1/users01.dbf','/u02/oradata/ORCLCDB/07AB4734637A6E5DE0630101007F8538/datafile/o1_mf_system_llnsto42_.dbf','/u02/oradata/ORCLCDB/07AB4734637A6E5DE0630101007F8538/datafile/o1_mf_sysaux_llnsto4j_.dbf','/u02/oradata/ORCLCDB/07AB4734637A6E5DE0630101007F8538/datafile/o1_mf_undotbs1_llnsto4o_.dbf','/u02/oradata/ORCLCDB/07AB4734637A6E5DE0630101007F8538/datafile/o1_mf_users_llnsto4z_.dbf'
CHARACTER SET AL32UTF8
;
-- Commands to re-create incarnation table
-- Below log names MUST be changed to existing filenames on
-- disk. Any one log file from each branch can be used to
-- re-create incarnation records.
-- ALTER DATABASE REGISTER LOGFILE '/opt/oracle/product/19c/dbhome_1/dbs/arch1_1_1005785759.dbf';
-- ALTER DATABASE REGISTER LOGFILE '/opt/oracle/product/19c/dbhome_1/dbs/arch1_1_1149758071.dbf';
-- Recovery is required if any of the datafiles are restored backups,
-- or if the last shutdown was not normal or immediate.
RECOVER DATABASE USING BACKUP CONTROLFILE
-- Database can now be opened zeroing the online logs.
ALTER DATABASE OPEN RESETLOGS;
-- Open all the PDBs.
ALTER PLUGGABLE DATABASE ALL OPEN;
-- Commands to add tempfiles to temporary tablespaces.
-- Online tempfiles have complete space information.
-- Other tempfiles may require adjustment.
ALTER TABLESPACE TEMP ADD TEMPFILE '/opt/oracle/oradata/ORCLCDB/temp01.dbf'SIZE 135266304  REUSE AUTOEXTEND ON NEXT 655360  MAXSIZE 32767M;
ALTER SESSION SET CONTAINER = "PDB$SEED";
ALTER TABLESPACE TEMP ADD TEMPFILE '/opt/oracle/oradata/ORCLCDB/pdbseed/temp012023-10-09_09-26-58-555-AM.dbf'SIZE 37748736  REUSE AUTOEXTEND ON NEXT 655360  MAXSIZE 32767M;
ALTER SESSION SET CONTAINER = "ORCLPDB1";
ALTER TABLESPACE TEMP ADD TEMPFILE '/opt/oracle/oradata/ORCLCDB/ORCLPDB1/temp01.dbf'SIZE 37748736  REUSE AUTOEXTEND ON NEXT 655360  MAXSIZE 32767M;
ALTER SESSION SET CONTAINER = "ORCLPDB2";
ALTER TABLESPACE TEMP ADD TEMPFILE '/u02/oradata/ORCLCDB/07AB4734637A6E5DE0630101007F8538/datafile/o1_mf_temp_llnsto4t_.dbf' REUSE;
ALTER SESSION SET CONTAINER = "CDB$ROOT";
-- End of tempfile additions.
--

相关文章:

  • TensortRT:sample.py:DeprecationWarning:
  • Linux shell编程学习笔记35:seq
  • 33.搜索旋转排序数组
  • Certbot实现 HTTPS 免费证书(Let‘s Encrypt)自动续期
  • 【Linux】tree命令使用
  • 第七章 SpringCloud Alibaba 实现微服务集成Sentinel
  • Ubuntu22,桌面服务状态查看与重启
  • 2024黑龙江省职业院校技能大赛暨国赛选拔赛“GZ031应用软件系统开发”赛项赛题题库
  • 3.DevEco Studio安装鸿蒙手机app本地模拟器
  • 2019年AMC8数学竞赛真题的典型考点和详细解析
  • 后端项目全局异常处理-使用RuntimeException自定义异常异常分类简单举例
  • 详细教程 - 从零开发 Vue 鸿蒙harmonyOS应用 第三节 (封装TabBar JS版)
  • 基于以太坊的智能合约开发Solidity(事件日志篇)
  • Java8 IfPresent 与 forEach 的组合操作
  • Nacos配置管理-微服务配置拉取
  • [Vue CLI 3] 配置解析之 css.extract
  • [译]CSS 居中(Center)方法大合集
  • css布局,左右固定中间自适应实现
  • ES6核心特性
  • ESLint简单操作
  • JavaScript 基本功--面试宝典
  • JavaScript对象详解
  • Node 版本管理
  • node-sass 安装卡在 node scripts/install.js 解决办法
  • Python打包系统简单入门
  • SpingCloudBus整合RabbitMQ
  • Spring Boot MyBatis配置多种数据库
  • 大数据与云计算学习:数据分析(二)
  • 入手阿里云新服务器的部署NODE
  • 一、python与pycharm的安装
  • 异常机制详解
  • 原生JS动态加载JS、CSS文件及代码脚本
  • 运行时添加log4j2的appender
  • (Git) gitignore基础使用
  • (java版)排序算法----【冒泡,选择,插入,希尔,快速排序,归并排序,基数排序】超详细~~
  • (二)PySpark3:SparkSQL编程
  • (十七)devops持续集成开发——使用jenkins流水线pipeline方式发布一个微服务项目
  • (五)关系数据库标准语言SQL
  • (转)c++ std::pair 与 std::make
  • .libPaths()设置包加载目录
  • .NET Compact Framework 3.5 支持 WCF 的子集
  • .NET Framework Client Profile - a Subset of the .NET Framework Redistribution
  • .Net IOC框架入门之一 Unity
  • .NET/C# 使窗口永不获得焦点
  • ??eclipse的安装配置问题!??
  • @SuppressWarnings注解
  • [100天算法】-每个元音包含偶数次的最长子字符串(day 53)
  • [3D基础]理解计算机3D图形学中的坐标系变换
  • [8481302]博弈论 斯坦福game theory stanford week 1
  • [AutoSar]BSW_OS 01 priority ceiling protocol(PCP)
  • [C++]二叉搜索树
  • [ChromeApp]指南!让你的谷歌浏览器好用十倍!
  • [cogs2652]秘术「天文密葬法」
  • [Flutter]WindowsPlatform上运行遇到的问题总结
  • [LeetCode] 148. Sort List 链表排序