歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux綜合 >> Linux資訊 >> 更多Linux >> 在linux上單機模擬Oracle 10g RAC集群(OCFS+ASM)

在linux上單機模擬Oracle 10g RAC集群(OCFS+ASM)

日期:2017/2/27 9:49:06   编辑:更多Linux
本文是在參考Oracle 10g 雙機集群的基礎上通過實踐並且精簡而得,撰寫本文的目的是為了方便大家探討技術,相信本文仍有許多不足之處
參考文檔:http://www.oracle.com/technology/global/cn/pub/articles/hunter_rac10g.Html
注:對於與多機多節點集群相同的地方,文中將直接引用參考文檔相關部分
一、簡介
熟悉 Oracle 真正應用集群 (RAC) 10g 技術的最有效方法之一是訪問一個實際的 Oracle RAC 10g 集群。沒有什麼方法比直接體驗它們能夠更好地理解其好處的了 — 包括容錯、安全性、負載均衡和可伸縮性。
Oracle RAC 的核心是共享磁盤子系統。集群中的所有節點必須能夠訪問集群中所有節點的所有數據、重做日志文件、控制文件和參數文件。數據磁盤必須在全局范圍內可用,以便允許所有節點訪問數據庫。每個節點擁有自己的重做日志和控制文件,但是其他節點必須能夠訪問這些文件,以便在系統故障時恢復該節點。
希望本文能對一些手頭上只有一台PC而沒有真正的雙機環境的朋友提供一個參考。
二、本文實踐環境
1、PC主要配置:
Celeron(R) CPU 1.80GHz
Maxtor 6E040L0, ATA DISK drive 40G
RelTek 8139C 網卡 一塊
內存DDR333 512MB * 2
顯示卡:ATI [Radeon 9200 SE]
操作系統:White Box Enterprise Linux 3 (本文同樣適用於RedHat企業版,不同之處是WBEL3目前可以免費運用於商業)
遠程終端一台,裝有windowsXP和遠程X-server軟件
2、服務器分區方案
Oracle 數據庫文件
RAC節點名
實例名
數據庫名
$ORACLE_BASE
文件系統
dbrac
orcl1
orcl
/home/oracle
ASM
Oracle CRS 共享文件
文件類型
文件名
分區
掛載點
文件系統
oracle集群注冊表
/u01/orcl/orcfile
/dev/hda8
/u01
OCFS
CRS表決磁盤
/u01/orcl/Cssfile
/dev/hda8
/u01
OCFS
3、所涉及軟件
1)oracle 10g 數據庫軟件
ship.db.lnx32.cpio.gz
2)oracle 10g 集群服務軟件
ship.crs.lnx32.cpio.gz
3)OCFS文件系統支持
ocfs-2.4.21-EL-1.0.14-1.i686.rpm
ocfs-support-1.0.10-1.i386.rpm
ocfs-tools-1.0.10-1.i386.rpm
4)ASMlib驅動程序
oracleasm-2.4.21-EL-1.0.3-1.i686.rpm
oracleasm-support-1.0.3-1.i386.rpm
oracleasmlib-1.0.0-1.i386.rpm
以上軟件包均可以從oracle官方網站下載
WBEL linux下載地址:http://www.whiteboxlinux.org/download.html
三、基礎操作
1、安裝linux
安裝過程中一些需要注意的地方:
1)磁盤分區:swap分區大小建議是內存的2倍,這裡是2048MB,劃出一些系統必要的分區根分區/,var分區/var,usr分區/usr, home分區/home,臨時文件分區/tmp。注意:這裡不要把所有的硬盤空間劃分進操作系統,留下一半給後面安裝oarcle集群磁盤使用,本文示例



