oracle database的asm磁盘管理
asm磁盤管理
1. 擴(kuò)容
1.1 掛盤
服務(wù)器掛載共享磁盤。找出新掛載的磁盤,或者由存儲工程師提供新掛載磁盤的uuid。
[root@rac01 ~]# lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sdf 8:80 0 5G 0 disk └─ol-root 252:0 0 36.5G 0 lvm / sdd 8:48 0 10G 0 disk └─asm_ocr_3 252:2 0 10G 0 mpath sdb 8:16 0 10G 0 disk └─asm_ocr_1 252:3 0 10G 0 mpath sr0 11:0 1 4.3G 0 rom sdg 8:96 0 10G 0 disk └─mpathc 252:6 0 10G 0 mpath sde 8:64 0 10G 0 disk └─asm_data_1 252:5 0 10G 0 mpath sdc 8:32 0 10G 0 disk └─asm_ocr_2 252:4 0 10G 0 mpath sda 8:0 0 40G 0 disk ├─sda2 8:2 0 39.5G 0 part │ ├─ol-swap 252:1 0 8G 0 lvm [SWAP] │ └─ol-root 252:0 0 36.5G 0 lvm / └─sda1 8:1 0 500M 0 part /boot由lsblk命令分析,本次新掛載的磁盤為sdg。
1.2 配置多路徑(rac01&rac02)
- 查看共享磁盤uuid
以本次新增sdg盤為例:
[root@rac01 ~]# /usr/lib/udev/scsi_id -g -u /dev/sdg 36000c299b5e68b5b56df4dab0ff2904a- 配置multipath
- multipath reload
1.3 新增udev規(guī)則(rac01&rac02)
- 配置UDEV綁盤:
- 重載udev:
至此,多路徑共享存儲配置完成。
- 查看共享磁盤:
1.4 asm擴(kuò)容(rac01)
在grid用戶下,登錄sysdba,查詢剛才新增的磁盤狀態(tài)
su - grid sqlplus / as sysasm查看剛才創(chuàng)建的硬盤
SQL> set lines 200 pages 50000 SQL> col name for a25 SQL> col path for a55 SQL> select group_number,disk_number,name,path,total_mb/1024 total_G,mode_status,repair_timer from v$asm_disk order by group_number,disk_number;GROUP_NUMBER DISK_NUMBER NAME PATH TOTAL_G MODE_STATUS REPAIR_TIMER ------------ ----------- ------------------------- ------------------------------------------------------- ---------- --------------------- ------------0 0 /dev/asm_asm_data_2 0 ONLINE 01 0 DATA_0000 /dev/asm_asm_data_1 10 ONLINE 02 0 OCR_0000 /dev/asm_asm_ocr_1 10 ONLINE 02 1 OCR_0001 /dev/asm_asm_ocr_2 10 ONLINE 02 2 OCR_0002 /dev/asm_asm_ocr_3 10 ONLINE 0查看原磁盤組的情況
SQL> select name,state,type,total_mb,free_mb from v$asm_diskgroup;NAME STATE TYPE TOTAL_MB FREE_MB ------------------------- --------------------------------- ------------------ ---------- ---------- DATA MOUNTED EXTERN 10240 2696 OCR MOUNTED NORMAL 30720 29708將查詢到的硬盤添加到DATA磁盤組
SQL> alter diskgroup DATA add disk '/dev/asm_asm_data_2' rebalance power 6;Diskgroup altered.注:rebalance power的級別從1到11中選擇一個數(shù)值;數(shù)值越大,rebalance速度越快,對現(xiàn)有運(yùn)行系統(tǒng)影響也越大。需要根據(jù)當(dāng)時業(yè)務(wù)權(quán)衡選擇適合的級別;
查看磁盤平衡進(jìn)度
SQL> select group_number,operation,state,est_work,est_rate,est_minutes,error_code from v$asm_operation; ##直到查詢結(jié)果是no rows selected,表示rebalance已經(jīng)完成。重新查詢磁盤狀態(tài)
SQL> set lines 200 pages 50000 SQL> col name for a25 SQL> col path for a55 SQL> select group_number,disk_number,name,path,total_mb/1024 total_G,mode_status,repair_timer from v$asm_disk order by group_number,disk_number;GROUP_NUMBER DISK_NUMBER NAME PATH TOTAL_G MODE_STATUS REPAIR_TIMER ------------ ----------- ------------------------- ------------------------------------------------------- ---------- --------------------- ------------1 0 DATA_0000 /dev/asm_asm_data_1 10 ONLINE 01 1 DATA_0001 /dev/asm_asm_data_2 10 ONLINE 02 0 OCR_0000 /dev/asm_asm_ocr_1 10 ONLINE 02 1 OCR_0001 /dev/asm_asm_ocr_2 10 ONLINE 02 2 OCR_0002 /dev/asm_asm_ocr_3 10 ONLINE 0重新查詢磁盤組狀態(tài)
SQL> select group_number,name,state,type,total_mb,free_mb from v$asm_diskgroup;GROUP_NUMBER NAME STATE TYPE TOTAL_MB FREE_MB ------------ ------------------------- --------------------------------- ------------------ ---------- ----------1 DATA MOUNTED EXTERN 20480 128402 OCR MOUNTED NORMAL 30720 29708至此,ASM磁盤組擴(kuò)容完成。
2. 縮容
2.1 asm信息確認(rèn)
查詢磁盤狀態(tài)
SQL> set lines 200 pages 50000 SQL> col name for a25 SQL> col path for a55 SQL> select group_number,disk_number,name,path,total_mb/1024 total_G,mode_status,repair_timer from v$asm_disk order by group_number,disk_number;GROUP_NUMBER DISK_NUMBER NAME PATH TOTAL_G MODE_STATUS REPAIR_TIMER ------------ ----------- ------------------------- ------------------------------------------------------- ---------- --------------------- ------------1 0 DATA_0000 /dev/asm_asm_data_1 10 ONLINE 01 1 DATA_0001 /dev/asm_asm_data_2 10 ONLINE 02 0 OCR_0000 /dev/asm_asm_ocr_1 10 ONLINE 02 1 OCR_0001 /dev/asm_asm_ocr_2 10 ONLINE 02 2 OCR_0002 /dev/asm_asm_ocr_3 10 ONLINE 0查詢磁盤組狀態(tài)
SQL> select group_number,name,state,type,total_mb,free_mb from v$asm_diskgroup;GROUP_NUMBER NAME STATE TYPE TOTAL_MB FREE_MB ------------ ------------------------- --------------------------------- ------------------ ---------- ----------1 DATA MOUNTED EXTERN 20480 128402 OCR MOUNTED NORMAL 30720 29708確定要刪除的磁盤,本次以移除/dev/sdg為例:
[root@rac01 ~]# lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sdf 8:80 0 5G 0 disk └─ol-root 252:0 0 36.5G 0 lvm / sdd 8:48 0 10G 0 disk └─asm_ocr_3 252:5 0 10G 0 mpath sdb 8:16 0 10G 0 disk └─asm_ocr_1 252:4 0 10G 0 mpath sr0 11:0 1 4.3G 0 rom sdg 8:96 0 10G 0 disk └─asm_data_2 252:6 0 10G 0 mpath sde 8:64 0 10G 0 disk └─asm_data_1 252:2 0 10G 0 mpath sdc 8:32 0 10G 0 disk └─asm_ocr_2 252:3 0 10G 0 mpath sda 8:0 0 40G 0 disk ├─sda2 8:2 0 39.5G 0 part │ ├─ol-swap 252:1 0 8G 0 lvm [SWAP] │ └─ol-root 252:0 0 36.5G 0 lvm / └─sda1 8:1 0 500M 0 part /boot [root@rac01 ~]# /usr/lib/udev/scsi_id -g -u /dev/sdg 36000c299b5e68b5b56df4dab0ff2904a找到sdg的多路徑和udev配置信息,結(jié)合asm磁盤中的path信息,確定本次要移除的/dev/sdg磁盤的多路徑配置信息為wwid為“36000c299b5e68b5b56df4dab0ff2904a”相關(guān)的配置,udev配置為“36000c299b5e68b5b56df4dab0ff2904a”和“asm_asm_data_2”相關(guān)的配置,asm磁盤path為“/dev/asm_asm_data_2”。
2.2 asm磁盤移除(rac01)
在grid用戶下,登錄sysdba
su - grid sqlplus / as sysasm移除磁盤
SQL> alter diskgroup DATA drop disk 'DATA_0001';查看磁盤重新平衡進(jìn)度
SQL> select group_number,operation,state,est_work,est_rate,est_minutes,error_code from v$asm_operation;GROUP_NUMBER OPERATION STATE EST_WORK EST_RATE EST_MINUTES ------------ --------------- ------------ ---------- ---------- ----------- ERROR_CODE ------------------------------------------------------------------------------------------------------------------------------------1 REBAL REAP 0 0 01 REBAL DONE 949 0 01 REBAL DONE 0 0 0SQL> select group_number,operation,state,est_work,est_rate,est_minutes,error_code from v$asm_operation;no rows selected2.3 移除udev配置(rac01&rac02)
- 配置UDEV綁盤:
- 重載udev:
至此,多路徑共享存儲配置完成。
- 查看共享磁盤:
2.4 多路徑配置(rac01&rac02)
- 配置multipath
- multipath reload
至此磁盤移除配置完成。/dev/sdg磁盤可以從操作系統(tǒng)中移除,或者改為其他用途。
3 磁盤替換
在實(shí)際生產(chǎn)中,還會遇到另外一種情況,就是需要對正在使用的磁盤進(jìn)行替換。那么我們可以按照前面的內(nèi)容進(jìn)行增加和刪除磁盤,但是在實(shí)際應(yīng)用中我發(fā)現(xiàn)先增加磁盤,再刪除磁盤的方案雖然可行,但是在數(shù)據(jù)量很大的情況下實(shí)際操作很慢。故查閱文檔,發(fā)現(xiàn)了文檔中提到了一個將刪除和添加磁盤放到一個sql語句中執(zhí)行的方案,并且經(jīng)過驗(yàn)證,該方法可以大幅提升磁盤數(shù)據(jù)遷移的效率。以下為sql案例:
SQL> alter diskgroup DATA drop disk 'DATA_0001' add disk '/dev/asm_asm_data_2' rebalance power 6;4 擴(kuò)展命令
以下命令用于對ASM實(shí)例進(jìn)行管理:
srvctl status asm srvctl stop asm srvctl start asm以下命令用于對ASM磁盤組進(jìn)行管理:
srvctl status diskgroup -g data srvctl stop diskgroup -g data srvctl start diskgroup -g data創(chuàng)建磁盤組(一般建議用asmca圖形化工具進(jìn)行創(chuàng)建):
$ sqlplus / as sysasm SQL> CREATE DISKGROUP dg1 external REDUNDANCYDISK'/dev/raw/raw1','/dev/raw/raw2'磁盤組通過mirror方式保證數(shù)據(jù)的安全
普通冗余:每個磁盤組有兩個FAILGROUP
高冗余:每個磁盤組有三個FAILGROUP
外部冗余:通過存儲設(shè)備的冗余來保證數(shù)據(jù)安全
SQL> CREATE DISKGROUP dg1 NORMAL REDUNDANCYFAILGROUP fg1 DISK‘/dev/raw/raw1, '/dev/raw/raw3'FAILGROUP fg2 DISK‘/dev/raw/raw2’, '/dev/raw/raw4';在創(chuàng)建磁盤組的節(jié)點(diǎn)上,磁盤組被自動掛接。在其他節(jié)點(diǎn)需要手動掛載:
SQL> ALTER DISKGROUP dg1 MOUNT;磁盤組卸載:
SQL> ALTER DISKGROUP dg1 DISMOUNT;向磁盤組中添加磁盤:
SQL>ALTER DISKGROUP dg1 ADD DISK'/dev/raw/raw3' NAME disk3,'/dev/raw/raw4' NAME disk4;從磁盤組中剔除磁盤:
SQL> ALTER DISKGROUP dg1 DROP DISK disk3; SQL> alter diskgroup dg1 drop disk3 in failgroup fg2; SQL> ALTER DISKGROUP DG1 UNDROP DISKS;當(dāng)磁盤組中的磁盤發(fā)生變化時,磁盤組將自動進(jìn)行重新平衡。平衡級別為0-11,當(dāng)手工進(jìn)行重新平衡時,可以指定平衡級別。可用的最高級別通過初始化參數(shù)ASM_POWER_LIMIT指定。
SQL> ALTER DISKGROUP dg1 REBALANCE POWER 3; SQL> ALTER DISKGROUP dg1 REBALANCE POWER 3 WAIT;在其中一個選定的節(jié)點(diǎn)上保持磁盤組處于mounted狀態(tài),**在其他節(jié)點(diǎn)上將磁盤組卸載**,在選定的節(jié)點(diǎn)上執(zhí)行:
SQL> DROP DISKGROUP dg1; SQL> DROP DISKGROUP dg1 INCLUDING CONTENTS;#清理磁盤頭信息方法。 dd if=/dev/null of=/dev/sdb1 bs=1m count=1磁盤組的查詢:
select name,state,type,total_mb,free_mb from v$asm_diskgroup; select group_num,path,total_mb,free_mb from v$asm_disk; select group_number,instance_name,db_name,status from v$asm_client;磁盤組中目錄的管理:
#目錄的創(chuàng)建: SQL>ALTER DISKGROUP dg1 ADD DIRECTORY '+dg1/dir1'; #目錄的重新命名: SQL>ALTER DISKGROUP dg1 RENAME DIRECTORY ‘+dg1/dir1’ TO ‘+dg1/dir2‘ #目錄的刪除: SQL>ALTER DISKGROUP dg1 DROP DIRECTORY '+dg1/dir1' FORCE; #刪除磁盤組中不再需要的文件,例如: SQL> ALTER DISKGROUP dg1 DROP FILE '+dg1/myfiles/my_undo_ts';總結(jié)
以上是生活随笔為你收集整理的oracle database的asm磁盘管理的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: matrox 采集卡使用范例
- 下一篇: PPT里面添加3Dvia Compose