遷移ASM磁碟組

raysuen發表於2019-11-18
#開啟歸檔
SQL> startup mount
ORACLE instance started.
Total System Global Area 1586708480 bytes
Fixed Size                  2253624 bytes
Variable Size            1426066632 bytes
Database Buffers          150994944 bytes
Redo Buffers                7393280 bytes
Database mounted.
SQL>  alter database archivelog;
Database altered.
SQL> alter system set log_archive_dest_1='location=+data02';
System altered.
SQL> alter database open;
Database altered.
#啟動第二個節點的例項
[root@ray32 /]# /u01/app/gridhome/product/11.2.0/grid_1/bin/srvctl start instance -d racdb -n ray32
#copy資料檔案到新磁碟組,並遷移
rman target / log='/home/oracle/rman.log'
RMAN> backup as copy database format '+data02';
#關閉資料庫,並啟動到mount
[oracle@ray31 ~]$ sqlplus /nolog
SQL> conn / as sysdba
Connected to an idle instance.
SQL> startup mount
ORACLE instance started.
Total System Global Area 1586708480 bytes
Fixed Size                  2253624 bytes
Variable Size            1426066632 bytes
Database Buffers          150994944 bytes
Redo Buffers                7393280 bytes
Database mounted.
SQL>
#遷移資料檔案
[oracle@ray31 ~]$ rman target /
Recovery Manager: Release 11.2.0.4.0 - Production on Mon Nov 18 10:55:41 2019
Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.
connected to target database: RACDB (DBID=1016754416, not open)
RMAN> switch database to copy;
using target database control file instead of recovery catalog
datafile 1 switched to datafile copy "+DATA02/racdb/datafile/system.257.1024656613"
datafile 2 switched to datafile copy "+DATA02/racdb/datafile/sysaux.258.1024656647"
datafile 3 switched to datafile copy "+DATA02/racdb/datafile/undotbs1.259.1024656673"
datafile 4 switched to datafile copy "+DATA02/racdb/datafile/undotbs2.260.1024656699"
datafile 5 switched to datafile copy "+DATA02/racdb/datafile/users.262.1024656717"
#遷移控制檔案
[oracle@ray31 ~]$ sqlplus /nolog
SQL*Plus: Release 11.2.0.4.0 Production on Mon Nov 18 11:01:44 2019
Copyright (c) 1982, 2013, Oracle.  All rights reserved.
SQL> conn / as sysdba
Connected.
SQL> shutdown immediate
ORA-01109: database not open
Database dismounted.
ORACLE instance shut down.
SQL>
[grid@ray31 ~]$ asmcmd
ASMCMD> cp +DATA01/racdb/controlfile/current.256.1019137651 +DATA02/racdb/controlfile/current.ora
copying +DATA01/racdb/controlfile/current.256.1019137651 -> +DATA02/racdb/controlfile/current.ora
#編輯引數檔案
SQL> create pfile ='/home/oracle/pfileracdb.ora' from spfile;
File created.
#編輯引數檔案
*.control_files=' +DATA02/racdb/controlfile/current.ora'  #磁碟組名稱替換為新的磁碟組名稱
*.db_block_size=8192
*.db_create_file_dest=' +DATA02'   #磁碟組名稱替換為新的磁碟組名稱
SQL> create spfile='+DATA02/racdb/spfileRACDB.ora' from pfile='/home/oracle/pfileracdb.ora';
File created.
#更新spfile
[root@ray32 /]# /u01/app/gridhome/product/11.2.0/grid_1/bin/srvctl modify database -d racdb -p  +DATA02/racdb/spfileracdb.ora
[root@ray32 /]# /u01/app/gridhome/product/11.2.0/grid_1/bin/srvctl config database -d racdb
Database unique name: RACDB
Database name: RACDB
Oracle home: /u01/app/oracle/product/11.2.0/db_1
Oracle user: oracle
Spfile: +DATA02/racdb/spfileracdb.ora
Domain:
Start options: open
Stop options: immediate
Database role: PRIMARY
Management policy: AUTOMATIC
Server pools: RACDB
Database instances: RACDB1,RACDB2
Disk Groups: DATA01
Mount point paths:
Services:
Type: RAC
Database is administrator managed
#更新本地init$ORACLE_SID.ora,兩個節點都要更新
[oracle@ray31 dbs]$ cat initRACDB2.ora
SPFILE='+DATA02/RACDB/spfileRACDB.ora'
[oracle@ray32 dbs]$ cat initRACDB2.ora
SPFILE='+DATA02/RACDB/spfileRACDB.ora'
#遷移臨時資料檔案
SQL> alter database rename file '+DATA01/racdb/tempfile/temp.262.1019137685' to '+data02';
Database altered.
SQL> select name from v$tempfile;
NAME
--------------------------------------------------------------------------------
+DATA02
SQL>
#啟動資料庫
run
{
recover database;
alter database open;
}
Recovery Manager complete.
[oracle@ray31 ~]$ rman target /
Recovery Manager: Release 11.2.0.4.0 - Production on Mon Nov 18 13:40:42 2019
Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.
connected to target database: RACDB (DBID=1016754416, not open)
RMAN> run
2> {
3> recover database;
4> alter database open;
5>  }
Starting recover at 18-NOV-19
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=36 instance=RACDB1 device type=DISK
starting media recovery
media recovery complete, elapsed time: 00:00:01
Finished recover at 18-NOV-19
database opened
#檢查所有檔案的位置
[oracle@ray31 dbs]$ sqlplus /nolog
SQL*Plus: Release 11.2.0.4.0 Production on Mon Nov 18 13:41:31 2019
Copyright (c) 1982, 2013, Oracle.  All rights reserved.
SQL> conn / as sysdba
Connected.
SQL> select name from v$datafile;
NAME
--------------------------------------------------------------------------------
+DATA02/racdb/datafile/system.257.1024656613
+DATA02/racdb/datafile/sysaux.258.1024656647
+DATA02/racdb/datafile/undotbs1.259.1024656673
+DATA02/racdb/datafile/undotbs2.260.1024656699
+DATA02/racdb/datafile/users.262.1024656717
SQL> select name from v$tempfile;
NAME
--------------------------------------------------------------------------------
+DATA02/racdb/tempfile/temp.266.1024666863
SQL> select name from v$controlfile;
NAME
--------------------------------------------------------------------------------
+DATA02/racdb/controlfile/current.ora
SQL> show parameter pfile
NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
spfile                               string      +DATA02/racdb/spfileracdb.ora
SQL> show parameter db_create_file_dest
NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
db_create_file_dest                  string      +DATA02
#遷移redo日誌組
SQL> set linesize 500
SQL> col group# for 999
SQL> col mb for 9999
SQL> col member for a60
SQL> col thread# for 999
SQL> col archived for a10
SQL> select a.group#,a.BYTES/1024/1024 mb,b.MEMBER,a.thread#,a.sequence#,a.members,a.archived,a.status,a.first_time,a.next_time from gv$log a,gv$logfile b where a.GROUP#=b.GROUP#
    group by a.group#,a.thread#,a.BYTES/1024/1024,b.MEMBER,a.sequence#,a.members,a.archived,a.status,a.first_time,a.next_time order by group#;