2)文件系統 容量 掛載點
/dev/hda1 1012M /
/dev/hda2 7.7G /home
/dev/hda7 1012M /tmp
/dev/hda3 5.8G /usr
/dev/hda5 2.0G /var
3)組件選取:一定要選上delvelopment tools和X-windows兩項,為了節省空間其他可以不要
4)防火牆:最好不要
5)網絡設置:eth0
取消選中 [Configure using DHCP] 復選項
選中 [Activate on boot]
IP 地址:192.168.22.44
網絡掩碼: 255.255.255.0
6)主機名:dbrac
2、.安裝完成後檢查必需的 RPM
3、必須安裝以下程序包(或更高版本):
make-3.79.1
gcc-3.2.3-34
glibc-2.3.2-95.20
glibc-devel-2.3.2-95.20
glibc-headers-2.3.2-95.20
glibc-kernheaders-2.4-8.34
cpp-3.2.3-34
compat-db-4.0.14-5
compat-gcc-7.3-2.96.128
compat-gcc-c++-7.3-2.96.128
compat-libstdc++-7.3-2.96.128
compat-libstdc++-devel-7.3-2.96.128
openmotif-2.2.2-16
setarch-1.3-1
四、設置
1、更改/etc/hosts
vi /etc/hosts
127.0.0.1 localhost.localdomain localhost
192.168.22.44 dbrac int-dbrac
192.168.22.244 vip-dbrac
確保RAC節點名沒有出現在回送地址中。
此處設置相當重要,不能跳過,一定按照此設置,IP和主機別名可以自己定
oracle 10g RAC中 使用了虛擬IP(VIP)技術,這是一個令人心動的高可用性、多機無縫切換的解決方案,但在單機模擬環境中僅僅是個形式而已,為了以後的順利安裝,不得不配置它
2、調整內核網絡設置參數
編輯/etc/sysctl.conf,增加下面的設置:
vi /etc/sysctl.conf
# Default setting in bytes of the socket receive buffer
net.core.rmem_default=262144
# Default setting in bytes of the socket send buffer
net.core.wmem_default=262144
# Maximum socket receive buffer size which may be set by using
# the SO_RCVBUF socket option
net.core.rmem_max=262144
# Maximum socket send buffer size which may be set by using
# the SO_SNDBUF socket option
net.core.wmem_max=262144
3、添加模塊選項:
將下列行添加到 /etc/modules.conf 中:
options sbp2 sbp2_exclusive_login=0
4、創建“oracle”用戶和目錄
$su -
#groupadd dba
#useradd -g dba -m oracle
#passwd oracle
5、編輯.bash_profile文件,增加oracle環境變量
$vi .bash_profile
export PATH
unset USERNAME
export LANG=zh_CN.EUC
ORACLE_BASE=/home/oracle;export ORACLE_BASE
export ORACLE_HOME=$ORACLE_BASE/product/10.1.0/db_1
export ORA_CRS_HOME=$ORACLE_BASE/product/10.1.0/crs_1
export ORACLE_SID=rac1
export NLS_LANG='SIMPLIFIED CHINESE_CHINA.ZHS16GBK'
PATH=$ORACLE_HOME/bin:/bin:/sbin:/usr/bin:/usr/ccs/bin:/usr/local/bin:/usr/ucb;export PATH
LD_LIBRARY_PATH=$ORACLE_HOME/lib:$ORACLE_HOME/network/lib:$ORACLE_HOME/oracm/lib:/usr/local/lib:/usr/lib;export LD_LIBRARY_PATH
export ORACLE_TERM=xterm
export CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib:$ORACLE_HOME/rdbms/jlib:$ORACLE_HOME/network/jlib
export THREADS_FLAG=native
export TEMP=/tmp
export TMPDIR=/tmp
export LD_ASSUME_KERNEL=2.4.1
6、創建CRS分區和數據文件分區
1)先建立CRS分區掛載點
mkdir /u01
chown oracle:dba /u01
2)接著創建CRS分區和共享數據文件分區
fdisk /dev/hda
CRS分區只要500M就夠了,剩下的全部劃分給數據文件分區,這裡為數據文件只分了1個區/dev/hda9
CRS分區為/dev/hda8
[root@dbrac root]# fdisk /dev/hda
The number of cylinders for this disk is set to 4997.
[root@dbrac root]# fdisk /dev/hda
The number of cylinders for this disk is set to 4997.


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)
Command (m for help): p
Disk /dev/hda: 41.1 GB, 41109061120 bytes
255 heads, 63 sectors/track, 4997 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/hda1 * 1 131 1052226 83 Linux
/dev/hda2 132 1151 8193150 83 Linux
/dev/hda3 1152 1916 6144862+ 83 Linux
/dev/hda4 1917 4998 24756165 f Win95 Ext'd (LBA)
/dev/hda5 1917 2177 2096451 83 Linux
/dev/hda6 2178 2438 2096451 82 Linux swap
/dev/hda7 2439 2569 1052226 83 Linux
Command (m for help): n
First cylinder (2570-4998, default 2570):
Using default value 2570
Last cylinder or +size or +sizeM or +sizeK (2570-4998, default 4998): +500M
Command (m for help): n
First cylinder (2632-4998, default 2632):
Using default value 2632
Last cylinder or +size or +sizeM or +sizeK (2632-4998, default 4998): +15000M
Command (m for help): p
Disk /dev/hda: 41.1 GB, 41109061120 bytes
255 heads, 63 sectors/track, 4997 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/hda1 * 1 131 1052226 83 Linux
/dev/hda2 132 1151 8193150 83 Linux
/dev/hda3 1152 1916 6144862+ 83 Linux
/dev/hda4 1917 4998 24756165 f Win95 Ext'd (LBA)
/dev/hda5 1917 2177 2096451 83 Linux
/dev/hda6 2178 2438 2096451 82 Linux swap
/dev/hda7 2439 2569 1052226 83 Linux
/dev/hda8 2570 2631 497983+ 83 Linux
/dev/hda9 2632 4456 14659281 83 Linux
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
WARNING: Re-reading the partition table failed with error 16: 設備或資源忙.
The kernel still uses the old table.
The new table will be used at the next reboot.
Syncing disks.
7、編輯/etc/sysctl.conf,增加下面2行以設置系統共享內存大小和文件句柄
kernel.shmmax=2147483648
kernel.sem=250 32000 100 128
本文涉及到的linux操作系統的內核參數默認設置大多符合oracle安裝所需,不需要做更大的改動
8、配置 hangcheck-timer 內核模塊
在/etc/modules.conf中增加下面一行
options hangcheck-timer hangcheck_tick=30 hangcheck_margin=180
為了確保系統每次重新啟動的時候都能自動加載hangcheck-timer 模塊,需要在/etc/rc.local文件中增加下面一行
echo “modprobe hangcheck-timer” >;>; /etc/rc.local
重啟系統並檢查hangcheck-timer模塊是否已經加載
[root@dbrac root]# lsmod grep hangcheck-timer
hangcheck-timer 2616 0 (unused)
9、配置 RAC 節點以進行遠程訪問
在 RAC 節點上運行 Oracle Universal Installer 時,它將使用 rsh 、rcp或scp命令將 Oracle 軟件復制到 RAC 集群中的所有其他節點。雖然是單機模擬,但仍然要配置,無法跳過,從oracle 10g開始已經支持ssh協議,本文將首先嘗試使用它
使用oracle用戶創建ssh公共密匙:
[oracle@dbrac oracle]$ ssh-keygen -t dsa
Generating public/private dsa key pair.
Enter file in which to save the key (/home/oracle/.ssh/id_dsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/oracle/.ssh/id_dsa.


Your public key has been saved in /home/oracle/.ssh/id_dsa.pub.
The key fingerprint is:
2d:09:9a:c0:40:c7:99:46:ea:43:0d:22:4b:d0:a0:26 oracle@dbrac
復制公匙到其他節點(這裡是單機)
[oracle@dbrac oracle]$ cp -v .ssh/id_dsa.pub .ssh/authorized_keys
測試密匙是否生效
[oracle@dbrac oracle]$ ssh dbrac
The authenticity of host 'dbrac (192.168.22.44)' can't be established.
RSA key fingerprint is e7:ff:ce:5e:92:ac:c4:96:a8:ca:3e:20:2e:5c:75:ae.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'dbrac,192.168.22.44' (RSA) to the list of known hosts.
[oracle@dbrac oracle]$
無需密碼即可登陸表示密匙已經生效
10、安裝和配置 OCFS
OCFS是Oracle 集群文件系統 (OCFS),由 Oracle 開發,用於消除數據庫管理員和系統管理員管理原始設備這一負擔,它提供了與通常的文件系統相同的功能和用法。盡量不要在OCFS文件系統上使用linux二進制文件系統操作命令
在目前的版本1種支持以下文件類型:
Oracle 數據庫文件
聯機重做日志文件
歸檔重做日志文件
控制文件
服務器參數文件 (SPFILE)
Oracle 集群注冊表 (OCR) 文件
CRS 表決磁盤。

安裝和配置
1)上傳ocfs-2.4.21-EL-1.0.14-1.i686.rpm,ocfs-support-1.0.10-1.i386.rpm,ocfs-tools-1.0.10-1.i386.rpm到/home/oracle/install/rac/ocfs目錄
2)執行rpm -ivh ocfs*.rpm 開始安裝
[oracle@dbrac oracle]$ su -
PassWord:
[root@dbrac root]# cd /home/oracle/install/rac/ocfs
[root@dbrac ocfs]# rpm -ivh ocfs*.rpm
Preparing... ########################################### [100%]
1 ocfs-support ########################################### [ 33%]
2 ocfs-2.4.21-EL ########################################### [ 67%]
3 ocfs-tools ########################################### [100%]
3)生成並配置/etc/ocfs.conf文件
root@dbrac ocfs]# ocfstool &
4)使用 ocfstool GUI 工具執行以下步驟:
5)選擇 [Task] - [Generate Config]
在“OCFS Generate Config”對話框中,輸入專用互連的接口和 DNS 名。
驗證所有節點上的所有值正確之後,請退出應用程序
6)檢查/etc/ocfs.conf
[root@dbrac ocfs]# cat /etc/ocfs.conf
#
# ocfs config
# Ensure this file exists in /etc
#
node_name = dbrac
ip_address = 192.168.22.44
ip_port = 7000
comm_voting = 1
guid = B907DC7945D81C0A2C8C000D61EB0166
注意guid在集群中唯一對應一個節點,如果要更換網卡,請使用ocfs_uid_gen -c 命令重新創建
7)重新啟動系統並確認ocfs模塊已經正確加載
[oracle@dbrac oracle]$ lsmod grep ocfs
ocfs 299104 0 (unused)
8)創建 OCFS 文件系統
[oracle@dbrac oracle]$ id
uid=500(oracle) gid=500(dba) groups=500(dba)
[oracle@dbrac oracle]$ su -
Password:
[root@dbrac root]# mkfs.ocfs -F -b 128 -L crs -m /u01 -u '500' -g '500' -p 0775 /dev/hda8
Cleared volume header sectors
Cleared node config sectors
Cleared publish sectors
Cleared vote sectors
Cleared bitmap sectors
Cleared data block
Wrote volume header
注意-u和-g 是oracle用戶的id和dba組的id,一定要填寫正確,-p是設置/u01目錄的訪問權限,如果要設置dba組用戶有權管理集群注冊文件的話,請設置0775
9)載入 OCFS 文件系統
$ su -
# mount -t ocfs /dev/hda8 /u01
10)將 OCFS分區配置為在啟動時自動載入
11)將以下條目添加到/etc/fstab 文件中
/dev/hda8 /u01 ocfs _netdev 0 0
12)重新啟動服務器並檢查CRS分區已經正確安裝
[root@dbrac root]# mount grep ocfs


