免费高清特黄a大片,九一h片在线免费看,a免费国产一级特黄aa大,国产精品国产主播在线观看,成人精品一区久久久久,一级特黄aa大片,俄罗斯无遮挡一级毛片

分享

使用 VMware Server 在 Oracle Enterprise Linux 上安...

 dazheng 2007-03-22
作者:Vincent Chan

 

使用虛擬機(jī)在 Oracle Enterprise Linux 上免費(fèi)試用 Oracle 真正應(yīng)用集群 10g 第 2 版

2007 年 1 月發(fā)表

于 10 月份 Oracle OpenWorld 2006 上推介的 Oracle 堅(jiān)不可摧的 Linux 旨在為 Red Hat Linux 提供企業(yè)級支持服務(wù),更快地修復(fù)錯(cuò)誤,以及顯著降低支持價(jià)格。此外,Oracle 自己的 Enterprise Linux(基于包含額外錯(cuò)誤修補(bǔ)的 Red Hat Advanced Server 第 4 版 (Update 4))提供免費(fèi)下載

因此,現(xiàn)在可以通過 VMware Server(VMware 提供的一個(gè)免費(fèi)虛擬環(huán)境)在家用電腦上免費(fèi)使用運(yùn)行在 Red Hat Advanced Server 上的 Oracle 真正應(yīng)用集群 (RAC) 10g

VMware Server 允許您在一臺(tái)物理計(jì)算機(jī)上運(yùn)行多個(gè)操作系統(tǒng)。每個(gè)虛擬機(jī)都是一個(gè)獨(dú)立的操作環(huán)境,并帶有一組自己的虛擬組件,如磁盤、處理器和內(nèi)存。虛擬技術(shù)在計(jì)算環(huán)境中十分有用,它允許您在同一物理主機(jī)上獨(dú)立地開發(fā)和測試軟件以防止數(shù)據(jù)或軟件損壞。VMware 軟件廣泛地用于服務(wù)器整合,以降低總擁有成本并加快應(yīng)用程序開發(fā)和測試周期。

在本指南中,您將了解如何安裝和配置兩個(gè)在 Enterprise Linux 和 VMware Server 上運(yùn)行 Oracle RAC 10g 第 2 版的節(jié)點(diǎn)。注意,本指南僅用于教學(xué)/評估目的;Oracle 及其他供應(yīng)商不會(huì)為本配置提供支持。

本指南分為以下幾個(gè)部分:

  1. 硬件要求和概述
  2. 配置第一個(gè)虛擬機(jī)
  3. 在第一個(gè)虛擬機(jī)上配置 Enterprise Linux
  4. 創(chuàng)建并配置第二個(gè)虛擬機(jī)
  5. 配置 Oracle 自動(dòng)存儲(chǔ)管理 (ASM)
  6. 配置 Oracle 集群文件系統(tǒng) (OCFS2)
  7. 安裝 Oracle 集群件
  8. 安裝 Oracle 數(shù)據(jù)庫 10g 第 2 版
  9. 探索 RAC 數(shù)據(jù)庫環(huán)境
  10. 測試透明應(yīng)用程序故障切換 (TAF)
  11. 數(shù)據(jù)庫備份與恢復(fù)
  12. 探索 Oracle 企業(yè)管理器 (OEM) 數(shù)據(jù)庫控制臺(tái)
  13. 常見問題

1. 硬件要求和概述

在本指南中,您將安裝 32 位 Linux 客戶操作系統(tǒng)。只有在主機(jī)上運(yùn)行的以下 64 位處理器支持 64 位客戶操作系統(tǒng):

  • AMD Athlon 64 修訂版 D 或更高版本
  • AMD Opteron 修訂版 E 或更高版本
  • AMD Turion 64 修訂版 E 或更高版本
  • AMD Sempron 64-bit-capable 修訂版 D 或更新的 Intel EM64T VT-capable 處理器

如果您決定安裝 64 位客戶操作系統(tǒng),請確定上面列出了您的處理器。您還需要確保在 BIOS 中啟用了虛擬技術(shù) (VT)。一些主流制造商在默認(rèn)情況下禁用了該技術(shù)。此處提供了有關(guān)處理器兼容性的其他信息。
要驗(yàn)證您的處理器是否受支持,請從 VMware 網(wǎng)站下載處理器兼容性檢查工具。

為每個(gè)虛擬機(jī)至少分配 700MB 內(nèi)存;為所有虛擬機(jī)預(yù)留至少 30GB 磁盤空間。

主機(jī)操作系統(tǒng)環(huán)境概況:

主機(jī)名 操作系統(tǒng) 處理器 內(nèi)存 磁盤 網(wǎng)卡
pacu Windows XP Professional Service Pack 2(32 位) Intel Pentium 4 550, 3.4MHz, HT 2 GB DDR2 SDRAM, 533 MHz 250 GB, Ultra ATA/133, 7200 RPM Intel Pro/1000 MT

客戶操作系統(tǒng)環(huán)境概況:

主機(jī)名 操作系統(tǒng) 處理器 內(nèi)存
rac1 Oracle Enterprise Linux 4(32 位) 1 700 MB
rac2 Oracle Enterprise Linux 4(32 位) 1 700 MB

虛擬磁盤布局概況:

主機(jī)操作系統(tǒng)上的虛擬磁盤 客戶操作系統(tǒng)上的虛擬磁盤 虛擬設(shè)備節(jié)點(diǎn) 大小 (MB) 描述
d:\vm\rac\localdisk.vmdk /dev/sda1
/dev/sda2
/dev/sda3
SCSI 0:0 20 “/”掛載點(diǎn)
交換空間
Oracle 二進(jìn)制文件
d:\vm\rac\sharedstorage\ocfs2disk.vmdk /dev/sdb SCSI 1:0 512 OCFS2 磁盤
d:\vm\rac\sharedstorage\asmdisk1.vmdk /dev/sdc SCSI 1:1 3072 ASM 磁盤組 1
d:\vm\rac\sharedstorage\asmdisk2.vmdk /dev/sdd SCSI 1:2 3072 ASM 磁盤組 1
d:\vm\rac\sharedstorage\asmdisk3.vmdk /dev/sde SCSI 1:3 2048 ASM 閃回恢復(fù)區(qū)

(要配置共享存儲(chǔ),客戶 OS 不能與共享存儲(chǔ)共享同一個(gè) SCSI 總線。指定客戶 OS 使用 SCSI0,共享磁盤使用 SCSI1。)

RAC 數(shù)據(jù)庫環(huán)境概況:

主機(jī)名 ASM 實(shí)例名 RAC 實(shí)例名 數(shù)據(jù)庫名 數(shù)據(jù)庫文件存儲(chǔ) OCR 與表決磁盤 (Voting Disk)
rac1 +ASM1 devdb1 devdb ASM OCFS2
rac2 +ASM2 devdb2 devdb ASM OCFS2

您將在每個(gè)節(jié)點(diǎn)上安裝 Oracle 主目錄供冗余使用。每個(gè)節(jié)點(diǎn)上的 ASM 和 Oracle RAC 實(shí)例共享同一個(gè) Oracle 主目錄。

2. 配置第一個(gè)虛擬機(jī)

要?jiǎng)?chuàng)建和配置第一個(gè)虛擬機(jī),您需要添加虛擬硬件設(shè)備,如磁盤和處理器。在繼續(xù)執(zhí)行安裝之前,請創(chuàng)建以下 windows 文件夾以存放虛擬機(jī)和共享存儲(chǔ)。

D:\>mkdir vm\rac\rac1
D:\>mkdir vm\rac\rac2
D:\>mkdir vm\rac\sharedstorage

雙擊桌面上的 VMware Server 圖標(biāo)以啟動(dòng)應(yīng)用程序:

  1. 按 CTRL-N 創(chuàng)建一個(gè)新的虛擬機(jī)。
  2. 新建虛擬機(jī)向?qū)В簡螕?Next。
  3. 選擇適當(dāng)?shù)呐渲茫?
    1. 虛擬機(jī)配置:選擇 Custom
  4. 選擇客戶操作系統(tǒng):
    1. 客戶操作系統(tǒng):選擇 Linux。
    2. 版本:選擇 Red Hat Enterprise Linux 4。
  5. 命名虛擬機(jī):
    1. 虛擬機(jī)名稱:輸入“rac1”。
    2. 位置:輸入“d:\vm\rac\rac1”。
  6. 設(shè)置訪問權(quán)限:
    1. 訪問權(quán)限:選擇 Make this virtual machine private
  7. 啟動(dòng)/關(guān)閉選項(xiàng):
    1. 虛擬機(jī)帳戶:選擇 User that powers on the virtual machine。
  8. 處理器配置:
    1. 處理器:選擇一個(gè)處理器。
  9. 虛擬機(jī)內(nèi)存:
    1. 內(nèi)存:選擇 700MB。
  10. 網(wǎng)絡(luò)類型:
    1. 網(wǎng)絡(luò)連接:選擇 Use bridged networking。
  11. 選擇 I/O 適配器類型:
    1. I/O 適配器類型:選擇 LSI Logic。
  12. 選擇磁盤:
    1. 磁盤:選擇 Create a new virtual disk。
  13. 選擇磁盤類型:
    1. 虛擬磁盤類型:選擇 SCSI (Recommended)。
  14. 指定磁盤容量:
    1. 磁盤容量:輸入“20GB”。
    2. 取消選擇 Allocate all disk space now。為了節(jié)省空間,您現(xiàn)在不必分配所有磁盤空間。
  15. 指定磁盤文件:
    1. 磁盤文件:輸入“l(fā)ocaldisk.vmdk”。
    2. 單擊 Finish

重復(fù)步驟 16-24 以創(chuàng)建四個(gè)虛擬 SCSI 硬盤 — ocfs2disk.vmdk (512MB)、asmdisk1.vmdk (3GB)、asmdisk2.vmdk (3GB) 和 asmdisk3.vmdk (2GB)。

  1. VMware Server 控制臺(tái):單擊 Edit virtual machine settings。
  2. 虛擬機(jī)設(shè)置:單擊 Add。
  3. 新增硬件向?qū)В簡螕?Next
  4. 硬件類型:
    1. 硬件類型:選擇 Hard Disk。
  5. 選擇磁盤:
    1. 磁盤:選擇 Create a new virtual disk。
  6. 選擇磁盤類型:
    1. 虛擬磁盤類型:選擇 SCSI (Recommended)。
  7. 指定磁盤容量:
    1. 磁盤容量:輸入“0.5GB”。
    2. 選擇 Allocate all disk space now。如果您希望節(jié)省空間,則不必分配所有磁盤空間。出于性能方面的考慮,您需要為每個(gè)虛擬共享磁盤預(yù)先分配所有磁盤空間。特別是在 Oracle 數(shù)據(jù)庫創(chuàng)建期間或者當(dāng)數(shù)據(jù)庫的 DML 活動(dòng)較頻繁時(shí),如果共享磁盤的大小增長快速,虛擬機(jī)可能會(huì)間歇掛起一段較短的時(shí)間甚至崩潰(這種情況很少見)。
  8. 指定磁盤文件:
    1. 磁盤文件:輸入“d:\vm\rac\sharedstorage\ocfs2disk.vmdk”。
    2. 單擊 Advanced
  9. 新增硬件向?qū)В?
    1. 虛擬設(shè)備節(jié)點(diǎn):選擇 SCSI 1:0。
    2. 模式:選擇 Independent,針對所有共享磁盤選擇 Persistent
    3. 單擊 Finish。

