oracle 11G RAC 建立詳細過程

aishu521發表於2013-10-27

好久沒有建立RAC ,以下是我10/19建立過程,希望對學習RAC 朋友有一定幫助,如有疑問,請留言,如果需要安裝相關軟體可以留言時候註明,我可以共享給大家
虛擬機器設定硬碟如下:

 注意: 在磁碟外面新增共享磁碟 需要配置比例1:1:1 ,1:2,1:3 設定
 然後在RAC2 上新增磁碟為 已經選擇存在虛擬磁碟主機增加三個空間4/4/12G 進入系統顯示為dev/sdb sdc sdd  通過fdisk -l查詢
然後進行分割槽
檔案修改 txt 開啟rac1.vmx 和rac2.vmx  增加
disk.locking="false"
scsi1.sharedBus="virtual"

以下文件測試環境如下:
vmware workstation 9.0
linux 5.5 redhat 64bit
oracle 11g R2  64bit

1,設定網路環境(各節點配置)
[root@rac1 ~]# cat /etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1        localhost.localdomain localhost
#::1            localhost6.localdomain6 localhost6

#public
192.168.1.61     rac1
192.168.1.62     rac2
#vip
192.168.1.161   rac1-vip
192.168.1.162   rac2-vip
#priv
9.9.9.61    rac1-priv
9.9.9.61    rac2-priv

#scan
192.168.1.65     rac-scan

2,新增組和使用者 (各節點配置)
[root@rac3 /]# groupadd -g 501 dba
[root@rac3 /]# useradd -u 500 -g dba oracle
[root@rac3 /]# useradd -u 502 -g dba grid

[root@rac3 ~]# passwd oracle
[root@rac3 ~]# passwd grid

配置相關路徑 (各節點配置)
[root@rac3 ~]# cd /
[root@rac3 /]# mkdir u01
[root@rac3 /]# mkdir -p /u01/app/grid
[root@rac3 /]# mkdir -p /u01/app/11.2.0/grid
[root@rac3 /]# mkdir -p /u01/app/oracle
[root@rac3 /]# chown -R grid:dba /u01
[root@rac3 /]# chown -R oracle:dba /u01/app/oracle
[root@rac3 /]# chmod 775 /u01

3,ASMLib套件安裝
  查詢OS版本 並下載ASMLib
 [root@rac3 ~]# cat /etc/redhat-release
 Red Hat Enterprise Linux Server release 5.5 (Tikanga)
 [root@rac3 ~]# uname -a
 Linux rac3 2.6.18-194.el5 #1 SMP Tue Mar 16 21:52:39 EDT 2010 x86_64 x86_64 x86_64 GNU/Linux
asmlib下載地址

 http://www.oracle.com/technetwork/server-storage/linux/downloads/rhel5-084877.html

[root@rac3 ~]# rpm -ivh oracleasm-support-2.1.8-1.el5.x86_64.rpm
  warning: oracleasm-support-2.1.8-1.el5.x86_64.rpm: Header V3 DSA signature: NOKEY, key ID 1e5e0159
  Preparing...                ########################################### [100%]
   1:oracleasm-support      ########################################### [100%]


[root@rac3 ~]# rpm -ivh oracleasm-2.6.18-194.el5-2.0.5-1.el5.x86_64.rpm
warning: oracleasm-2.6.18-194.el5-2.0.5-1.el5.x86_64.rpm: Header V3 DSA signature: NOKEY, key ID 1e5e0159
Preparing...                ########################################### [100%]
   1:oracleasm-2.6.18-194.el########################################### [100%]
[root@rac3 ~]# rpm -ivh oracleasmlib-2.0.4-1.el5.x86_64.rpm
warning: oracleasmlib-2.0.4-1.el5.x86_64.rpm: Header V3 DSA signature: NOKEY, key ID 1e5e0159
Preparing...                ########################################### [100%]
   1:oracleasmlib           ########################################### [100%]


[root@rac2 ~]# /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 []: grid
Default group to own the driver interface []: dba
Start Oracle ASM library driver on boot (y/n) [n]: y
Scan for Oracle ASM disks on boot (y/n) [y]: y
Writing Oracle ASM library driver configuration: done
Initializing the Oracle ASMLib driver:                     [  OK  ]
Scanning the system for Oracle ASMLib disks:               [  OK  ]

 注意: 在磁碟外面新增共享磁碟 需要配置比例1:1:1 ,1:2,1:3 設定
 然後在RAC2 上新增磁碟為 已經選擇存在虛擬磁碟主機增加三個空間4/4/12G 進入系統顯示為dev/sdb sdc sdd  通過fdisk -l查詢
然後進行分割槽

注意點:節點2要顯示出來,需要重啟動系統

