4. 創建并配置第二個虛擬機
要創建第二個虛擬機,只需關閉第一個虛擬機,將 d:vmracrac1 中的所有文件復制到 d:vmracrac2,然后更改幾個配置即可。
修改網絡配置。- 在 rac1 上,以 root 用戶身份執行
# shutdown –h now - 在主機系統上,將 rac1 文件夾中的所有文件復制到 rac2。
D:>copy d:vmracrac1 d:vmracrac2 - 在 VMware Server 控制臺上,按 CTRL-O 打開第二個虛擬機 d:racrac2Red Hat Enterprise Linux 4.vmx。
- VMware Server 控制臺:
- 將虛擬機名稱從 rac1 重命名為 rac2。右鍵單擊您剛才打開的新 rac1 選項卡,然后選擇 Settings。
- 選擇 Options 選項卡。
1. 虛擬機名稱:輸入“rac2”。
- 選擇 Options 選項卡。
- 將虛擬機名稱從 rac1 重命名為 rac2。右鍵單擊您剛才打開的新 rac1 選項卡,然后選擇 Settings。
- 單擊 Start this virtual machine 啟動 rac2,保留 rac1 為電源關閉狀態。
- rac2 — 虛擬機:選擇 Create a new identifier。
- 以 root 用戶身份登錄并執行 system-config-network,以修改網絡配置。
IP 地址:雙擊每個以太網設備,并使用下面的表進行必要的更改。
設備 IP 地址 子網掩碼 默認網關地址 eth0 192.168.2.132 255.255.255.0 192.168.2.1 eth1 10.10.10.32 255.255.255.0 <保留空白> MAC 地址:導航到 Hardware Device 選項卡,并探測每個以太網設備的新 MAC 地址。
主機名和 DNS:使用下面的表對 DNS 選項卡中的項進行必要的更改,然后按 CTRL-S 保存。
主機名 首選 DNS 備用 DNS DNS 搜索路徑 rac2.mycorpdomain.com 輸入 DNS IP 地址或保留空白。 輸入 DNS IP 地址或保留空白。 接受默認設置或保留空白。 最后,激活每個以太網設備。
修改 /etc/hosts。將以下項添加到 /etc/hosts 中。
127.0.0.1 localhost
稍后,在 Oracle 集群件軟件安裝期間,VIPCA 將嘗試使用回送地址。
修改 /export/home/oracle/.profile。用 devdb2 替換 ORACLE_SID 的值。
使用 SSH 建立用戶等效性。在集群就緒服務 (CRS) 和 RAC 安裝過程中,Oracle Universal Installer (OUI) 必須能夠以 oracle 的身份將軟件復制到所有 RAC 節點,而不提示輸入口令。在 Oracle 10g 中,可以使用 ssh 代替 rsh 完成此操作。
要建立用戶等效性,請在兩個節點上以 oracle 用戶身份生成用戶的公鑰和私鑰。打開 rac1 的電源,在這兩個節點上執行以下任務。
在 rac1 上執行
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.mycorpdomain.com
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.mycorpdomain.com
在 rac2 上執行
rac2-> mkdir ~/.sshrac2-> 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.mycorpdomain.com
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.mycorpdomain.com
在 rac1 上執行
rac1-> cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keysrac1-> 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
在每個節點上測試連接。驗證當您再次運行以下命令時,系統是否不提示您輸入口令。
ssh rac1 datessh rac2 date
ssh rac1-priv date
ssh rac2-priv date
ssh rac1.mycorpdomain.com date
ssh rac2.mycorpdomain.com date
ssh rac1-priv.mycorpdomain.com date
ssh rac2-priv.mycorpdomain.com date
一定要確認不需要密碼就能執行 否則后面從rac1遠程安裝cluster ware到rac2上的時候會報錯.
5. 配置 Oracle 自動存儲管理 (ASM)
Oracle ASM 與 Oracle 數據庫緊密集成在一起,并與 Oracle 的數據管理工具套件配合工作。它可以簡化數據庫存儲管理,并提供原始磁盤 I/O 的性能。
配置 ASMLib。以 root 用戶身份在兩個節點上配置 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 ('[]'). Hittingwithout 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 ]
創建 ASM 磁盤。以 root 用戶身份在任何一個節點上創建 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 集群文件系統 (OCFS2)
OCFS2 是 Oracle 開發的一個通用集群文件系統,與 Enterprise Linux 內核集成在一起。它允許所有節點在集群文件系統上同時共享文件,因而消除了管理原始設備的需求。這里,您將在 OCFS2 文件系統中寄宿 OCR 和表決磁盤。您可以從 OCFS2 用戶指南獲取有關 OCFS2 的其他信息。
在 Enterprise Linux 安裝期間,您應該已經安裝了 OCFS2 RPM。驗證 RPM 是否已經安裝在兩個節點上。
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
要去oracle 下載
創建 OCFS2 配置文件。 在 rac1 上,以 root 用戶身份執行
# ocfs2console
- OCFS2 控制臺:選擇 Cluster,然后選擇 Configure Nodes。
- “集群堆棧已經啟動”:單擊 Close。
- 節點配置:單擊 Add。
- 新增節點:添加以下節點,然后單擊 Apply。
- 名稱:rac1
- IP 地址: 192.168.2.131
- IP 端口: 7777
- 名稱:rac2
- IP 地址: 192.168.2.132
- IP 端口: 7777
- 驗證生成的配置文件。
# 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 - 將配置文件傳播到 rac2。您可以在 rac2 上重新運行上述步驟以生成配置文件,或者在 rac1 的 OCFS2 控制臺上選擇 Cluster 和 Propagate Configuration 以將配置文件傳播到 rac2。
配置 O2CB 驅動程序。O2CB 是一組集群服務,負責管理節點與集群文件系統之間的通信。下面是對各個服務的說明:
- NM:用于跟蹤 cluster.conf 中的所有節點的節點管理器
- HB:當節點加入或離開集群時向上/向下發出通知的心跳服務
- TCP:處理節點之間的通信
- DLM:用于跟蹤所有鎖、這些鎖的所有者以及狀態的分布式鎖管理器
- CONFIGFS:在 /config 中掛載的用戶空間驅動的配置文件系統
- DLMFS:用戶空間與內核空間 DLM 的接口
在兩個節點上執行下面的過程,將 O2CB 配置為在引導時啟動。
當系統提示您指定心跳死亡閾值時,您必須指定一個大于 7 的值,以防止節點由于較慢的 IDE 磁盤驅動器而崩潰。心跳死亡閾值是一個用于計算隔離時間的變量。
Fence time (seconds) = (heartbeat dead threshold -1) * 2
在我們的環境中,120 秒的隔離時間很合適。兩個節點上的心跳死亡閾值應該完全相同。
以 root 用戶身份執行
# /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
格式化文件系統。在格式化和掛載文件系統之前,應驗證 O2CB 在兩個節點上均聯機;O2CB 心跳當前沒有活動,因為文件系統未掛載。
# /etc/init.d/o2cb status
(很重要的命令,重新啟動后應該首先判斷這個服務是否開啟,狀態如何,特別是heartbeat是不是active
一般都是ocfs沒有mount上的原因造成沒有啟動)
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
您只需在一個節點上格式化文件系統。在 rac1 上,以 root 用戶身份執行
# ocfs2console
- OCFS2 控制臺:選擇 Tasks、Format。
- 格式:
- 可用設備:/dev/sdb1
- 卷標:oracle
- 集群大小:Auto
- 節點插槽數量: 4
- 塊大小:Auto
- OCFS2 控制臺:按 CTRL-Q 退出。
掛載文件系統。要掛載文件系統,在兩個節點上執行以下命令。
# mount -t ocfs2 -o datavolume,nointr /dev/sdb1 /ocfs
要在引導時掛載文件系統,在兩個節點的 /etc/fstab 中添加以下行。
/etc/fstab
/dev/sdb1 /ocfs ocfs2 _netdev,datavolume,nointr 0 0
創建 Oracle 集群件目錄。在 OCR 和表決磁盤將駐留的 OCFS2 文件系統中創建目錄。
在 rac1 上執行
# mkdir /ocfs/clusterware
# chown -R oracle:dba /ocfs
現在,您已經完成了 OCFS2 的設置。驗證您可以在兩個節點的共享集群文件系統上讀寫文件。
7. 安裝 Oracle 集群件
下載后,在 rac1 上以 oracle 用戶身份執行(注銷切換到oracle ,這樣起安裝圖形就沒有問題)
安裝之前最好是用安裝目錄下的檢測工具來檢查是否滿足安裝的要求
../. cluvfy stage -pre crsinst -n rac1,rac2
我安裝的時候還差幾個gcc 的包 安裝好了就可以了
檢查的時候會報vips的錯誤可以忽略,等cluster安裝后了以后再設置.
rac1-> /u01/staging/clusterware/runInstaller
- 歡迎頁面:單擊 Next。
- 指定 Inventory 目錄和證書:
- 輸入 inventory 目錄的完整路徑:/u01/app/oracle/oraInventory。
- 指定操作系統組名:oinstall。
- 指定 Home 詳細內容:
- 名稱:OraCrs10g_home
- /u01/app/oracle/product/10.2.0/crs_1
- 特定于產品的必要條件檢查:
- 忽略有關物理內存要求的警告。
- 指定集群配置:單擊 Add。
- 公共節點名稱:rac2.mycorpdomain.com
- 專用節點名稱:rac2-priv.mycorpdomain.com
- 虛擬主機名稱:rac2-vip.mycorpdomain.com
- 最好這里直接用rac1,rac1-priv,rac1-vip來指名節點
- 指定網絡接口用法:
- 接口名稱:eth0
- 子網: 192.168.2.0
- 接口類型:Public
- 接口名稱:eth1
- 子網: 10.10.10.0
- 接口類型:Private
- 指定 Oracle 集群注冊表 (OCR) 位置:選擇 External Redundancy。
為了簡單起見,這里將不鏡像 OCR。在生產環境中,您可能會考慮復用 OCR 以實現更高的冗余。- 指定 OCR 位置:/ocfs/clusterware/ocr
- 指定表決磁盤位置:選擇 External Redundancy。
同樣,為了簡單起見,我們選擇不鏡像表決磁盤。- 表決磁盤位置:/ocfs/clusterware/votingdisk
- 摘要:單擊 Install。
- 執行配置腳本:以 root 用戶身份按順序執行以下腳本(一次執行一個)。在當前腳本完成后,再繼續執行下一個腳本。
- 在 rac1 上執行 /u01/app/oracle/oraInventory/orainstRoot.sh。
- 在 rac2 上執行 /u01/app/oracle/oraInventory/orainstRoot.sh。
- 在 rac1 上執行 /u01/app/oracle/product/10.2.0/crs_1/root.sh。
- 在 rac2 上執行 /u01/app/oracle/product/10.2.0/crs_1/root.sh。
- 以 root 用戶身份在第二個節點上手動調用 VIPCA。
# /u01/app/oracle/product/10.2.0/crs_1/bin/vipca - 歡迎頁面:單擊 Next。
- 網絡接口:選擇 eth0。
- 集群節點的虛擬 IP:
- 節點名稱:rac1
- IP 別名:rac1-vip
- IP 地址: 192.168.2.31
- 子網掩碼: 255.255.255.0
- 節點名稱:rac2
- IP 別名:rac2-vip
- IP 地址: 192.168.2.32
- 子網掩碼: 255.255.255.0
- 摘要:單擊 Finish。
- 配置助手進度對話框:配置完成后,單擊 OK。
- 配置結果:單擊 Exit。
- 返回到 rac1 的執行配置腳本屏幕,然后單擊 OK。
- 配置助手:驗證所有檢查均成功。OUI 在最后會執行集群件安裝后檢查。如果 CVU 失敗,請更正問題,并以 oracle 用戶身份重新運行以下命令:
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. - 安裝結束:單擊 Exit。
8. 安裝 Oracle 數據庫 10g 第 2 版
下載后,在 rac1 上以 oracle 用戶身份執行
rac1-> /u01/staging/database/runInstaller
- 歡迎頁面:單擊 Next。
- 選擇安裝類型:
- 選擇 Enterprise Edition。
- 指定 Home 詳細內容:
- 名稱:OraDb10g_home1
- 路徑:/u01/app/oracle/product/10.2.0/db_1
- 指定硬件集群安裝模式:
- 選擇 Cluster Installation。
- 單擊 Select All。
- 特定于產品的必要條件檢查:
- 忽略有關物理內存要求的警告。
- 選擇配置選項:
- 創建數據庫。
- 選擇數據庫配置:
- 選擇 Advanced。
- 摘要:單擊 Install。
- 數據庫模板:
- 選擇 General Purpose。
- 數據庫標識:
- 全局數據庫名稱:devdb
- SID 前綴:devdb
- 管理選項:
- 選擇 Configure the Database with Enterprise Manager。
- 數據庫證書:
- 針對所有帳戶使用相同的口令。
- 存儲選項:
- 選擇 Automatic Storage Management (ASM)。
- 創建 ASM 實例:
- SYS 口令:<輸入 SYS 口令>。
- 選擇 Create initialization parameter file (IFILE)。
- ASM 磁盤組:
- 單擊 Create New。
- 創建磁盤組:
創建兩個磁盤組 — DG1 和 RECOVERYDEST。
- 磁盤組名稱:DG1
- 選擇 Normal 冗余。
- 選擇磁盤路徑 ORCL:VOL1 和 ORCL:VOL2。如果您已經使用標準 Linux I/O 配置了 ASM 磁盤,則請選擇 /u01/oradata/devdb/asmdisk1 和 /u01/oradata/devdb/asmdisk2。
- 單擊 OK。
- 磁盤組名稱:RECOVERYDEST。
- 選擇 External 冗余。
- 選擇磁盤路徑 ORCL:VOL3。如果您已經使用標準 Linux I/O 配置了 ASM 磁盤,則請選擇 /u01/oradata/devdb/asmdisk3。
- 單擊 OK。
- ASM 磁盤組:單擊 Next。
- 數據庫文件位置:
- 選擇 Use Oracle-Managed Files。
- 數據庫區域:+DG1
- 選擇 Use Oracle-Managed Files。
- 恢復配置:
- 選擇 Specify Flash Recovery Area。
- 閃回恢復區:+RECOVERYDEST
- 閃回恢復區大小:1500M
- 選擇 Enable Archiving。
- 選擇 Specify Flash Recovery Area。
- 數據庫內容:
- 選擇或取消選擇示例模式。
- 數據庫服務:
- 單擊 Next。稍后,您可以使用 DBCA 或 srvctl 創建或修改其他服務。
- 初始化參數:
- 選擇 Custom。
- 共享內存管理:Automatic
- SGA 大小:200MB
- PGA 大小:25MB
- b. 根據需要修改其余參數。
- 選擇 Custom。
- 數據庫存儲:單擊 Next。
- 創建選項:
- 選擇 Create Database。
- 單擊 Finish。
- 摘要:單擊 OK。
- 數據庫配置助手:單擊 Exit。
- 執行配置腳本:以 root 用戶身份執行下面的腳本。
- 在 rac1 上執行 /u01/app/oracle/product/10.2.0/db_1/root.sh。
- 在 rac2 上執行 /u01/app/oracle/product/10.2.0/db_1/root.sh。
- 返回到 rac1 的執行配置腳本屏幕,然后單擊 OK。
- 安裝結束:單擊 Exit。
恭喜,您已經在 Enterprise Linux 上成功安裝了 Oracle RAC 數據庫 10g!
我裝的還是比較順利的,主要是cluster ware那里因為節點名字的原因導致在遠程ssh 安裝的時候要輸入密碼.所以遠程安裝失敗.要么保證那幾個ssh xx date命令都需要密碼,要么就直接用最簡單的節點名字.
其它參考:
Oracle Enterprise Linux 和 iSCSI 上構建您自己的 Oracle RAC 集群
http://www.oracle.com/technology/global/cn/pub/articles/hunter_rac11gr1_iscsi.html