最后,額外添加一個(gè)虛擬網(wǎng)卡以用于專用互聯(lián),并移除軟盤驅(qū)動(dòng)器(如果有)。

  1. VMware Server 控制臺(tái):單擊 Edit virtual machine settings。
  2. 虛擬機(jī)設(shè)置:單擊 Add。
  3. 新增硬件向?qū)В簡螕?Next。
  4. 硬件類型:
    1. 硬件類型:以太網(wǎng)適配器。
  5. 網(wǎng)絡(luò)類型:
    1. 主機(jī)模式:與主機(jī)共享的專用網(wǎng)絡(luò)
    2. 單擊 Finish。
  6. 虛擬機(jī)設(shè)置:
    1. 選擇 Floppy 并單擊 Remove。
  7. 虛擬機(jī)設(shè)置:單擊 OK
圖 1

修改虛擬機(jī)配置文件。還需要設(shè)置其他參數(shù)以啟用兩個(gè)虛擬 RAC 節(jié)點(diǎn)之間的磁盤共享。打開配置文件 d:\vm\rac\rac1\Red Hat Enterprise Linux 4.vmx,并添加下面列出的粗體參數(shù)。

config.version = "8"
virtualHW.version = "4"
scsi0.present = "TRUE"
scsi0.virtualDev = "lsilogic"
memsize = "700"
scsi0:0.present = "TRUE"
scsi0:0.fileName = "localdisk.vmdk"
ide1:0.present = "TRUE"
ide1:0.fileName = "auto detect"
ide1:0.deviceType = "cdrom-raw"
floppy0.fileName = "A:"
Ethernet0.present = "TRUE"
displayName = "rac1"
guestOS = "rhel4"
priority.grabbed = "normal"
priority.ungrabbed = "normal"
disk.locking = "FALSE"
diskLib.dataCacheMaxSize = "0"
scsi1.sharedBus = "virtual"
scsi1.present = "TRUE"
scsi1:0.present = "TRUE"
scsi1:0.fileName = "D:\vm\rac\sharedstorage\ocfs2disk.vmdk"
scsi1:0.mode = "independent-persistent"
scsi1:0.deviceType = "disk"
scsi1:1.present = "TRUE"
scsi1:1.fileName = "D:\vm\rac\sharedstorage\asmdisk1.vmdk"
scsi1:1.mode = "independent-persistent"
scsi1:1.deviceType = "disk"
scsi1:2.present = "TRUE"
scsi1:2.fileName = "D:\vm\rac\sharedstorage\asmdisk2.vmdk"
scsi1:2.mode = "independent-persistent"
scsi1:2.deviceType = "disk"
scsi1:3.present = "TRUE"
scsi1:3.fileName = "D:\vm\rac\sharedstorage\asmdisk3.vmdk"
scsi1:3.mode = "independent-persistent"
scsi1:3.deviceType = "disk"
scsi1.virtualDev = "lsilogic"
ide1:0.autodetect = "TRUE"
floppy0.present = "FALSE"
Ethernet1.present = "TRUE"
Ethernet1.connectionType = "hostonly"

3. 在第一個(gè)虛擬機(jī)上安裝并配置 Enterprise Linux

從 Oracle 網(wǎng)站下載 Enterprise Linux 并解壓縮文件:

  • Enterprise-R4-U4-i386-disc1.iso
  • Enterprise-R4-U4-i386-disc2.iso
  • Enterprise-R4-U4-i386-disc3.iso
  • Enterprise-R4-U4-i386-disc4.iso
  1. 在 VMware Server 控制臺(tái)上,雙擊右面板上的 CD-ROM 設(shè)備,然后選擇第 1 張磁盤的 ISO 鏡像 Enterprise-R4-U4-i386-disc1.iso。
  2. VMware Server 控制臺(tái):
    • 單擊 Start this virtual machine。
  3. Enter 鍵以圖形模式安裝。
  4. 跳過介質(zhì)測試并啟動(dòng)安裝。
  5. 歡迎使用 Enterprise Linux:單擊 Next。
  6. 語言選擇:<選擇語言首選項(xiàng)>。
  7. 鍵盤配置:<選擇鍵盤首選項(xiàng)>。
  8. 安裝類型:自定義。
  9. 磁盤分區(qū)設(shè)置:使用 Disk Druid 進(jìn)行手動(dòng)分區(qū)。
    • 警告:單擊 Yes 將初始化每個(gè)設(shè)備 — sda、sdb、sdc、sdd 和 sde。
  10. 磁盤設(shè)置:通過雙擊掛載點(diǎn)(/ 和 /u01)和交換空間的 /dev/sda 可用空間來分配 sda 驅(qū)動(dòng)器上的磁盤空間。您稍后將為 OCFS2 和 ASM 配置其余驅(qū)動(dòng)器。
    • 添加分區(qū):
      • 掛載點(diǎn): /
      • 文件系統(tǒng)類型:ext3
      • 開始柱面: 1
      • 結(jié)束柱面: 910

      • 文件系統(tǒng)類型:Swap
      • 開始柱面: 911
      • 結(jié)束柱面: 1170

      • 掛載點(diǎn):/u01
      • 文件系統(tǒng)類型:ext3
      • 開始柱面: 1171
      • 結(jié)束柱面: 2610
圖 2
  1. 引導(dǎo)加載程序配置:僅選擇默認(rèn)的 /dev/sda1,其余選項(xiàng)均保留未選中狀態(tài)。
  2. 網(wǎng)絡(luò)配置:
    1. 網(wǎng)絡(luò)設(shè)備
      • 選擇并編輯 eth0
        1. 取消選擇 Configure Using DHCP。
        2. 選擇 Activate on boot。
        3. IP 地址:輸入“192.168.2.131”。
        4. 網(wǎng)絡(luò)掩碼:輸入“255.255.255.0”。
      • 選擇并編輯 eth1
        1. 取消選擇 Configure Using DHCP
        2. 選擇 Activate on boot。
        3. IP 地址:輸入“10.10.10.31”。
        4. 網(wǎng)絡(luò)掩碼:輸入“255.255.255.0”。
    2. 主機(jī)名
      • 選擇 manually 并輸入“rac1.”。
    3. 雜項(xiàng)設(shè)置
      • 網(wǎng)關(guān):輸入“192.168.2.1”。
      • 首選 DNS:<可選>
      • 備用 DNS:<可選>
  3. 防火墻配置:
    1. 選擇 No Firewall。如果啟用了防火墻,當(dāng)您稍后在設(shè)置期間嘗試掛載 ocfs2 文件系統(tǒng)時(shí),可能會(huì)遇到錯(cuò)誤“mount.ocfs2:Transport endpoint is not connected while mounting”。
    2. 啟用 SELinux 嗎?:Active。
  4. 警告 — 無防火墻:單擊 Proceed。
  5. 其他語言支持:<選擇所需的語言>。
  6. 時(shí)區(qū)選擇:<選擇您的時(shí)區(qū)>
  7. 設(shè)置 Root 口令:<輸入您的 root 口令>
  8. 程序包組選擇:
    1. 選擇 X Window System
    2. 選擇 GNOME Desktop Environment。
    3. 選擇 Editors。
      • 單擊 Details 并選擇您偏好的文本編輯器。
    4. 選擇 Graphical Internet。
    5. 選擇 Text-based Internet。
    6. 選擇 Office/Productivity
    7. 選擇 Sound and Video。
    8. 選擇 Graphics
    9. 選擇 Server Configuration Tools。
    10. 選擇 FTP Server
    11. 選擇 Legacy Network Server。
      • 單擊 Details
        1. 選擇 rsh-server。
        2. 選擇 telnet-server
    12. 選擇 Development Tools。
    13. 選擇 Legacy Software Development
    14. 選擇 Administration Tools。
    15. 選擇 System Tools。
      • 單擊 Details。除了默認(rèn)選中的程序包外,再選擇以下程序包。
        1. 選擇 ocfs-2-2.6.9-42.0.0.0.1EL(UP 內(nèi)核驅(qū)動(dòng)程序),或者選擇 ocfs-2-2.6.9-42.0.0.0.1ELsmp(SMP 內(nèi)核驅(qū)動(dòng)程序)。
        2. 選擇 ocfs2-tools
        3. 選擇 ocfs2console。
        4. 選擇 oracle oracleasm-2.6.9-42.0.0.0.1EL(UP 內(nèi)核驅(qū)動(dòng)程序),或者選擇 oracleasm-2.6.9-42.0.0.0.1ELsmp(SMP 內(nèi)核驅(qū)動(dòng)程序)。
        5. 選擇 sysstat。
    16. 選擇 Printing Support
  9. 準(zhǔn)備安裝:單擊 Next。
  10. 所需的安裝介質(zhì):單擊 Continue
  11. 更改 CD-ROM:在 VMware Server 控制臺(tái)上,按 CTRL-D 顯示 Virtual Machine Settings。單擊 CD-ROM 設(shè)備并選擇第 2 張磁盤的 ISO 鏡像 Enterprise-R4-U4-i386-disc2.iso,然后是第 3 張磁盤的 ISO 鏡像 Enterprise-R4-U4-i386-disc3.iso。
  12. 安裝結(jié)束時(shí):
    1. 在 VMware Server 控制臺(tái)上,按 CTRL-D 顯示 Virtual Machine Settings。單擊 CD-ROM 設(shè)備并選擇 Use physical drive。
    2. 單擊 Reboot
  13. 歡迎頁面:單擊 Next。
  14. 許可協(xié)議:選擇 Yes, I agree to the License Agreement。
  15. 日期和時(shí)間:設(shè)置日期和時(shí)間。
  16. 顯示:<選擇所需的分辨率>。
  17. 系統(tǒng)用戶:保留項(xiàng)目為空并單擊 Next
  18. 其他 CD:單擊 Next。
  19. 完成設(shè)置:單擊 Next。
圖 3

恭喜,您已經(jīng)在 VMware Server 上安裝了 Enterprise Linux!

安裝 VMware 工具。VMware 工具要求同步主機(jī)和客戶機(jī)的時(shí)間。

