数据库在挂载状态下可以进行consistent backup

 证明的思路是:
1、使用在数据库处于NOARCHIVELOG非归档模式的mount状态下进行的数据库备份在进行还原数据库之后
   不需要恢复(recover)操作的话,即可认为数据库处于NOARCHIVELOG非归档模式的mount状态下可以进行
   consistant backup;
2、再对数据库处于ARCHIVELOG非归档模式的mount状态下进行的数据库备份,然后在mount状态下进行一
   些操作,以产生日志,然后再进行还原操作,不进行recover操作直接open数据库如何?进行recover操
   作之后进行open数据库如何?

下面的是证明的具体操作步骤:
下面在数据库处于NOARCHIVELOG非归档模式的mount状态下进行consistant backup
1、首先数据需要处于NOARCHIVELOG非归档模式下:
SQL> select name,log_mode from v$database;
NAME      LOG_MODE
--------- ------------
MYDB      NOARCHIVELOG

SQL> archive log list;
Database log mode              No Archive Mode
Automatic archival             Disabled
Archive destination            USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence     6
Current log sequence           8

2、挂载数据库
SQL> connect / as sysdba
Connected to an idle instance.
SQL> startup mount;
ORACLE instance started.
Total System Global Area  167772160 bytes
Fixed Size                  1218316 bytes
Variable Size              71305460 bytes
Database Buffers           92274688 bytes
Redo Buffers                2973696 bytes
Database mounted.

3、在数据库挂载状态下备份一致数据库(consistant backup)
RMAN> backup database tag 'tag_1';
Starting backup at 26-NOV-08
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=155 devtype=DISK
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00001 name=/opt/oracle/oradata/mydb/system01.dbf
input datafile fno=00003 name=/opt/oracle/oradata/mydb/sysaux01.dbf
input datafile fno=00002 name=/opt/oracle/oradata/mydb/undotbs01.dbf
input datafile fno=00004 name=/opt/oracle/oradata/mydb/users01.dbf
channel ORA_DISK_1: starting piece 1 at 26-NOV-08
channel ORA_DISK_1: finished piece 1 at 26-NOV-08
piece handle=/opt/oracle/flash_recovery_area/MYDB/backupset/2008_11_26/o1_mf_nnndf_TAG_1_4lstn3pz_.bkp tag=TAG_1 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:01:56
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
including current control file in backupset
including current SPFILE in backupset
channel ORA_DISK_1: starting piece 1 at 26-NOV-08
channel ORA_DISK_1: finished piece 1 at 26-NOV-08
piece handle=/opt/oracle/flash_recovery_area/MYDB/backupset/2008_11_26/o1_mf_ncsnf_TAG_1_4lstqw5g_.bkp tag=TAG_1 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:07
Finished backup at 26-NOV-08

RMAN> shutdown immediate
database dismounted
Oracle instance shut down

SQL> connect / as sysdba
Connected to an idle instance.
SQL> startup mount;
ORACLE instance started.
Total System Global Area  167772160 bytes
Fixed Size                  1218316 bytes
Variable Size              71305460 bytes
Database Buffers           92274688 bytes
Redo Buffers                2973696 bytes
Database mounted.

--使用consistant backup来进行还原数据库
RMAN> restore database from tag='tag_1';
Starting restore at 26-NOV-08
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=155 devtype=DISK
skipping datafile 1; already restored to file /opt/oracle/oradata/mydb/system01.dbf
skipping datafile 2; already restored to file /opt/oracle/oradata/mydb/undotbs01.dbf
skipping datafile 3; already restored to file /opt/oracle/oradata/mydb/sysaux01.dbf
skipping datafile 4; already restored to file /opt/oracle/oradata/mydb/users01.dbf
restore not done; all files readonly, offline, or already restored
Finished restore at 26-NOV-08

--此时不需要做recover操作即可进行open数据库操作
RMAN> SQL 'ALTER DATABASE OPEN';
sql statement: ALTER DATABASE OPEN

RMAN> SHUTDOWN IMMEDIATE;
database closed
database dismounted
Oracle instance shut down


下面在数据库处于归档模式的mount状态下进行consistant backup
1、首先需要数据库是处于归档模式下:
SQL> archive log list;
Database log mode              No Archive Mode
Automatic archival             Disabled
Archive destination            USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence     6
Current log sequence           8

SQL> select name,log_mode from v$database;
NAME      LOG_MODE
--------- ------------
MYDB      NOARCHIVELOG

SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.

SQL> startup mount;
ORACLE instance started.
Total System Global Area  167772160 bytes
Fixed Size                  1218316 bytes
Variable Size              71305460 bytes
Database Buffers           92274688 bytes
Redo Buffers                2973696 bytes
Database mounted.

修改数据库为归档模式:
SQL>  alter database archivelog;
Database altered.

SQL> select name,log_mode from v$database;
NAME      LOG_MODE
--------- ------------
MYDB      ARCHIVELOG   --修改为归档模式

SQL> select name,log_mode from v$database;
NAME      LOG_MODE
--------- ------------
MYDB      ARCHIVELOG   --修改为归档模式