GROUP#    MB MEMBER                                                       THREAD#  SEQUENCE#    MEMBERS ARCHIVED   STATUS           FIRST_TIM NEXT_TIME
------ ----- ------------------------------------------------------------ ------- ---------- ---------- ---------- ---------------- --------- ---------
     1    50 +DATA01/racdb/onlinelog/group_1.257.1019137653                     1         57          1 NO         CURRENT          18-NOV-19
     2    50 +DATA01/racdb/onlinelog/group_2.258.1019137653                     1         56          1 YES        INACTIVE         14-NOV-19 18-NOV-19
     3    50 +DATA01/racdb/onlinelog/group_3.265.1019139563                     2          5          1 YES        INACTIVE         18-NOV-19 18-NOV-19
     4    50 +DATA01/racdb/onlinelog/group_4.266.1019139563                     2          6          1 YES        INACTIVE         18-NOV-19 18-NOV-19
SQL> alter database add logfile thread 2 group 5 '+data02' size 200M ;
Database altered.
SQL> SQL> alter database add logfile thread 2 group 6 '+data02' size 200M ;
Database altered.
SQL> alter database drop logfile group 3;
Database altered.
SQL> SQL> alter database add logfile thread 1 group 3 '+data02' size 200M ;
Database altered.
SQL> SQL> alter database drop logfile group 2;
Database altered.
SQL> SQL> alter database add logfile thread 1 group 2 '+data02' size 200M ;
Database altered.
SQL> alter system switch logfile;
System altered.
SQL> alter system checkpoint;
System altered.
SQL> alter database drop logfile group 1;
Database altered.
SQL> alter database add logfile thread 1 group 1 '+data02' size 200M ;
Database altered.
SQL> alter database drop logfile group 4;
Database altered.
SQL> alter database add logfile thread 2 group 4 '+data02' size 200M ;
Database altered.
SQL> select a.group#,a.BYTES/1024/1024 mb,b.MEMBER,a.thread#,a.sequence#,a.members,a.archived,a.status,a.first_time,a.next_time from gv$log a,gv$logfile b where a.GROUP#=b.GROUP#
  2      group by a.group#,a.thread#,a.BYTES/1024/1024,b.MEMBER,a.sequence#,a.members,a.archived,a.status,a.first_time,a.next_time order by group#;
GROUP#    MB MEMBER                                                       THREAD#  SEQUENCE#    MEMBERS ARCHIVED   STATUS           FIRST_TIM NEXT_TIME
------ ----- ------------------------------------------------------------ ------- ---------- ---------- ---------- ---------------- --------- ---------
     1   200 +DATA02/racdb/onlinelog/group_1.274.1024667599                     1          0          1 YES        UNUSED
     2   200 +DATA02/racdb/onlinelog/group_2.272.1024667447                     1         58          1 NO         CURRENT          18-NOV-19
     3   200 +DATA02/racdb/onlinelog/group_3.271.1024667425                     1          0          1 YES        UNUSED
     4   200 +DATA02/racdb/onlinelog/group_4.270.1024667761                     2          0          1 YES        UNUSED
     5   200 +DATA02/racdb/onlinelog/group_5.268.1024667359                     2          7          1 NO         CURRENT          18-NOV-19 18-NOV-19
     6   200 +DATA02/racdb/onlinelog/group_6.269.1024667367                     2          0          1 YES        UNUSED
6 rows selected.


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

相關文章