在 VMware 控制臺(tái)上,以 root 用戶身份登錄。

  1. 單擊 VM,然后選擇 Install VMware Tools。
  2. rac1 — 虛擬機(jī):單擊 Install
  3. 雙擊桌面上的 VMware Tools 圖標(biāo)。
  4. cdrom:雙擊 VMwareTools-1.0.1-29996.i386.rpm。
圖 4
  1. 完成系統(tǒng)準(zhǔn)備:單擊 Continue
  2. 打開一個(gè)終端并執(zhí)行 vmware-config-tools.pl。
    • 輸入所需的顯示大小。
同步客戶 OS 與主機(jī) OS 的時(shí)間。在安裝 Oracle 集群件和 Oracle 數(shù)據(jù)庫軟件時(shí),Oracle 安裝程序?qū)⑹紫仍诒镜毓?jié)點(diǎn)上安裝軟件,然后再將軟件遠(yuǎn)程復(fù)制到遠(yuǎn)程節(jié)點(diǎn)。如果兩個(gè) RAC 節(jié)點(diǎn)的日期和時(shí)間未同步,您可能會(huì)收到類似于以下內(nèi)容的錯(cuò)誤。
"/bin/tar: ./inventory/Components21/oracle.ordim.server/10.2.0.1.0: time
stamp  2006-11-04 06:24:04 is 25 s in the future"
要確保成功安裝 Oracle RAC,虛擬機(jī)上的時(shí)間必須與主機(jī)上的時(shí)間同步。執(zhí)行下面的步驟,以 root 用戶身份同步時(shí)間。
  1. 執(zhí)行“vmware-toolbox”以顯示 VMware Tools Properties 窗口。在 Options 選項(xiàng)卡下,選擇 Time synchronization between the virtual machine and the host operating system。您應(yīng)該發(fā)現(xiàn) tools.syncTime = "TRUE" 參數(shù)已經(jīng)追加到虛擬機(jī)配置文件 d:\vm\rac\rac1\Red Hat Enterprise Linux 4.vmx 中。
  2. 編輯 /boot/grub/grub.conf,并將選項(xiàng)“clock=pit nosmp noapic nolapic”添加到讀取內(nèi)核 /boot/ 的那一行。您已經(jīng)將選項(xiàng)添加到兩個(gè)內(nèi)核,現(xiàn)在只需對特定內(nèi)核進(jìn)行更改。
    #boot=/dev/sda
        default=0
        timeout=5
        splashimage=(hd0,0)/boot/grub/splash.xpm.gz
        hiddenmenu
        title Enterprise (2.6.9-42.0.0.0.1.ELsmp)
        root (hd0,0)
        kernel /boot/vmlinuz-2.6.9-42.0.0.0.1.ELsmp ro
        root=LABEL=/ rhgb quiet clock=pit nosmp noapic nolapic
        initrd /boot/initrd-2.6.9-42.0.0.0.1.ELsmp.img
        title Enterprise-up (2.6.9-42.0.0.0.1.EL)
        root (hd0,0)
        kernel /boot/vmlinuz-2.6.9-42.0.0.0.1.EL ro root=LABEL=/
        rhgb quiet clock=pit nosmp noapic nolapic
        initrd /boot/initrd-2.6.9-42.0.0.0.1.EL.img
        
  3. 重新引導(dǎo) rac1。
    # reboot
創(chuàng)建 oracle 用戶。 以 root 用戶身份執(zhí)行
# groupadd oinstall
# groupadd dba
# mkdir -p /export/home/oracle /ocfs
# useradd -d /export/home/oracle -g oinstall -G dba -s /bin/ksh oracle
# chown oracle:dba /export/home/oracle /u01
# passwd oracle
New Password:
Re-enter new Password:
passwd: password successfully changed for oracle
創(chuàng)建 oracle 用戶環(huán)境文件。

/export/home/oracle/.profile

export PS1="`/bin/hostname -s`-> "
export EDITOR=vi
export ORACLE_SID=devdb1
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/10.2.0/db_1
export ORA_CRS_HOME=$ORACLE_BASE/product/10.2.0/crs_1
export LD_LIBRARY_PATH=$ORACLE_HOME/lib
export PATH=$ORACLE_HOME/bin:$ORA_CRS_HOME/bin:/bin:
/usr/bin:/usr/sbin:/usr/local/bin:/usr/X11R6/bin
umask 022
創(chuàng)建文件系統(tǒng)目錄結(jié)構(gòu)。以 oracle 用戶身份執(zhí)行
rac1-> mkdir p $ORACLE_BASE/admin
rac1-> mkdir p $ORACLE_HOME
rac1-> mkdir p $ORA_CRS_HOME
rac1-> mkdir -p /u01/oradata/devdb

提高 Oracle 用戶的 shell 限制。使用文本編輯器將下面列出的行添加到 /etc/security/limits.conf、/etc/pam.d/login 和 /etc/profile。其他信息可以從文檔中獲得。

/etc/security/limits.conf

oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
/etc/pam.d/login
session required /lib/security/pam_limits.so
/etc/profile
if [ $USER = "oracle" ]; then
if [ $SHELL = "/bin/ksh" ]; then
ulimit -p 16384
ulimit -n 65536
else
ulimit -u 16384 -n 65536
fi
fi
安裝 Enterprise Linux 軟件程序包。安裝 Oracle 軟件需要以下附加程序包。如果您已經(jīng)安裝了 64 位版本的 Enterprise Linux,則安裝程序應(yīng)該已安裝了這些程序包。
  • libaio-0.3.105-2.i386.rpm
  • openmotif21-2.1.30-11.RHEL4.6.i386.rpm

從 ISO CD 解壓縮這些程序包,并以 root 用戶身份執(zhí)行下面的命令。

# ls
libaio-0.3.105-2.i386.rpm  openmotif21-2.1.30-11.RHEL4.6.i386.rpm
#
# rpm -Uvh *.rpm
warning: libaio-0.3.105-2.i386.rpm: V3 DSA signature: NOKEY, key ID b38a8516
Preparing...
########################################### [100%]
1:openmotif21
########################################### [ 50%]
2:libaio
########################################### [100%]
配置內(nèi)核參數(shù)。使用文本編輯器將下面列出的行添加到 /etc/sysctl.conf。要使更改立即生效,請執(zhí)行 /sbin/sysctl –p
# more  /etc/sysctl.conf
kernel.shmall                = 2097152
kernel.shmmax                = 2147483648
kernel.shmmni                = 4096
kernel.sem                   = 250 32000 100 128
fs.file-max                  = 65536
net.ipv4.ip_local_port_range = 1024 65000
net.core.rmem_default        = 1048576
net.core.rmem_max            = 1048576
net.core.wmem_default        = 262144
net.core.wmem_max            = 262144
修改 /etc/hosts 文件。
# more /etc/hosts
127.0.0.1               localhost
192.168.2.131           rac1.        rac1
192.168.2.31            rac1-vip.    rac1-vip
10.10.10.31             rac1-priv.   rac1-priv
192.168.2.132           rac2.        rac2
192.168.2.32            rac2-vip.    rac2-vip
10.10.10.32             rac2-priv.   rac2-priv
配置 hangcheck timer 內(nèi)核模塊。hangcheck timer 內(nèi)核模塊可監(jiān)控系統(tǒng)的運(yùn)行情況,并重新啟動(dòng)出現(xiàn)故障的 RAC 節(jié)點(diǎn)。它使用兩個(gè)參數(shù),即 hangcheck_tick(定義系統(tǒng)檢查頻率)和 hangcheck_margin(定義在重置 RAC 節(jié)點(diǎn)前的最大掛起延時(shí))來確定節(jié)點(diǎn)是否出現(xiàn)故障。

在 /etc/modprobe.conf 中添加以下行,以設(shè)置 hangcheck 內(nèi)核模塊參數(shù)。

/etc/modprobe.conf
options hangcheck-timer hangcheck_tick=30 hangcheck_margin=180

要立即加載模塊,執(zhí)行“modprobe -v hangcheck-timer”。

為 OCFS2 和 Oracle ASM 創(chuàng)建磁盤分區(qū)。為 OCFS2 (/dev/sdb) 和 Oracle ASM(/dev/sdc、/dev/sdd、/dev/sde)準(zhǔn)備一組原始磁盤。

在 rac1 上,以 root 用戶身份執(zhí)行

# 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-512, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-512, default 512):
Using default value 512
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.

# 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-391, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-391, default 391):
Using default value 391
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.

# 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-391, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-391, default 391):
Using default value 391
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.

# fdisk /dev/sde

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.

# fdisk -l

Disk /dev/sda: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1         910     7309543+  83  Linux
/dev/sda2             911        1170     2088450   82  Linux swap
/dev/sda3            1171        2610    11566800   83  Linux
Disk /dev/sdb: 536 MB, 536870912 bytes
64 heads, 32 sectors/track, 512 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes
Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1         512      524272   83  Linux
Disk /dev/sdc: 3221 MB, 3221225472 bytes
255 heads, 63 sectors/track, 391 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot      Start         End      Blocks   Id  System
/dev/sdc1               1         391     3140676   83  Linux
Disk /dev/sdd: 3221 MB, 3221225472 bytes
255 heads, 63 sectors/track, 391 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot      Start         End      Blocks   Id  System
/dev/sdd1               1         391     3140676   83  Linux
Disk /dev/sde: 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/sde1               1         261     2096451   83  Linux
安裝 oracleasmlib 程序包。 從 OTN 下載 ASM 庫,并以 root 用戶身份安裝 ASM RPM。
 # rpm -Uvh oracleasmlib-2.0.2-1.i386.rpm
Preparing...
########################################### [100%]
1:oracleasmlib
########################################### [100%]

在這個(gè)階段,您應(yīng)該已經(jīng)安裝了以下 ASM 程序包。

[root@rac1 swdl]# rpm -qa | grep oracleasm
oracleasm-support-2.0.3-2
oracleasm-2.6.9-42.0.0.0.1.ELsmp-2.0.3-2
oracleasmlib-2.0.2-1
為 ASM 磁盤映射原始設(shè)備。僅當(dāng)您打算使用標(biāo)準(zhǔn) Linux I/O 創(chuàng)建 ASM 磁盤時(shí),才需要原始設(shè)備映射。創(chuàng)建 ASM 磁盤的另一個(gè)方法是使用 Oracle 提供的 ASM 庫驅(qū)動(dòng)程序。稍后,您將使用 ASM 庫驅(qū)動(dòng)程序配置 ASM 磁盤。

執(zhí)行以下任務(wù),將原始設(shè)備映射到先前創(chuàng)建的共享分區(qū)。每次引導(dǎo)集群節(jié)點(diǎn)時(shí),原始設(shè)備都必須與塊設(shè)備綁定。

將以下行添加到 /etc/sysconfig/rawdevices 中。

/etc/sysconfig/rawdevices

