【BUILD_ORACLE】使用ASMLib包搭建ASM磁碟

Attack_on_Jager發表於2021-01-22

前言

雖然目前主流使用的是UDEV去搭建ASM磁碟,但ASMLib包依舊是Oracle官方推薦的搭建方式,此文件適用於Linux 6和Linux 7,也適用於ASM單例項和RAC環境(唯一的區別是ASMLib包需要分別下載對應OS支援的版本)。本文件以Linux 6的ASM單例項資料庫舉例。

注:udev繫結的方式參考:

http://blog.itpub.net/69992972/viewspace-2754349/


實驗環境準備

OS:RHEL 6.4

ASM&DB:Oracle 11.2.0.4

RPM:oracleasm-support-2.1.8-1.el6.x86_64.rpm,kmod-oracleasm-2.0.6.rh1-2.el6.x86_64.rpm,oracleasmlib-2.0.4-1.el6.x86_64.rpm(缺一不可)

RPM下載地址:

OL6:

OL7:


安裝步驟

1. 給磁碟分割槽

# fdisk /dev/sdb
Welcome to fdisk (util-linux 2.23.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Device does not contain a recognized partition table
Building a new DOS disklabel with disk identifier 0x37d16a21.

Command (m for help): n
Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p):
p    ##只需要一個主分割槽就行,不需要擴充套件分割槽,邏輯分割槽這些

Partition number (1-4, default 1): 1
First sector (2048-106587366, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-106587366, default 106587366):
+2G    ##隨便給個大小,全部劃分給主分割槽都行
Partition 1 of type Linux and of size 2 GiB is set

Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.


2.  安裝Oracle缺失rpm包:

# rpm -ivh libaio-devel-0.3.106-3.2.x86_64.rpm

# rpm -ivh pdksh-5.2.14-30.x86_64.rpm

# rpm -ivh elfutils-libelf-devel-0.152-1.el6.x86_64.rpm


3. 安裝ASMLIB包:

# rpm -ivh oracleasm-support-2.1.8-1.el6.x86_64.rpm

# rpm -ivh kmod-oracleasm-2.0.6.rh1-2.el6.x86_64.rpm

# rpm -ivh oracleasmlib-2.0.4-1.el6.x86_64.rpm

# oracleasm -V     ##安裝後檢視oracleasm命令是否可用


4. 建立相關使用者,組,環境變數和安裝目錄:

DB:

# groupadd -g 501 oinstall

# groupadd -g 502 dba

# groupadd -g 503 oper

# groupadd -g 504 asmadmin

# groupadd -g 505 asmoper

# groupadd -g 506 asmdba

Grid:

# useradd -g oinstall -G dba,asmdba,oper -u 501 oracle

# passwd oracle

# useradd -g oinstall -G asmadmin,asmdba,asmoper,dba -u 502 grid

# passwd grid


# Oracle Settings     oracle使用者環境變數

export TMP=/tmp

export TMPDIR=$TMP

export ORACLE_BASE=/oracle/app/oracle

export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1

export ORACLE_SID=

export ORACLE_TERM=xterm

export PATH=/usr/sbin:$PATH

export PATH=$ORACLE_HOME/bin:$PATH

export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib

export CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib

export NLS_LANG=american_america.zhs16cgb231280


$source .bash_profile生效


# grid Settings    grid使用者環境變數

export TMP=/tmp

export TMPDIR=$TMP

export ORACLE_SID=+ASM

export ORACLE_BASE=/oracle/app/grid

export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1

export ORACLE_TERM=xterm

export PATH=/usr/sbin:$PATH

export PATH=$ORACLE_HOME/bin:$PATH

export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib

export CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib

export NLS_LANG=american_america.zhs16cgb231280


$source .bash_profile生效


# mkdir -p /oracle/app/oracle/product/11.2.0/db_1       ##oracle使用者$ORACLE_HOME

# mkdir -p /oracle/app/grid/product/11.2.0/db_1          ##grid使用者$GI_HOME

# chown -R oracle:oinstall /oracle/

# chown -R grid:oinstall /oracle/app/grid

# chmod -R 775 /oracle


5. 建立ASM磁碟

# /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 []: grid

Default group to own the driver interface []: oinstall

Start Oracle ASM library driver on boot (y/n) [y]: 

Scan for Oracle ASM disks on boot (y/n) [y]: 

Writing Oracle ASM library driver configuration: done

Initializing the Oracle ASMLib driver:                     [  OK  ]

Scanning the system for Oracle ASMLib disks:               [  OK  ]


# fdisk -l

# oracleasm createdisk ORACLEASM1 /dev/sdb1     ##建立ASM

# oracleasm listdisks    ##檢視是否建立成功

# ls -l /dev/oracleasm/disks    ##檢視建立的asm磁碟


6. 後續操作

接下來就可以安裝grid軟體,db軟體和建庫了


注意:

單例項在安裝Grid軟體的時候,需要選擇下圖的第二項,因為需要選擇ASM磁碟(RAC可以直接選第一項):

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

相關文章