2、在数据库mount状态下进行备份
RMAN> backup database tag 'tag_2';
Starting backup at 28-NOV-08
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00001 name=/opt/oracle/oradata/mydb/system01.dbf
input datafile fno=00003 name=/opt/oracle/oradata/mydb/sysaux01.dbf
input datafile fno=00002 name=/opt/oracle/oradata/mydb/undotbs01.dbf
input datafile fno=00004 name=/opt/oracle/oradata/mydb/users01.dbf
input datafile fno=00005 name=/opt/oracle/oradata/mydb/users02.dbf
channel ORA_DISK_1: starting piece 1 at 28-NOV-08
channel ORA_DISK_1: finished piece 1 at 28-NOV-08
piece handle=/opt/oracle/flash_recovery_area/MYDB/backupset/2008_11_28/o1_mf_nnndf_TAG_2_4lym5r1k_.bkp tag=TAG_2 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:01:36
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
including current control file in backupset
including current SPFILE in backupset
channel ORA_DISK_1: starting piece 1 at 28-NOV-08
channel ORA_DISK_1: finished piece 1 at 28-NOV-08
piece handle=/opt/oracle/flash_recovery_area/MYDB/backupset/2008_11_28/o1_mf_ncsnf_TAG_2_4lym8vhc_.bkp tag=TAG_2 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:07
Finished backup at 28-NOV-08


3、以sys用户登陆mount状态下的数据库,只做一些查询操作,
   观察SCN是否改变(不允许做其他的维护操作,mount状态下只能做fixed tables/views做查询操作如果做其他操作,会报如下错误:
   ORA-01219: database not open: queries allowed on fixed tables/views only),
   做了查询发现SCN并没有发生改变
--查看还原之后数据库的SCN
SQL> select current_scn from v$database;
CURRENT_SCN
-----------
          0
SQL> select dbms_flashback.get_system_change_number from dual;
select dbms_flashback.get_system_change_number from dual
       *
ERROR at line 1:
ORA-00904: "DBMS_FLASHBACK"."GET_SYSTEM_CHANGE_NUMBER": invalid identifier
分析:mount状态下不能获取到当前数据库的SCN


4、使用在mount下进行的备份进行还原
SQL> shutdown immediate;
ORA-01109: database not open
Database dismounted.
ORACLE instance shut down.

SQL> startup mount;
ORACLE instance started.
Total System Global Area  167772160 bytes
Fixed Size                  1218316 bytes
Variable Size              71305460 bytes
Database Buffers           92274688 bytes
Redo Buffers                2973696 bytes
Database mounted.

[oracle@localhost ~]$ rman target sys/test@MYDB

Recovery Manager: Release 10.2.0.1.0 - Production on Thu Nov 27 13:19:14 2008

Copyright (c) 1982, 2005, Oracle.  All rights reserved.

connected to target database: MYDB (DBID=2586727849, not open)

RMAN> restore database from tag='tag_2';
Starting restore at 27-NOV-08
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=155 devtype=DISK
skipping datafile 1; already restored to file /opt/oracle/oradata/mydb/system01.dbf
skipping datafile 2; already restored to file /opt/oracle/oradata/mydb/undotbs01.dbf
skipping datafile 3; already restored to file /opt/oracle/oradata/mydb/sysaux01.dbf
skipping datafile 4; already restored to file /opt/oracle/oradata/mydb/users01.dbf
restore not done; all files readonly, offline, or already restored
Finished restore at 27-NOV-08

--不进行recover操作,直接open数据库
RMAN> SQL 'alter database open';
sql statement: alter database open

结论:数据库处于mount状态下,不管数据库是归档模式还是非归档模式,所做的备份都是consistent backup.


 

安装Docker安装插件,可以按照以下步骤进行操作: 1. 首先,安装Docker。可以按照官方文档提供的步骤进行安装,或者使用适合您操作系统的包管理器进行安装。 2. 安装Docker Compose插件。可以使用以下方法安装: 2.1 下载指定版本的docker-compose文件: curl -L https://github.com/docker/compose/releases/download/1.21.2/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose 2.2 赋予docker-compose文件执行权限: chmod +x /usr/local/bin/docker-compose 2.3 验证安装是否成功: docker-compose --version 3. 在安装插件之前,可以测试端口是否已被占用,以避免编排过程中出错。可以使用以下命令安装netstat并查看端口号是否被占用: yum -y install net-tools netstat -npl | grep 3306 现在,您已经安装Docker安装Docker Compose插件,可以继续进行其他操作,例如上传docker-compose.yml文件到服务器,并在服务器上安装MySQL容器。可以参考Docker的官方文档或其他资源来了解如何使用DockerDocker Compose进行容器的安装和配置。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *2* [Docker安装docker-compose插件](https://blog.csdn.net/qq_50661854/article/details/124453329)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] - *3* [Docker安装MySQL docker安装mysql 完整详细教程](https://blog.csdn.net/qq_40739917/article/details/130891879)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值