一、安裝配置先決條件
1,安裝oracleasm支持包
http://www.oracle.com/technology/software/tech/linux/asmlib/rhel5.html
http://www.oracle.com/technology/tech/linux/asmlib/index.html
驅動下載地址:http://www.oracle.com/technology/software/tech/linux/asmlib /rhel5.html
創建asm數據庫,首先需要ASMLib驅動程序包,可以從相關的網站下載到和操作系統對應的rpm文件,分別為oracleasm-support- 2.0.3-1、oracleasm-2.6.18-8.el5- 2.0.4-1.el5、oracleasmlib-2.0.3-1.el5。
# rpm -Uvh oracleasm*.rpm
# rpm -qa|grep oracleasm
oracleasm-support-2.0.3-1
oracleasm-2.6.18-8.el5-2.0.4-1.el5
oracleasmlib-2.0.3-1.el5
[root@RHEL5 Desktop]# rpm -Uhv oracleasmlib-2.0.4-1.el5.i386.rpm
error: Failed dependencies:
oracleasm >= 1.0.4 is needed by oracleasmlib-2.0.4-1.el5.i386
[root@RHEL5 Desktop]#
My kernel version is:
[root@RHEL5 Desktop]# uname -rn
RHEL5.3????? 2.6.18-164.el5
1. 先安裝 oracleasm-support-2.1.3-1.el5.i386.rpm
2. 再直接運行 [root@RHEL5 ~]# oracleasm update-driver
系統自動查找驅動程序,運行過程顯示如下:
[root@Rm-DevDB ~]# oracleasm update-driver
Kernel:???????? 2.6.18-194.3.1.el5 x86_64
Driver name:??? oracleasm-2.6.18-194.3.1.el5
Latest version: oracleasm-2.6.18-194.3.1.el5-2.0.5-1.el5.x86_64.rpm
Installing driver...
warning: /tmp/oracleasm.M21786/oracleasm-2.6.18-194.3.1.el5-2.0.5-1.el5.x86_64.rpm: Header V3 DSA signature: NOKEY, key ID 1e5e0159
Preparing...??????????????? ########################################### [100%]
1:oracleasm-2.6.18-194.3.########################################### [100%]
Driver installed successfully
[root@Rm-DevDB dhj]# rpm -qa|grep oracleasm
oracleasm-support-2.1.3-1.el5
oracleasm-2.6.18-194.3.1.el5-2.0.5-1.el5
[root@Rm-DevDB dhj]#
[root@Rm-DevDB dhj]# rpm -Uvh oracleasmlib-2.0.4-1.el5.x86_64.rpm?????
warning: oracleasmlib-2.0.4-1.el5.x86_64.rpm: Header V3 DSA signature: NOKEY, key ID 1e5e0159
Preparing...??????????????? ########################################### [100%]
1:oracleasmlib?????????? ########################################### [100%]
添加一塊磁盤并格式化。如果sdb比較大,分區的時候可以留一些空間,分一部分空間給sdb1。
# fdisk /dev/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.
The number of cylinders for this disk is set to 1044.
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): n
Command action
e?? extended
p?? primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-1044, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-1044, default 1044):
Using default value 1044
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
# fdisk -l
Disk /dev/sda: 17.1 GB, 17179869184 bytes
255 heads, 63 sectors/track, 2088 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot????? Start???????? End????? Blocks?? Id System
/dev/sda1?? *?????????? 1????????? 13????? 104391?? 83 Linux
/dev/sda2????????????? 14??????? 2088??? 16667437+ 8e Linux LVM
Disk /dev/sdb: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot????? Start???????? End????? Blocks?? Id System
/dev/sdb1?????????????? 1??????? 1044???? 8385898+ 83 Linux
4.配置rawdevices
因為rh5中取消了rawdevices服務,要使用裸設備創建asm,需要做以下配置。
# vi /etc/udev/rules.d/60-raw.rules
添加以下部分的內容
ACTION=="add", KERNEL=="sdb1", RUN+="/bin/raw /dev/raw/raw1 %N"
ACTION=="add", ENV{MAJOR}=="8", ENV{MINOR}=="1", RUN+="/bin/raw /dev/raw/raw2 %M %m"
# start_udev
Starting udev: [ OK ]
5,.配置oracleasm
以root用戶登陸,執行
# /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) [y]:
Fix permissions of Oracle ASM disks on boot (y/n) [y]:
Writing Oracle ASM library driver configuration: [ OK ]
Loading module "oracleasm": [ OK ]
Mounting ASMlib driver filesystem: [ OK ]
Scanning system for ASM disks:
[ OK ]
以上操作將加載oracleasm.o驅動,并且mount上ASM文件系統,同時我們可以通過以下命令來手工的卸載和加載ASMLib
#/etc/init.d/oracleasm disable //出錯檢查/var/log/messages文件,確認需要更新的內核版本
#/etc/init.d/oracleasm enable
6,添加init文件使系統啟動時自動加載ASMLib
$su -
#cd /etc/rc3.d
#ln -s ../init.d/oracleasm S99oracleasm
#ln -s ../init.d/oracleasm K01oracleasm
注意:如果系統啟動是自動進入圖形界面,也就是系統的init level是5,那么上面生成鏈接的命令應該在/etc/rc5.d目錄中操作
重新啟動系統,確認ASMLib已經可以自動加載
#lsmod |grep oracleasm
#dmesg |grep oracleasm
7,創建ASM磁盤(說明:createdisk 是針對分區,不是針對磁盤,即:先應將磁盤分區)
#/etc/init.d/oracleasm createdisk VOL1 /dev/sdb1
#/etc/init.d/oracleasm createdisk VOL2 /dev/sdc1
...
...
#/etc/init.d/oracleasm listdisks //列出ASM磁盤
VOL1
VOL2
VOL3
VOL4
如果要刪除ASM磁盤通過以下命令
#/etc/init.d/oracleasm deletedisk VOL4
注意:
如果是在RAC環境中的某一個節點中添加了ASM磁盤,那么需要在其他的節點上運行scandisk來獲取這種變化
#/etc/init.d/oracleasm scandisks
OK,現在已經完成了創建ASM實例的物理基礎,下面開始安裝數據庫
# /etc/init.d/oracleasm createdisk VOL1 /dev/sdb1
Marking disk "/dev/sdb1" as an ASM disk: [ OK ]
#
# /etc/init.d/oracleasm listdisks
VOL1
# /etc/init.d/oracleasm scandisks
Scanning system for ASM disks:
[ OK ]
如果ASM已經被配置了
View the contents of the oratab file to determine whether an ASM instance i
configured on the system:
# more /etc/oratab
If an ASM instance is configured on the system, then the oratab file should
contain a line similar to the following:
+ASM:oracle_home_path:N
In this example, +ASM is the system identifier (SID) of the ASM instance and
oracle_home_path is the Oracle home directory where it is installed. By
convention, the SID for an ASM instance begins with a plus sign.
二、使用DBCA創建ASM數據庫過程
1,利用dbca建庫時,需要運行腳本,注意是root用戶,但環境變量是oracle
[root@dbsvr bin]# localconfig add
/etc/oracle does not exist. Creating it now.
Successfully accumulated necessary OCR keys.
Creating OCR keys for user 'root', privgrp 'root'..
Operation successful.
Configuration for local CSS has been initialized
Adding to inittab
Startup will be queued to init within 90 seconds.
Checking the status of new Oracle init process...
Expecting the CRS daemons to be up within 600 seconds.
CSS is active on these nodes.
dbsvr
CSS is active on all nodes.
Oracle CSS service is installed and running under init(1M)
建庫時報ora-12547錯誤,需要安裝如下包:
[root@dbsvr tmp]# rpm -qa|grep libaio
libaio-0.3.105-2
libaio-0.3.105-2
libaio-devel-0.3.105-2
2,安裝Oracle
接下來,創建ASM數據庫的工作就非常的簡單了。執行dbca實用程序,在第六步“storage options”部分選擇“Automatic Storage Management ”,在接下來的“ASM Disk Groups”步驟中,選擇之前創建的“DGROUP1”,再按照普通建庫的方式完成數據庫的創建就OK了。
在DBCA創建磁盤組過程中,找不到ASM硬盤解決方法:
磁盤組名稱
輸入磁盤組名稱,如 DATA1。
冗余
- High 鏡像數據兩次。
- Normal 鏡像數據一次。
- External 不鏡像 ASM 中的數據。如果外部 RAID 陣列提供冗余,則通常使用此選項。
選擇成員磁盤
必須手動指示 ASM 到什么地方查找 ASMLib 磁盤,因此,單擊
Change Disk Discovery Path
-
彈出一個窗口,提示輸入磁盤發現路徑。如下所示將磁盤發現路徑更改為“ORCL:*”。如果還找不到使用絕對路徑 '/dev/oracleasm/disks/*'
- 單擊
OK
繼續。