/dev/hda8 on /u01 type ocfs (rw)
如果沒有被自動加載,請執行如下命令echo “mount -t ocfs /dev/hda8 /u01” >;>; /etc/rc.local,然後重新啟動
也可用使用oracle官方為我們提供的打過補丁的linux內核來解決此問題
11、安裝並配置自動存儲管理和磁盤
Oracle 數據庫 10g 中引入了 ASM,使管理員不必再管理單個文件和驅動器,ASM 被內置到 Oracle 內核中,通過它,數據庫管理員可以全天候管理單個實例以及集群實例的上千個磁盤驅動器。本文將使用ASM來自動存儲和管理所有 Oracle 物理數據庫文件(數據、聯機重做日志、控制文件、歸檔重做日志)。
oracle不推薦使用裸設備,因此這裡使用前面創建的/dev/hda9分區
1)上傳oracleasm-2.4.21-EL-1.0.3-1.i686.rpm,oracleasmlib-1.0.0-1.i386.rpm, oracleasm-support-1.0.3-1.i386.rpm三個軟件包到/home/oracle/install/rac/asm目錄中, 開始安裝:
[oracle@dbrac asmlib]$ su -
Password:
[root@dbrac root]# cd /home/oracle/install/rac/asmlib
[root@dbrac asmlib]# rpm -ivh oracleasm*.rpm
Preparing... ########################################### [100%]
1 oracleasm-support ########################################### [ 33%]
2 oracleasm-2.4.21-EL ########################################### [ 67%]
3 oracleasmlib ########################################### [100%]
2)配置並加載 ASMLib 程序包
[root@dbrac 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 <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) [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 ]
為 Oracle 共享數據文件創建 ASM 磁盤
[root@dbrac asmlib]# /etc/init.d/oracleasm createdisk oradata /dev/hda9
Marking disk "/dev/hda9" as an ASM disk [ OK ]
其中oradata是ASM磁盤的卷標
列出ASM磁盤的命令是/etc/init.d/oracleasm listdisks
刪除ASM磁盤得命令是/etc/init.d/oracleasm deltedisk ORADATA(注意:此處大寫)
/etc/init.d/oraclerasm scandisk命令用於其它節點上掃描並識別新卷,由於此處是單機,所以這裡不需要執行。
五、安裝oracle 10g集群服務軟件
從這裡開始,建議所有的安裝過程全部使用英文界面安裝,在簡體中文環境下安裝會有問題,如果安裝操作系統的時候選擇了默認語言為簡體中文,請更改/etc/sysconfig/i18n文件中LANG的值,然後重新登陸系統。
LANG="en_US.UTF-8"
在附錄本文會給出全中文環境數據庫安裝解決方案
1)上傳ship.crs.lnx32.cpio.gz到/home/oracle/install/rac目錄中並解壓縮;
gzip -dv ship.crs.lnx32.cpio.gz;cpio -idmv <ship.crs.lnx32.cpio
2)在安裝過程中oracle 10g集群服務軟件會在CRS分區創建2個文件,分別是/u01/orcl/ocrfile和/u01/orcl/cssfile,相當重要,不能跳過;檢查/tmp目錄是否有足夠的空間,必須保證/tmp目錄有500M以上空余空間;
3)更改oracle用戶環境變量;
unset ORA_CRS_HOME
$ unset ORACLE_HOME