系統啟動後 設定自動載入 ASMLib相關設定
[root@rac2 ~]# vi /etc/inittab
id:5:initdefault:
[root@rac2 rc5.d]# cd /etc/rc5.d/ 
[root@rac2 rc5.d]# ln -s /etc/init.d/oracleasm S99oracleasm
[root@rac2 rc5.d]# ln -s /etc/init.d/oracleasm K01oracleasm

3 配置ASM磁碟


[root@rac2 ~]# fdisk  /dev/sdb
 n->p->1,2,3,4->+4096M->w
 [root@rac2 ~]# fdisk -l

Disk /dev/sda: 42.9 GB, 42949672960 bytes
255 heads, 63 sectors/track, 5221 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          13      104391   83  Linux
/dev/sda2              14        5221    41833260   8e  Linux LVM

Disk /dev/sdb: 4294 MB, 4294967296 bytes
255 heads, 63 sectors/track, 522 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1         522     4192933+  83  Linux

Disk /dev/sdc: 4294 MB, 4294967296 bytes
255 heads, 63 sectors/track, 522 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdc1               1         522     4192933+  83  Linux

Disk /dev/sdd: 12.8 GB, 12884901888 bytes
255 heads, 63 sectors/track, 1566 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdd1               1        1566    12578863+  83  Linux


[root@rac2 ~]# /etc/init.d/oracleasm createdisk ASM1 /dev/sdb1
Marking disk "ASM1" as an ASM disk:                        [  OK  ]
[root@rac2 ~]# /etc/init.d/oracleasm createdisk ASM2 /dev/sdc1
Marking disk "ASM2" as an ASM disk:                        [  OK  ]
[root@rac2 ~]# /etc/init.d/oracleasm createdisk ASM3 /dev/sdd1
Marking disk "ASM3" as an ASM disk:                        [  OK  ]

[root@rac2 ~]# /etc/init.d//oracleasm scandisks

[root@rac2 ~]# /etc/init.d//oracleasm listdisks
ASM1
ASM2
ASM3

4,配置 RAC2 和RAC3 作業系統互相信任
 grid 使用者
 兩臺機子執行
[grid@rac2 ~]$ mkdir ~/.ssh
[grid@rac2 ~]$ chmod 755 ~/.ssh
[grid@rac2 ~]$ ssh-keygen -t rsa
[grid@rac2 ~]$ ssh-keygen -t dsa
使用Grid 帳號在RAC2 產生授權KEY
[grid@rac2 ~]$ cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
[grid@rac2 ~]$ cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys
[grid@rac2 ~]$ ssh rac1 cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
grid@rac3's password:
[grid@rac2 ~]$ ssh rac1 cat  ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys
grid@rac3's password:
[grid@rac2 ~]$ scp  ~/.ssh/authorized_keys rac1:~/.ssh/authorized_keys
grid@rac3's password:
authorized_keys                               100% 1980     1.9KB/s   00:00

注意一:記得chmod 755 /home/grid 兩個節點許可權一樣。

注意二:解壓Grid infrastructure 在 /home/grid/grid目錄  執行認出共享磁碟

[grid@rac2 grid]$  ./runcluvfy.sh stage -pre crsinst -n rac1,rac2 -fixup -verbose
 
[grid@rac3 grid]$  ./runcluvfy.sh stage -pre crsinst -n rac2,rac3 -fixup -verbose

對時間

[root@rac1 client]# /u01/app/11.2.0/grid/root.sh
[root@rac2 oracle]# date
2013年 10月 19日 星期六 16:44:34 CST
[root@rac2 oracle]# hwclock
2013年10月19日 星期六 16時44分50秒  -0.870728 seconds
[root@rac2 oracle]# clock --systohc
[root@rac2 oracle]# hwclock

grid@rac2 grid]$  ./runcluvfy.sh stage -pre crsinst -n rac2,rac3 -fixup -verbose

結果:"ntpd" 的活動性檢查失敗
PRVF-5415 : 檢查以確定 NTP 守護程式是否執行失敗
結果:使用網路時間協議 (NTP) 進行時鐘同步檢查失敗
gird時間同步所需要的設定(11gR2新增檢查項)

#Network Time Protocol Setting
/sbin/service ntpd stop
chkconfig ntpd off

mv /etc/ntp.conf to /etc/ntp.conf.org
rm /etc/ntp.conf

  CTSS時間同步服務配置
11gR2版本中,Oracle推出了自己的時間同步服務,這只是在一個RAC的所有節點中有效,與其他系統的時間並不同步。如果要使用CTSS同步時間,除了要停止、禁止自動重啟NTP服務外,/etc/ntp.conf配置檔案也不允許存在,執行以下的步驟清除NTP服務。
(1)停止NTP服務
/sbin/service ntpd stop
(2)禁用NTP伺服器自啟動
chkconfig ntpd off
(3)刪除或重新命名NTP配置檔案
rm /etc/ntp.conf
或者:
mv /etc/ntp.conf /etc/ntp.conf.bak
這樣就徹底清除了NTP,在安裝Grid Infrastructure的時候會自動建立CTSS。