/dev/raw/raw1 /dev/sdc1
/dev/raw/raw2 /dev/sdd1
/dev/raw/raw3 /dev/sde1
要使映射立即生效,以 root 用戶身份執(zhí)行以下命令:
# /sbin/service rawdevices restart
Assigning devices:
/dev/raw/raw1  -->   /dev/sdc1
/dev/raw/raw1:  bound to major 8, minor 33
/dev/raw/raw2  -->   /dev/sdd1
/dev/raw/raw2:  bound to major 8, minor 49
/dev/raw/raw3  -->   /dev/sde1
/dev/raw/raw3:  bound to major 8, minor 65
done
# chown oracle:dba /dev/raw/raw[1-3]
# chmod 660 /dev/raw/raw[1-3]
# ls -lat /dev/raw/raw*
crw-rw----  1 oracle dba 162, 3 Nov  4 07:04 /dev/raw/raw3
crw-rw----  1 oracle dba 162, 2 Nov  4 07:04 /dev/raw/raw2
crw-rw----  1 oracle dba 162, 1 Nov  4 07:04 /dev/raw/raw1

以 oracle 用戶身份執(zhí)行

rac1-> ln -sf /dev/raw/raw1 /u01/oradata/devdb/asmdisk1
rac1-> ln -sf /dev/raw/raw2 /u01/oradata/devdb/asmdisk2
rac1-> ln -sf /dev/raw/raw3 /u01/oradata/devdb/asmdisk3