$ unset ORA_NLS33
$ unset TNS_ADMIN
4)轉到安裝源文件目錄/home/oracle/install/rac/Disk1目錄,執行./runInstaller &開始安裝;
屏幕名稱
回應
Welcome Screen
單擊 Next
Specify Inventory Directory and credentials
接受默認值
Root Script Window - Run orainstRoot.sh
以“root”用戶帳戶打開一個新的控制台窗口。改變目錄到/home/oracle/oraInventory 目錄,運行 orainstRoot.sh。 返回 OUI 並確認此對話框窗口。
Specify File Locations
Source 目錄使用默認值;Name: OraCrs10g_home1;Location:/home/oracle/product/10.1.0/crs_1
Language Selection
請使用English,可以加入簡體中文支持
Cluster Configuration
Cluster Name: crs;
Public Node Name:dbrac Private Node Name:int-dbrac
Specify Network Interface Usage
使用默認
Oracle Cluster Registry
/u01/orcl/ocrfile
Voting Disk
/u01/orcl/cssfile
Root Script Window - Run orainstRoot.sh
以“root”用戶帳戶打開一個新的控制台窗口。轉到/home/oracle/product/10.1.0/crs_1目錄,運行root.sh。 返回 OUI 並確認此對話框窗口。



5)核實CRS安裝
a)檢查集群節點
[oracle@dbrac oracle]$ product/10.1.0/crs_1/bin/olsnodes -n
dbrac 1
a)檢查CRS自啟動腳本
[oracle@dbrac oracle]$ ll /etc/init.d/init.*
-r-xr-xr-x 1 root root 1204 May 10 16:54 /etc/init.d/init.crs
-r-xr-xr-x 1 root root 5489 May 10 16:54 /etc/init.d/init.crsd
-r-xr-xr-x 1 root root 18598 May 10 16:54 /etc/init.d/init.cssd
-r-xr-xr-x 1 root root 4550 May 10 16:54 /etc/init.d/init.evmd
六、安裝 Oracle 10g數據庫軟件
1)上傳ship.db.lnx32.cpio.gz至/home/oracle/install目錄並解壓
gzip -dv ship.db.lnx32.cpio.gz && cpio -idmv < ship.db.lnx32.cpio
2)更改oracle用戶環境變量
unset ORA_CRS_HOME
$ unset ORACLE_HOME
$ unset ORA_NLS33
$ unset TNS_ADMIN

