Oracle 10gR2 Clusterware 簡明安裝步驟

來源:互聯網
上載者:User

Oracle 10gR2 Clusterware 簡明安裝步驟

一、安裝作業系統(略)
注意,我這裡用的都是OEL 5u5版本,因為內建了Oracle提供的環境變數安裝包,因此可以很方便地進行Oracle軟體的安裝,因此推薦使用該版本

二、配置本地yum源

--把安裝盤mount到media
mount -t iso9660 /dev/cdrom /media


--配置repos添加以下內容
vi /etc/yum.repos.d/oel5.repos
[oel5]
name = oel 5 DVD
basurl = file:///media/Server
gpgcheck =0
enabled = 1    --為1表示啟用這個repos

三、配置信任關係(oracle使用者)

--節點1和節點2分別執行:
ssh-keygen -t rsa
ssh-keygen -t dsa

--節點1執行:
cat ~/.ssh/*.pub >> ~/.ssh/authorized_keys
ssh rac2 cat ~/.ssh/*.pub >> ~/.ssh/authorized_keys
scp ~/.ssh/authorized_keys rac2:~/.ssh/authorized_keys

總之就是把2邊節點的資訊寫到公開金鑰檔案中去,然後互相ssh就不再要求輸入密碼了,因為RAC安裝時需要在節點之間複製檔案

--驗證
節點1執行:
ssh rac1 date
ssh rac2 date
ssh rac1-priv date
ssh rac2-priv date


節點2執行:
ssh rac1 date
ssh rac2 date
ssh rac1-priv date
ssh rac2-priv date

多驗證幾次,直到不需要輸入密碼為止,這裡要注意authorized_keys中不要漏掉s,我曾經試了半天也沒有成功,最後發現是公開金鑰檔案名稱錯了,少了個s導致的

四、配置共用磁碟

--添加若干塊磁碟並分區
fdisk -l
fdisk /dev/sdb
fdisk /dev/sdc
fdisk /dev/sdd
fdisk /dev/sde

如果碰到需要重啟後才能識別分區資訊,可以使用linux內建的partporbe命令,執行一下就可以在不重啟的情況下讓kernel識別新的分區
也可以執行partprobe -s進行查看

[root@rac1 ~]# 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-12, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-12, default 12):
Using default value 12

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: Device or resource busy.
The kernel still uses the old table.
The new table will be used at the next reboot.
Syncing disks.
[root@rac1 ~]# partprobe -s
/dev/sda: msdos partitions 1 2
/dev/sdb: msdos partitions 1
/dev/sdc: msdos partitions 1
/dev/sdd: msdos partitions 1
/dev/sde: msdos partitions 1
[root@rac2 install]#

--綁定磁碟
對於4.x和5.x的系統,Binder 方法是不同的

4.x:
# vi /etc/sysconfig/rawdevices

/dev/raw/raw1 /dev/sdc1
/dev/raw/raw2 /dev/sdd1
/dev/raw/raw3 /dev/sde1

#  vi /etc/udev/permissions.d/50-udev.permissions
# raw devices
ram*:root:disk:0660
#raw/*:root:disk:0660
raw/*:oracle:dba:0660

5.x:

# vi /etc/udev/rules.d/60-raw.rulesACTION=="add",KERNEL=="/dev/sdb1",RUN+="/bin/raw /dev/raw/raw1 %N"ACTION=="add",ENV{MAJOR}=="8",ENV{MINOR}=="17",RUN+="/bin/raw /dev/raw/raw1 %M %m"ACTION=="add",KERNEL=="/dev/sdc1",RUN+="/bin/raw /dev/raw/raw2 %N"ACTION=="add",ENV{MAJOR}=="8",ENV{MINOR}=="33",RUN+="/bin/raw /dev/raw/raw2 %M %m"ACTION=="add",KERNEL=="/dev/sdd1",RUN+="/bin/raw /dev/raw/raw3 %N"ACTION=="add",ENV{MAJOR}=="8",ENV{MINOR}=="49",RUN+="/bin/raw /dev/raw/raw3 %M %m"ACTION=="add",KERNEL=="/dev/sde1",RUN+="/bin/raw /dev/raw/raw4 %N"ACTION=="add",ENV{MAJOR}=="8",ENV{MINOR}=="65",RUN+="/bin/raw /dev/raw/raw4 %M %m"ACTION=="add",KERNEL=="raw*",OWNER="oracle",GROUP="oinstall",MODE="660"

只需要添加紅色部分就可以了,然後重啟udev,配置正常就會顯示如下內容:

[root@rac1 ~]$ ll /dev/raw

total 0
crw-rw---- 1 oracle oinstall 162,  1 Jan 15 22:54 raw1
crw-rw---- 1 oracle oinstall 162,  2 Jan 15 22:24 raw2
crw-rw---- 1 oracle oinstall 162,  3 Jan 15 22:56 raw3
crw-rw---- 1 oracle oinstall 162,  4 Jan 15 22:54 raw4

五、添加環境變數

節點1:
[oracle@rac1 ~]$vi .bash_profile
export ORACLE_SID=RAC1
export ORACLE_HOME=/u01/oracle/10.2.0/db_1
export ORA_CRS_HOME=/u01/oracle/10.2.0/crs_1
export PATH=$ORACLE_HOME/bin:$ORA_CRS_HOME/bin:$ORACLE_HOME/jdk/bin:$PATH

節點2:
[oracle@rac1 ~]$vi .bash_profile
export ORACLE_SID=RAC2
export ORACLE_HOME=/u01/oracle/10.2.0/db_1
export ORA_CRS_HOME=/u01/oracle/10.2.0/crs_1
export PATH=$ORACLE_HOME/bin:$ORA_CRS_HOME/bin:$ORACLE_HOME/jdk/bin:$PATH

六、安裝Clusterware

--先進行安裝前校正
cd ./clusterware/cluvfy

./cluvfy.sh -stage pre crsinst -n rac1,rac2 -verbose

會列出很多內容,檢測是否符合安裝Clusterware的條件,其中需要單獨安裝一個compat_db的包,oracle-validated包不會裝這個
另外會報幾個其他compat包檢測失敗則不用理會,因為只是版本不對而已
如果還碰到其他的沒有passed的內容,則需要處理,直到除以上幾個錯誤之外全都pass為止

--開始安裝
cd ./clusterware

./runInstall -ignoreSysPreReqs (參數可以忽略大小寫,命令不允許)

運行OUI到最後,會要求分別在2個節點執行2個指令碼,順序為:指令碼1:RAC1->RAC2 ->指令碼2:RAC1->RAC2
前3個次執行都沒有問題,到第4步,在節點2上執行root.sh的時候,會報錯:

[root@rac2 bin]# /u01/oracle/10.2.0/crs_1/root.sh

WARNING: directory '/u01' is not owned by root
Checking to see if Oracle CRS stack is already configured

Setting the permissions on OCR backup directory
Setting up NS directories
Oracle Cluster Registry configuration upgraded successfully
WARNING: directory '/u01' is not owned by root
clscfg: EXISTING configuration version 3 detected.
clscfg: version 3 is 10G Release 2.
assigning default hostname rac1 for node 1.
assigning default hostname rac2 for node 2.
Successfully accumulated necessary OCR keys.
Using ports: CSS=49895 CRS=49896 EVMC=49898 and EVMR=49897.
node <nodenumber>: <nodename> <private interconnect name> <hostname>
node 1: rac1 rac1-priv rac1
node 2: rac2 rac2-priv rac2
clscfg: Arguments check out successfully.

NO KEYS WERE WRITTEN. Supply -force parameter to override.
-force is destructive and will destroy any previous cluster
configuration.
Oracle Cluster Registry for cluster has already been initialized
Startup will be queued to init within 90 seconds.
Adding daemons to inittab
Expecting the CRS daemons to be up within 600 seconds.
CSS is active on these nodes.
        rac1
        rac2
CSS is active on all nodes.
Waiting for the Oracle CRSD and EVMD to start
Oracle CRS stack installed and running under init(1M)
Running vipca(silent) for configuring nodeapps
/u01/oracle/10.2.0/crs_1/jdk/jre//bin/java: error while loading shared libraries: libpthread.so.0: cannot open shared object file: No such file or directory

需要耐心等待好幾分鐘(90s+600s),然後會出現一個報錯,這是由於Oracle在10.2.0.1上的bug所致,解決辦法是通過修改$ORA_CRS_HOME/bin下滿的vipca和srvctl檔案,分別在這2個檔案的第124行和168行(注意,不是檔案末尾,否則更改可能會無效)添加unset LD_ASSUME_KERNEL後儲存退出,再重新再節點2執行root.sh

[root@rac2 bin]# /u01/oracle/10.2.0/crs_1/root.sh
WARNING: directory '/u01' is not owned by root
Checking to see if Oracle CRS stack is already configured
Oracle CRS stack is already configured and will be running under init(1M)
[root@rac2 bin]# ./crs_stat -t
CRS-0202: No resources are registered.

此時由於還沒有配置vip,因此沒有資源被註冊,去任意節點運行vipca(前提是這個節點的vipca已修改過),如果報以下錯誤:

[oracle@rac1 bin]$ vipca
Error 0(Native: listNetInterfaces:[3])
  [Error 0(Native: listNetInterfaces:[3])]

那麼需要配置一下網卡:
[oracle@rac1 bin]$ ./oifcfg iflist
eth0  192.168.1.0
eth1  10.0.0.0
[oracle@rac1 bin]$ ./oifcfg getif
[oracle@rac1 bin]$ ./oifcfg setif -global eth0/192.168.1.0:public
[oracle@rac1 bin]$ ./oifcfg setif -global eth1/10.10.10.1:cluster_interconnect
[oracle@rac1 bin]$ ./oifcfg getif
eth0  192.168.1.0  global  public
eth1  10.10.10.1  global  cluster_interconnect

注意要有開啟圖形介面的許可權,並用root使用者去執行vipca,而不是oracle使用者,否則會報許可權不足
[oracle@rac1 bin]$ vipca
Insufficient privileges.
Insufficient privileges.

接著就會跳出vip配置助手的OUI介面,開始配置vip,輸入vip的節點別名後會自動填補vip的IP地址(過程略)
運行完vipca後退出,再次執行crs_stat,就會發現資源都已經註冊到crs了
[root@rac1 bin]# ./crs_stat -t
Name          Type          Target    State    Host       
------------------------------------------------------------
ora.rac1.gsd  application    ONLINE    ONLINE    rac1       
ora.rac1.ons  application    ONLINE    ONLINE    rac1       
ora.rac1.vip  application    ONLINE    ONLINE    rac1       
ora.rac2.gsd  application    ONLINE    ONLINE    rac2       
ora.rac2.ons  application    ONLINE    ONLINE    rac2       
ora.rac2.vip  application    ONLINE    ONLINE    rac2

最後有個小細節要注意,就是在ORACLE_HOME/bin路徑下面也有srvctl的命令,也是需要通過設定unset LD_ASSUME_KERNEL來解決的,否則會和ORA_CRS_HOME/bin中的srvctl一樣,報庫檔案連結錯誤,如果不想改,也不是不可以,那麼就要調整一下PATH環境變數中ORA_CRS_HOME和ORACLE_HOME的位置了,因為在執行命令的時候,預設會從第一個路徑開始尋找,直到最後一個路徑,這樣就不會用到ORACLE_HOME/bin下的那個srvctl命令檔案了,把ORA_CRS_HOME放到最前面,寫法如下:
export PATH=$ORA_CRS_HOME/bin:$ORACLE_HOME/bin:$ORACLE_HOME/jdk/bin:$PATH

無論採用哪種方法(推薦使用第2種方法),都可以解決oracle使用者不能執行srvctl和crsctl等命令問題了。

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.