小編給大家分享一下oracle中數(shù)據(jù)fs到asm遷移的示例分析,相信大部分人都還不怎么了解,因此分享這篇文章給大家參考一下,希望大家閱讀完這篇文章后大有收獲,下面讓我們一起去了解一下吧!
成都創(chuàng)新互聯(lián)主要為客戶提供服務(wù)項目涵蓋了網(wǎng)頁視覺設(shè)計、VI標(biāo)志設(shè)計、全網(wǎng)營銷推廣、網(wǎng)站程序開發(fā)、HTML5響應(yīng)式網(wǎng)站建設(shè)、移動網(wǎng)站建設(shè)、微商城、網(wǎng)站托管及成都網(wǎng)站維護、WEB系統(tǒng)開發(fā)、域名注冊、國內(nèi)外服務(wù)器租用、視頻、平面設(shè)計、SEO優(yōu)化排名。設(shè)計、前端、后端三個建站步驟的完善服務(wù)體系。一人跟蹤測試的建站服務(wù)標(biāo)準(zhǔn)。已經(jīng)為成都集裝箱行業(yè)客戶提供了網(wǎng)站開發(fā)服務(wù)。(RedHat 10g Oracle環(huán)境)
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)實例參數(shù)
[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、創(chuàng)建裸設(shè)備,修改用戶和權(quán)限
1)添加磁盤;
2)為磁盤分區(qū):
[root@redhat10g ~]# fdisk /dev/sdb
Device Boot Start End Blocks Id System
/dev/sdb1 1 2610 20964793+ 83 Linux
3)創(chuàng)建物理卷(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)創(chuàng)建卷組:
[root@redhat10g ~]# vgcreate asmvg /dev/sdb1
5)創(chuàng)建邏輯卷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)綁定裸設(shè)備:
[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
服務(wù)器啟動自動掛載裸設(shè)備:
[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
重啟服務(wù)驗證能否掛載:
[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)修改設(shè)備屬性:
[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、創(chuàng)建ASM磁盤組
為了能使ASM啟動時,自動掛載磁盤和磁盤組,將下邊的參數(shù)添加到初始化文件中:
asm_diskstring='/dev/mapper/asmvg-*'
asm_diskgroups='DG1','RCY1'
6、修改參數(shù):
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、轉(zhuǎn)儲控制文件
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、轉(zhuǎn)儲數(shù)據(jù)文件
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、恢復(fù)數(shù)據(jù)庫
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、遷移聯(lián)機日志組:
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.
由于第二組日志還沒有歸檔所以現(xiàn)在無法刪除,所以要切換日志,使日志組 2 變成非活動狀態(tài)
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、調(diào)整recover area參數(shù)
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中數(shù)據(jù)fs到asm遷移的示例分析”這篇文章的所有內(nèi)容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內(nèi)容對大家有所幫助,如果還想學(xué)習(xí)更多知識,歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道!
另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)cdcxhl.cn,海內(nèi)外云服務(wù)器15元起步,三天無理由+7*72小時售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國服務(wù)器、虛擬主機、免備案服務(wù)器”等云主機租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡單易用、服務(wù)可用性高、性價比高”等特點與優(yōu)勢,專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場景需求。