3)執行./runInstaller開始安裝
屏幕名稱
回應
Welcome Screen
選擇高級安裝
Specify File Locations
Name: OraDb10g_home1
Location:/home/oracle/product/10.1.0/db_1
Specify Hardware Cluster Installation Mode
默認dbrac
Select Installation Type
選擇Enterprise Edition 選項
Select Database Configuration
選擇Do not create a starter database (必須選這個)
Root Script Window - Run root.sh
以“root”用戶帳戶打開一個新的控制台窗口。轉到/home/oracle/product/10.1.0/db_1目錄,運行root.sh程序。
當 VIPCA 出現時,請回應如下所示的屏幕提示:
Welcome: 單擊 Next
Network interfaces:選擇接口 - eth0
Virtual IPs for cluster notes:
Node Name:dbrac
IP Alias Name:vip-dbrac
IP Address:192.168.22.244
Subnet Mask: 255.255.255.0
注意:如果在安裝操作系統的時候選擇了默認語言支持是簡體中文,請在執行root.sh之前先取消root中文環境設置,命令export LANG=zh_CN.EUC
End of installation
安裝結束時,退出 OUI



七、創建 TNS 監聽器進程
DBCA 需要在 RAC 集群的所有節點上配置並運行 Oracle TNS 監聽器進程,然後它才能創建集群化數據庫。
$export LANG=zh_CN.EUC
$ netca &
屏幕名稱
回應
Select the Type of Oracle
Net Services Configuration
選擇 Cluster Configuration
Select the nodes to configure
選擇節點dbrac
Listener Configuration - Next 6 Screens
接下來全部選擇默認,然後返回到Select the Type of Oracle Net Services Configuration
Type of Configuration
選擇 Naming Methods configuration。
Naming Methods Configuration
Selected Naming Methods: Local Naming


