溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

oracle 11g ASM 磁盤組在線擴容實驗:

發(fā)布時間:2020-08-11 00:11:49 來源:ITPUB博客 閱讀:182 作者:huangdazhu 欄目:關系型數(shù)據(jù)庫
oracle 11g ASM磁盤組擴容實驗:

該主機為我經(jīng)常用的測試機,因為為了順便學習ASM,底層存儲使用的是ASM的方式,但是以前規(guī)劃的時候磁盤組只有4G,由于數(shù)據(jù)文件增加,導致沒有可用的空間。所以,模擬生產(chǎn)環(huán)境做了ASM在線擴容的實驗。

建議在做之前,對數(shù)據(jù)庫進行備份。

---------------------------------------1.主機和數(shù)據(jù)庫環(huán)境---------------------------------------

SQL> select * from v$version;

BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
PL/SQL Release 11.2.0.3.0 - Production
CORE    11.2.0.3.0      Production
TNS for Linux: Version 11.2.0.3.0 - Production
NLSRTL Version 11.2.0.3.0 - Production


[root@ray ~]# lsb_release -a
LSB Version:    :core-4.0-amd64:core-4.0-ia32:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-ia32:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-ia32:printing-4.0-noarch
Distributor ID: EnterpriseEnterpriseServer
Description:    Enterprise Linux Enterprise Linux Server release 5.6 (Carthage)
Release:        5.6
Codename:       Carthage
[root@ray ~]# 


--------------------------------------2. 存儲環(huán)境-------------------------------------------------
由于我用的是虛擬機,所以在虛擬機添加硬盤是很容易的,我們添加一塊5G大小的磁盤,重啟主機,通過下面查詢可以看到我們在/dev/sde就是我們所添加的硬盤。

1. [root@ray ~]# ls -l /dev/sd*
brw-r----- 1 root disk 8,  0 Dec 18 21:17 /dev/sda
brw-r----- 1 root disk 8,  1 Dec 18 21:18 /dev/sda1
brw-r----- 1 root disk 8,  2 Dec 18 21:18 /dev/sda2
brw-r----- 1 root disk 8,  3 Dec 18 21:17 /dev/sda3
brw-r----- 1 root disk 8,  4 Dec 18 21:17 /dev/sda4
brw-r----- 1 root disk 8,  5 Dec 18 21:18 /dev/sda5
brw-r----- 1 root disk 8, 16 Dec 18 21:17 /dev/sdb
brw-r----- 1 root disk 8, 32 Dec 18 21:17 /dev/sdc
brw-r----- 1 root disk 8, 48 Dec 18 21:17 /dev/sdd
brw-r----- 1 root disk 8, 49 Dec 18 21:17 /dev/sdd1
brw-r----- 1 root disk 8, 64 Dec 18 21:17 /dev/sde
[root@ray ~]# fdisk /dev/sde 
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel. Changes will remain in memory only,
until you decide to write them. After that, of course, the previous
content won't be recoverable.

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

Command (m for help): q

[root@ray ~]# fdisk -l

Disk /dev/sda: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          25      200781   83  Linux
/dev/sda2              26         286     2096482+  83  Linux
/dev/sda3             287         547     2096482+  82  Linux swap / Solaris
/dev/sda4             548        2610    16571047+   5  Extended
/dev/sda5             548        2610    16571016   83  Linux

Disk /dev/sdb: 2147 MB, 2147483648 bytes
255 heads, 63 sectors/track, 261 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/sdb doesn't contain a valid partition table

Disk /dev/sdc: 2147 MB, 2147483648 bytes
255 heads, 63 sectors/track, 261 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/sdc doesn't contain a valid partition table

Disk /dev/sdd: 5368 MB, 5368709120 bytes
255 heads, 63 sectors/track, 652 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdd1               1         623     5004216   83  Linux

Disk /dev/sde: 5368 MB, 5368709120 bytes                  ------------------可以看到是5G大小
255 heads, 63 sectors/track, 652 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/sde doesn't contain a valid partition table


--------------------------------------------3. 綁定物理設備----------------------------------
[root@ray ~]# /bin/raw /dev/raw/raw3 /dev/sde 
/dev/raw/raw3:  bound to major 8, minor 64



--------------------------------------------4.  配置UDEV規(guī)則---------------------------------
[root@ray ~]# vi /etc/udev/rules.d/60-raw.rules
# Enter raw device bindings here.
#
# An example would be:
#   ACTION=="add", KERNEL=="sda", RUN+="/bin/raw /dev/raw/raw1 %N"
# to bind /dev/raw/raw1 to /dev/sda, or
#   ACTION=="add", ENV{MAJOR}=="8", ENV{MINOR}=="1", RUN+="/bin/raw /dev/raw/raw2 %M %m"
# to bind /dev/raw/raw2 to the device with major 8, minor 1.


ACTION=="add",KERNEL=="/dev/sdb",  RUN+="/bin/raw /dev/raw/raw1 %N",OWNER="grid", GROUP="asmadmin", MODE="0660"
ACTION=="add",KERNEL=="/dev/sdc",  RUN+="/bin/raw /dev/raw/raw2 %N",OWNER="grid", GROUP="asmadmin", MODE="0660
#add:
ACTION=="add",KERNEL=="/dev/sde",  RUN+="/bin/raw /dev/raw/raw3 %N",OWNER="grid", GROUP="asmadmin", MODE="0660
KERNEL=="raw*", WNER="grid", GROUP="asmadmin", MODE="0660"
chown grid:oinstall /dev/raw/raw*"
~
~
------------------------------------------5. 配置RAW的控制文件---------------------------------