修改 /etc/udev/permissions.d/50-udev.permissions。原始設(shè)備在引導(dǎo)時(shí)會(huì)重新映射。默認(rèn)情況下,在引導(dǎo)時(shí)原始設(shè)備的擁有者將更改為 root 用戶。如果擁有者不是 oracle 用戶,則 ASM 在訪問共享分區(qū)時(shí)會(huì)出現(xiàn)問題。在 /etc/udev/permissions.d/50-udev.permissions 中為原始行“raw/*:root:disk:0660”添加注釋,然后添加一個(gè)新行“raw/*:oracle:dba:0660”。

/etc/udev/permissions.d/50-udev.permissions

# raw devices
ram*:root:disk:0660
#raw/*:root:disk:0660
raw/*:oracle:dba:0660

4. 創(chuàng)建并配置第二個(gè)虛擬機(jī)

要?jiǎng)?chuàng)建第二個(gè)虛擬機(jī),只需關(guān)閉第一個(gè)虛擬機(jī),將 d:\vm\rac\rac1 中的所有文件復(fù)制到 d:\vm\rac\rac2,然后更改幾個(gè)配置即可。

修改網(wǎng)絡(luò)配置。
  1. 在 rac1 上,以 root 用戶身份執(zhí)行
    # shutdown –h now
  2. 在主機(jī)系統(tǒng)上,將 rac1 文件夾中的所有文件復(fù)制到 rac2。
    D:\>copy d:\vm\rac\rac1 d:\vm\rac\rac2
  3. 在 VMware Server 控制臺(tái)上,按 CTRL-O 打開第二個(gè)虛擬機(jī) d:\rac\rac2\Red Hat Enterprise Linux 4.vmx。
  4. VMware Server 控制臺(tái):
    • 將虛擬機(jī)名稱從 rac1 重命名為 rac2。右鍵單擊您剛才打開的新 rac1 選項(xiàng)卡,然后選擇 Settings。
      • 選擇 Options 選項(xiàng)卡。
        1. 虛擬機(jī)名稱:輸入“rac2”。

圖 5

  • 單擊 Start this virtual machine 啟動(dòng) rac2,保留 rac1 為電源關(guān)閉狀態(tài)。
  • rac2 — 虛擬機(jī):選擇 Create a new identifier。
  1. 以 root 用戶身份登錄并執(zhí)行 system-config-network,以修改網(wǎng)絡(luò)配置。

    IP 地址:雙擊每個(gè)以太網(wǎng)設(shè)備,并使用下面的表進(jìn)行必要的更改。

    設(shè)備 IP 地址 子網(wǎng)掩碼 默認(rèn)網(wǎng)關(guān)地址
    eth0 192.168.2.132 255.255.255.0 192.168.2.1
    eth1 10.10.10.32 255.255.255.0 <保留空白>

    MAC 地址:導(dǎo)航到 Hardware Device 選項(xiàng)卡,并探測每個(gè)以太網(wǎng)設(shè)備的新 MAC 地址。

    主機(jī)名和 DNS:使用下面的表對 DNS 選項(xiàng)卡中的項(xiàng)進(jìn)行必要的更改,然后按 CTRL-S 保存。

    主機(jī)名 首選 DNS 備用 DNS DNS 搜索路徑
    rac2. 輸入 DNS IP 地址或保留空白。 輸入 DNS IP 地址或保留空白。 接受默認(rèn)設(shè)置或保留空白。

    最后,激活每個(gè)以太網(wǎng)設(shè)備。

修改 /etc/hosts。將以下項(xiàng)添加到 /etc/hosts 中。

127.0.0.1 localhost

稍后,在 Oracle 集群件軟件安裝期間,VIPCA 將嘗試使用回送地址。

修改 /export/home/oracle/.profile。用 devdb2 替換 ORACLE_SID 的值。

使用 SSH 建立用戶等效性。在集群就緒服務(wù) (CRS) 和 RAC 安裝過程中,Oracle Universal Installer (OUI) 必須能夠以 oracle 的身份將軟件復(fù)制到所有 RAC 節(jié)點(diǎn),而不提示輸入口令。在 Oracle 10g 中,可以使用 ssh 代替 rsh 完成此操作。

要建立用戶等效性,請?jiān)趦蓚€(gè)節(jié)點(diǎn)上以 oracle 用戶身份生成用戶的公鑰和私鑰。打開 rac1 的電源,在這兩個(gè)節(jié)點(diǎn)上執(zhí)行以下任務(wù)。
在 rac1 上執(zhí)行

rac1-> mkdir ~/.ssh
rac1-> chmod 700 ~/.ssh
rac1-> ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/export/home/oracle/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /export/home/oracle/.ssh/id_rsa.
Your public key has been saved in /export/home/oracle/.ssh/id_rsa.pub.
The key fingerprint is:
87:54:4f:92:ba:ed:7b:51:5d:1d:59:5b:f9:44:da:b6 oracle@rac1.
rac1-> ssh-keygen -t dsa
Generating public/private dsa key pair.
Enter file in which to save the key (/export/home/oracle/.ssh/id_dsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /export/home/oracle/.ssh/id_dsa.
Your public key has been saved in /export/home/oracle/.ssh/id_dsa.pub.
The key fingerprint is:
31:76:96:e6:fc:b7:25:04:fd:70:42:04:1f:fc:9a:26 oracle@rac1.

在 rac2 上執(zhí)行

rac2-> mkdir ~/.ssh
rac2-> chmod 700 ~/.ssh
rac2-> ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/export/home/oracle/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /export/home/oracle/.ssh/id_rsa.
Your public key has been saved in /export/home/oracle/.ssh/id_rsa.pub.
The key fingerprint is:
29:5a:35:ac:0a:03:2c:38:22:3c:95:5d:68:aa:56:66 oracle@rac2.
rac2-> ssh-keygen -t dsa
Generating public/private dsa key pair.
Enter file in which to save the key (/export/home/oracle/.ssh/id_dsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /export/home/oracle/.ssh/id_dsa.
Your public key has been saved in /export/home/oracle/.ssh/id_dsa.pub.
The key fingerprint is:
4c:b2:5a:8d:56:0f:dc:7b:bc:e0:cd:3b:8e:b9:5c:7c oracle@rac2.
在 rac1 上執(zhí)行
rac1-> cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
rac1-> cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys
rac1-> ssh rac2 cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
The authenticity of host ‘rac2 (192.168.2.132)‘ can‘t be established.
RSA key fingerprint is 63:d3:52:d4:4d:e2:cb:ac:8d:4a:66:9f:f1:ab:28:1f.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added ‘rac2,192.168.2.132‘ (RSA) to the list of known hosts.
oracle@rac2‘s password:
rac1-> ssh rac2 cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys
oracle@rac2‘s password:
rac1-> scp ~/.ssh/authorized_keys rac2:~/.ssh/authorized_keys
oracle@rac2‘s password:
authorized_keys                           100% 1716     1.7KB/s   00:00
在每個(gè)節(jié)點(diǎn)上測試連接。驗(yàn)證當(dāng)您再次運(yùn)行以下命令時(shí),系統(tǒng)是否不提示您輸入口令。
ssh rac1 date
ssh rac2 date
ssh rac1-priv date
ssh rac2-priv date
ssh rac1. date
ssh rac2. date
ssh rac1-priv. date
ssh rac2-priv. date

5. 配置 Oracle 自動(dòng)存儲(chǔ)管理 (ASM)

Oracle ASM 與 Oracle 數(shù)據(jù)庫緊密集成在一起,并與 Oracle 的數(shù)據(jù)管理工具套件配合工作。它可以簡化數(shù)據(jù)庫存儲(chǔ)管理,并提供原始磁盤 I/O 的性能。

配置 ASMLib。以 root 用戶身份在兩個(gè)節(jié)點(diǎn)上配置 ASMLib。
# /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  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  ]
Loading module "oracleasm":                                [  OK  ]
Mounting ASMlib driver filesystem:                         [  OK  ]
Scanning system for ASM disks:                             [  OK  ]
創(chuàng)建 ASM 磁盤。以 root 用戶身份在任何一個(gè)節(jié)點(diǎn)上創(chuàng)建 ASM 磁盤。
# /etc/init.d/oracleasm createdisk VOL1 /dev/sdc1
Marking disk "/dev/sdc1" as an ASM disk:                   [  OK  ]
# /etc/init.d/oracleasm createdisk VOL2 /dev/sdd1
Marking disk "/dev/sdd1" as an ASM disk:                   [  OK  ]
# /etc/init.d/oracleasm createdisk VOL3 /dev/sde1
Marking disk "/dev/sde1" as an ASM disk:                   [  OK  ]
Verify that the ASM disks are visible from every node.
# /etc/init.d/oracleasm scandisks
Scanning system for ASM disks:                      [  OK  ]
# /etc/init.d/oracleasm listdisks
VOL1
VOL2
VOL3
VOL4

6. 配置 Oracle 集群文件系統(tǒng) (OCFS2)

OCFS2 是 Oracle 開發(fā)的一個(gè)通用集群文件系統(tǒng),與 Enterprise Linux 內(nèi)核集成在一起。它允許所有節(jié)點(diǎn)在集群文件系統(tǒng)上同時(shí)共享文件,因而消除了管理原始設(shè)備的需求。這里,您將在 OCFS2 文件系統(tǒng)中寄宿 OCR 和表決磁盤。您可以從 OCFS2 用戶指南獲取有關(guān) OCFS2 的其他信息。

在 Enterprise Linux 安裝期間,您應(yīng)該已經(jīng)安裝了 OCFS2 RPM。驗(yàn)證 RPM 是否已經(jīng)安裝在兩個(gè)節(jié)點(diǎn)上。

rac1-> rpm -qa | grep ocfs
ocfs2-tools-1.2.2-2
ocfs2console-1.2.2-2
ocfs2-2.6.9-42.0.0.0.1.ELsmp-1.2.3-2
創(chuàng)建 OCFS2 配置文件。 在 rac1 上,以 root 用戶身份執(zhí)行
# ocfs2console
  1. OCFS2 控制臺(tái):選擇 Cluster,然后選擇 Configure Nodes。
  2. “集群堆棧已經(jīng)啟動(dòng)”:單擊 Close。
  3. 節(jié)點(diǎn)配置:單擊 Add
  4. 新增節(jié)點(diǎn):添加以下節(jié)點(diǎn),然后單擊 Apply。
    • 名稱:rac1
    • IP 地址: 192.168.2.131
    • IP 端口: 7777
    • 名稱:rac2
    • IP 地址: 192.168.2.132
    • IP 端口: 7777
  5. 驗(yàn)證生成的配置文件。
    # more /etc/ocfs2/cluster.conf
        node:
        ip_port = 7777
        ip_address = 192.168.2.131
        number = 0
        name = rac1
        cluster = ocfs2
        node:
        ip_port = 7777
        ip_address = 192.168.2.132
        number = 1
        name = rac2
        cluster = ocfs2
        cluster:
        node_count = 2
        name = ocfs2
        
  6. 將配置文件傳播到 rac2。您可以在 rac2 上重新運(yùn)行上述步驟以生成配置文件,或者在 rac1 的 OCFS2 控制臺(tái)上選擇 ClusterPropagate Configuration 以將配置文件傳播到 rac2。
配置 O2CB 驅(qū)動(dòng)程序。O2CB 是一組集群服務(wù),負(fù)責(zé)管理節(jié)點(diǎn)與集群文件系統(tǒng)之間的通信。下面是對各個(gè)服務(wù)的說明:
  • NM:用于跟蹤 cluster.conf 中的所有節(jié)點(diǎn)的節(jié)點(diǎn)管理器
  • HB:當(dāng)節(jié)點(diǎn)加入或離開集群時(shí)向上/向下發(fā)出通知的心跳服務(wù)
  • TCP:處理節(jié)點(diǎn)之間的通信
  • DLM:用于跟蹤所有鎖、這些鎖的所有者以及狀態(tài)的分布式鎖管理器
  • CONFIGFS:在 /config 中掛載的用戶空間驅(qū)動(dòng)的配置文件系統(tǒng)
  • DLMFS:用戶空間與內(nèi)核空間 DLM 的接口

在兩個(gè)節(jié)點(diǎn)上執(zhí)行下面的過程,將 O2CB 配置為在引導(dǎo)時(shí)啟動(dòng)。

當(dāng)系統(tǒng)提示您指定心跳死亡閾值時(shí),您必須指定一個(gè)大于 7 的值,以防止節(jié)點(diǎn)由于較慢的 IDE 磁盤驅(qū)動(dòng)器而崩潰。心跳死亡閾值是一個(gè)用于計(jì)算隔離時(shí)間的變量。

Fence time (seconds) = (heartbeat dead threshold -1) * 2

在我們的環(huán)境中,120 秒的隔離時(shí)間很合適。兩個(gè)節(jié)點(diǎn)上的心跳死亡閾值應(yīng)該完全相同。

以 root 用戶身份執(zhí)行

# /etc/init.d/o2cb unload
Stopping O2CB cluster ocfs2: OK
Unmounting ocfs2_dlmfs filesystem: OK
Unloading module "ocfs2_dlmfs": OK
Unmounting configfs filesystem: OK
Unloading module "configfs": OK
# /etc/init.d/o2cb configure
Configuring the O2CB driver.
This will configure the on-boot properties of the O2CB driver.
The following questions will determine whether the driver is loaded on
boot.  The current values will be shown in brackets (‘[]‘).  Hitting
 without typing an answer will keep that current value.  Ctrl-C
will abort.
Load O2CB driver on boot (y/n) [y]: y
Cluster to start on boot (Enter "none" to clear) [ocfs2]:
Specify heartbeat dead threshold (>=7) [7]: 61
Writing O2CB configuration: OK
Loading module "configfs": OK
Mounting configfs filesystem at /config: OK
Loading module "ocfs2_nodemanager": OK
Loading module "ocfs2_dlm": OK
Loading module "ocfs2_dlmfs": OK
Mounting ocfs2_dlmfs filesystem at /dlm: OK
Starting O2CB cluster ocfs2: OK
格式化文件系統(tǒng)。在格式化和掛載文件系統(tǒng)之前,應(yīng)驗(yàn)證 O2CB 在兩個(gè)節(jié)點(diǎn)上均聯(lián)機(jī);O2CB 心跳當(dāng)前沒有活動(dòng),因?yàn)槲募到y(tǒng)未掛載。
# /etc/init.d/o2cb status
Module "configfs": Loaded
Filesystem "configfs": Mounted
Module "ocfs2_nodemanager": Loaded
Module "ocfs2_dlm": Loaded
Module "ocfs2_dlmfs": Loaded
Filesystem "ocfs2_dlmfs": Mounted
Checking O2CB cluster ocfs2: Online
Checking O2CB heartbeat: Not active

您只需在一個(gè)節(jié)點(diǎn)上格式化文件系統(tǒng)。在 rac1 上,以 root 用戶身份執(zhí)行

# ocfs2console
  1. OCFS2 控制臺(tái):選擇 Tasks、Format。
  2. 格式:
    • 可用設(shè)備:/dev/sdb1
    • 卷標(biāo):oracle
    • 集群大?。篈uto
    • 節(jié)點(diǎn)插槽數(shù)量: 4
    • 塊大小:Auto
  3. OCFS2 控制臺(tái):按 CTRL-Q 退出。
掛載文件系統(tǒng)。要掛載文件系統(tǒng),在兩個(gè)節(jié)點(diǎn)上執(zhí)行以下命令。
# mount -t ocfs2 -o datavolume,nointr /dev/sdb1 /ocfs

要在引導(dǎo)時(shí)掛載文件系統(tǒng),在兩個(gè)節(jié)點(diǎn)的 /etc/fstab 中添加以下行。

/etc/fstab

/dev/sdb1 /ocfs ocfs2 _netdev,datavolume,nointr 0 0
創(chuàng)建 Oracle 集群件目錄。在 OCR 和表決磁盤將駐留的 OCFS2 文件系統(tǒng)中創(chuàng)建目錄。

在 rac1 上執(zhí)行

# mkdir /ocfs/clusterware
# chown -R oracle:dba /ocfs

現(xiàn)在,您已經(jīng)完成了 OCFS2 的設(shè)置。驗(yàn)證您可以在兩個(gè)節(jié)點(diǎn)的共享集群文件系統(tǒng)上讀寫文件。

7. 安裝 Oracle 集群件

下載后,在 rac1 上以 oracle 用戶身份執(zhí)行

rac1-> /u01/staging/clusterware/runInstaller
  1. 歡迎頁面:單擊 Next。
  2. 指定 Inventory 目錄和證書:
    • 輸入 inventory 目錄的完整路徑:/u01/app/oracle/oraInventory。
    • 指定操作系統(tǒng)組名:oinstall。
  3. 指定 Home 詳細(xì)內(nèi)容:
    • 名稱:OraCrs10g_home
    • /u01/app/oracle/product/10.2.0/crs_1
  4. 特定于產(chǎn)品的必要條件檢查:
    • 忽略有關(guān)物理內(nèi)存要求的警告。
  5. 指定集群配置:單擊 Add。
    • 公共節(jié)點(diǎn)名稱:rac2.
    • 專用節(jié)點(diǎn)名稱:rac2-priv.
    • 虛擬主機(jī)名稱:rac2-vip.
  6. 指定網(wǎng)絡(luò)接口用法:
    • 接口名稱:eth0
    • 子網(wǎng): 192.168.2.0
    • 接口類型:Public
    • 接口名稱:eth1
    • 子網(wǎng): 10.10.10.0
    • 接口類型:Private
  7. 指定 Oracle 集群注冊表 (OCR) 位置:選擇 External Redundancy
    為了簡單起見,這里將不鏡像 OCR。在生產(chǎn)環(huán)境中,您可能會(huì)考慮復(fù)用 OCR 以實(shí)現(xiàn)更高的冗余。
    • 指定 OCR 位置:/ocfs/clusterware/ocr
  8. 指定表決磁盤位置:選擇 External Redundancy。
    同樣,為了簡單起見,我們選擇不鏡像表決磁盤。
    • 表決磁盤位置:/ocfs/clusterware/votingdisk
  9. 摘要:單擊 Install。
  10. 執(zhí)行配置腳本:以 root 用戶身份按順序執(zhí)行以下腳本(一次執(zhí)行一個(gè))。在當(dāng)前腳本完成后,再繼續(xù)執(zhí)行下一個(gè)腳本。
    • 在 rac1 上執(zhí)行 /u01/app/oracle/oraInventory/orainstRoot.sh。
    • 在 rac2 上執(zhí)行 /u01/app/oracle/oraInventory/orainstRoot.sh。
    • 在 rac1 上執(zhí)行 /u01/app/oracle/product/10.2.0/crs_1/root.sh。
    • 在 rac2 上執(zhí)行 /u01/app/oracle/product/10.2.0/crs_1/root.sh。
    rac2 上的 root.sh 腳本會(huì)自動(dòng)調(diào)用 VIPCA,但會(huì)因?yàn)椤癟he given interface(s), "eth0" is not public.Public interfaces should be used to configure virtual IPs.”錯(cuò)誤而失敗。如果您的公共接口使用不可路由的 IP 地址 (192.168.x.x),則 Oracle 集群驗(yàn)證實(shí)用程序 (CVU) 將無法找到合適的公共接口。一種解決方法是手動(dòng)運(yùn)行 VIPCA。
  11. 以 root 用戶身份在第二個(gè)節(jié)點(diǎn)上手動(dòng)調(diào)用 VIPCA。
    # /u01/app/oracle/product/10.2.0/crs_1/bin/vipca
  12. 歡迎頁面:單擊 Next。
  13. 網(wǎng)絡(luò)接口:選擇 eth0。
  14. 集群節(jié)點(diǎn)的虛擬 IP:
    • 節(jié)點(diǎn)名稱:rac1
    • IP 別名:rac1-vip
    • IP 地址: 192.168.2.31
    • 子網(wǎng)掩碼: 255.255.255.0
    • 節(jié)點(diǎn)名稱:rac2
    • IP 別名:rac2-vip
    • IP 地址: 192.168.2.32
    • 子網(wǎng)掩碼: 255.255.255.0
  15. 摘要:單擊 Finish。

    圖 6

  16. 配置助手進(jìn)度對話框:配置完成后,單擊 OK
  17. 配置結(jié)果:單擊 Exit。
  18. 返回到 rac1 的執(zhí)行配置腳本屏幕,然后單擊 OK。

    圖 7

  19. 配置助手:驗(yàn)證所有檢查均成功。OUI 在最后會(huì)執(zhí)行集群件安裝后檢查。如果 CVU 失敗,請更正問題,并以 oracle 用戶身份重新運(yùn)行以下命令:
    rac1-> /u01/app/oracle/product/10.2.0/crs_1/bin/cluvfy stage
        -post crsinst -n rac1,rac2
        Performing post-checks for cluster services setup
        Checking node reachability...
        Node reachability check passed from node "rac1".
        Checking user equivalence...
        User equivalence check passed for user "oracle".
        Checking Cluster manager integrity...
        Checking CSS daemon...
        Daemon status check passed for "CSS daemon".
        Cluster manager integrity check passed.
        Checking cluster integrity...
        Cluster integrity check passed
        Checking OCR integrity...
        Checking the absence of a non-clustered configuration...
        All nodes free of non-clustered, local-only configurations.
        Uniqueness check for OCR device passed.
        Checking the version of OCR...
        OCR of correct Version "2" exists.
        Checking data integrity of OCR...
        Data integrity check for OCR passed.
        OCR integrity check passed.
        Checking CRS integrity...
        Checking daemon liveness...
        Liveness check passed for "CRS daemon".
        Checking daemon liveness...
        Liveness check passed for "CSS daemon".
        Checking daemon liveness...
        Liveness check passed for "EVM daemon".
        Checking CRS health...
        CRS health check passed.
        CRS integrity check passed.
        Checking node application existence...
        Checking existence of VIP node application (required)
        Check passed.
        Checking existence of ONS node application (optional)
        Check passed.
        Checking existence of GSD node application (optional)
        Check passed.
        Post-check for cluster services setup was successful.
        
  20. 安裝結(jié)束:單擊 Exit。

8. 安裝 Oracle 數(shù)據(jù)庫 10g 第 2 版

下載后,在 rac1 上以 oracle 用戶身份執(zhí)行

rac1-> /u01/staging/database/runInstaller
  1. 歡迎頁面:單擊 Next。
  2. 選擇安裝類型:
    • 選擇 Enterprise Edition。
  3. 指定 Home 詳細(xì)內(nèi)容:
    • 名稱:OraDb10g_home1
    • 路徑:/u01/app/oracle/product/10.2.0/db_1
  4. 指定硬件集群安裝模式:
    • 選擇 Cluster Installation。
    • 單擊 Select All
  5. 特定于產(chǎn)品的必要條件檢查:
    • 忽略有關(guān)物理內(nèi)存要求的警告。
  6. 選擇配置選項(xiàng):
    • 創(chuàng)建數(shù)據(jù)庫。
  7. 選擇數(shù)據(jù)庫配置:
    • 選擇 Advanced。
  8. 摘要:單擊 Install
  9. 數(shù)據(jù)庫模板:
    • 選擇 General Purpose。
  10. 數(shù)據(jù)庫標(biāo)識(shí):
    • 全局?jǐn)?shù)據(jù)庫名稱:devdb
    • SID 前綴:devdb
  11. 管理選項(xiàng):
    • 選擇 Configure the Database with Enterprise Manager。
  12. 數(shù)據(jù)庫證書:
    • 針對所有帳戶使用相同的口令。
  13. 存儲(chǔ)選項(xiàng):
    • 選擇 Automatic Storage Management (ASM)
  14. 創(chuàng)建 ASM 實(shí)例:
    • SYS 口令:<輸入 SYS 口令>。
    • 選擇 Create initialization parameter file (IFILE)。
  15. ASM 磁盤組:
    • 單擊 Create New。
  16. 創(chuàng)建磁盤組:
    創(chuàng)建兩個(gè)磁盤組 — DG1 和 RECOVERYDEST。
    • 磁盤組名稱:DG1
    • 選擇 Normal 冗余。
    • 選擇磁盤路徑 ORCL:VOL1 和 ORCL:VOL2。如果您已經(jīng)使用標(biāo)準(zhǔn) Linux I/O 配置了 ASM 磁盤,則請選擇 /u01/oradata/devdb/asmdisk1 和 /u01/oradata/devdb/asmdisk2。
    • 單擊 OK。

圖 8

  • 磁盤組名稱:RECOVERYDEST。
  • 選擇 External 冗余。
  • 選擇磁盤路徑 ORCL:VOL3。如果您已經(jīng)使用標(biāo)準(zhǔn) Linux I/O 配置了 ASM 磁盤,則請選擇 /u01/oradata/devdb/asmdisk3。
  • 單擊 OK。

圖 9

  1. ASM 磁盤組:單擊 Next。

圖 10

  1. 數(shù)據(jù)庫文件位置:
    • 選擇 Use Oracle-Managed Files。
      • 數(shù)據(jù)庫區(qū)域:+DG1
  2. 恢復(fù)配置:
    • 選擇 Specify Flash Recovery Area。
      • 閃回恢復(fù)區(qū):+RECOVERYDEST
      • 閃回恢復(fù)區(qū)大?。?500M
    • 選擇 Enable Archiving。
  3. 數(shù)據(jù)庫內(nèi)容:
    • 選擇或取消選擇示例模式。
  4. 數(shù)據(jù)庫服務(wù):
    • 單擊 Next。稍后,您可以使用 DBCA 或 srvctl 創(chuàng)建或修改其他服務(wù)。
  5. 初始化參數(shù):
    • 選擇 Custom。
      • 共享內(nèi)存管理:Automatic
      • SGA 大小:200MB
      • PGA 大?。?5MB
    • b. 根據(jù)需要修改其余參數(shù)。
  6. 數(shù)據(jù)庫存儲(chǔ):單擊 Next。
  7. 創(chuàng)建選項(xiàng):
    • 選擇 Create Database
    • 單擊 Finish。
  8. 摘要:單擊 OK
  9. 數(shù)據(jù)庫配置助手:單擊 Exit。

圖 11

圖 12

  1. 執(zhí)行配置腳本:以 root 用戶身份執(zhí)行下面的腳本。
    • 在 rac1 上執(zhí)行 /u01/app/oracle/product/10.2.0/db_1/root.sh。
    • 在 rac2 上執(zhí)行 /u01/app/oracle/product/10.2.0/db_1/root.sh。
  2. 返回到 rac1 的執(zhí)行配置腳本屏幕,然后單擊 OK
  3. 安裝結(jié)束:單擊 Exit。

圖 13

恭喜,您已經(jīng)在 Enterprise Linux 上成功安裝了 Oracle RAC 數(shù)據(jù)庫 10g!

9. 探索 RAC 數(shù)據(jù)庫環(huán)境

現(xiàn)在,您已經(jīng)成功安裝了虛擬雙節(jié)點(diǎn) RAC 數(shù)據(jù)庫,下面我們來探究一下您剛剛配置的環(huán)境。

檢查應(yīng)用程序資源的狀態(tài)。
rac1-> crs_stat -t
Name           Type           Target    State     Host
------------------------------------------------------------
ora.devdb.db   application    ONLINE    ONLINE    rac1
ora....b1.inst application    ONLINE    ONLINE    rac1
ora....b2.inst application    ONLINE    ONLINE    rac2
ora....SM1.asm application    ONLINE    ONLINE    rac1
ora....C1.lsnr application    ONLINE    ONLINE    rac1
ora.rac1.gsd   application    ONLINE    ONLINE    rac1
ora.rac1.ons   application    ONLINE    ONLINE    rac1
ora.rac1.vip   application    ONLINE    ONLINE    rac1
ora....SM2.asm application    ONLINE    ONLINE    rac2
ora....C2.lsnr application    ONLINE    ONLINE    rac2
ora.rac2.gsd   application    ONLINE    ONLINE    rac2
ora.rac2.ons   application    ONLINE    ONLINE    rac2
ora.rac2.vip   application    ONLINE    ONLINE    rac2
rac1-> srvctl status nodeapps -n rac1
VIP is running on node: rac1
GSD is running on node: rac1
Listener is running on node: rac1
ONS daemon is running on node: rac1
rac1-> srvctl status nodeapps -n rac2
VIP is running on node: rac2
GSD is running on node: rac2
Listener is running on node: rac2
ONS daemon is running on node: rac2
rac1-> srvctl status asm -n rac1
ASM instance +ASM1 is running on node rac1.
rac1-> srvctl status asm -n rac2
ASM instance +ASM2 is running on node rac2.
rac1-> srvctl status database -d devdb
Instance devdb1 is running on node rac1
Instance devdb2 is running on node rac2
rac1-> srvctl status service -d devdb
rac1->
檢查 Oracle 集群件的狀態(tài)。
rac1-> crsctl check crs
CSS appears healthy
CRS appears healthy
EVM appears healthy
rac2-> crsctl check crs
CSS appears healthy
CRS appears healthy
EVM appears healthy

在命令行執(zhí)行 crsctl 以查看所有可用選項(xiàng)。

列出 RAC 實(shí)例。
SQL> select
2  instance_name,
3  host_name,
4  archiver,
5  thread#,
6  status
7  from gv$instance;
INSTANCE_NAME  HOST_NAME             ARCHIVE  THREAD# STATUS
-------------- --------------------- ------- -------- ------
devdb1         rac1. STARTED        1 OPEN
devdb2         rac2. STARTED        2 OPEN
檢查連接。

驗(yàn)證您能夠連接到每個(gè)節(jié)點(diǎn)上的實(shí)例和服務(wù)。

sqlplus system@devdb1
sqlplus system@devdb2
sqlplus system@devdb
檢查數(shù)據(jù)庫配置。
rac1-> export ORACLE_SID=devdb1
rac1-> sqlplus / as sysdba
SQL> show sga
Total System Global Area  209715200 bytes
Fixed Size                  1218556 bytes
Variable Size             104859652 bytes
Database Buffers          100663296 bytes
Redo Buffers                2973696 bytes
SQL> select file_name,bytes/1024/1024 from dba_data_files;
FILE_NAME                                   BYTES/1024/1024
------------------------------------------- ---------------
+DG1/devdb/datafile/users.259.606468449                   5
+DG1/devdb/datafile/sysaux.257.606468447                240
+DG1/devdb/datafile/undotbs1.258.606468449               30
+DG1/devdb/datafile/system.256.606468445                480
+DG1/devdb/datafile/undotbs2.264.606468677               25
SQL> select
2  group#,
3  type,
4  member,
5  is_recovery_dest_file
6  from v$logfile
7  order by group#;
GROUP# TYPE    MEMBER                                              IS_
------ ------- --------------------------------------------------- ---
1 ONLINE  +RECOVERYDEST/devdb/onlinelog/group_1.257.606468581 YES
1 ONLINE  +DG1/devdb/onlinelog/group_1.261.606468575          NO
2 ONLINE  +RECOVERYDEST/devdb/onlinelog/group_2.258.606468589 YES
2 ONLINE  +DG1/devdb/onlinelog/group_2.262.606468583          NO
3 ONLINE  +DG1/devdb/onlinelog/group_3.265.606468865          NO
3 ONLINE  +RECOVERYDEST/devdb/onlinelog/group_3.259.606468875 YES
4 ONLINE  +DG1/devdb/onlinelog/group_4.266.606468879          NO
4 ONLINE  +RECOVERYDEST/devdb/onlinelog/group_4.260.606468887 YES
rac1-> export ORACLE_SID=+ASM1
rac1-> sqlplus / as sysdba
SQL> show sga
Total System Global Area   92274688 bytes
Fixed Size                  1217884 bytes
Variable Size              65890980 bytes
ASM Cache                  25165824 bytes
SQL> show parameter asm_disk
NAME                           TYPE        VALUE
------------------------------ ----------- ------------------------
asm_diskgroups                 string      DG1, RECOVERYDEST
asm_diskstring                 string
SQL> select
2  group_number,
3  name,
4  allocation_unit_size alloc_unit_size,
5  state,
6  type,
7  total_mb,
8  usable_file_mb
9  from v$asm_diskgroup;
ALLOC                        USABLE
GROUP                  UNIT                 TOTAL    FILE
NUMBER NAME             SIZE STATE   TYPE       MB      MB
------ ------------ -------- ------- ------ ------ -------
1 DG1           1048576 MOUNTED NORMAL   6134    1868
2 RECOVERYDEST  1048576 MOUNTED EXTERN   2047    1713
SQL> select
2  name,
3  path,
4  header_status,
5  total_mb free_mb,
6  trunc(bytes_read/1024/1024) read_mb,
7  trunc(bytes_written/1024/1024) write_mb
8  from v$asm_disk;
NAME  PATH       HEADER_STATU    FREE_MB    READ_MB   WRITE_MB
----- ---------- ------------ ---------- ---------- ----------
VOL1  ORCL:VOL1  MEMBER             3067        229       1242
VOL2  ORCL:VOL2  MEMBER             3067        164       1242
VOL3  ORCL:VOL3  MEMBER             2047         11        354
創(chuàng)建表空間。
SQL> connect system/oracle@devdb
Connected.
SQL> create tablespace test_d datafile ‘+DG1‘ size 10M;
Tablespace created.
SQL> select
2  file_name,
3  tablespace_name,
4  bytes
5  from dba_data_files
6  where tablespace_name=‘TEST_D‘;
FILE_NAME                                TABLESPACE_NAME      BYTES
---------------------------------------- --------------- ----------
+DG1/devdb/datafile/test_d.269.606473423 TEST_D            10485760
創(chuàng)建在線重做日志文件組。
SQL> connect system/oracle@devdb
Connected.
SQL> alter database add logfile thread 1 group 5 size 50M;
Database altered.
SQL> alter database add logfile thread 2 group 6 size 50M;
Database altered.
SQL> select
2  group#,
3  thread#,
4  bytes,
5  members,
6  status
7  from v$log;
GROUP#    THREAD#      BYTES    MEMBERS STATUS
---------- ---------- ---------- ---------- ----------------
1          1   52428800          2 CURRENT
2          1   52428800          2 INACTIVE
3          2   52428800          2 ACTIVE
4          2   52428800          2 CURRENT
5          1   52428800          2 UNUSED
6          2   52428800          2 UNUSED
SQL> select
2  group#,
3  type,
4  member,
5  is_recovery_dest_file
6  from v$logfile
7  where group# in (5,6)
8  order by group#;
GROUP# TYPE    MEMBER                                               IS_
------ ------- ---------------------------------------------------- ---
5 ONLINE  +DG1/devdb/onlinelog/group_5.271.606473683           NO
5 ONLINE  +RECOVERYDEST/devdb/onlinelog/group_5.261.606473691  YES
6 ONLINE  +DG1/devdb/onlinelog/group_6.272.606473697           NO
6 ONLINE  +RECOVERYDEST/devdb/onlinelog/group_6.262.606473703  YES
檢查閃回恢復(fù)區(qū)空間使用率。
SQL> select * from v$recovery_file_dest;
NAME          SPACE_LIMIT SPACE_USED SPACE_RECLAIMABLE NUMBER_OF_FILES
------------- ----------- ---------- ----------------- ---------------
+RECOVERYDEST  1572864000  331366400                 0               7
SQL> select * from v$flash_recovery_area_usage;
FILE_TYPE    PERCENT_SPACE_USED PERCENT_SPACE_RECLAIMABLE NUMBER_OF_FILES
------------ ------------------ ------------------------- ---------------
CONTROLFILE                 .97                         0               1
ONLINELOG                    20                         0               6
ARCHIVELOG                    0                         0               0
BACKUPPIECE                   0                         0               0
IMAGECOPY                     0                         0               0
FLASHBACKLOG                  0                         0               0
啟動(dòng)和停止應(yīng)用程序資源。

遵循以下步驟啟動(dòng)和停止單獨(dú)的應(yīng)用程序資源。

srvctl start nodeapps -n <node1 hostname>
srvctl start nodeapps -n <node2 hostname>
srvctl start asm -n <node1 hostname>
srvctl start asm -n <node2 hostname>
srvctl start database -d <database name>
srvctl start service -d <database name> -s <service name>
crs_stat -t
srvctl stop service -d <database name> -s <service name>
srvctl stop database -d <database name>
srvctl stop asm -n <node1 hostname>
srvctl stop asm -n <node2 hostname>
srvctl stop nodeapps -n <node1 hostname>
srvctl stop nodeapps -n <node2 hostname>
crs_stat -t

10. 測試透明故障切換 (TAF)

Oracle TAF 中的故障切換機(jī)制使任何失敗的數(shù)據(jù)庫連接能夠重新連接到集群中的其他節(jié)點(diǎn)。故障切換對用戶是透明的。Oracle 在故障切換實(shí)例上重新執(zhí)行查詢并繼續(xù)向用戶顯示余下的結(jié)果。

創(chuàng)建一個(gè)新的數(shù)據(jù)庫服務(wù)。首先,創(chuàng)建一個(gè)名為 CRM 的新服務(wù)。可以使用 DBCA 或 srvctl 實(shí)用程序來創(chuàng)建數(shù)據(jù)庫服務(wù)。這里,您將使用 DBCA 在 devdb1 上創(chuàng)建 CRM 服務(wù)。


服務(wù)名 數(shù)據(jù)庫名 首選實(shí)例 可用實(shí)例 TAF 策略
CRM devdb devdb1 devdb2 BASIC

在 rac1 上,以 oracle 用戶身份執(zhí)行

rac1-> dbca
  1. 歡迎頁面:選擇 Oracle Real Application Clusters database。
  2. 操作:選擇 Services Management
  3. 集群數(shù)據(jù)庫列表:單擊 Next。
  4. 數(shù)據(jù)庫服務(wù):單擊 Add。
    • 添加服務(wù):輸入“CRM”。
      • 選擇 devdb1 作為首選實(shí)例。
      • 選擇 devdb2 作為可用實(shí)例。
      • TAF 策略:選擇 Basic。
    • 單擊 Finish

圖 14

  1. 數(shù)據(jù)庫配置助手:單擊 No 退出。

數(shù)據(jù)庫配置助手將在 tnsnames.ora 中創(chuàng)建以下 CRM 服務(wù)名項(xiàng):

CRM =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = rac1-vip)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = rac2-vip)(PORT = 1521))
(LOAD_BALANCE = yes)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = CRM)
(FAILOVER_MODE =
(TYPE = SELECT)
(METHOD = BASIC)
(RETRIES = 180)
(DELAY = 5)
)
)
)
SQL> connect system/oracle@devdb1
Connected.
SQL> show parameter service
NAME                           TYPE        VALUE
------------------------------ ----------- ------------------------
service_names                  string      devdb, CRM
SQL> connect system/oracle@devdb2
Connected.
SQL> show parameter service
NAME                           TYPE        VALUE
------------------------------ ----------- ------------------------
service_names                  string      devdb
使用 CRM 服務(wù)連接第一個(gè)會(huì)話。如果 failover_type 和 failover_mode 返回的輸出為“NONE”,則驗(yàn)證是否在 tnsnames.ora 中正確配置了 CRM 服務(wù)。
SQL> connect system/oracle@crm
Connected.
SQL> select
2  instance_number instance#,
3  instance_name,
4  host_name,
5  status
6  from v$instance;
INSTANCE# INSTANCE_NAME    HOST_NAME             STATUS
---------- ---------------- --------------------- ------------
1 devdb1           rac1. OPEN
SQL> select
2  failover_type,
3  failover_method,
4  failed_over
5  from v$session
6  where username=‘SYSTEM‘;
FAILOVER_TYPE FAILOVER_METHOD FAILED_OVER
------------- --------------- ----------------
SELECT        BASIC           NO
從其他會(huì)話中關(guān)閉該實(shí)例。在 CRM 實(shí)例上以 sys 用戶身份連接,并關(guān)閉該實(shí)例。
rac1-> export ORACLE_SID=devdb1
rac1-> sqlplus / as sysdba
SQL> select
2  instance_number instance#,
3  instance_name,
4  host_name,
5  status
6  from v$instance;
INSTANCE# INSTANCE_NAME    HOST_NAME             STATUS
---------- ---------------- --------------------- ------------
1 devdb1           rac1. OPEN
SQL> shutdown abort;
ORACLE instance shut down.
驗(yàn)證會(huì)話已經(jīng)完成故障切換。從您先前打開的同一 CRM 會(huì)話執(zhí)行以下查詢,以驗(yàn)證該會(huì)話已經(jīng)故障切換到其他實(shí)例。
SQL> select
2  instance_number instance#,
3  instance_name,
4  host_name,
5  status
6  from v$instance;
INSTANCE# INSTANCE_NAME    HOST_NAME             STATUS
---------- ---------------- --------------------- ------------
2 devdb2           rac2. OPEN
SQL> select
2  failover_type,
3  failover_method,
4  failed_over
5  from v$session
6  where username=‘SYSTEM‘;
FAILOVER_TYPE FAILOVER_METHOD FAILED_OVER
------------- --------------- ----------------
SELECT        BASIC           YES
將 CRM 服務(wù)重新定位到首選實(shí)例。恢復(fù) devdb1 之后,CRM 服務(wù)不會(huì)自動(dòng)重新定位到首選實(shí)例。您必須手動(dòng)將服務(wù)重新定位到 devdb1。
rac1-> export ORACLE_SID=devdb1
rac1-> sqlplus / as sysdba
SQL> startup
ORACLE instance started.
Total System Global Area  209715200 bytes
Fixed Size                  1218556 bytes
Variable Size             104859652 bytes
Database Buffers          100663296 bytes
Redo Buffers                2973696 bytes
Database mounted.
Database opened.
SQL> show parameter service
NAME                           TYPE        VALUE
------------------------------ ----------- ------------------------
service_names                  string      devdb
rac2-> export ORACLE_SID=devdb2
rac2-> sqlplus / as sysdba
SQL> show parameter service
NAME                           TYPE        VALUE
------------------------------ ----------- ------------------------
service_names                  string      devdb, CRM
rac1-> srvctl relocate service -d devdb -s crm -i devdb2 -t devdb1
SQL> connect system/oracle@devdb1
Connected.
SQL> show parameter service
NAME                           TYPE        VALUE
------------------------------ ----------- ------------------------
service_names                  string      devdb, CRM
SQL> connect system/oracle@devdb2
Connected.
SQL> show parameter service
NAME                           TYPE        VALUE
------------------------------ ----------- ------------------------
service_names                  string      devdb

11. 數(shù)據(jù)庫備份與恢復(fù)

使用 Oracle 恢復(fù)管理器 (RMAN) 備份和恢復(fù) Oracle RAC 數(shù)據(jù)庫的過程與單實(shí)例數(shù)據(jù)庫的備份和恢復(fù)過程相同。

在本部分中,您將看到一個(gè)非常簡單的備份和恢復(fù)案例:

1. 執(zhí)行完整的數(shù)據(jù)庫備份。
2. 在 test_d 表空間中創(chuàng)建 mytable 表。
3. 在 t1 時(shí)間,向 mytable 中插入第一個(gè)記錄。
4 在 t2 時(shí)間,向 mytable 中插入第二個(gè)記錄。
5. 在 t3 時(shí)間,刪除 mytable 表。
6. 將 test_d 表空間恢復(fù)到某個(gè)時(shí)間點(diǎn)。
7. 驗(yàn)證恢復(fù)結(jié)果。

執(zhí)行完整的數(shù)據(jù)庫備份。

rac1-> rman nocatalog target /
Recovery Manager: Release 10.2.0.1.0 - Production on Mon Nov 13 18:15:09 2006
Copyright (c) 1982, 2005, Oracle.  All rights reserved.
connected to target database: DEVDB (DBID=511198553)
using target database control file instead of recovery catalog
RMAN> configure controlfile autobackup on;
RMAN> backup database plus archivelog delete input;

在 test_d 表空間中創(chuàng)建 mytable 表。

19:01:56 SQL> connect system/oracle@devdb2
Connected.
19:02:01 SQL> create table mytable (col1 number) tablespace test_d;
Table created.

在 t1 時(shí)間,向 mytable 中插入第一個(gè)記錄。

19:02:50 SQL> insert into mytable values (1);
1 row created.
19:02:59 SQL> commit;
Commit complete.

在 t2 時(shí)間,向 mytable 中插入第二個(gè)記錄。

19:04:41 SQL> insert into mytable values (2);
1 row created.
19:04:46 SQL> commit;
Commit complete.

在 t3 時(shí)間,刪除 mytable 表。

19:05:09 SQL> drop table mytable;
Table dropped.

將 test_d 表空間恢復(fù)到某個(gè)時(shí)間點(diǎn)。

為輔助數(shù)據(jù)庫創(chuàng)建輔助目錄。

rac1-> mkdir /u01/app/oracle/aux
RMAN> recover tablespace test_d
2> until time "to_date(‘13-NOV-2006 19:03:10‘,‘DD-MON-YYYY HH24:MI:SS‘)"
3> auxiliary destination ‘/u01/app/oracle/aux‘;
RMAN> backup tablespace test_d;
RMAN> sql ‘a(chǎn)lter tablespace test_d online‘;

驗(yàn)證恢復(fù)結(jié)果。

19:15:09 SQL> connect system/oracle@devdb2
Connected.
19:15:16 SQL> select * from mytable;
COL1
----------
1

12. 探索 Oracle 企業(yè)管理器 (OEM) 數(shù)據(jù)庫控制臺(tái)

Oracle 企業(yè)管理器數(shù)據(jù)庫控制臺(tái)提供了一個(gè)非常好的集成式綜合 GUI 界面,用于管理集群數(shù)據(jù)庫環(huán)境。您可以在控制臺(tái)內(nèi)執(zhí)行幾乎所有的任務(wù)。

要訪問數(shù)據(jù)庫控制臺(tái),請打開 Web 瀏覽器并輸入下面的 URL。
以 sysman 用戶身份登錄,并輸入您先前在數(shù)據(jù)庫安裝期間選擇的口令。

http://rac1:1158/em

圖 15

啟動(dòng)和停止數(shù)據(jù)庫控制臺(tái)。

rac1-> emctl stop dbconsole
TZ set to US/Eastern
Oracle Enterprise Manager 10g Database Control Release 10.2.0.1.0
Copyright (c) 1996, 2005 Oracle Corporation.  All rights reserved.
http://rac1.:1158/em/console/aboutApplication
Stopping Oracle Enterprise Manager 10g Database Control ...
...  Stopped.
rac1-> emctl start dbconsole
TZ set to US/Eastern
Oracle Enterprise Manager 10g Database Control Release 10.2.0.1.0
Copyright (c) 1996, 2005 Oracle Corporation.  All rights reserved.
http://rac1.:1158/em/console/aboutApplication
Starting Oracle Enterprise Manager 10g Database Control
................... started.
------------------------------------------------------------------
Logs are generated in directory
/u01/app/oracle/product/10.2.0/db_1/rac1_devdb1/sysman/log

驗(yàn)證數(shù)據(jù)庫控制臺(tái)的狀態(tài)。

rac1-> emctl status dbconsole
TZ set to US/Eastern
Oracle Enterprise Manager 10g Database Control Release 10.2.0.1.0
Copyright (c) 1996, 2005 Oracle Corporation.  All rights reserved.
http://rac1.:1158/em/console/aboutApplication
Oracle Enterprise Manager 10g is running.
------------------------------------------------------------------
Logs are generated in directory
/u01/app/oracle/product/10.2.0/db_1/rac1_devdb1/sysman/log
rac1-> emctl status agent
TZ set to US/Eastern
Oracle Enterprise Manager 10g Database Control Release 10.2.0.1.0
Copyright (c) 1996, 2005 Oracle Corporation.  All rights reserved.
---------------------------------------------------------------
Agent Version     : 10.1.0.4.1
OMS Version       : 10.1.0.4.0
Protocol Version  : 10.1.0.2.0
Agent Home        : /u01/app/oracle/product/10.2.0/db_1/rac1_devdb1
Agent binaries    : /u01/app/oracle/product/10.2.0/db_1
Agent Process ID  : 10263
Parent Process ID : 8171
Agent URL         : http://rac1.:3938/emd/main
Started at        : 2006-11-12 08:10:01
Started by user   : oracle
Last Reload       : 2006-11-12 08:20:33
Last successful upload                       : 2006-11-12 08:41:53
Total Megabytes of XML files uploaded so far :     4.88
Number of XML files pending upload           :        0
Size of XML files pending upload(MB)         :     0.00
Available disk space on upload filesystem    :    71.53%
---------------------------------------------------------------
Agent is Running and Ready

13. 常見問題

下面是可能對您有用的問題和解決方法摘要列表。

問題 1:無法激活以太網(wǎng)設(shè)備。
錯(cuò)誤消息為“Cannot activate network device eth0!Device eth0 has different MAC address than expected, ignoring.”

解決方法:
“ifconfig”報(bào)告的 MAC 地址與 /etc/sysconfig/network-scripts/ifcfg-eth0 不匹配。您可以使用新的 MAC 地址更新文件,或者只需通過 system-config-network 工具探測新的 MAC 地址。


問題 2:無法生成 OCFS2 配置文件。
在嘗試生成 OCFS2 配置文件時(shí),出現(xiàn)錯(cuò)誤消息“Could not start cluster stack.This must be resolved before any OCFS2 filesystem can be mounted”。

解決方法:
以 root 用戶身份(而非 oracle 用戶身份)執(zhí)行 ocfs2console。


問題 3:無法在遠(yuǎn)程節(jié)點(diǎn)上安裝 Oracle 集群件或 Oracle 數(shù)據(jù)庫軟件。
在 Oracle 集群件軟件安裝期間,出現(xiàn)錯(cuò)誤消息“/bin/tar:./inventory/Components21/oracle.ordim.server/10.2.0.1.0:time stamp 2006-11-04 06:24:04 is 25 s in the future”。

解決方法:
通過安裝 VMware 工具來同步客戶 OS 與主機(jī) OS 的時(shí)間,并在 /boot/grub/grub.conf 中包含選項(xiàng)“clock=pit nosmp noapic nolapic”。請參閱第 3 部分,以獲得更多信息。


問題 4:無法掛載 OCFS2 文件系統(tǒng)。
在嘗試掛載 ocfs2 文件系統(tǒng)時(shí),出現(xiàn)錯(cuò)誤消息“mount.ocfs2:Transport endpoint is not connected while mounting”。

解決方法:
執(zhí)行 /usr/bin/system-config-securitylevel 以禁用防火墻。


問題 5:無法啟動(dòng) ONS 資源。
當(dāng) VIPCA 嘗試啟動(dòng) ONS 應(yīng)用程序資源時(shí),出現(xiàn)錯(cuò)誤消息“CRS-0215:Could not start resource ‘ora.rac2.ons’”。

解決方法:
ONS 嘗試訪問本地主機(jī),但無法解析 IP 地址。將以下項(xiàng)添加到 /etc/hosts 中。

127.0.0.1 localhost

結(jié)論

希望通過本指南的學(xué)習(xí),您可以免費(fèi)、快速地使用 VMware Server 構(gòu)建集群 Oracle 數(shù)據(jù)庫環(huán)境。利用免費(fèi)軟件,開始學(xué)習(xí)并試用 Enterprise Linux 上的 Oracle RAC!


Vincent Chan (vkchan99@yahoo.com) 是 MSD Inc. 的高級顧問。他是一位經(jīng)過 Oracle 認(rèn)證的高級數(shù)據(jù)庫管理員,擁有十年以上的針對各種客戶端設(shè)計(jì)和實(shí)施 Oracle 解決方案的經(jīng)驗(yàn)。

    本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點(diǎn)擊一鍵舉報(bào)。
    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評論

    發(fā)表

    請遵守用戶 評論公約

    類似文章 更多