【轉】Oracle ASM介紹

kidking2010發表於2017-05-17
Oracle 10g在安裝的時候必須要選擇的一個檔案儲存方式的選項,可以選擇“檔案系統”、“ASM”、“裸裝置”。其中ASM現在已經越來越多的應用到實踐中。ASM的時候,可以使Oracle脫離OS檔案系統的約束,使得對檔案管理時更加方便,同時也改善了很多的硬體屬性。當然,使用ASM需要專門配置、建立一個ASM磁碟組。下面找了些文章介紹一下,初步瞭解ASM。
Oracle資料庫自動儲存管理(ASM)

關於ASM的討論很多,但是到底什麼是ASM?ASM是一個有效的抽象層,使你的Oracle資料庫可以與叫做DiskGroups的抽象空間一起使用,而不是直接使用DataFiles。這帶來了很多好處,但是也要求學習一些新的概念、命令、使用和管理任務。所以在投入你的生產系統之前,看看它解決什麼、管理什麼,以及對它的正反面評價。
為什麼建立它?
  回答這個問題的最好方式是直接追溯源頭,Bill Bridge——自動儲存管理的最初架構師。在Oracle Press標題中的Oracle ASM,Bill提供了一個連結,他在那裡討論了使用供應商特定作業系統的檔案系統來管理Oracle資料檔案放置所遇到的問題:
  1. 對於歸檔日誌和備份,作業系統供應商不提供共享磁碟檔案系統。
  2. 邏輯卷管理器隱藏了檔案的位置,使得很難管理磁碟I/O和提供良好的統計。
  3. 當磁碟數超過100時,現有的lvm不能工作得很好。
  4. 當資料庫有1000以上的資料檔案時,作業系統和Oracle不能很好地處理資料庫。
  5. 當有大量資料檔案時命名就變得很困難了。
  6. 特性和檔案系統限制隨作業系統的不同而不同。
  7. 作業系統級的使用者可以透過標準使用接觸到Oracle檔案,而Oracle並不知道。
  所以,他透過建立Oracle自己的檔案系統開始解決這些問題。他的目標是提供這些特性:
  1. 與Oracle緊密整合,並與叢集一起使用(並行伺服器)。
  2. 自動使用新的儲存,作為磁碟單元或磁碟組來管理。
  3. 支援成千上萬的磁碟。
  4. 檔案不會名字,並會在作業系統中隱藏起來。
誰需要它?
  現在快速瀏覽一下上面那些問題和解決方案會幫助你確定誰需要ASM。起初,它是用來處理現在很大型的聯機資料庫。所以如果它包括你的商店,那麼你可能已經在關注它了,或者開始執行ASM。如果你的資料庫較小,資料檔案也不多,那麼你可能需要再一些理由使你考慮採用它。
  1. 你將要熟悉一些新技術,並且應該從在你的開發環境中建立它開始,並測試幾個月。
  2. 如果你想從你現有的磁碟子系統中獲得更高的效能,並獲得更好的統計用於預測磁碟I/O。
  3. 如果你正在使用RAC,那麼就需要考慮ASM了。
開始
  ASM是由一個例項管理,非常類似於Oracle資料庫。但是初始引數是非常有限的,而且啟動過程也簡單得多。
  a. 將你的ORACLE_SID設定為+ASM1
  b. 編輯init.ora

  # as opposed to RDBMS for a normal Oracle instance
  INSTANCE_TYPE=ASM
  # these names will be used in place of datafile names when you create tablespaces
  ASM_DISKGROUPS=SEAN, AARON
  processes=100
  # this parameter is platform. specific and is the path to the raw disk device
  ASM_DISKSTRING='/dev/cciss/c0d0p1'
  # on 11g you should use diagnostic_dest instead of these
  background_dump_dest=/opt/oracle/admin/+ASM/bdump'
  core_dump_dest=/opt/oracle/admin/+ASM/cdump'
  user_dump_dest=/opt/oracle/admin/+ASM/udump'
  c. 啟動ASM例項
  $ sqlplus / as sysdba
  SQL> startup

  d. 建立磁碟組
  SQL> create diskgroup SEAN disk '/dev/cciss/c0d0p1';
  e. 檢查表空間的建立
  你可能會猜測,建立一個表空間會有輕微的改變。預設方法如下所示:
  SQL> create tablespace sean_space datafile '+SEAN' size 1GB;
  不過想一下這個很好的特性。如果在你的資料庫中init.ora檔案你設定引數為:
db_create_file_dest=+SEAN
  那麼你可以這樣做:
  SQL> create tablespace sean_space;
  然後讓Oracle做其餘的工作。在這兩種情形下,你將發現在v$datafile中列出的檔案路徑是和抽象的+SEAN 磁碟組有關,而不是與一個實際的作業系統資料檔案。
  f. 更多的
  當然簡化檔名稱和表空間的建立只是ASM可以為你做的工作的冰山一角。它還可以提供一個冗餘級別。
  在資料庫方面,外部冗餘能力主要是當你在硬體級別(RAID)上或Oracle可以看到的其它外部方法中具有冗餘。換句話說,如果asm_diskstring裝置是它們自己的邏輯,隱藏物理磁碟於一些冗餘的硬體層後面,那麼你就會有外部冗餘能力。
  但是,如果你沒有這個冗餘能力,那麼ASM可以提供。你可以指定冗餘、失敗組和一組其它的選項來防止損失一個或多個磁碟、控制器或甚至是整個SAM失效。ASM還提供了在磁碟組中均勻分佈的I/O。因為ASM很好的瞭解背後發生了什麼,所以Oracle可以自動的為你提供I/O到磁碟的一個更好的平衡。
使用ASM遇到的挑戰
  ASM當然是一個具有很大潛能的強大技術。但是對於每一個技術解決方案,都會有很多的挑戰。對於ASM,它潛在地破壞了Unix系統管理組和資料庫/資料庫管理員組間力量的普通平衡。以前的組管理磁碟、硬體和作業系統級別,使資料庫管理員與它們協作獲取新的資源。這將在某種程度上挑戰這個平衡,而這會引起一些來自於這個組的阻力。
  最後,應該是業務需求促使了它的採用。還要注意到ASM仍然是處於企業計算認識階段,相對還比較新。有一些供應商他們的核心業務已經放在邏輯空間管理器/檔案系統空間中很多年了。一般來說,對於軟體系統和可靠性來說成熟是很重要的。
總結
  ASM很強大,它為目前部署的不斷髮展的大型資料庫系統提供瞭解決方案。它還可以為較小資料庫安裝或者那些使用叢集的資料庫提供解決方案。如同對於任何新技術一樣,評估、測試,然後更多的測試。
再轉一篇ASM的配置文章
********************************************************************************************
配置Oracle 10g ASM磁碟

總結一下ASM的磁碟建立過程
此次實驗是基於CentOS 4.6系統的實驗,
1.首先,我需要在Oracle的網站上download的一些ASM的lib包

因為自己實驗的環境是基於Linux的,而且是RHEL AS 4所以會根據當前的kernel和OS的版本下載三個包
分別是:
oracleasm-2.6.9-67.EL-2.0.3-1.i686.rpm
oracleasmlib-2.0.2-1.i386.rpm
oracleasm-support-2.0.3-1.i386.rpm
2.之後可以透過RPM的軟體對他們分別進行安裝
[root@orahost01 ASM]# rpm -Uvh oracleasm-support-2.0.3-1.i386.rpm
Preparing... ########################################### [100%]
1:oracleasm-support ########################################### [100%]
[root@orahost01 ASM]# rpm -Uvh oracleasm-2.6.9-67.EL-2.0.3-1.i686.rpm
Preparing... ########################################### [100%]
1:oracleasm-2.6.9-67.EL ########################################### [100%]
[root@orahost01 ASM]# rpm -Uvn oracleasmlib-2.0.2-1.i386.rpm
-Uvn: unknown option
[root@orahost01 ASM]# rpm -Uvh oracleasmlib-2.0.2-1.i386.rpm
Preparing... ########################################### [100%]
1:oracleasmlib ########################################### [100%]
並且建立相應的Oracle使用者和組
[root@orahost01 ASM]# groupadd oinstall
[root@orahost01 ASM]# groupadd dba
[root@orahost01 ASM]# mkdir -p /opt/oracle/product
[root@orahost01 ASM]# mkdir -p /home/oracle
[root@orahost01 ASM]# useradd -g oinstall -G dba -d /home/oracle oracle
[root@orahost01 ASM]# passwd oracle
Changing password for user oracle.
New UNIX password:
BAD PASSWORD: it is based on a dictionary word
Retype new UNIX password:
passwd: all authentication tokens updated successfully.
[root@orahost01 ASM]# id oracle
uid=500(oracle) gid=500(oinstall) groups=500(oinstall),501(dba)
[root@orahost01 ASM]# chown -R oracle:oinstall /opt/oracle
[root@orahost01 ASM]# cd /home
[root@orahost01 home]# chown -R oracle:oinstall oracle
3.配置ASM的庫檔案
[root@orahost01 home]#/etc/init.d/oracleasm configure
Configuring the Oracle ASM library driver.
This will configure the on-boot properties of the Oracle ASM library
driver. The following questions will determine whether the driver is
loaded on boot and what permissions it will have. The current values
will be shown in brackets ('[]'). Hitting <ENTER> without typing an
answer will keep that current value. Ctrl-C will abort.
Default user to own the driver interface []: oracle
Default group to own the driver interface []: dba
Start Oracle ASM library driver on boot (y/n) [n]: y
Fix permissions of Oracle ASM disks on boot (y/n) [y]: y
Writing Oracle ASM library driver configuration: [ OK ]
Creating /dev/oracleasm mount point: [ OK ]
Loading module "oracleasm": [ OK ]
Mounting ASMlib driver filesystem: [ OK ]
Scanning system for ASM disks: [ OK ]
以上操作會載入和ASM相關的一些.o的驅動.並且mount上asm的檔案系統
4.如何disable和enable ASM

