当你在主库删除一个或多个数据文件或者删除一个或多个表空间时,你也需要在备库删除相关的数据文件,以下部分提供的例子,当STAN
8.3.2Dropping Tablespaces and Deleting Datafiles
8.3.2 删除表空间和删除数据文件
When you delete one or moredatafiles or drop one or more tablespaces in the primary database, you also need to delete the corresponding datafiles to the standby database. The following sections provide examples of dropping tablespaces and deleting datafiles when theSTANDBY_FILE_MANAGEMENTinitialization parameter is set toAUTOorMANUAL.
当你在主库删除一个或多个数据文件或者删除一个或多个表空间时,你也需要在备库删除相关的数据文件,以下部分提供的例子,当
8.3.2.1When STANDBY_FILE_MANAGEMENT Is Set to AUTO or MANUAL
8.3.2.1 当STANDBY_FILE_MANAGEMENT设置为AUTO或者MANUAL时
The following procedure works whether theSTANDBY_FILE_MANAGEMENTinitialization parameter is set to eitherMANUALorAUTO, as follows:
以下的步骤不管STANDBY_FILE_MANAGEMENT参数设置为MANUAL还是AUTO,都能工作,如下:
Drop the tablespace from the primary database:
1.从主库删除一个表空间
SQL> DROP TABLESPACE tbs_4;
SQL> ALTER SYSTEM SWITCH LOGFILE;
Make sure that Redo Apply is running (so that the change is applied to the standby database). If the following query returns the MRP or MRP0 process, Redo Apply is running.
确保重做应用在运行,这样备库就会应用这些变化。如果以下的查询返回的MRP或者MRP0进程,则说明重做应用在运行
SQL> SELECT PROCESS, STATUS FROM V$MANAGED_STANDBY;
To verify that deleted datafiles are no longer part of the database, query theV$DATAFILEview.
验证已经删除的数据文件不再存在数据库中,可查询V$DATAFILE视图。
Delete the corresponding datafile on the standby system after the archived redo log file was applied to the standby database. For example:
在归档重做日志被应用再备库之后,在备库删除相应的数据文件,例如:
% rm /disk1/Oracle/oradata/payroll/s2tbs_4.dbf
On the primary database, after ensuring the standby database applied the redo information for the dropped tablespace, you can remove the datafile for the tablespace. For example:
在主库中,确保备库应用删除表空间的重做信息之后,你可以从表空间移除数据文件,例如:
% rm /disk1/oracle/oradata/payroll/tbs_4.dbf
8.3.2.2Using DROP TABLESPACE INCLUDING CONTENTS AND DATAFILES
8.3.2.2 使用DROP TABLESPACE INCLUDING CONTENTS AND DATAFILES
You can issue the SQLDROP TABLESPACE INCLUDING CONTENTS AND DATAFILESstatement on the primary database to delete the datafiles on both the primary and standby databases. To use this statement, theSTANDBY_FILE_MANAGEMENTinitialization parameter must be set toAUTO. For example, to drop the tablespace at the primary site:
你可以在主库上使用DROP TABLESPACE INCLUDING CONTENTS AND DATAFILES来删除主库和备库的数据文件,前提是STANDBY_FILE_MANAGEMENT必须设置为AUTO,例如,,在主库上删除一个表空间:
SQL> DROP TABLESPACE INCLUDING CONTENTS AND DATAFILES tbs_4;
SQL> ALTER SYSTEM SWITCH LOGFILE;
###########################################################################################################
我的实验:主库使用DROP TABLESPACE INCLUDING CONTENTS AND DATAFILES删除表空间,备库中的STANDBY_FILE_MANAGEMENT参数设置为AUTO
主库:PROD
备库:PRODSTD
1.首先查看STANDBY_FILE_MANAGEMENT参数是否设置为AUTO
SYS@PRODSTD>show parameter STANDBY_FILE_MANAGEMENT
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
standby_file_management string AUTO
2.查看两边的表空间以及数据文件
主库:
SYS@PROD>select file_name,tablespace_name from dba_data_files;
FILE_NAME TABLESPACE_NAME
-------------------------------------------------- ------------------------------
/u01/app/oracle/oradata/PROD/Disk1/system01.dbf SYSTEM
/u01/app/oracle/oradata/PROD/Disk1/undotbs01.dbf UNDOTBS1
/u01/app/oracle/oradata/PROD/Disk1/sysaux01.dbf SYSAUX
/u01/app/oracle/oradata/PROD/Disk1/example01.dbf EXAMPLE
/u01/app/oracle/oradata/PROD/Disk1/users01.dbf USERS
/u01/app/oracle/oradata/PROD/Disk1/swtich_tbs01.db SWTICH_TBS
f
6 rows selected.
备库:
SYS@PRODSTD>select name from v$datafile;
NAME
--------------------------------------------------------------------------------
/u01/app/oracle/oradata/PRODSTD/Disk1/system01.dbf
/u01/app/oracle/oradata/PRODSTD/Disk1/undotbs01.dbf
/u01/app/oracle/oradata/PRODSTD/Disk1/sysaux01.dbf
/u01/app/oracle/oradata/PRODSTD/Disk1/example01.dbf
/u01/app/oracle/oradata/PRODSTD/Disk1/PRODSTD/datafile/o1_mf_swtich_t_9m21f1f0_.
dbf
/u01/app/oracle/oradata/PRODSTD/Disk1/users01.dbf
6 rows selected.
3.在主库执行删除表空间及数据文件
SYS@PROD>drop tablespace SWTICH_TBS including contents and datafiles;
Tablespace dropped.
------------------------------------------------------------------------------------------
主库告警日志:
Sun Mar 30 10:47:37 2014
drop tablespace SWTICH_TBS including contents and datafiles
Sun Mar 30 10:47:42 2014
Deleted file /u01/app/oracle/oradata/PROD/Disk1/swtich_tbs01.dbf
Completed: drop tablespace SWTICH_TBS including contents and datafiles
------------------------------------------------------------------------------------------
4.再次查看两边的表空间以及数据文件
主库:
SYS@PROD>select file_name,tablespace_name from dba_data_files;
FILE_NAME TABLESPACE_NAME
-------------------------------------------------- ------------------------------
/u01/app/oracle/oradata/PROD/Disk1/system01.dbf SYSTEM
/u01/app/oracle/oradata/PROD/Disk1/undotbs01.dbf UNDOTBS1
/u01/app/oracle/oradata/PROD/Disk1/sysaux01.dbf SYSAUX
/u01/app/oracle/oradata/PROD/Disk1/example01.dbf EXAMPLE
/u01/app/oracle/oradata/PROD/Disk1/users01.dbf USERS
备库:
SYS@PRODSTD>select name from v$datafile;
NAME
--------------------------------------------------------------------------------
/u01/app/oracle/oradata/PRODSTD/Disk1/system01.dbf
/u01/app/oracle/oradata/PRODSTD/Disk1/undotbs01.dbf
/u01/app/oracle/oradata/PRODSTD/Disk1/sysaux01.dbf
/u01/app/oracle/oradata/PRODSTD/Disk1/example01.dbf
/u01/app/oracle/oradata/PRODSTD/Disk1/PRODSTD/datafile/o1_mf_swtich_t_9m21f1f0_.dbf
/u01/app/oracle/oradata/PRODSTD/Disk1/users01.dbf
6 rows selected.
此时主库的归档重做日志还没有传到备库。
5.手动切换日志,同步主备库,让备库应用重做日志。
SYS@PROD>alter system switch logfile;
System altered.
-------------------------------------------------------------------------------------------
主库告警日志:
LNS1 started with pid=57, OS id=3000
Sun Mar 30 10:58:08 2014
Thread 1 advanced to log sequence 34
Current log# 2 seq# 34 mem# 0: /u01/app/oracle/oradata/PROD/Disk1/redo02.log
Current log# 2 seq# 34 mem# 1: /u01/app/oracle/oradata/PROD/Disk2/redo02_1.log
Sun Mar 30 10:58:10 2014
LNS: Standby redo logfile selected for thread 1 sequence 34 for destination LOG_ARCHIVE_DEST_2
Sun Mar 30 10:58:11 2014
ARC5: Standby redo logfile selected for thread 1 sequence 33 for destination LOG_ARCHIVE_DEST_2
备库告警日志:
Sun Mar 30 10:58:11 2014
Redo Shipping Client Connected as PUBLIC
-- Connected User is Valid
RFS[3]: Assigned to RFS process 2939
RFS[3]: Identified database type as 'physical standby'
Sun Mar 30 10:58:11 2014
Redo Shipping Client Connected as PUBLIC
-- Connected User is Valid
RFS[4]: Assigned to RFS process 2941
RFS[4]: Identified database type as 'physical standby'
Primary database is in MAXIMUM PERFORMANCE mode
Primary database is in MAXIMUM PERFORMANCE mode
RFS[4]: Successfully opened standby log 6: '/u01/app/oracle/oradata/PRODSTD/Disk1/standby06.log'
Sun Mar 30 10:58:12 2014
RFS[3]: Successfully opened standby log 7: '/u01/app/oracle/oradata/PRODSTD/Disk1/standby07.log'
Sun Mar 30 10:58:17 2014
Media Recovery Log /u01/app/oracle/oradata/PRODSTD/Disk2/arch/1_33_842523531.arc
Recovery deleting file #5:'/u01/app/oracle/oradata/PRODSTD/Disk1/PRODSTD/datafile/o1_mf_swtich_t_9mh1rzf6_.dbf' from controlfile.
Deleted Oracle managed file /u01/app/oracle/oradata/PRODSTD/Disk1/PRODSTD/datafile/o1_mf_swtich_t_9mh1rzf6_.dbf
Recovery dropped tablespace 'SWTICH_TBS'
Media Recovery Waiting for thread 1 sequence 34 (in transit)
-----------------------------------------------------------------------------------------------------------
6.查看备库数据文件
SYS@PRODSTD>select file#,name from v$datafile;
FILE# NAME
---------- -------------------------------------------------------
1 /u01/app/oracle/oradata/PRODSTD/Disk1/system01.dbf
2 /u01/app/oracle/oradata/PRODSTD/Disk1/undotbs01.dbf
3 /u01/app/oracle/oradata/PRODSTD/Disk1/sysaux01.dbf
4 /u01/app/oracle/oradata/PRODSTD/Disk1/example01.dbf
7 /u01/app/oracle/oradata/PRODSTD/Disk1/users01.dbf
此时备库的SWITCH_TBS表空间已经被删除。
相关参考:
Oracle Data Guard 重要配置参数
基于同一主机配置 Oracle 11g Data Guard
探索Oracle之11g DataGuard
Oracle Data Guard (RAC+DG) 归档删除策略及脚本
Oracle Data Guard 的角色转换
Oracle Data Guard的日志FAL gap问题
Oracle 11g Data Guard Error 16143 Heartbeat failed to connect to standby 处理方法

