rename備庫資料檔案

parknkjun發表於2015-09-13
1、檢視資料庫角色
SYS@jyp>select db_unique_name,database_role from v$database;
DB_UNIQUE_NAME                 DATABASE_ROLE
------------------------------ ----------------
jyp                            PRIMARY
SYS@jzh>select db_unique_name,database_role from v$database;
DB_UNIQUE_NAME                 DATABASE_ROLE
------------------------------ ----------------
jzh                            PHYSICAL STANDBY
SYS@jyp>show parameter convert
NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
db_file_name_convert                 string      /u01/oracle/oradata/jyp, /u01/
                                                 oracle/oradata/jzh
log_file_name_convert                string      /u01/oracle/oradata/jyp, /u01/
                                                 oracle/oradata/jzh
SYS@jyp>show parameter standby
NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
standby_archive_dest                 string      ?/dbs/arch
standby_file_management              string      AUTO
SYS@jyp>select name from v$dbfile;
NAME
--------------------------------------------------------------------------------
/u01/oracle/oradata/jyp/users01.dbf
/u01/oracle/oradata/jyp/undotbs01.dbf
/u01/oracle/oradata/jyp/sysaux01.dbf
/u01/oracle/oradata/jyp/system01.dbf
/u01/oracle/oradata/jyp/jzh01.dbf
2、建立測試表空間(資料檔案存放/software目錄下)
SYS@jyp>create tablespace test datafile '/software/test01.dbf' size 10m;
Tablespace created.
SYS@jyp>archive log list
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            /u01/oracle/arch
Oldest online log sequence     70
Next log sequence to archive   72
Current log sequence           72
SYS@jyp>alter system switch logfile;
System altered.
SYS@jyp>archive log list
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            /u01/oracle/arch
Oldest online log sequence     71
Next log sequence to archive   73
Current log sequence           73
3、檢視standby alert log
Media Recovery Log /u01/oracle/arch/1_72_867602649.arc
WARNING: File being created with same name as in Primary
Existing file may be overwritten
Errors in file /u01/oracle/diag/rdbms/jzh/jzh/trace/jzh_mrp0_11208.trc:
ORA-01119: error in creating database file '/software/test01.dbf'
ORA-27054: NFS file system where the file is created or resides is not mounted with correct options
Linux-x86_64 Error: 13: Permission denied
File #6 added to control file as 'UNNAMED00006'.---6號檔案在control file記錄UNNAMED00006
Originally created as:
'/software/test01.dbf'
Recovery was unable to create the file as:
'/software/test01.dbf'
Errors with log /u01/oracle/arch/1_72_867602649.arc
MRP0: Background Media Recovery terminated with error 1274
Errors in file /u01/oracle/diag/rdbms/jzh/jzh/trace/jzh_mrp0_11208.trc:
ORA-01274: cannot add datafile '/software/test01.dbf' - file could not be created
Recovery interrupted!
Recovered data files to a consistent state at change 981554
MRP0: Background Media Recovery process shutdown (jzh)    ----mrp程式被shutdown
SYS@jzh>select name from v$dbfile;
NAME
--------------------------------------------------------------------------------
/u01/oracle/oradata/jzh/system01.dbf
/u01/oracle/oradata/jzh/sysaux01.dbf
/u01/oracle/oradata/jzh/undotbs01.dbf
/u01/oracle/oradata/jzh/users01.dbf
/u01/oracle/oradata/jzh/jzh01.dbf
/u01/oracle/product/11.2.0/db_1/dbs/UNNAMED00006-----資料檔案被建立在$ORACLE_HOME/dbs目錄下,並且命名為UNNAMED00006
6 rows selected.
4、在備庫rename資料檔案
SYS@jzh>alter system set standby_file_management=manual;
System altered.
SYS@jzh>alter database create datafile '/u01/oracle/product/11.2.0/db_1/dbs/UNNAMED00006' as '/u01/oracle/oradata/jzh/test01';
Database altered.
SYS@jzh>select name from v$dbfile;
NAME
--------------------------------------------------------------------------------
/u01/oracle/oradata/jzh/system01.dbf
/u01/oracle/oradata/jzh/sysaux01.dbf
/u01/oracle/oradata/jzh/undotbs01.dbf
/u01/oracle/oradata/jzh/users01.dbf
/u01/oracle/oradata/jzh/jzh01.dbf
/u01/oracle/oradata/jzh/test01
6 rows selected.
SYS@jzh>alter system set standby_file_management=auto;
System altered.
SYS@jzh>recover managed standby database disconnect from session;
Media recovery complete.
5、檢視standby alert log
at Sep 12 16:37:08 2015
ALTER SYSTEM SET standby_file_management='AUTO' SCOPE=BOTH;
Sat Sep 12 16:37:25 2015
ALTER DATABASE RECOVER  managed standby database disconnect from session  
Attempt to start background Managed Standby Recovery process (jzh)
Sat Sep 12 16:37:25 2015
MRP0 started with pid=33, OS id=11451 
MRP0: Background Managed Standby Recovery process started (jzh)----MRP程式啟動了。








來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/10271187/viewspace-1798261/,如需轉載,請註明出處,否則將追究法律責任。

相關文章