[root@ray ~]# vi /etc/sysconfig/rawdevices
# raw device bindings
# format:  <rawdev> <major> <minor>
#          <rawdev> <blockdev>
# example: /dev/raw/raw1 /dev/sda1
#          /dev/raw/raw2 8 5

/dev/raw/raw1 /dev/sdb
/dev/raw/raw2 /dev/sdc
/dev/raw/raw3 /dev/sde
~


[root@ray ~]# ls -l /dev/raw/raw*
crw-rw---- 1 grid asmadmin 162, 1 Aug 21 17:28 /dev/raw/raw1
crw-rw---- 1 grid asmadmin 162, 2 Aug 21 17:28 /dev/raw/raw2
crw-rw---- 1 grid asmadmin 162, 3 Aug 21 17:27 /dev/raw/raw3

在上面,我們在屋里層面上的操作已經(jīng)做完了。下面我們要在數(shù)據(jù)庫層面做。




----------------------------------------DATA擴容----------------------------------


1. 登錄到數(shù)據(jù)庫服務器節(jié)點1,以grid用戶查看ASM磁盤組空間情況:

[root@ray ~]# su - grid
grid@ray:/home/grid>asmcmd
ASMCMD> lsdg
State    Type    Rebal  Sector  Block       AU  Total_MB  Free_MB  Req_mir_free_MB  Usable_file_MB  Offline_disks  Voting_files  Name
MOUNTED  NORMAL  N         512   4096  1048576      4096      174                0              87              0             N  DATA/

注:可以看到,我們的DATA磁盤只有174M的可用容量。


2. 如果在生產(chǎn)環(huán)境,磁盤組添加磁盤需要很長的平衡時間,所以,我們先查詢asm_power_limit的值,并調整為10;

grid@ray:/home/grid>sqlplus / as sysdba

SQL*Plus: Release 11.2.0.3.0 Production on Thu Aug 21 17:30:36 2014

Copyright (c) 1982, 2011, Oracle.  All rights reserved.

Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Automatic Storage Management option

SQL> show parameter asm_power_limit;

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
asm_power_limit                      integer     1
SQL> alter system set asm_power_limit=10  scope=both;    

System altered.

SQL> show parameter asm_power_limit

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
asm_power_limit                      integer     10


3. 查看磁盤組使用情況及磁盤名稱和路徑

SQL> select group_number,name,state,total_mb,free_mb from v$asm_diskgroup;

GROUP_NUMBER NAME                           STATE         TOTAL_MB    FREE_MB
------------ ------------------------------ ----------- ---------- ----------
           1 DATA                           MOUNTED           4096        174
                                
SQL> col name for a10
SQL> col path for a30
SQL> select name,path from v$asm_disk;

NAME       PATH
---------- ------------------------------
DATA_0001  /dev/raw/raw2
DATA_0000  /dev/raw/raw1
DATA_0002  /dev/raw/raw3


4. 將新增加的磁盤添加到DATA磁盤組:
grid@ray:/home/grid>sqlplus / as sysasm

SQL*Plus: Release 11.2.0.3.0 Production on Thu Aug 21 17:31:59 2014

Copyright (c) 1982, 2011, Oracle.  All rights reserved.

Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Automatic Storage Management option

注:此處必須以sysasm身份操作,否則報錯ORA-15032和ORA-15260,這是oracle 11G ASM磁盤管理上的一個改進。

SQL> alter diskgroup DATA add disk '/dev/raw/raw3';

Diskgroup altered.

5. 查看是否添加完成
SQL> col name for a10
SQL> col path for a30
SQL> select name,path from v$asm_disk;

NAME       PATH
---------- ------------------------------
DATA_0001  /dev/raw/raw2
DATA_0000  /dev/raw/raw1
DATA_0002  /dev/raw/raw3


6. 將數(shù)據(jù)進行冗余

將當前的diskgroup組的rebalance速度修改為10:

SQL> alter diskgroup DATA  rebalance power  10;

Diskgroup altered.
查看重新平衡需要的時間:這里已經(jīng)完了,因為磁盤只有5G。
SQL> select operation,est_minutes from v$asm_operation;

OPERA EST_MINUTES
----- -----------
REBAL           0

SQL> select name,path from v$asm_disk;

NAME       PATH
---------- ------------------------------
DATA_0001  /dev/raw/raw2
DATA_0000  /dev/raw/raw1
DATA_0002  /dev/raw/raw3

7. 將參數(shù)改回去

SQL> alter diskgroup DATA rebalance power 1;

Diskgroup altered.

SQL> alter system set asm_power_limit=1 scope=both;

System altered.


查詢DATA磁盤組容量,可以看到,我們已經(jīng)增加了5G的容量。


SQL> select group_number,name,state,total_mb,free_mb from v$asm_diskgroup;


GROUP_NUMBER NAME       STATE         TOTAL_MB    FREE_MB
------------ ---------- ----------- ---------- ----------
           1 DATA       MOUNTED           9216       5233


歡迎大家批評指正:
QQ交流群:300392987
論        壇:www.oraclefreebase.com

向AI問一下細節(jié)

免責聲明:本站發(fā)布的內容(圖片、視頻和文字)以原創(chuàng)、轉載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權內容。

AI