MySQL processes data replication through three modes: asynchronous, semi-synchronous and group replication. 1) Asynchronous replication performance is high but data may be lost. 2) Semi-synchronous replication improves data security but increases latency. 3) Group replication supports multi-master replication and failover, suitable for high availability requirements.

The EXPLAIN statement can be used to analyze and improve SQL query performance. 1. Execute the EXPLAIN statement to view the query plan. 2. Analyze the output results, pay attention to access type, index usage and JOIN order. 3. Create or adjust indexes based on the analysis results, optimize JOIN operations, and avoid full table scanning to improve query efficiency.

Using mysqldump for logical backup and MySQLEnterpriseBackup for hot backup are effective ways to back up MySQL databases. 1. Use mysqldump to back up the database: mysqldump-uroot-pmydatabase>mydatabase_backup.sql. 2. Use MySQLEnterpriseBackup for hot backup: mysqlbackup--user=root-password=password--backup-dir=/path/to/backupbackup. When recovering, use the corresponding life

The main reasons for slow MySQL query include missing or improper use of indexes, query complexity, excessive data volume and insufficient hardware resources. Optimization suggestions include: 1. Create appropriate indexes; 2. Optimize query statements; 3. Use table partitioning technology; 4. Appropriately upgrade hardware.

MySQL view is a virtual table based on SQL query results and does not store data. 1) Views simplify complex queries, 2) Enhance data security, and 3) Maintain data consistency. Views are stored queries in databases that can be used like tables, but data is generated dynamically.

MySQLdiffersfromotherSQLdialectsinsyntaxforLIMIT,auto-increment,stringcomparison,subqueries,andperformanceanalysis.1)MySQLusesLIMIT,whileSQLServerusesTOPandOracleusesROWNUM.2)MySQL'sAUTO_INCREMENTcontrastswithPostgreSQL'sSERIALandOracle'ssequenceandt

MySQL partitioning improves performance and simplifies maintenance. 1) Divide large tables into small pieces by specific criteria (such as date ranges), 2) physically divide data into independent files, 3) MySQL can focus on related partitions when querying, 4) Query optimizer can skip unrelated partitions, 5) Choosing the right partition strategy and maintaining it regularly is key.

How to grant and revoke permissions in MySQL? 1. Use the GRANT statement to grant permissions, such as GRANTALLPRIVILEGESONdatabase_name.TO'username'@'host'; 2. Use the REVOKE statement to revoke permissions, such as REVOKEALLPRIVILEGESONdatabase_name.FROM'username'@'host' to ensure timely communication of permission changes.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 English version
Recommended: Win version, supports code prompts!

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

SublimeText3 Chinese version
Chinese version, very easy to use

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function
