Oracle Physical dataguard Rename data file instance

Source: Internet
Author: User
Tags manual

We know that when Standby_file_management is set to auto, if the primary library creates a new Datafile,standby, it automatically synchronizes a new datafile; but when primary Rename a datafile, although Standby_file_management is set to Auto,standby will not sync, at this time need manual modification;
Do the following experiment to verify that the datafile of the Zyh tablespace is renamed to/U01/ORACLE/ORADATA/STANDBY/ZYH02.DBF

The code is as follows Copy Code

Sql> select name from V$datafile;

02

The NAME

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

05/u01/oracle/oradata/standby/system01.dbf

06/u01/oracle/oradata/standby/undotbs01.dbf

07/u01/oracle/oradata/standby/sysaux01.dbf

08/u01/oracle/oradata/standby/users01.dbf

09/u01/oracle/oradata/standby/mgmt.dbf

10/u01/oracle/oradata/standby/mgmt_ecm_depot1.dbf

11/u01/oracle/oradata/standby/zyh01.dbf

12

7 rows selected.

14

Sql> select Tablespace_name from Dba_tablespaces;

16

Tablespace_name

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

SYSTEM

UNDOTBS1

Sysaux

TEMP

USERS

Mgmt_tablespace

Mgmt_ecm_depot_ts

Num ZYH

27

8 rows selected.

29

Sql>

1, on the primary, will rename the tablespace off-line

The code is as follows Copy Code

1 sql> alter tablespace ZYH offline;

2

3 tablespace altered.
2, the use of operating system command MV to the data file rename

1 [Oracle@prod dbs]$ mv/u01/oracle/oradata/standby/zyh01.dbf/u01/oracle/oradata/standby/zyh02.dbf
3, at the database level to modify the name of DataFile, and let its online

1 sql> alter tablespace zyh rename datafile '/u01/oracle/oradata/standby/zyh01.dbf ' to '/u01/oracle/oradata/standby/ ZYH02.DBF ';

2

3 tablespace altered.

4

5 sql> alter tablespace ZYH online;

6

7 tablespace altered.

4, the main library to switch logs, view the location of the data file

  code is as follows copy code

sql> alter system switch logfile;

02

The System altered.

04

Sql> select name from V$datafile;

06

Modified NAME

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

09/u01/oracle/oradata/standby/system01.dbf

10/u01/oracle/oradata/standby/undotbs01.dbf

11/u01/oracle/oradata/standby/sysaux01.dbf

12/u01/oracle/oradata/standby/users01.dbf

13/u01/oracle/oradata/standby/mgmt.dbf

14/u01/oracle/oradata/standby/mgmt_ecm_depot1.dbf

15/u01/oracle/oradata/standby/zyh02.dbf

16

7 rows selected.

A query on the standby, found datafile or ZYH01.DBF, that the library is not automatically synchronized

The code is as follows Copy Code

Sql> select name from V$datafile;

02

The NAME

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

05/u01/oracle/oradata/spdb/system01.dbf

06/u01/oracle/oradata/spdb/undotbs01.dbf

07/u01/oracle/oradata/spdb/sysaux01.dbf

08/u01/oracle/oradata/spdb/users01.dbf

09/u01/oracle/oradata/spdb/mgmt.dbf

10/u01/oracle/oradata/spdb/mgmt_ecm_depot1.dbf

11/u01/oracle/oradata/spdb/zyh01.dbf

12

7 rows selected.

5, stop the standby log application, and close the standby library

The code is as follows Copy Code

1 sql> ALTER database RECOVER MANAGED STANDBY database CANCEL;

2

3 Database altered.

4

5 sql> shutdown Immediate;

6 Ora-01109:database not open

7

8 Database dismounted.

9 ORACLE instance shut down.
6, the use of the operating system in the standby command, the data file rename

1 [oracle@edbjr2p6 ~]$ mv/u01/oracle/oradata/spdb/zyh01.dbf/u01/oracle/oradata/spdb/zyh02.dbf
7. Start the standby to mount

1 sql> startup Mount;

2 ORACLE instance started.

3

4 Total System Global area 285212672 bytes

5 Fixed Size 1218992 bytes

6 Variable Size 92276304 bytes

7 Database buffers 188743680 bytes

8 Redo buffers 2973696 bytes

9 Database mounted.

8. Set the standby_file_management parameter to manual and rename the datafile at the database level

The code is as follows Copy Code

Sql> Show Parameter Standby_file_management

02

The NAME TYPE VALUE

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

Standby_file_management string AUTO

Sql> alter system set standby_file_management=manual;

07

The System altered.

09

sql> ALTER DATABASE rename file '/u01/oracle/oradata/spdb/zyh01.dbf ' to '/u01/oracle/oradata/spdb/zyh02.dbf ';

11

Database altered.

9. Re-apply the log

The code is as follows Copy Code

1 sql> ALTER database RECOVER MANAGED STANDBY database DISCONNECT from session;

2

3 Database altered.

10, to see whether the logs are synchronized on both sides
Main Library:

The code is as follows Copy Code

1 sql> Archive Log list

2 Database Log mode Archive mode

3 Automatic Archival Enabled

4 Archive Destination/u01/oracle/standby

5 oldest online log sequence 209

6 Next Log sequence to archive 211

7 Current Log Sequence 211

Prepare library:

The code is as follows Copy Code

Sql> select sequence#,applied from V$archived_log;

02

sequence# APP

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

197 YES

196 YES

Modified 198 YES

199 YES

YES

Ten 201 YES

YES

203 YES

204 YES

205 YES

206 YES

16

sequence# APP

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

207 YES

YES

209 YES

210 YES

23

Rows selected.

11. Change the standby_file_management parameter to auto

  code is as follows copy code


1 SQL > alter system set STANDBY_FILE_MANAGEMENT=AUTO;&NBSP

2   

3 system altered

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.