Type of Configuration
單擊 Finish 退出 NETCA。


測試
[oracle@dbrac oracle]$ ps -ef grep lsnr grep -v 'grep' grep -v 'ocfs' awk '{print $9}'
LISTENER_DBRAC
八、創建oracle集群數據庫
1)在執行 DBCA 前,請確保為 $ORACLE_BASE/product/10.1.0/db_1 環境正確設置了 $ORACLE_HOME 和 $PATH。
2)在試圖開始創建集群化數據庫之前,還應確保已安裝的所有服務(Oracle TNS 監聽器、CRS 進程等)正在運行。
屏幕名稱
回應
Welcome Screen
選擇 Oracle Real Application Clusters database。
Operations
選擇 Create a Database
Node Selection
選擇dbrac
Database Templates
選擇 Custom Database
Database Identification
Global Database Name: orcl
SID Prefix: orcl
Management Option
保留默認
Database Credentials
選擇 Use the Same Password for All Accounts,並輸入兩次密碼
Storage Options
選擇使用 ASM
Create ASM Instance
推薦選擇spfile
ASM Disk Groups
單擊 Create New創建ASM,在彈出的Create Disk Group窗口中,Disk Group Name: orcl_data;選擇“Select Member Disks”窗口中的ASM 卷ORCL:ORADATA,並確保狀態為PROVISIONED,最後單擊ok完成,如果不能格式化,請選擇redundancy為external
Database File Locations
選擇使用默認值Oracle Managed Files
Database Area: +ORCL_DATA
Recovery Configuration
選擇默認Flash Recovery Area,如果要使用傳統歸檔方式,請選擇Enable Archiving
Database Content
本文為了加快安裝速度,去掉了所有組件支持,僅保留了Enterprise Manager Repository
Database Services
單擊 Add,輸入 orcltest 作為“Service Name”。
TAF Policy選Basic
Initialization Parameters
保留默認
Database Storage
保留默認
Creation Options
選擇默認
End of Database Creation
退出DBCA

