2013年7月25日 星期四

Oracle 11g-建立ASM DISK

如果你才剛安裝好Linux的話,也還沒安裝Grid Infrastructure 跟 database software的話
 ASMDISK配置是你絕對不能錯過的~





Step 1.  登入OS後,切換root帳號 ,找出你其它配置的磁碟

[root@oracleEXdb ~]# ls /dev/sd*
/dev/sda  /dev/sda1  /dev/sda2  /dev/sdb  /dev/sdc  /dev/sdd  /dev/sde  /dev/sdf  /dev/sdg  /dev/sdh  /dev/sdi

這裡說明了除了 sda (sda1/sda2)外,其他的就可以拿來給ASMDISK使用
本章使用VM 並虛擬 8顆HDD 每顆容量大小是10GB,實際應用請依據你的磁碟大小或是Storage配置決定。(這裡的數量我覺得會跟災害復原時有較大的關係,但是現在的硬體本身就已經有硬體raid在,因此對ASM來說數量就不會是一個很大的問題)

Step 2.  執行fdisk指令進行初始化設定

目標對象:   /dev/sdb  /dev/sdc  /dev/sdd  /dev/sde  /dev/sdf  /dev/sdg  /dev/sdh  /dev/sdi

[root@oracleEXdb ~]# cd /dev/
[root@oracleEXdb ~]# fdisk sdb

The number of cylinders for this disk is set to 1305.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
   (e.g., DOS FDISK, OS/2 FDISK)
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

Command (m for help): m <<輸入[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 < 輸入[n] [add a new partition] 
Command action
   e   extended
   p   primary partition (1-4)  <<輸入[p] [primary partition]
p
Partition number (1-4): 1 <<輸入[1]  
First cylinder (1-1305, default 1):  起始磁區 請直接按ENETR (採預設值)
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-1305, default 1305):    起始磁區 請直接按ENETR (採預設值)
Using default value 1305

Command (m for help): w <<輸入[w] [write table to disk and exit]
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

請依據此操作完成想要變成ASMDISK的硬碟!!!!



Step 3.  確認ASMLIB driver 已經安裝

[root@oracleEXdb dev]#  rpm -qa|grep oracleasm
oracleasm-support-2.1.7-1.el5                             
oracleasm-2.6.18-274.el5PAE-2.0.5-1.el5
oracleasm-2.6.18-274.el5-2.0.5-1.el5
oracleasm-2.6.18-274.el5debug-2.0.5-1.el5
oracleasm-2.6.18-274.el5xen-2.0.5-1.el5

(事實上只要有上述紅字這三個即可)


Step 4.設定ASMLIB driver 已經安裝

(這裡有一個比較奇怪的地方要先說明一下,不要在 /etc/init.d/下直接執行oracleasm configure因為不知道為什麼它會不出現互動讓你設定會變成要人工設定,我第一次卡在這地方的時候
我都快把電腦給拆了)


[root@oracleEXdb /]# /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     <<輸入使用oracle的使用者
Default group to own the driver interface []: dba      <<輸入使用oracle的群組
Start Oracle ASM library driver on boot (y/n) [n]: Y <<是否一開機就載入Drive
Scan for Oracle ASM disks on boot (y/n) [y]: Y       <<是否一開機就掃描ASMDISK
Writing Oracle ASM library driver configuration: done
Initializing the Oracle ASMLib driver:                     [  OK  ]
Scanning the system for Oracle ASMLib disks:               [  OK  ]


Step 5.建立ASM DISK


[root@oracleEXdb init.d]# oracleasm
Usage: oracleasm [--exec-path=<exec_path>] <command> [ <args> ]
       oracleasm --exec-path
       oracleasm -h
       oracleasm -V

The basic oracleasm commands are:
    configure        Configure the Oracle Linux ASMLib driver
    init             Load and initialize the ASMLib driver
    exit             Stop the ASMLib driver
    scandisks        Scan the system for Oracle ASMLib disks
    status           Display the status of the Oracle ASMLib driver
    listdisks        List known Oracle ASMLib disks
    querydisk        Determine if a disk belongs to Oracle ASMlib
    createdisk       Allocate a device for Oracle ASMLib use
    deletedisk       Return a device to the operating system
    renamedisk       Change the label of an Oracle ASMlib disk
    update-driver    Download the latest ASMLib driver
[root@oracleEXdb init.d]# pwd
/etc/init.d


Step 5-1 使用createdisk 來對應sd*的磁碟,請依序完成下列操作


[root@oracleEXdb /]# cd /etc/init.d/
[root@oracleEXdb init.d]# oracleasm createdisk asmdisk1 /dev/sdb1
Writing disk header: done
Instantiating disk: done
[root@oracleEXdb init.d]# oracleasm createdisk asmdisk2 /dev/sdc1
Writing disk header: done
Instantiating disk: done
[root@oracleEXdb init.d]# oracleasm createdisk asmdisk3 /dev/sdd1
Writing disk header: done
Instantiating disk: done
[root@oracleEXdb init.d]# oracleasm createdisk asmdisk4 /dev/sde1
Writing disk header: done
Instantiating disk: done
[root@oracleEXdb init.d]# oracleasm createdisk asmdisk5 /dev/sdf1
Writing disk header: done
Instantiating disk: done
[root@oracleEXdb init.d]# oracleasm createdisk asmdisk6 /dev/sdg1
Writing disk header: done
Instantiating disk: done
[root@oracleEXdb init.d]# oracleasm createdisk asmdisk7 /dev/sdh1
Writing disk header: done
Instantiating disk: done
[root@oracleEXdb init.d]# oracleasm createdisk asmdisk8 /dev/sdi1
Writing disk header: done
Instantiating disk: done
[root@oracleEXdb init.d]#


Step 5-2 列出以建立的ASMDISK

做到這一步如果listdisks是有剛剛的那幾棵硬碟的話,那幾乎是完成了80%接下來在安裝Grid Infrastructure 時就能夠順利的使用ASMDISK了

[root@oracleEXdb init.d]# oracleasm listdisks
ASMDISK1
ASMDISK2
ASMDISK3
ASMDISK4
ASMDISK5
ASMDISK6
ASMDISK7
ASMDISK8

[root@oracleEXdb init.d]#





**** 如果您也喜歡本篇內容的話,請幫忙點選一下下方的廣告,做為對小弟的鼓勵****

****當然如果我的內容不好也請您給予建議以做為檢討的基礎****

1 則留言:

  1. good article and excellent technology for ASM installation

    回覆刪除