第 4 部分:配置存儲(chǔ)
為了使用文件系統(tǒng)或 ASM,您必須有未分配的磁盤分區(qū)。該部分將介紹如何創(chuàng)建新文件系統(tǒng)或 ASM 使用的分區(qū)。
使用 /dev/sda(/dev/sdb,/dev/sdc)(一個(gè)沒(méi)有分區(qū)的空磁盤)為整個(gè)磁盤創(chuàng)建一個(gè)分區(qū)。
Oracle 建議每個(gè)磁盤僅包含一個(gè)分區(qū)
[root@db ~]# fdisk /dev/sdb
Command (m for help): n
Command action
e?? extended
p?? primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-261, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-261, default 261):
Using default value 261
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
[root@db ~]# fdisk /dev/sdc
Command (m for help): n
Command action
e?? extended
p?? primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-261, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-261, default 261):
Using default value 261
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
[root@db ~]# fdisk /dev/sdd
Command (m for help): n
Command action
e?? extended
p?? primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-261, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-261, default 261):
Using default value 261
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
現(xiàn)在驗(yàn)證新分區(qū):
Ex:
[root@db ~]# fdisk -l /dev/sdc
Disk /dev/sdc: 2147 MB, 2147483648 bytes
255 heads, 63 sectors/track, 261 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot????? Start???????? End????? Blocks?? Id System
/dev/sdc1?????????????? 1???????? 261???? 2096451?? 83 Linux
對(duì)每個(gè)要分區(qū)的磁盤重復(fù)上述步驟。
第 5 部分: 安裝Oracle ASMLib
安裝:
$su –
# rpm -Uvh oracleasm-support-2.0.4-1.el5.i386.rpm
# rpm -Uvh oracleasm-2.6.18-53.el5xen-2.0.4-1.el5.i686.rpm
# rpm -Uvh oracleasmlib-2.0.3-1.el5.i386.rpm
配置ASMLib:
[root@db Server]# /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 ]
Scanning system for ASM disks: [ OK ]
以上操作將加載oracleasm.o 驅(qū)動(dòng),并且mount 上ASM 文件系統(tǒng),同時(shí)我們可以通過(guò)以
下命令來(lái)手工的卸載和加載ASMLib
[root@db Server]# /etc/init.d/oracleasm disable
Writing Oracle ASM library driver configuration: [ OK ]
Unmounting ASMlib driver filesystem: [ OK ]
Unloading module "oracleasm": [ OK ]
[root@db Server]# /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 ]
[root@db Server]#
添加init 文件使系統(tǒng)啟動(dòng)時(shí)自動(dòng)加載ASMLib
$ su –
# cd /etc/rc3.d
# ln -s ../init.d/oracleasm S99oracleasm
# ln -s ../init.d/oracleasm K01oracleasm
注意:如果系統(tǒng)啟動(dòng)是自動(dòng)進(jìn)入圖形界面,也就是系統(tǒng)的init level 是5,那么上面生成鏈
接的命令應(yīng)該在/etc/rc5.d 目錄中操作。
重新啟動(dòng)系統(tǒng),確認(rèn)ASMLib 已經(jīng)可以自動(dòng)加載
#lsmod | grep oracleasm
oracleasm 14224 1
#dmesg | grep oracleasm
ASM: oracleasmfs mounted with options: <defaults>
通過(guò)以 root 用戶身份運(yùn)行以下命令來(lái)標(biāo)記 ASMLib 使用的磁盤:
/etc/init.d/oracleasm createdisk DISK_NAME device_name
提示:DISK_NAME 應(yīng)由大寫字母組成。
[root@db ~]# /etc/init.d/oracleasm createdisk VOL1 /dev/sdc1
Marking disk "/dev/sdc1" as an ASM disk: [ OK ]
[root@db ~]# /etc/init.d/oracleasm createdisk VOL2 /dev/sdd1
Marking disk "/dev/sdd1" as an ASM disk: [ OK ]
[root@db ~]# /etc/init.d/oracleasm listdisks
VOL1
VOL2
如果要?jiǎng)h除ASM 磁盤通過(guò)以下命令:
# /etc/init.d/oracleasm deletedisk VOL4
注意:如果是在RAC 環(huán)境中的某一個(gè)節(jié)點(diǎn)中添加了ASM 磁盤,那么需要在其它的節(jié)點(diǎn)上
運(yùn)行scandisk 來(lái)獲取這種變化。
[root@db ~]# /etc/init.d/oracleasm scandisks
Scanning system for ASM disks: [ OK ]
第 6 部分:安裝 Oracle
配置ORACLE環(huán)境變量
雙擊打開(kāi) .bash_profile添加以下行,將 ORACLE_BASE 添加到登錄配置文件:
#su - oracle
$vi .bash_profile
ORACLE_BASE=/u01/app/oracle;
export ORACLE_BASE
ORACLE_SID=oradb;
export ORACLE_SID
ORACLE_HOME=$ORACLE_BASE/product/11.1.0/db_1;
export ORACLE_HOME
PATH=$PATH:$HOME/bin:$ORACLE_HOME/bin;
export PATH
umask 022
安裝Oracle10g
在安裝Oracle10g 的時(shí)候,我們選擇不創(chuàng)建數(shù)據(jù)庫(kù),只安裝軟件的方式,在軟件安裝結(jié)束
以后再通過(guò)dbca 來(lái)創(chuàng)建ASM 實(shí)例和數(shù)據(jù)庫(kù)。
以 oracle 身份登錄并啟動(dòng) runInstaller:
$ ./runInstaller
1. 選擇安裝方式
選擇 Advanced Installation。
單擊 Next
2. 指定清單目錄和憑證
清單目錄:/u01/app/oraInventory
操作系統(tǒng)組名:oinstall
單擊 Next
3. 選擇安裝類型
選擇 Enterprise Edition
單擊 Next
4. 安裝位置
Oracle Base:/u01/app/oracle
名稱: OraDB11gASM
路徑:/u01/app/oracle/product/11.1.0/asm
注意:為了便于管理,Oracle 建議 ASM 使用與數(shù)據(jù)庫(kù)不同的 ORACLE_HOME。
單擊 Next
5. 產(chǎn)品特定的前提條件檢查
如果您一直在依循本指南中的步驟,則所有檢查都應(yīng)順利通過(guò)。如果一個(gè)或多個(gè)檢查失敗,應(yīng)在繼續(xù)操作前糾正該問(wèn)題。
單擊 Next
6. 選擇配置選項(xiàng)
選擇 Install Software Only
單擊 Next
7. 特權(quán)操作系統(tǒng)組
數(shù)據(jù)庫(kù)操作員 (OSDBA) 組:dba
數(shù)據(jù)庫(kù)操作員 (OSOPER) 組:dba
ASM 管理員 (OSASM) 組:dba
單擊 Next
8. 總結(jié)
顯示已安裝產(chǎn)品的摘要。
單擊 Install。
9. 安裝
將顯示安裝進(jìn)度
10. 執(zhí)行配置腳本
在安裝的結(jié)尾,將彈出一個(gè)窗口,提示需要以 root 用戶身份運(yùn)行腳本。以 root 用戶身份登錄,運(yùn)行提示的腳本。
[root@db /]# /u01/app/oraInventory/orainstRoot.sh
[root@db /]# /u01/app/oracle/product/11.1.0/db_1/root.sh
完成后單擊 OK。
11. 安裝結(jié)束
單擊 Exit
創(chuàng)建ASM 實(shí)例
1. 創(chuàng)建初始化文件
$ su – oracle
$ cd $ORACLE_HOME/dbs
$ vi init+ASM.ora
創(chuàng)建asm 實(shí)例的初始化腳本,腳本內(nèi)容如下所示:
說(shuō)明 /u01/app/oracle?? 是$ORACLE_BASE目錄
# ******Below is init script for asm instance******
*.asm_diskstring='ORCL: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'
# ******Above is init script for asm instance******
說(shuō)明:
1. dump 目錄指向$ORACLE_BASE/<sid>,本文中ASM 實(shí)例的SID 是+ASM。最好
不要修改這個(gè)實(shí)例名,否則在下一步用dbca 創(chuàng)建數(shù)據(jù)庫(kù)的時(shí)候,dbca 將找不到可用的磁
盤組,我想這應(yīng)該是dbca 的一個(gè)bug,手工創(chuàng)建ASM 類型的數(shù)據(jù)庫(kù)就應(yīng)該沒(méi)有這個(gè)限制
了。
2. asm_diskstring 用于實(shí)例啟動(dòng)的時(shí)候檢查可用的ASM 磁盤,由于我們前面創(chuàng)建ASM
磁盤的名稱是VOL1 到VOL4,所以我們此處使用*通配符,前面的’ORCL:’不可以省略,
否則ASM 實(shí)例將無(wú)法檢查到磁盤。
2. 創(chuàng)建密碼文件
$ su – oracle
$ cd $ORACLE_HOME/dbs
[oracle@db dbs]$ orapwd file=orapw+ASM password=dba
[oracle@db dbs]$ ls -l
total 36
-rw-r--r-- 1 oracle oinstall?? 272 Apr 18 21:04 init+ASM.ora
-rw-r--r-- 1 oracle oinstall 12920 May 3 2001 initdw.ora
-rw-r--r-- 1 oracle oinstall 8385 Sep 11 1998 init.ora
-rw-r----- 1 oracle oinstall 1536 Apr 18 21:08 orapw+ASM
3. 創(chuàng)建目錄結(jié)構(gòu)
$ su – oracle
$ cd $ORACLE_HOME/dbs
[oracle@db dbs]$ mkdir -p $ORACLE_BASE/admin/+ASM/udump
[oracle@db dbs]$ mkdir -p $ORACLE_BASE/admin/+ASM/bdump
[oracle@db dbs]$ mkdir -p $ORACLE_BASE/admin/+ASM/cdump
4. 啟動(dòng)實(shí)例
$ 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
--說(shuō)明下面的解決辦法是10G里面有效
--如果啟動(dòng)實(shí)例的時(shí)候碰到如下報(bào)錯(cuò):
--ORA-29701: unable to connect to Cluster Manager
--那么請(qǐng)檢查/etc/inittab 文件,看看是否有下面這行
--h1:35:respawn:/etc/init.d/init.cssd run >/dev/null 2>&1 </dev/null
--如果沒(méi)有請(qǐng)?zhí)砑樱绻蛔⑨屃苏?qǐng)取消注釋。
ORA-32004: obsolete and/or deprecated parameter(s) specified
ORA-29701: unable to connect to Cluster Manager
你先用dbca創(chuàng)建asm類型的數(shù)據(jù)庫(kù),做到第六步是生成init.cssd的,你生成后退出
[root@db etc]# /u01/app/oracle/product/11.1.0/db_1/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
Cleaning up Network socket directories
Setting up Network socket directories
Adding to inittab
Startup will be queued to init within 30 seconds.
Checking the status of new Oracle init process...
Expecting the CRS daemons to be up within 600 seconds.
Cluster Synchronization Services is active on these nodes.
db
Cluster Synchronization Services is active on all the nodes.
Oracle CSS service is installed and running under init(1M)
11g中ASM SYS應(yīng)該用sqlplus / as sysasm進(jìn)行連接
[oracle@db ~]$ sqlplus / as sysdba
Connected to an idle instance.
SQL> startup
ORA-32004: obsolete and/or deprecated parameter(s) specified
ASM instance started
Total System Global Area 284565504 bytes
Fixed Size????????????????? 1299428 bytes
Variable Size???????????? 258100252 bytes
ASM Cache????????????????? 25165824 bytes
ORA-15110: no diskgroups mounted
解決錯(cuò)誤ORA-32004: obsolete and/or deprecated parameter(s) specified
SQL> shutdown
ORA-15100: invalid or missing diskgroup name
ASM instance shutdown
SQL> startup pfile=$ORACLE_HOME/dbs/init+ASM.ora
ORA-32006: BACKGROUND_DUMP_DEST initialization parameter has been deprecated
ORA-32006: USER_DUMP_DEST initialization parameter has been deprecated
ASM instance started
Total System Global Area 284565504 bytes
Fixed Size????????????????? 1299428 bytes
Variable Size???????????? 258100252 bytes
ASM Cache????????????????? 25165824 bytes
ORA-15110: no diskgroups mounted
修改參數(shù)文件
[oracle@db ~]$ cd $ORACLE_HOME/dbs
[oracle@db dbs]$ vi init+ASM.ora
*.asm_diskstring='ORCL: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'
關(guān)閉數(shù)據(jù)庫(kù)后再啟動(dòng)
SQL> shutdown
ORA-15100: invalid or missing diskgroup name
ASM instance shutdown
SQL> startup
ASM instance started
Total System Global Area 284565504 bytes
Fixed Size????????????????? 1299428 bytes
Variable Size???????????? 258100252 bytes
ASM Cache????????????????? 25165824 bytes
ORA-15110: no diskgroups mounted
因?yàn)槲覀兪鞘状螁?dòng)asm 實(shí)例,還沒(méi)有創(chuàng)建diskgroup,所以顯示15110 錯(cuò)誤是正常的。
5. 創(chuàng)建spfile,重新啟動(dòng)
SQL> create spfile from pfile;
File created.
SQL> shutdown immediate;
ORA-15100: invalid or missing diskgroup name
ASM instance shutdown
SQL> startup
ASM instance started
Total System Global Area 284565504 bytes
Fixed Size????????????????? 1299428 bytes
Variable Size???????????? 258100252 bytes
ASM Cache????????????????? 25165824 bytes
ORA-15110: no diskgroups mounted
6. 創(chuàng)建diskgroup
--這里第一次我創(chuàng)建不成功重啟動(dòng)系統(tǒng)
[root@db ~]# su - oracle
[oracle@db ~]$ lsnrctl start
[oracle@db ~]$ export ORACLE_SID=+ASM
[oracle@db ~]$ sqlplus / as sysdba
SQL*Plus: Release 11.1.0.6.0 - Production on Fri Apr 18 23:50:09 2008
Copyright (c) 1982, 2007, Oracle. All rights reserved.
Connected to an idle instance.
SQL> startup
ORA-29701: unable to connect to Cluster Manager
SQL> conn / as sysasm
Connected to an idle instance.
SQL> startup
ASM instance started
Total System Global Area 284565504 bytes
Fixed Size????????????????? 1299428 bytes
Variable Size???????????? 258100252 bytes
ASM Cache????????????????? 25165824 bytes
ORA-15110: no diskgroups mounted
SQL> create diskgroup dgroup1 normal redundancy
2?? failgroup fgroup1 disk 'ORCL:VOL1','ORCL:VOL2'
3?? failgroup fgroup2 disk 'ORCL:VOL3','ORCL:VOL4';
Diskgroup created.
SQL>
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.
此時(shí)檢查數(shù)據(jù)庫(kù)初始化參數(shù),發(fā)現(xiàn)asm_diskgroups 參數(shù)值已經(jīng)自動(dòng)設(shè)置為DGROUP1,
這表明在下次啟動(dòng)asm 實(shí)例的時(shí)候,這個(gè)diskgroup 會(huì)被自動(dòng)掛載。
SQL> col name for a10
SQL> col type for a10
SQL> col value for a20
SQL> show parameter asm_diskgroups
NAME???????????????????????????????? TYPE??????? VALUE
------------------------------------ ----------- ------------------------------
asm_diskgroups?????????????????????? string????? DGROUP1
SQL>
如果要卸載diskgroup,使用下面的命令:
ALTER DISKGROUP ALL DISMOUNT;
創(chuàng)建ASM 數(shù)據(jù)庫(kù)
用dbca 創(chuàng)建數(shù)據(jù)庫(kù),一直到選擇數(shù)據(jù)類型的畫面以前都跟創(chuàng)建普通數(shù)據(jù)庫(kù)沒(méi)有區(qū)別。
1. 選擇配置選項(xiàng)
選擇 Create a Database
單擊 Next
2. 選擇數(shù)據(jù)庫(kù)配置
選擇 General Purpose or Transaction Processing
單擊 Next
3. 指定數(shù)據(jù)庫(kù)配置選項(xiàng)
輸入全局?jǐn)?shù)據(jù)庫(kù)名稱和 SID (asmdemo)
單擊 Next
4. 選擇數(shù)據(jù)庫(kù)管理選項(xiàng)
選擇 configure enterprise manager
選擇 Use Database Control for Database Management
單擊 Next
5. 指定數(shù)據(jù)庫(kù)模式口令
選擇 Use the same password for all the accounts
輸入口令并確認(rèn)
單擊 Next
6. 指定數(shù)據(jù)庫(kù)存儲(chǔ)選項(xiàng)
選擇 Automatic Storage Management (ASM)
單擊 Next
7. 指定 ASM的SYS密碼(sys)
單擊 Next
單擊 OK
這里要把數(shù)據(jù)庫(kù)關(guān)閉狀態(tài)。才可以進(jìn)行下一步。
SQL> shutdown
ORA-15100: invalid or missing diskgroup name
ASM instance shutdown
SQL> conn / as sysasm
Connected.
SQL> ALTER DISKGROUP dgroup1 MOUNT;
7. 選擇 ASM 磁盤組
選擇在前一部分中創(chuàng)建的 DATA 磁盤組
如果沒(méi)有MOUNTED磁盤組,這點(diǎn)擊mount按鈕
單擊 Next
在數(shù)據(jù)文件的位置管理設(shè)定界面,通常應(yīng)該使用OMF,由oracle 自己管理數(shù)據(jù)文件的命名,
這樣才算是進(jìn)一步解放了DBA 對(duì)于物理存儲(chǔ)方面的繁瑣工作。
繼續(xù)往下的步驟,基本是默認(rèn)值。跟創(chuàng)建普通數(shù)據(jù)庫(kù)已經(jīng)沒(méi)有什么區(qū)別了
8。 選擇Use Oracle-Managed Files +DGROUP1
9. 選擇Specify flash recovery area 和enable archiving 其他的默認(rèn)。
10. 選擇 sample schemas
11. 在character sets里面選擇 use unicode(AL32UTF8)
12. 選擇keep the enhanced 11g default security settings
13. 選擇enable automatic maintenance tasks
14. 缺省
15. 選擇create database
選擇finish 安裝
啟動(dòng)ASM 數(shù)據(jù)庫(kù)的步驟
由于啟動(dòng)ASM 數(shù)據(jù)庫(kù)必須要先啟動(dòng)ASM 實(shí)例,所以基本上啟動(dòng)步驟如下。
1. 以oracle 用戶進(jìn)入操作系統(tǒng)
2. $ export ORACLE_SID=+ASM
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
在 Rhel Linux 5.1 (32 位)上安裝 Oracle ASM數(shù)據(jù)庫(kù) 11g (第二部分)
更多文章、技術(shù)交流、商務(wù)合作、聯(lián)系博主
微信掃碼或搜索:z360901061

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