3)完成DBCA後,一個單節點集群的oracle數據庫服務器已經成功創建了
4)核實orcltest服務
SQL>; show parameter service
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
service_names string orcl, orcltest
如果value只有一個值orcl,則需要手工添加orcltest
SQL>; alter system set service_names ='orcl, orcltest' scope=spfile;
九、測試集群
先檢查VIP是否已經啟動
[oracle@dbrac oracle]$ ifconfig eth0:1
eth0:1 Link encap:Ethernet HWaddr 00:0D:61:EB:01:66
inet addr:192.168.22.244 Bcast:192.168.22.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
Interrupt:11 Base address:0xc000
從外部客戶端連接集群化數據庫
在裝有oracle 10g 客戶端的pc上執行下面的命令進行連接測試,客戶端需要配置TNS,配置的時候把服務名指定為orcltest,數據庫服務器IP使用VIP(192.168.22.244)
C:\Documents and Settings\Administrator>;sqlplus /nolog
SQL*Plus: Release 10.1.0.2.0 - Production on 星期三 5月 11 13:24:34 2005
Copyright (c) 1982, 2004, Oracle. All rights reserved.
SQL>; connect sys/racrac@orcltest as sysdba
已連接。

在服務器上執行下面的命令
[oracle@dbrac oracle]$ srvctl status database -d orcl
例程 orcl1 正在節點 dbrac 上運行

[oracle@dbrac oracle]$ srvctl status nodeapps -n dbrac
VIP 正在運行的節點: dbrac
GSD 正在運行的節點: dbrac
監聽程序正在節點上運行: dbrac
ONS 守護程序正在節點上運行:dbrac
[oracle@dbrac oracle]$ srvctl status asm -n dbrac
ASM 例程 +ASM1 正在節點 dbrac 上運行。

顯示數據庫配置
[oracle@dbrac oracle]$ srvctl config database -d orcl
dbrac orcl1 /home/oracle/product/10.1.0/db_1
scrctl命令還有很多測試功能,這裡不再一一介紹



十、啟動和停止集群
這裡很重要,和一般的非集群數據庫的啟動和關閉有點不同.
1)停止 Oracle RAC 10g 環境
先停止 Oracle 實例。當此實例(和相關服務)關閉後,關閉 ASM 實例。最後,關閉節點應用程序(虛擬 IP、GSD、TNS 監聽器和 ONS)。
$ export ORACLE_SID=orcl1
$ emctl stop dbconsole
$ srvctl stop instance -d orcl -i orcl1
$ srvctl stop asm -n dbrac
$ srvctl stop nodeapps -n dbrac
2)啟動 Oracle RAC 10g 環境
第一步是啟動節點應用程序(虛擬 IP、GSD、TNS 監聽器和 ONS)。當成功啟動節點應用程序後,啟動 ASM 實例。最後,啟動 Oracle 實例(和相關服務)以及企業管理器數據庫控制台。
$ export ORACLE_SID=orcl1
$ srvctl start nodeapps -n dbrac
$ srvctl start asm -n dbrac
$ srvctl start instance -d orcl -i orcl1
$ emctl start dbconsole
3)使用 SRVCTL 啟動/停止所有實例
$ srvctl start database -d orcl
$ srvctl stop database -d orcl