-
您將返回到 Select Member Disks 窗口。您的所有 ASMLib 磁盤現在應顯示在此窗口中。
單擊該行開頭的框,選擇加入磁盤組的磁盤。完成后單擊 OK 。

您將返回到 Select Member Disks 窗口。您的所有 ASMLib 磁盤現在應顯示在此窗口中。
單擊該行開頭的框,選擇加入磁盤組的磁盤。完成后單擊 OK。
這個時候如果還發現不了 硬盤,可以使用RAW
Add Disks: Enter /dev/raw as the disk recovery path. You can also clisk
Disk Recovery Path and enter the required disk recovery path in the dialog
box and clisk OK.
3,,ora-15031 DBCA找不到ASM磁盤組解決方法:
使用DBCA創建數據庫,使用ASM存儲。ASM實例已經創建,但是在創建磁盤組窗口,無法找到已經創建的ASM磁盤組。ORACLEASM顯示正常。
[yangwenchao@yangwenchao ~]$ /etc/init.d/oracleasm status
Checking if ASM is loaded: [ OK ]
Checking if /dev/oracleasm is mounted: [ OK ]
[yangwenchao@yangwenchao ~]$ /etc/init.d/oracleasm listdisks
VOL1
VOL2
VOL3
VOL4
VOL5
[yangwenchao@yangwenchao ~]$ /etc/init.d/oracleasm scandisks
Scanning system for ASM disks:
請問怎樣才能添加上ASM磁盤組?
#/etc/init.d/oracleasm createdisk VOL1 /dev/sdb
#/etc/init.d/oracleasm createdisk VOL2 /dev/sdc
#/etc/init.d/oracleasm createdisk VOL3 /dev/sdd
#/etc/init.d/oracleasm createdisk VOL4 /dev/sde
#/etc/init.d/oracleasm createdisk VOL5 /dev/sdf
解決方法一
[root@racdb1 ~]# /etc/init.d/oracleasm scandisks
Scanning system for ASM disks: [ OK ]
[root@racdb1 disks]# /etc/init.d/oracleasm status
Checking if ASM is loaded: [ OK ]
Checking if /dev/oracleasm is mounted: [ OK ]
注意mount在 /dev/oracleasm
創建的時候路徑要用全部路徑(絕對路徑)同時要要看
*.asm_diskgroups='ORACLE','dgtest' -----這個地方要經常更改
*.asm_diskstring='/dev/oracleasm/disks/VOL*' -----特別要注意這個地方
*.background_dump_dest='/u01/app/oracle/admin/+ASM/bdump'
*.core_dump_dest='/u01/app/oracle/admin/+ASM/cdump'
*.instance_type='asm'
*.large_pool_size=12M
*.remote_login_passwordfile='SHARED'
*.user_dump_dest='/u01/app/oracle/admin/+ASM/udump'
SQL> create diskgroup dgtest1 normal redundancy
2 failgroup dgtest_0001 disk '/dev/oracleasm/disks/VOL4' name dgtest_0003
3 failgroup dgtest_0002 disk '/dev/oracleasm/disks/VOL5' name dgtest_0004;
Diskgroup created.
解決方法二
修改$ORACLE_HOME/dbs/init+ASM.ora文件
添加一行:asm_diskstring='ORCL:VOL*'
啟動實例
報錯,ORA-29701: unable to connect to Cluster Manager
查google,查不到
再查metalink,原來是因為安裝完10g以后,就直接把/etc/inittab中的
h1:35:respawn:/etc/init.d/init.cssd run >/dev/null 2>&1 這句注釋了
原來這就是10g內置的cluster manager
取消注釋
重新啟動系統
再次啟動實例,OK
三、手工創建ASM實例
1.創建初始化文件
$ su – oracle
$ cd $ORACLE_HOME/dbs
$ vi init+ASM.ora
*.asm_diskstring='ORCL:VOL*'
*.background_dump_dest='/oracle/admin/+ASM/bdump'
*.core_dump_dest='/oracle/admin/+ASM/cdump'
*.instance_type='asm'
*.large_pool_size=12M
*.remote_login_passwordfile='SHARED'
*.user_dump_dest='/oracle/admin/+ASM/udump'
如果找不到磁盤還 改成絕對路徑
#+ASM.asm_diskgroups='ASMDISK'#Manual Mount
#*.asm_diskstring='ORCL:VOL*'
#*.asm_diskgroups='ASMDISK'
*. asm_diskstring='/dev/oracleasm/disks/*'
*.background_dump_dest='/opt/app/oracle/admin/+ASM/bdump'
*.core_dump_dest='/opt/app/oracle/admin/+ASM/cdump'
*.instance_type='asm'
*.large_pool_size=12M
*.remote_login_passwordfile='SHARED'
2.創建密碼文件
$ su – oracle
$ cd $ORACLE_HOME/dbs
$ orapwd file=orapw+ASM password=dba
3. 創建目錄結構
$ su – oracle
$ cd $ORACLE_HOME/dbs
$ mkdir –p $ORALCE_BASE/admin/+ASM/udump
$ mkdir –p $ORALCE_BASE/admin/+ASM/bdump
$ mkdir –p $ORALCE_BASE/admin/+ASM/cdump
4. 啟動實例
$ export ORACLE_SID=+ASM
$ sqlplus / as sysdba
SQL> startup
ASM instance started
Total System Global Area?? 100663296 bytes
Fixed Size?????????????????? 777616 bytes
Variable Size????????????? 99885680 bytes
Database Buffers????????????????? 0 bytes
Redo Buffers????????????????????? 0 bytes
ORA-15110: no diskgroups mounted
因為我們是首次啟動asm實例,還沒有創建diskgroup,所以顯示15110錯誤是正常的。
如果啟動實例的時候碰到如下報錯:
ORA-29701: unable to connect to Cluster Manager
那么請檢查/etc/inittab 文件,看看是否有下面這行
h1:35:respawn:/etc/init.d/init.cssd run >/dev/null 2>&1 </dev/null
如果沒有請添加,如果被注釋了請取消注釋。
5. 創建 spfile,重新啟動
SQL> create spfile from pfile;
SQL> shutdown immediate;
SQL> startup;
6. 創建 diskgroup
SQL> create diskgroup dgroup1 external redundancy
2 failgroup fgroup1 disk 'ORCL:VOL1';
Diskgroup created.
SQL> col name for a10
SQL> select name,state from v$asm_diskgroup;
NAME?????? STATE
---------- ----------------------
DGROUP1??? MOUNTED
如果上述命令返回的 state是 DISMOUNTED,那么我們需要手工將掛載 diskgroup
SQL> ALTER DISKGROUP dgroup1 MOUNT;
Diskgroup altered.
SQL> show parameter asm_diskgroups
NAME???????????????????????????????? TYPE?????? VALUE
------------------------------------ ---------- ------------------------------
asm_diskgroups?????????????????????? string???? DGROUP1
四、ASM database簡單管理
開機啟動:
[oracle@asm dbs]$ lsnrctl start
[oracle@asm dbs]$ export ORACLE_SID=+ASM
[oracle@asm dbs]$ echo $ORACLE_SID
+ASM
[oracle@asm dbs]$ sqlplus / as sysdba
SQL>startup
[oracle@asm dbs]$ export ORACLE_SID=eagle
[oracle@asm dbs]$ echo $ORACLE_SID
eagle
SQL>startup
關機停止:
[oracle@asm dbs]$ export ORACLE_SID=+ASM
[oracle@asm dbs]$ echo $ORACLE_SID
+ASM
[oracle@asm dbs]$ sqlplus / as sysdba
SQL>shutdown immediate
[oracle@asm dbs]$ export ORACLE_SID=eagle
[oracle@asm dbs]$ echo $ORACLE_SID
eagle
SQL>shutdown immediate
附錄:
1,安裝好ASM后,啟動ASM數據的過程
啟動ASM 數據庫的步驟
由于啟動ASM 數據庫必須要先啟動ASM 實例,所以基本上啟動步驟如下。
1. 以oracle 用戶進入操作系統
2. $ export ORACLE_SID=+ASM //ORACLE_SID一定要大寫。
3. SQL> sqlplus / as sysdba
4. SQL> startup
5. SQL> exit
6. $ export ORACLE_SID=<your_real_db_sid>
7. SQL> sqlplus / as sysdba
8. SQL> startup
需要重新啟動2遍
2,遠程連接ASM數據配置listener.ora的情況
listener.ora 這個文件的配置
服務器端的配置
[oracle@rs2600-2 admin]$ vi listener.ora
# listener.ora Network Configuration File: /opt/app/oracle/product/10.2.0/server/network/admin/listener.ora
# Generated by Oracle configuration tools.
LSNRASM =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = rs2600-2)(PORT = 1521))
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))
)
)
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = +ASM)
(ORACLE_HOME = /opt/app/oracle/product/10.2.0/server)
(SID_NAME = +ASM)
)
(SID_DESC =
(GLOBAL_DBNAME = danghj)
(ORACLE_HOME = /opt/app/oracle/product/10.2.0/server)
(SID_NAME = danghj)
)
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME = /opt/app/oracle/product/10.2.0/server)
(PROGRAM = extproc)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = rs2600-2)(PORT = 1521))
)
)
客戶端的配置
ASM_172.22.11.124 =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 172.22.11.124)(PORT = 1521))
)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = danghj)
)
)
3,Oracle 中刪除 ASM 實例
刪除自動存儲管理實例+ASM實例+ASM的刪除是在數據庫被卸載之后完成的,并刪除/ORACLE_HOME/dbs目錄下的所有文件(除了 與ASM相關的)。因此必須完成下列步驟:
4.1在命令提示符中,設置oracle_sid環境變量為+ASM實例:
# export oracle_sid=+ASM
4.2啟動SQL*Plus并以sys用戶連接到自動存儲管理+ASM實例:
# sqlplus / as sysdba
4.3使用下列命令來確定是否有數據庫實例正在使用自動存儲管理實例+ASM:
SQL>select instance_name from v$asm_client;
該命令結果列出所有正在運行并使用+ASM實例的數據庫實例。只要+ASM包含正在支持的數據庫實例,就不能刪除該+ASM實例。(其實可以先 shutdown對應的數據庫實例,然后從asmcmd進入磁盤組所在目錄,刪掉對應的數據庫目錄和文件就可以了)。
4.4 如果沒有與+ASM相關聯的數據庫實例,則刪除與該實例相關聯的磁盤組。
首先,識別與+ASM相關聯的磁盤組:
SQL>select name from v$asm_diskgroup;
其次,用下列命令刪除每個要刪除的磁盤組:
SQL>drop diskgroup<disk_group_name>including contents;
4.5 關閉+ASM實例并退出SQL*Plus:
SQL>shutdown
SQL>exit
4.6 在命令提示符中輸入下列命令,刪除+ASM服務(我沒找到這個命令,所以沒有運行):
oradim -delete -asmsid +ASM
4,到ASM磁盤輸入sys密碼連接不上,顯示網絡問題
需要啟動istener就可以了
更多文章、技術交流、商務合作、聯系博主
微信掃碼或搜索:z360901061

微信掃一掃加我為好友
QQ號聯系: 360901061
您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。
【本文對您有幫助就好】元
