您好,登錄后才能下訂單哦!
小編給大家分享一下oracle中數據fs到asm遷移的示例分析,相信大部分人都還不怎么了解,因此分享這篇文章給大家參考一下,希望大家閱讀完這篇文章后大有收獲,下面讓我們一起去了解一下吧!
(RedHat 10g Oracle環境)
1、配置 Oracle Cluster Synchronization(CSS)
要想使用ASM,必須先配置并啟動CSS
[root@redhat10g ~]# cd /u01/app/oracle/product/10.2.0/db_1/bin
[root@redhat10g bin]# ./localconfig add
2、配置Automatic Storage Management(ASM)實例參數
[oracle@aix201 ~]$vi /u01/app/oracle/product/10.2.0/db_1/dbs/init+ASM.ora
instance_type='asm'
asm_diskstring='/dev/mapper/asmvg-*'
asm_diskgroups='DG1','RCY1'
large_pool_size=12m
background_dump_dest=/u01/app/oracle/product/10.2.0/db_1/admin/+ASM/bdump
core_dump_dest=/u01/app/oracle/product/10.2.0/db_1/admin/+ASM/cdump
user_dump_dest=/u01/app/oracle/product/10.2.0/db_1/admin/+ASM/udump
3、啟動asm實例
[oracle@redhat10g ~]$ export ORACLE_SID=+ASM
[oracle@redhat10g ~]$ sqlplus / as sysdba
SQL*Plus: Release 10.2.0.1.0 - Production on Sun Jun 29 17:04:44 2014
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to an idle instance.
SQL> startup
ASM instance started
Total System Global Area 83886080 bytes
Fixed Size 1217836 bytes
Variable Size 57502420 bytes
ASM Cache 25165824 bytes
4、創建裸設備,修改用戶和權限
1)添加磁盤;
2)為磁盤分區:
[root@redhat10g ~]# fdisk /dev/sdb
Device Boot Start End Blocks Id System
/dev/sdb1 1 2610 20964793+ 83 Linux
3)創建物理卷(pv):
[root@redhat10g ~]# pvcreate /dev/sdb1
/dev/cdrom: open failed: Read-only file system
Attempt to close device '/dev/cdrom' which is not open.
Physical volume "/dev/sdb1" successfully created
查看pv的信息:
4)創建卷組:
[root@redhat10g ~]# vgcreate asmvg /dev/sdb1
5)創建邏輯卷lv:
[root@redhat10g ~]# lvcreate -n datalv1 -L 5gb asmvg
/dev/cdrom: open failed: Read-only file system
Logical volume "datalv1" created
[root@redhat10g ~]# lvcreate -n datalv2 -L 5gb asmvg
/dev/cdrom: open failed: Read-only file system
Logical volume "datalv2" created
[root@redhat10g ~]# lvcreate -n ocrdisklv1 -L 4.5gb asmvg
/dev/cdrom: open failed: Read-only file system
Logical volume "ocrdisklv1" created
[root@redhat10g ~]# lvcreate -n ocrdisklv2 -L 4.5gb asmvg
/dev/cdrom: open failed: Read-only file system
Logical volume "ocrdisklv2" created
6)綁定裸設備:
[root@redhat10g ~]# raw /dev/raw/raw1 /dev/mapper/asmvg-datalv1
/dev/raw/raw1: bound to major 253, minor 2
[root@redhat10g ~]# raw /dev/raw/raw2 /dev/mapper/asmvg-datalv2
/dev/raw/raw2: bound to major 253, minor 3
[root@redhat10g ~]# raw /dev/raw/raw3 /dev/mapper/asmvg-
asmvg-datalv1 asmvg-datalv2 asmvg-ocrdisklv1 asmvg-ocrdisklv2
[root@redhat10g ~]# raw /dev/raw/raw3 /dev/mapper/asmvg-ocrdisklv1
/dev/raw/raw3: bound to major 253, minor 4
[root@redhat10g ~]# raw /dev/raw/raw4 /dev/mapper/asmvg-ocrdisklv2
/dev/raw/raw4: bound to major 253, minor 5
服務器啟動自動掛載裸設備:
[root@redhat10g ~]# vi /etc/sysconfig/rawdevices
/dev/raw/raw1 /dev/mapper/asmvg-datalv1
/dev/raw/raw2 /dev/mapper/asmvg-datalv2
/dev/raw/raw3 /dev/mapper/asmvg-ocrdisk1
/dev/raw/raw4 /dev/mapper/asmvg-ocrdisk2
重啟服務驗證能否掛載:
[root@redhat10g ~]# service rawdevices restart
Assigning devices:
/dev/raw/raw1 --> /dev/mapper/asmvg-datalv1
/dev/raw/raw1: bound to major 253, minor 2
/dev/raw/raw2 --> /dev/mapper/asmvg-datalv2
/dev/raw/raw2: bound to major 253, minor 3
/dev/raw/raw3 --> /dev/mapper/asmvg-ocrdisklv1
/dev/raw/raw3: bound to major 253, minor 4
/dev/raw/raw4 --> /dev/mapper/asmvg-ocrdisklv2
/dev/raw/raw4: bound to major 253, minor 5
7)修改設備屬性:
[root@redhat10g raw]# chown -R oracle:oinstall /dev/raw/raw1
[root@redhat10g raw]# chown -R oracle:oinstall /dev/raw/raw2
[root@redhat10g raw]# chown -R oracle:oinstall /dev/raw/raw3
[root@redhat10g raw]# chown -R oracle:oinstall /dev/raw/raw4
[root@redhat10g ~]# chown -R oracle:oinstall /dev/mapper/asmvg-datalv1
[root@redhat10g ~]# chown -R oracle:oinstall /dev/mapper/asmvg-datalv2
[root@redhat10g ~]# chown -R oracle:oinstall /dev/mapper/asmvg-ocrdisklv1
[root@redhat10g ~]# chown -R oracle:oinstall /dev/mapper/asmvg-ocrdisklv2
5、創建ASM磁盤組
為了能使ASM啟動時,自動掛載磁盤和磁盤組,將下邊的參數添加到初始化文件中:
asm_diskstring='/dev/mapper/asmvg-*'
asm_diskgroups='DG1','RCY1'
6、修改參數:
SQL> alter system set db_create_file_dest='+dg1' scope=spfile;
System altered.
SQL> alter system set control_files='+dg1' scope=spfile;
System altered.
7、轉儲控制文件
RMAN> shutdown immediate;
using target database control file instead of recovery catalog
database closed
database dismounted
Oracle instance shut down
RMAN> startup nomount;
connected to target database (not started)
Oracle instance started
Total System Global Area 1258291200 bytes
Fixed Size 1219160 bytes
Variable Size 318768552 bytes
Database Buffers 922746880 bytes
Redo Buffers 15556608 bytes
RMAN> restore controlfile from '/u01/app/oracle/oradata/prod/control01.ctl';
Starting restore at 29-JUN-14
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=156 devtype=DISK
channel ORA_DISK_1: copied control file copy
output filename=+DG1/prod/controlfile/backup.256.851554395
Finished restore at 29-JUN-14
8、轉儲數據文件
RMAN> alter database mount;
database mounted
released channel: ORA_DISK_1
RMAN> backup as copy database format '+dg1';
Starting backup at 29-JUN-14
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=156 devtype=DISK
channel ORA_DISK_1: starting datafile copy
input datafile fno=00001 name=/u01/app/oracle/oradata/prod/system01.dbf
output filename=+DG1/prod/datafile/system.257.851554507 tag=TAG20140629T225507 recid=8 stamp=851554598
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:01:35
channel ORA_DISK_1: starting datafile copy
input datafile fno=00003 name=/u01/app/oracle/oradata/prod/sysaux01.dbf
output filename=+DG1/prod/datafile/sysaux.258.851554603 tag=TAG20140629T225507 recid=9 stamp=851554652
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:56
channel ORA_DISK_1: starting datafile copy
input datafile fno=00005 name=/u01/app/oracle/oradata/prod/example01.dbf
output filename=+DG1/prod/datafile/example.259.851554659 tag=TAG20140629T225507 recid=10 stamp=851554677
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:25
channel ORA_DISK_1: starting datafile copy
input datafile fno=00002 name=/u01/app/oracle/oradata/prod/undotbs01.dbf
output filename=+DG1/prod/datafile/undotbs1.260.851554683 tag=TAG20140629T225507 recid=11 stamp=851554689
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:07
channel ORA_DISK_1: starting datafile copy
input datafile fno=00004 name=/u01/app/oracle/oradata/prod/users01.dbf
output filename=+DG1/prod/datafile/users.261.851554691 tag=TAG20140629T225507 recid=12 stamp=851554691
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:03
channel ORA_DISK_1: starting datafile copy
copying current control file
output filename=+DG1/prod/controlfile/backup.262.851554693 tag=TAG20140629T225507 recid=13 stamp=851554696
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:03
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
including current SPFILE in backupset
channel ORA_DISK_1: starting piece 1 at 29-JUN-14
channel ORA_DISK_1: finished piece 1 at 29-JUN-14
piece handle=+DG1/prod/backupset/2014_06_29/nnsnf0_tag20140629t225507_0.263.851554697 tag=TAG20140629T225507 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 29-JUN-14
RMAN> switch database to copy;
datafile 1 switched to datafile copy "+DG1/prod/datafile/system.257.851554507"
datafile 2 switched to datafile copy "+DG1/prod/datafile/undotbs1.260.851554683"
datafile 3 switched to datafile copy "+DG1/prod/datafile/sysaux.258.851554603"
datafile 4 switched to datafile copy "+DG1/prod/datafile/users.261.851554691"
datafile 5 switched to datafile copy "+DG1/prod/datafile/example.259.851554659"
9、恢復數據庫
RMAN> recover database;
Starting recover at 29-JUN-14
using channel ORA_DISK_1
starting media recovery
media recovery complete, elapsed time: 00:00:00
Finished recover at 29-JUN-14
RMAN> alter database open;
database opened
10、遷移臨時表空間
SQL> select name from v$datafile;
NAME
--------------------------------------------------------------------------------
+DG1/prod/datafile/system.257.851554507
+DG1/prod/datafile/undotbs1.260.851554683
+DG1/prod/datafile/sysaux.258.851554603
+DG1/prod/datafile/users.261.851554691
+DG1/prod/datafile/example.259.851554659
SQL> select name from v$tempfile;
NAME
--------------------------------------------------------------------------------
/u01/app/oracle/oradata/prod/temp01.dbf
/u01/app/oracle/product/10.2.0/db_1/dbs/temp01.dbf
報錯:
SQL> alter tablespace temp drop tempfile '/u01/app/oracle/product/10.2.0/db_1/dbs/temp01.dbf';
alter tablespace temp drop tempfile '/u01/app/oracle/product/10.2.0/db_1/dbs/temp01.dbf'
*
ERROR at line 1:
ORA-00600: internal error code, arguments: [drop tempfile-2], [3], [7], [], [],
[], [], []
11、遷移聯機日志組:
SQL> alter database add logfile ('+dg1','+rcy1') size 10m;
Database altered.
SQL> alter database add logfile ('+dg1','+rcy1') size 10m;
Database altered.
SQL> alter database add logfile ('+dg1','+rcy1') size 10m;
Database altered.
SQL> select group#,member from v$logfile order by 1;
GROUP# MEMBER
---------- ------------------------------------------------------------
1 /u01/app/oracle/oradata/prod/redo01.log
2 /u01/app/oracle/oradata/prod/redo02.log
3 /u01/app/oracle/oradata/prod/redo03.log
4 +DG1/prod/onlinelog/group_4.265.851556583
4 +RCY1/prod/onlinelog/group_4.256.851556585
5 +DG1/prod/onlinelog/group_5.266.851556591
5 +RCY1/prod/onlinelog/group_5.257.851556595
6 +DG1/prod/onlinelog/group_6.267.851556599
6 +RCY1/prod/onlinelog/group_6.258.851556601
SQL> alter database drop logfile group 1;
Database altered.
SQL> alter database drop logfile group 2;
alter database drop logfile group 2
*
ERROR at line 1:
ORA-01623: log 2 is current log for instance prod (thread 1) - cannot drop
ORA-00312: online log 2 thread 1: '/u01/app/oracle/oradata/prod/redo02.log'
SQL> alter database drop logfile group 3;
Database altered.
由于第二組日志還沒有歸檔所以現在無法刪除,所以要切換日志,使日志組 2 變成非活動狀態
SQL> alter system switch logfile;
SQL> select group#,members,status from v$log;
GROUP# MEMBERS STATUS
---------- ---------- ----------------
2 1 INACTIVE
4 2 CURRENT
5 2 INACTIVE
6 2 INACTIVE
SQL> alter database drop logfile group 2;
Database altered.
12、調整recover area參數
SQL> show parameter recover
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_recovery_file_dest string /u01/app/oracle/flash_recovery
_area
db_recovery_file_dest_size big integer 2G
recovery_parallelism integer 0
SQL> alter system set db_recovery_file_dest='+rcy1' scope=spfile;
System altered.
SQL> alter system set db_recovery_file_dest_size=2g scope=spfile;
System altered
以上是“oracle中數據fs到asm遷移的示例分析”這篇文章的所有內容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內容對大家有所幫助,如果還想學習更多知識,歡迎關注億速云行業資訊頻道!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。