[root@orahost01 home]#/etc/init.d/oracleasm disable
Writing Oracle ASM library driver configuration: [ OK ]
Unmounting ASMlib driver filesystem: [ OK ]
Unloading module "oracleasm": [ OK ]
[root@orahost01 home]#/etc/init.d/oracleasm enable
Writing Oracle ASM library driver configuration: [ OK ]
Loading module "oracleasm": [ OK ]
Mounting ASMlib driver filesystem: [ OK ]
Scanning system for ASM disks: [ OK ]
5.建立ASM磁碟

首先先將一些磁碟(4塊)插入我們的Server
之後
[root@orahost01 home]# /etc/init.d/oracleasm createdisk myVol1 /dev/sdb
Marking disk "/dev/sdb" as an ASM disk: asmtool: Device "/dev/sdb" is not a partition
[FAILED]
這裡出現錯誤的原因是由於我們還沒有對/dev/sdb這個裝置檔案所載入的磁碟進行分割槽,而且sdb也不是一個partition
因此我們先對sdb磁碟進行分割槽
[root@orahost01 dev]#fdisk sdb
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): m
Command action
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition
l list known partition types
m print this menu
n add a new partition
o create a new empty DOS partition table
p print the partition table
q quit without saving changes
s create a new empty Sun disklabel
t change a partition's system id
u change display/entry units
v verify the partition table
w write table to disk and exit
x extra functionality (experts only)
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-130, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-130, default 130):
Using default value 130
Command (m for help):w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
這個時候系統中會出現一個sdb1這個裝置檔案
之後我們繼續對sdc,sdd,sde以上面同樣的方法來進行分割槽。
------------------------------------------------------
重新建立ASM磁碟
[root@orahost01 dev]# /etc/init.d/oracleasm createdisk myVol1 /dev/sdb1
Marking disk "/dev/sdb1" as an ASM disk: [ OK ]
[root@orahost01 dev]# /etc/init.d/oracleasm listdisks
MYVOL1
[root@orahost01 dev]# /etc/init.d/oracleasm createdisk myVol2 /dev/sdc1
Marking disk "/dev/sdc1" as an ASM disk: [ OK ]
[root@orahost01 dev]# /etc/init.d/oracleasm createdisk myVol3 /dev/sde1
Marking disk "/dev/sde1" as an ASM disk: [ OK ]
[root@orahost01 dev]# /etc/init.d/oracleasm createdisk myVol4 /dev/sdd1
Marking disk "/dev/sdd1" as an ASM disk: [ OK ]
[root@orahost01 dev]#/etc/init.d/oracleasm listdisks
MYVOL1
MYVOL2
MYVOL3
MYVOL4
需要注意的是如果是在RAC環境中呢,如果在一個節點新增了ASM磁碟,在其他節點上要用過scandisks命令來獲得這種變化。
如:
[root@orahost01 dev]#/etc/init.d/oracleasm scandisks
Scanning system for ASM disks: [ OK ]
就此ASM環境的物理基礎就已經搭建成功.
其他OS類似於此,很簡單,只要按照這個思路走就可以了:)
 

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

相關文章