注意三, 使用 CVU 驗證硬體和作業系統設定
[grid@rac2 grid]$./runcluvfy.sh stage -post hwos -n rac2,rac3 -verbose

5 安裝Grid infrastructure
 編輯 grid 下的.bash_profile檔案
[grid@rac2 ~]$ cat .bash_profile
# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

# User specific environment and startup programs

PATH=$PATH:$HOME/bin

export PATH
TMP=/tmp;export TMP
TMPDIR=$TMP;export TMPDIR
ORACLE_HOSTNAME=rac1; export ORACLE_HOSTNAME
ORACLE_BASE=/u01/app/grid; export ORACLE_BASE
ORACLE_HOME=/u01/app/11.2.0/grid; export ORACLE_HOME
#ORACLE_PATH=/u01/app/oracle/common/oracle/sql; export ORACLE_PATH
ORACLE_SID=+ASM1; export ORACLE_SID
ORACLE_UNQNAME=ractx; export ORACLE_UNQNAME
ORACLE_TERM=xterm; export ORACLE_TERM
PATH=/user/bin:$PATH;export PATH
PATH=$ORACLE_HOME/bin:$PATH; export PATH

LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/bin;export LD_LIBARRY_PATH
CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib;export CLASSPATH

if [ $user="oracle" ];then
  if [ $SHELL="bin/ksh" ];then
    ulimit -p 16384
    ulimit -n 65536
  else
    ulimit -u 16384 -n 65536
  fi
fi

[grid@rac2 ~]$ source .bash_profile ~~使生效
 安裝時候 注意:
  1,grid 執行安裝報錯
 Xlib: connection to ":0.0" refused by server
 Xlib: No protocol specified
 Error: Can't open display: :0.0
 解決辦法:用root登陸,在#提示符後輸入:
 xhost local:grid non-network local connections being added to access control list

  1,安裝型別選擇”高階“
  2,網格即插即用 SCAN 名稱 ”rac-scan" 輸入/etc/hosts 配置的scan名稱
  3,  輸入資料庫密碼時候,需要點提示 more 然後再輸入 Boxwei3590

 驗證CRS狀態
 [grid@rac1 ~]$ crsctl check crs
 CRS-4638: Oracle High Availability Services is online
 CRS-4537: Cluster Ready Services is online
 CRS-4529: Cluster Synchronization Services is online
 CRS-4533: Event Manager is online
確認叢集所有節點
[grid@rac1 ~]$ olsnodes -n
rac1    1
rac2    2
確認叢集各項資源和服務
[grid@rac2 ~]$ crs_stat -t -v
確認叢集的監聽狀態
[grid@rac1 ~]$ srvctl status listener
監聽程式 LISTENER 已啟用
監聽程式 LISTENER 正在節點上執行: rac1,rac2

確認ASM 在各節點執行狀態
[grid@rac1 ~]$ srvctl status asm -a
ASM 正在 rac1,rac2 上執行
ASM 已啟用。

確認OCR 註冊狀態
[grid@rac1 ~]$ ocrcheck
Status of Oracle Cluster Registry is as follows :

確認Voting Disk 的狀態
[grid@rac2 ~]$ crsctl query css votedisk
##  STATE    File Universal Id                File Name Disk group
--  -----    -----------------                --------- ---------
 1. ONLINE   5f4f2506461f4f21bfbd25696cd8bbd8 (ORCL:ASM1) [CRS]
Located 1 voting disk(s).

設定ASM
grid@rac1 ~]$ asmca


6 安裝 資料庫軟體
 配置環境變數
[oracle@rac1 ~]$ cat .bash_profile
# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

# User specific environment and startup programs

PATH=$PATH:$HOME/bin

export PATH

ORACLE_HOSTNAME=rac1;export ORACLE_HOSTNAME
ORACLE_BASE=/u01/app/oracle;export ORACLE_BASE
ORACLE_HOME=/u01/app/oracle/11.2.0;export ORACLE_HOME
ORACLE_SID=RACDB1;export ORACLE_SID
ORACLE_UNQNAME=RACDB;export ORACLE_UNQNAME
ORACLE_TERM=xterm;export ORACLE_TERM
PATTH=/usr/sbin:$PATH;export PATH
PATH=$ORACLE_HOME/bin:$PATH;export PATH

本人文件絕對原創,複製請註明出處,謝謝!

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/15187685/viewspace-775107/,如需轉載,請註明出處,否則將追究法律責任。

相關文章