附錄、全中文數據庫環境安裝解決方法
更改oracle用戶的環境變量export LANG=zh_CN並轉到/home/oracle/install/Disk1目錄下執行如下代碼
cd stage/Components/oracle.swd.jre/1.4.2.02.0/1/DataFiles && unzip all_except_bin.jar && cd jre/1.4.2/lib && mv -v font.properties font.properties.bak && cp -v font.properties.zh_CN.Redhat8.0 font.properties && cd ../../../;zip -r all_except_bin.jar.new jre/;mv all_except_bin.jar.new all_except_bin.jar && rm -rfv jre && cd ../../../../../../
cd stage/Components/oracle.jdk/1.4.2.0.0/1/DataFiles && unzip -d sol_bin sol_bin.1.1.jar && cd sol_bin;cp -v font.properties font.properties.bak;cp -v font.properties.Redhat8.0 font.properties;zip -r ../sol_bin.1.1.jar * && cd ..;rm -rfv sol_bin && cd ../../../../../../



例程 orcl1 正在節點 dbrac 上運行

[oracle@dbrac oracle]$ srvctl status nodeapps -n dbrac
VIP 正在運行的節點: dbrac
GSD 正在運行的節點: dbrac
監聽程序正在節點上運行: dbrac
ONS 守護程序正在節點上運行:dbrac
[oracle@dbrac oracle]$ srvctl status asm -n dbrac
ASM 例程 +ASM1 正在節點 dbrac 上運行。

顯示數據庫配置
[oracle@dbrac oracle]$ srvctl config database -d orcl
dbrac orcl1 /home/oracle/product/10.1.0/db_1
scrctl命令還有很多測試功能,這裡不再一一介紹

十、啟動和停止集群
這裡很重要,和一般的非集群數據庫的啟動和關閉有點不同.
1)停止 Oracle RAC 10g 環境
先停止 Oracle 實例。當此實例(和相關服務)關閉後,關閉 ASM 實例。最後,關閉節點應用程序(虛擬 IP、GSD、TNS 監聽器和 ONS)。
$ export ORACLE_SID=orcl1
$ emctl stop dbconsole
$ srvctl stop instance -d orcl -i orcl1
$ srvctl stop asm -n dbrac
$ srvctl stop nodeapps -n dbrac
2)啟動 Oracle RAC 10g 環境
第一步是啟動節點應用程序(虛擬 IP、GSD、TNS 監聽器和 ONS)。當成功啟動節點應用程序後,啟動 ASM 實例。最後,啟動 Oracle 實例(和相關服務)以及企業管理器數據庫控制台。
$ export ORACLE_SID=orcl1
$ srvctl start nodeapps -n dbrac
$ srvctl start asm -n dbrac
$ srvctl start instance -d orcl -i orcl1
$ emctl start dbconsole
3)使用 SRVCTL 啟動/停止所有實例
$ srvctl start database -d orcl
$ srvctl stop database -d orcl

附錄、全中文數據庫環境安裝解決方法
更改oracle用戶的環境變量export LANG=zh_CN並轉到/home/oracle/install/Disk1目錄下執行如下代碼
cd stage/Components/oracle.swd.jre/1.4.2.02.0/1/DataFiles && unzip all_except_bin.jar && cd jre/1.4.2/lib && mv -v font.properties font.properties.bak && cp -v font.properties.zh_CN.Redhat8.0 font.properties && cd ../../../;zip -r all_except_bin.jar.new jre/;mv all_except_bin.jar.new all_except_bin.jar && rm -rfv jre && cd ../../../../../../
cd stage/Components/oracle.jdk/1.4.2.0.0/1/DataFiles && unzip -d sol_bin sol_bin.1.1.jar && cd sol_bin;cp -v font.properties font.properties.bak;cp -v font.properties.Redhat8.0 font.properties;zip -r ../sol_bin.1.1.jar * && cd ..;rm -rfv sol_bin && cd ../../../../../../



Copyright © Linux教程網 All Rights Reserved