作者:daniey MSN:danieyren@hotmail.com
申明:請珍惜作者勞動,如需要轉(zhuǎn)載,請注明出處
本文是在參考o(jì)racle 10g 雙機集群的基礎(chǔ)上通過實踐并且精簡而得,撰寫本文的目的是為了方便大家探討技術(shù),相信本文仍有許多不足之處
參考文檔:
http://www.oracle.com/technology/global/cn/pub/articles/hunter_rac10g.html注:對于與多機多節(jié)點集群相同的地方,文中將直接引用參考文檔相關(guān)部分
一、簡介
熟悉 Oracle 真正應(yīng)用集群 (RAC) 10g 技術(shù)的最有效方法之一是訪問一個實際的 Oracle RAC 10g 集群。沒有什么方法比直接體驗它們能夠更好地理解其好處的了 — 包括容錯、安全性、負(fù)載均衡和可伸縮性。
Oracle RAC 的核心是共享磁盤子系統(tǒng)。集群中的所有節(jié)點必須能夠訪問集群中所有節(jié)點的所有數(shù)據(jù)、重做日志文件、控制文件和參數(shù)文件。數(shù)據(jù)磁盤必須在全局范圍內(nèi)可用,以便允許所有節(jié)點訪問數(shù)據(jù)庫。每個節(jié)點擁有自己的重做日志和控制文件,但是其他節(jié)點必須能夠訪問這些文件,以便在系統(tǒng)故障時恢復(fù)該節(jié)點。
希望本文能對一些手頭上只有一臺PC而沒有真正的雙機環(huán)境的朋友提供一個參考。
二、本文實踐環(huán)境
1、PC主要配置:
Celeron(R) CPU 1.80GHz
Maxtor 6E040L0, ATA DISK drive 40G
RelTek 8139C 網(wǎng)卡 一塊
內(nèi)存DDR333 512MB * 2
顯示卡:ATI [Radeon 9200 SE]
操作系統(tǒng)
:White Box Enterprise Linux 3 (本文同樣適用于RedHat企業(yè)版,不同之處是WBEL3目前可以免費運用于商業(yè))遠(yuǎn)程終端一臺,裝有windowsXP和遠(yuǎn)程X-server軟件2、服務(wù)器分區(qū)方案
Oracle 數(shù)據(jù)庫文件
RAC節(jié)點名
實例名
數(shù)據(jù)庫名
$ORACLE_BASE
文件系統(tǒng)
dbrac
orcl1
orcl
/home/oracle
ASM
Oracle CRS 共享文件
文件類型
文件名
分區(qū)
掛載點
文件系統(tǒng)
oracle集群注冊表
/u01/orcl/orcfile
/dev/hda8
/u01
OCFS
CRS表決磁盤
/u01/orcl/cssfile
/dev/hda8
/u01
OCFS
3、所涉及軟件
1) oracle 10g 數(shù)據(jù)庫軟件
ship.db.lnx32.cpio.gz
2) oracle 10g 集群服務(wù)軟件
ship.crs.lnx32.cpio.gz
3) OCFS文件系統(tǒng)支持
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驅(qū)動程序
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官方網(wǎng)站下載
WBEL linux下載地址:http://www.whiteboxlinux.org/download.html
三、基礎(chǔ)操作
1、安裝linux
安裝過程中一些需要注意的地方:
1) 磁盤分區(qū):swap分區(qū)大小建議是內(nèi)存的2倍,這里是2048MB,劃出一些系統(tǒng)必要的分區(qū)根分區(qū)/,var分區(qū)/var,usr分區(qū)/usr,home分區(qū)/home,臨時文件分區(qū)/tmp。注意:這里不要把所有的硬盤空間劃分進操作系統(tǒng),留下一半給后面安裝oarcle集群磁盤使用,本文示例
2) 文件系統(tǒng) 容量 掛載點
/dev/hda1 1012M /
/dev/hda2 7.7G /home
/dev/hda7 1012M /tmp
/dev/hda3 5.8G /usr
/dev/hda5 2.0G /var
3) 組件選?。阂欢ㄒx上delvelopment tools和X-windows兩項,為了節(jié)省空間其他可以不要
4) 防火墻:最好不要
5) 網(wǎng)絡(luò)設(shè)置:eth0
取消選中 [Configure using DHCP] 復(fù)選項
選中 [Activate on boot]
IP 地址:192.168.22.44
網(wǎng)絡(luò)掩碼: 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
四、設(shè)置
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節(jié)點名沒有出現(xiàn)在回送地址中。
此處設(shè)置相當(dāng)重要,不能跳過,一定按照此設(shè)置,IP和主機別名可以自己定
oracle 10g RAC中 使用了虛擬IP(VIP)技術(shù),這是一個令人心動的高可用性、多機無縫切換的解決方案,但在單機模擬環(huán)境中僅僅是個形式而已,為了以后的順利安裝,不得不配置它
2、調(diào)整內(nèi)核網(wǎng)絡(luò)設(shè)置參數(shù)
編輯/etc/sysctl.conf,增加下面的設(shè)置:
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、創(chuàng)建“oracle”用戶和目錄
$su -
#groupadd dba
#useradd -g dba -m oracle
#passwd oracle
5、編輯.bash_profile文件,增加oracle環(huán)境變量
$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、創(chuàng)建CRS分區(qū)和數(shù)據(jù)文件分區(qū)
1) 先建立CRS分區(qū)掛載點
mkdir /u01
chown oracle:dba /u01
2) 接著創(chuàng)建CRS分區(qū)和共享數(shù)據(jù)文件分區(qū)
fdisk /dev/hda
CRS分區(qū)只要500M就夠了,剩下的全部劃分給數(shù)據(jù)文件分區(qū),這里為數(shù)據(jù)文件只分了1個區(qū)/dev/hda9
CRS分區(qū)為/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: 設(shè)備或資源忙.
The kernel still uses the old table.
The new table will be used at the next reboot.
Syncing disks.
7、編輯/etc/sysctl.conf,增加下面2行以設(shè)置系統(tǒng)共享內(nèi)存大小和文件句柄
kernel.shmmax=2147483648
kernel.sem=250 32000 100 128
本文涉及到的linux操作系統(tǒng)的內(nèi)核參數(shù)默認(rèn)設(shè)置大多符合oracle安裝所需,不需要做更大的改動
8、配置 hangcheck-timer 內(nèi)核模塊
在/etc/modules.conf中增加下面一行
options hangcheck-timer hangcheck_tick=30 hangcheck_margin=180
為了確保系統(tǒng)每次重新啟動的時候都能自動加載hangcheck-timer 模塊,需要在/etc/rc.local文件中增加下面一行
echo “modprobe hangcheck-timer” >> /etc/rc.local
重啟系統(tǒng)并檢查hangcheck-timer模塊是否已經(jīng)加載
[root@dbrac root]# lsmod | grep hangcheck-timer
hangcheck-timer 2616 0 (unused)
9、配置 RAC 節(jié)點以進行遠(yuǎn)程訪問
在 RAC 節(jié)點上運行 Oracle Universal Installer 時,它將使用 rsh 、rcp或scp命令將 Oracle 軟件復(fù)制到 RAC 集群中的所有其他節(jié)點。雖然是單機模擬,但仍然要配置,無法跳過,從oracle 10g開始已經(jīng)支持ssh協(xié)議,本文將首先嘗試使用它
使用oracle用戶創(chuàng)建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復(fù)制公匙到其他節(jié)點(這里是單機)
[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]$
無需密碼即可登陸表示密匙已經(jīng)生效
10、安裝和配置 OCFS
OCFS是Oracle 集群文件系統(tǒng) (OCFS),由 Oracle 開發(fā),用于消除數(shù)據(jù)庫管理員和系統(tǒng)管理員管理原始設(shè)備這一負(fù)擔(dān),它提供了與通常的文件系統(tǒng)相同的功能和用法。盡量不要在OCFS文件系統(tǒng)上使用linux二進制文件系統(tǒng)操作命令
在目前的版本1種支持以下文件類型:
· Oracle 數(shù)據(jù)庫文件
· 聯(lián)機重做日志文件
· 歸檔重做日志文件
· 控制文件
· 服務(wù)器參數(shù)文件 (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) 執(zhí)行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 工具執(zhí)行以下步驟:
5) 選擇 [Task] - [Generate Config]
在“OCFS Generate Config”對話框中,輸入專用互連的接口和 DNS 名。
驗證所有節(jié)點上的所有值正確之后,請退出應(yīng)用程序
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在集群中唯一對應(yīng)一個節(jié)點,如果要更換網(wǎng)卡,請使用ocfs_uid_gen -c 命令重新創(chuàng)建
7) 重新啟動系統(tǒng)并確認(rèn)ocfs模塊已經(jīng)正確加載
[oracle@dbrac oracle]$ lsmod | grep ocfs
ocfs 299104 0 (unused)
8) 創(chuàng)建 OCFS 文件系統(tǒng)
[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是設(shè)置/u01目錄的訪問權(quán)限,如果要設(shè)置dba組用戶有權(quán)管理集群注冊文件的話,請設(shè)置0775
9) 載入 OCFS 文件系統(tǒng)
$ su -
# mount -t ocfs /dev/hda8 /u01
10) 將 OCFS分區(qū)配置為在啟動時自動載入
11) 將以下條目添加到/etc/fstab 文件中
/dev/hda8 /u01 ocfs _netdev 0 0
12) 重新啟動服務(wù)器并檢查CRS分區(qū)已經(jīng)正確安裝
[root@dbrac root]# mount | grep ocfs
/dev/hda8 on /u01 type ocfs (rw)
如果沒有被自動加載,請執(zhí)行如下命令echo “mount -t ocfs /dev/hda8 /u01” >> /etc/rc.local,然后重新啟動
也可用使用oracle官方為我們提供的打過補丁的linux內(nèi)核來解決此問題
11、安裝并配置自動存儲管理和磁盤
Oracle 數(shù)據(jù)庫 10g 中引入了 ASM,使管理員不必再管理單個文件和驅(qū)動器,ASM 被內(nèi)置到 Oracle 內(nèi)核中,通過它,數(shù)據(jù)庫管理員可以全天候管理單個實例以及集群實例的上千個磁盤驅(qū)動器。本文將使用ASM來自動存儲和管理所有 Oracle 物理數(shù)據(jù)庫文件(數(shù)據(jù)、聯(lián)機重做日志、控制文件、歸檔重做日志)。
oracle不推薦使用裸設(shè)備,因此這里使用前面創(chuàng)建的/dev/hda9分區(qū)
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 共享數(shù)據(jù)文件創(chuàng)建 ASM 磁盤
[root@dbrac asmlib]# /etc/init.d/oracleasm createdisk oradata /dev/hda9
Marking disk "/dev/hda9" as an ASM disk [ OK ]
其中oradata是ASM磁盤的卷標(biāo)
列出ASM磁盤的命令是/etc/init.d/oracleasm listdisks
刪除ASM磁盤得命令是/etc/init.d/oracleasm deltedisk ORADATA(注意:此處大寫)
/etc/init.d/oraclerasm scandisk命令用于其它節(jié)點上掃描并識別新卷,由于此處是單機,所以這里不需要執(zhí)行。
五、安裝oracle 10g集群服務(wù)軟件
從這里開始,建議所有的安裝過程全部使用英文界面安裝,在簡體中文環(huán)境下安裝會有問題,如果安裝操作系統(tǒng)的時候選擇了默認(rèn)語言為簡體中文,請更改/etc/sysconfig/i18n文件中LANG的值,然后重新登陸系統(tǒng)。
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集群服務(wù)軟件會在CRS分區(qū)創(chuàng)建2個文件,分別是/u01/orcl/ocrfile和/u01/orcl/cssfile,相當(dāng)重要,不能跳過;檢查/tmp目錄是否有足夠的空間,必須保證/tmp目錄有500M以上空余空間;
3) 更改oracle用戶環(huán)境變量;
unset ORA_CRS_HOME
$ unset ORACLE_HOME
$ unset ORA_NLS33
$ unset TNS_ADMIN
4) 轉(zhuǎn)到安裝源文件目錄/home/oracle/install/rac/Disk1目錄,執(zhí)行./runInstaller &開始安裝;
屏幕名稱
回應(yīng)
Welcome Screen
單擊 Next
Specify Inventory directory and credentials
接受默認(rèn)值
Root Script Window - Run orainstRoot.sh
以“root”用戶帳戶打開一個新的控制臺窗口。改變目錄到/home/oracle/oraInventory 目錄,運行 orainstRoot.sh。 返回 OUI 并確認(rèn)此對話框窗口。
Specify File Locations
Source 目錄使用默認(rèn)值;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
使用默認(rèn)
Oracle Cluster Registry
/u01/orcl/ocrfile
Voting Disk
/u01/orcl/cssfile
Root Script Window - Run orainstRoot.sh
以“root”用戶帳戶打開一個新的控制臺窗口。轉(zhuǎn)到/home/oracle/product/10.1.0/crs_1目錄,運行root.sh。 返回 OUI 并確認(rèn)此對話框窗口。
5) 核實CRS安裝
a) 檢查集群節(jié)點
[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數(shù)據(jù)庫軟件
1) 上傳ship.db.lnx32.cpio.gz至/home/oracle/install目錄并解壓
gzip -dv ship.db.lnx32.cpio.gz && cpio -idmv < ship.db.lnx32.cpio
2) 更改oracle用戶環(huán)境變量
unset ORA_CRS_HOME
$ unset ORACLE_HOME
$ unset ORA_NLS33
$ unset TNS_ADMIN
3) 執(zhí)行./runInstaller開始安裝
屏幕名稱
回應(yīng)
Welcome Screen
選擇高級安裝
Specify File Locations
Name: OraDb10g_home1
Location:/home/oracle/product/10.1.0/db_1
Specify Hardware Cluster Installation Mode
默認(rèn)dbrac
Select Installation Type
選擇Enterprise Edition 選項
Select Database Configuration
選擇Do not create a starter database (必須選這個)
Root Script Window - Run root.sh
以“root”用戶帳戶打開一個新的控制臺窗口。轉(zhuǎn)到/home/oracle/product/10.1.0/db_1目錄,運行root.sh程序。
當(dāng) VIPCA 出現(xiàn)時,請回應(yīng)如下所示的屏幕提示:
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
注意:如果在安裝操作系統(tǒng)的時候選擇了默認(rèn)語言支持是簡體中文,請在執(zhí)行root.sh之前先取消root中文環(huán)境設(shè)置,命令export LANG=zh_CN.EUC
End of installation
安裝結(jié)束時,退出 OUI
七、創(chuàng)建 TNS 監(jiān)聽器進程
DBCA 需要在 RAC 集群的所有節(jié)點上配置并運行 Oracle TNS 監(jiān)聽器進程,然后它才能創(chuàng)建集群化數(shù)據(jù)庫。
$export LANG=zh_CN.EUC
$ netca &
屏幕名稱
回應(yīng)
Select the Type of Oracle
Net Services Configuration
選擇 Cluster Configuration
Select the nodes to configure
選擇節(jié)點dbrac
Listener Configuration - Next 6 Screens
接下來全部選擇默認(rèn),然后返回到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
八、創(chuàng)建oracle集群數(shù)據(jù)庫
1) 在執(zhí)行 DBCA 前,請確保為 $ORACLE_BASE/product/10.1.0/db_1 環(huán)境正確設(shè)置了 $ORACLE_HOME 和 $PATH。
2) 在試圖開始創(chuàng)建集群化數(shù)據(jù)庫之前,還應(yīng)確保已安裝的所有服務(wù)(Oracle TNS 監(jiān)聽器、CRS 進程等)正在運行。
屏幕名稱
回應(yīng)
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
保留默認(rèn)
Database Credentials
選擇 Use the Same Password for All Accounts,并輸入兩次密碼
Storage Options
選擇使用 ASM
Create ASM Instance
推薦選擇spfile
ASM Disk Groups
單擊 Create New創(chuàng)建ASM,在彈出的Create Disk Group窗口中,Disk Group Name:orcl_data;選擇“Select Member Disks”窗口中的ASM 卷ORCL:ORADATA,并確保狀態(tài)為PROVISIONED,最后單擊ok完成,如果不能格式化,請選擇redundancy為external
Database File Locations
選擇使用默認(rèn)值Oracle Managed Files
Database Area: +ORCL_DATA
Recovery Configuration
選擇默認(rèn)Flash Recovery Area,如果要使用傳統(tǒng)歸檔方式,請選擇Enable Archiving
Database Content
本文為了加快安裝速度,去掉了所有組件支持,僅保留了Enterprise Manager Repository
Database Services
單擊 Add,輸入 orcltest 作為“Service Name”。
TAF Policy選Basic
Initialization Parameters
保留默認(rèn)
Database Storage
保留默認(rèn)
Creation Options
選擇默認(rèn)
End of Database Creation
退出DBCA
3) 完成DBCA后,一個單節(jié)點集群的oracle數(shù)據(jù)庫服務(wù)器已經(jīng)成功創(chuàng)建了
4) 核實orcltest服務(wù)
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是否已經(jīng)啟動
[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
從外部客戶端連接集群化數(shù)據(jù)庫
在裝有oracle 10g 客戶端的pc上執(zhí)行下面的命令進行連接測試,客戶端需要配置TNS,配置的時候把服務(wù)名指定為orcltest,數(shù)據(jù)庫服務(wù)器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
已連接。
在服務(wù)器上執(zhí)行下面的命令
[oracle@dbrac oracle]$ srvctl status database -d orcl
例程 orcl1 正在節(jié)點 dbrac 上運行
[oracle@dbrac oracle]$ srvctl status nodeapps -n dbrac
VIP 正在運行的節(jié)點: dbrac
GSD 正在運行的節(jié)點: dbrac
監(jiān)聽程序正在節(jié)點上運行: dbrac
ONS 守護程序正在節(jié)點上運行:dbrac
[oracle@dbrac oracle]$ srvctl status asm -n dbrac
ASM 例程 +ASM1 正在節(jié)點 dbrac 上運行。
顯示數(shù)據(jù)庫配置
[oracle@dbrac oracle]$ srvctl config database -d orcl
dbrac orcl1 /home/oracle/product/10.1.0/db_1
scrctl命令還有很多測試功能,這里不再一一介紹
十、啟動和停止集群
這里很重要,和一般的非集群數(shù)據(jù)庫的啟動和關(guān)閉有點不同.
1) 停止 Oracle RAC 10g 環(huán)境
先停止 Oracle 實例。當(dāng)此實例(和相關(guān)服務(wù))關(guān)閉后,關(guān)閉 ASM 實例。最后,關(guān)閉節(jié)點應(yīng)用程序(虛擬 IP、GSD、TNS 監(jiān)聽器和 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 環(huán)境
第一步是啟動節(jié)點應(yīng)用程序(虛擬 IP、GSD、TNS 監(jiān)聽器和 ONS)。當(dāng)成功啟動節(jié)點應(yīng)用程序后,啟動 ASM 實例。最后,啟動 Oracle 實例(和相關(guān)服務(wù))以及企業(yè)管理器數(shù)據(jù)庫控制臺。
$ 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