Oracle RAC搭建(三)

dayong2015發表於2014-05-14
1.建立ASM儲存盤:
1)安裝所需軟體包
[root@rac2 ~]# uname -a
Linux rac2 2.6.18-164.el5 #1 SMP Tue Aug 18 15:51:54 EDT 2009 i686 i686 i386 GNU/Linux
[root@rac1 asmlib]# ls
oracleasm-2.6.18-164.el5-2.0.5-1.el5.i686.rpm
oracleasmlib-2.0.4-1.el5.i386.rpm
oracleasm-support-2.1.8-1.el5.i386.rpm
[root@rac1 asmlib]# rpm -ivh oracleasm-support-2.1.8-1.el5.i386.rpm
warning: oracleasm-support-2.1.8-1.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 1e5e0159
Preparing...                ########################################### [100%]
   1:oracleasm-support      ########################################### [100%]
[root@rac1 asmlib]# rpm -ivh oracleasm-2.6.18-164.el5-2.0.5-1.el5.i686.rpm
warning: oracleasm-2.6.18-164.el5-2.0.5-1.el5.i686.rpm: Header V3 DSA signature: NOKEY, key ID 1e5e0159
Preparing...                ########################################### [100%]
   1:oracleasm-2.6.18-164.el########################################### [100%]
[root@rac1 asmlib]# rpm -ivh oracleasmlib-2.0.4-1.el5.i386.rpm
warning: oracleasmlib-2.0.4-1.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 1e5e0159
Preparing...                ########################################### [100%]
   1:oracleasmlib           ########################################### [100%]
[root@rac2 asmlib]# rpm -ivh oracleasm-support-2.1.8-1.el5.i386.rpm
[root@rac2 asmlib]# rpm -ivh oracleasm-2.6.18-164.el5-2.0.5-1.el5.i686.rpm
[root@rac2 asmlib]# rpm -ivh oracleasmlib-2.0.4-1.el5.i386.rpm
2).我們將繫結的15G大小的裸裝置raw2和raw3作為建立asm盤
節點1上執行:
[root@rac1 ~]# /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 []:
Default group to own the driver interface []:
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  ]
在節點2上執行:
[root@rac2 ~]# /etc/init.d/oracleasm configure
3)建立ASM盤如下:
在節點rac1上操作如下:
[root@rac1 ~]# /etc/init.d/oracleasm createdisk ASMDISK1 /dev/sdc1
Marking disk "ASMDISK1" as an ASM disk:                    [  OK  ]
[root@rac1 ~]# /etc/init.d/oracleasm createdisk ASMDISK2 /dev/sdd1
Marking disk "ASMDISK2" as an ASM disk:                    [  OK  ]
掃描ASM盤:
[root@rac1 ~]# /etc/init.d/oracleasm scandisks
Scanning the system for Oracle ASMLib disks:               [  OK  ]
[root@rac1 ~]# /etc/init.d/oracleasm listdisks
ASMDISK1
ASMDISK2
節點2上掃描並檢視ASM盤:
[root@rac2 ~]# /etc/init.d/oracleasm scandisks
Scanning the system for Oracle ASMLib disks:               [  OK  ]
[root@rac2 ~]# /etc/init.d/oracleasm listdisks
ASMDISK1
ASMDISK2
2.安裝資料庫軟體:
[oracle@rac1 ~]$ cd /u01/app/database/
[oracle@rac1 database]$ ll
total 28
dr-xr-xr-x 9 oracle oinstall 4096 May 14 09:44 doc
dr-xr-xr-x 5 oracle oinstall 4096 May 14 09:44 install
dr-xr-xr-x 2 oracle oinstall 4096 May 14 09:44 response
-r-xr-xr-x 1 oracle oinstall 1327 May 14 09:44 runInstaller
dr-xr-xr-x 9 oracle oinstall 4096 May 14 09:45 stage
-r-xr-xr-x 1 oracle oinstall 5213 May 14 09:45 welcome.html
[oracle@rac1 database]$ ./runInstaller
此處採用企業級模式:
Oracle RAC搭建(三)
指定資料庫安裝目錄:
Oracle RAC搭建(三)
對兩個節點選中:
Oracle RAC搭建(三)
僅安裝資料庫軟體:
Oracle RAC搭建(三)
按照提示執行指令碼:
Oracle RAC搭建(三)
[root@rac1 ~]# /u01/app/oracle/db_1/root.sh
[root@rac2 ~]# /u01/app/oracle/db_1/root.sh
3.對資料庫進行升級:
1)準備工作,兩個節點分別在root下執行/u01/app/oracle/crs/bin/crsctl stop crs
#停止crs,確保除/bin/sh /etc/init.d/init.crsd run該程式外,沒有其他crs程式執行。
[root@rac1 ~]# /u01/app/oracle/crs/bin/crsctl stop crs
Stopping resources.
Successfully stopped CRS resources
Stopping CSSD.
Shutting down CSS daemon.
Shutdown request successfully issued.
[root@rac2 ~]# /u01/app/oracle/crs/bin/crsctl stop crs
Stopping resources.
Successfully stopped CRS resources
Stopping CSSD.
Shutting down CSS daemon.
Shutdown request successfully issued.
[root@rac1 ~]# ps -ef |grep crs
root     29438     1  0 10:07 ?        00:00:00 /bin/sh /etc/init.d/init.crsd run
root     29715 25495  0 10:07 pts/2    00:00:00 grep crs
[root@rac2 ~]# ps -ef |grep crs
root      5744     1  0 10:07 ?        00:00:00 /bin/sh /etc/init.d/init.crsd run
root      6024 29841  0 10:08 pts/2    00:00:00 grep crs
2)執行補丁包中的runInstaller:
[root@rac1 p6810189_10204_Linux-x86.zip]# unzip p6810189_10204_Linux-x86.zip
[root@rac1 p6810189_10204_Linux-x86]# chown -R oracle:oinstall Disk1/
[root@rac1 p6810189_10204_Linux-x86]# ll
total 1030248
drwxr-xr-x 5 oracle oinstall       4096 Feb 22  2008 Disk1
-rw-r--r-- 1 root   root     1053748381 Nov  1  2010 p6810189_10204_Linux-x86.zip
-rw-r--r-- 1 root   root         178473 Feb 26  2008 README.html
[root@rac1 Disk1]# ll
total 1784
-rw-r--r--  1 oracle oinstall 1620786 Feb 22  2008 10204_buglist.htm
drwxr-xr-x  4 oracle oinstall    4096 Feb 17  2008 install
-rw-r--r--  1 oracle oinstall  178465 Feb 23  2008 patch_note.htm
drwxr-xr-x  2 oracle oinstall    4096 Feb 17  2008 response
-rwxr-xr-x  1 oracle oinstall    1756 Feb 17  2008 runInstaller
drwxr-xr-x 10 oracle oinstall    4096 Feb 22  2008 stage
先對clusterware打補丁:
指定CRS的目錄:
Oracle RAC搭建(三)
此處預設兩個節點已經選中,只需下一步:
Oracle RAC搭建(三)
按照提示執行指令碼:
Oracle RAC搭建(三)
Oracle RAC搭建(三)
[root@rac1 ~]# /u01/app/oracle/crs/bin/crsctl stop crs
Stopping resources.
Error while stopping resources. Possible cause: CRSD is down.
Stopping CSSD.
Unable to communicate with the CSS daemon.
[root@rac1 ~]# /u01/app/oracle/crs/install/root102.sh
Creating pre-patch directory for saving pre-patch clusterware files
Completed patching clusterware files to /u01/app/oracle/crs
Relinking some shared libraries.
Relinking of patched files is complete.
WARNING: directory '/u01/app/oracle' is not owned by root
WARNING: directory '/u01/app' is not owned by root
WARNING: directory '/u01' is not owned by root
Preparing to recopy patched init and RC scripts.
Recopying init and RC scripts.
Startup will be queued to init within 30 seconds.
Starting up the CRS daemons.
Waiting for the patched CRS daemons to start.
  This may take a while on some systems.
.
.
.
. . . . . .
Timed out waiting for the CRS daemons to start. Look at the
system message file and the CRS log files for diagnostics.
[root@rac2 ~]# /u01/app/oracle/crs/bin/crsctl stop crs
[root@rac2 ~]# /u01/app/oracle/crs/install/root102.sh
驗證節點的CRS是否已經起來:
[oracle@rac2 ~]$ crs_stat -t -v
Name           Type           R/RA   F/FT   Target    State     Host
----------------------------------------------------------------------
ora.rac1.gsd   application    0/5    0/0    ONLINE    ONLINE    rac1
ora.rac1.ons   application    0/3    0/0    ONLINE    ONLINE    rac1
ora.rac1.vip   application    0/0    0/0    ONLINE    ONLINE    rac1
ora.rac2.gsd   application    0/5    0/0    ONLINE    ONLINE    rac2
ora.rac2.ons   application    0/3    0/0    ONLINE    ONLINE    rac2
ora.rac2.vip   application    0/0    0/0    ONLINE    ONLINE    rac2
對資料庫進行升級:
指定之前配置的資料庫軟體目錄:

Oracle RAC搭建(三)
Oracle RAC搭建(三)
在彈出的錯誤框中依據提示,root使用者終端執行如下命令:
Oracle RAC搭建(三)
[root@rac1 ~]# /u01/app/oracle/db_1/root.sh
[root@rac2 ~]#  /u01/app/oracle/db_1/root.sh
3)驗證CRS和資料庫的版本是否升級:
[oracle@rac1 ~]$ cd /u01/app/oracle/crs/OPatch/
[oracle@rac1 OPatch]$ ll
total 48
drwxrwx--- 2 oracle oinstall  4096 May 14 10:20 docs
-rw-r--r-- 1 oracle oinstall 19263 Dec 26  2006 emdpatch.pl
drwxrwx--- 2 oracle oinstall  4096 May 14 10:20 jlib
-rwxr-xr-x 1 oracle oinstall  6315 Nov 23  2007 opatch
-rw-r--r-- 1 oracle oinstall    49 May 14 10:20 opatch.ini
-rw-r--r-- 1 oracle oinstall  2571 Aug  8  2006 opatch.pl
drwxrwx--- 4 oracle oinstall  4096 May 14 10:20 opatchprereqs
[oracle@rac1 OPatch]$  ./opatch lsinventory
Invoking OPatch 10.2.0.4.2
Oracle Interim Patch Installer version 10.2.0.4.2
Copyright (c) 2007, Oracle Corporation.  All rights reserved.
Oracle Home       : /u01/app/oracle/db_1
Central Inventory : /u01/app/oracle/oraInventory
   from           : /etc/oraInst.loc
OPatch version    : 10.2.0.4.2
OUI version       : 10.2.0.4.0
OUI location      : /u01/app/oracle/db_1/oui
Log file location : /u01/app/oracle/db_1/cfgtoollogs/opatch/opatch2014-05-14_10-53-55AM.log
Lsinventory Output file location : /u01/app/oracle/db_1/cfgtoollogs/opatch/lsinv/lsinventory2014-05-14_10-53-55AM.txt
--------------------------------------------------------------------------------
Installed Top-level Products (2):
Oracle Database 10g                                                  10.2.0.1.0
Oracle Database 10g Release 2 Patch Set 3                            10.2.0.4.0
There are 2 products installed in this Oracle Home.

There are no Interim patches installed in this Oracle Home.

Rac system comprising of multiple nodes
  Local node = rac1
  Remote node = rac2
--------------------------------------------------------------------------------
OPatch succeeded.
4.配置ASM例項和資料庫例項
1)配置監聽
[oracle@rac1 ~]$ netca
Oracle RAC搭建(三)
Oracle RAC搭建(三)
Oracle RAC搭建(三)
檢查監聽狀態:
[oracle@rac2 ~]$ crs_stat -t -v
Name           Type           R/RA   F/FT   Target    State     Host
----------------------------------------------------------------------
ora....C1.lsnr application    0/5    0/0    ONLINE    ONLINE    rac1
ora.rac1.gsd   application    0/5    0/0    ONLINE    ONLINE    rac1
ora.rac1.ons   application    0/3    0/0    ONLINE    ONLINE    rac1
ora.rac1.vip   application    0/0    0/0    ONLINE    ONLINE    rac1
ora....C2.lsnr application    0/5    0/0    ONLINE    ONLINE    rac2
ora.rac2.gsd   application    0/5    0/0    ONLINE    ONLINE    rac2
ora.rac2.ons   application    0/3    0/0    ONLINE    ONLINE    rac2
ora.rac2.vip   application    0/0    0/0    ONLINE    ONLINE    rac2
2)配置ASM例項
首先在兩個節點執行檢視ASM磁碟看是否存在:
[oracle@rac1 admin]$ oracleasm listdisks
ASMDISK1
ASMDISK2
[oracle@rac2 ~]$ oracleasm listdisks
ASMDISK1
ASMDISK2
[oracle@rac1 admin]$ dbca
Oracle RAC搭建(三)
Oracle RAC搭建(三)
Oracle RAC搭建(三)
Oracle RAC搭建(三)
指定磁碟組的名字:
Oracle RAC搭建(三)
顯示在第二個節點上無法掛載磁碟組,此處先不管它,稍後手動掛載:
Oracle RAC搭建(三)
磁碟組掛載情況:
Oracle RAC搭建(三)
配置完成之後檢視ASM,如下:
[oracle@rac1 ~]$ crs_stat -t -v
Name           Type           R/RA   F/FT   Target    State     Host
----------------------------------------------------------------------
ora....SM1.asm application    0/5    0/0    ONLINE    ONLINE    rac1
ora....C1.lsnr application    0/5    0/0    ONLINE    ONLINE    rac1
ora.rac1.gsd   application    0/5    0/0    ONLINE    ONLINE    rac1
ora.rac1.ons   application    0/3    0/0    ONLINE    ONLINE    rac1
ora.rac1.vip   application    0/0    0/0    ONLINE    ONLINE    rac1
ora....SM2.asm application    0/5    0/0    ONLINE    ONLINE    rac2
ora....C2.lsnr application    0/5    0/0    ONLINE    ONLINE    rac2
ora.rac2.gsd   application    0/5    0/0    ONLINE    ONLINE    rac2
ora.rac2.ons   application    0/3    0/0    ONLINE    ONLINE    rac2
ora.rac2.vip   application    0/0    0/0    ONLINE    ONLINE    rac2
在節點rac2上掛載磁碟組,如下;

[oracle@rac2 ~]$ export ORACLE_SID=+ASM2
[oracle@rac2 ~]$ sqlplus / as sysdba

SQL*Plus: Release 10.2.0.4.0 - Production on Wed May 14 20:52:15 2014

Copyright (c) 1982, 2007, Oracle.  All Rights Reserved.


Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Production
With the Partitioning, Real Application Clusters, OLAP, Data Mining
and Real Application Testing options

SQL> select inst_id,name,state from gv$asm_diskgroup;

   INST_ID NAME                           STATE
---------- ------------------------------ -----------
         1 RAC_GROUP                      MOUNTED
         2 RAC_GROUP                      DISMOUNTED

SQL> show parameter asm;

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
asm_diskgroups                       string      RAC_GROUP
asm_diskstring                       string
asm_power_limit                      integer     1
SQL> alter system set asm_diskstring='/dev/raw/raw2,/dev/raw/raw3';

System altered.

SQL> alter diskgroup RAC_GROUP mount;
alter diskgroup RAC_GROUP mount
*
ERROR at line 1:
ORA-15032: not all alterations performed
ORA-15063: ASM discovered an insufficient number of disks for diskgroup
"RAC_GROUP"                          #出現掛載不了的情況
重啟節點rac2,檢視是否能夠掛載:
[oracle@rac2 ~]$ export ORACLE_SID=+ASM2
[oracle@rac2 ~]$ sqlplus / as sysdba

SQL*Plus: Release 10.2.0.4.0 - Production on Wed May 14 21:13:01 2014

Copyright (c) 1982, 2007, Oracle.  All Rights Reserved.


Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Production
With the Partitioning, Real Application Clusters, OLAP, Data Mining
and Real Application Testing options

SQL> select inst_id,state,name from gv$asm_diskgroup;

   INST_ID STATE       NAME
---------- ----------- ------------------------------
         1 MOUNTED     RAC_GROUP
         2 MOUNTED     RAC_GROUP               #是不是很邪乎,ASM是oracle10g出來的產品,可能存在一些需要改進的地方,此處不再敖述
3)建立資料庫例項
[oracle@rac1 ~]$ dbca
指定建立的是叢集資料庫:
Oracle RAC搭建(三)
建立資料庫例項:
Oracle RAC搭建(三)
選中兩個節點:
Oracle RAC搭建(三)
此處選擇一般用途:
Oracle RAC搭建(三)
指定全域性資料庫名:
Oracle RAC搭建(三)
禁用企業管理器:
Oracle RAC搭建(三)
設定資料庫管理員的密碼:
Oracle RAC搭建(三)
採用ASM自動儲存管理方式:
Oracle RAC搭建(三)
輸入之前設定的磁碟組的密碼:
Oracle RAC搭建(三)
檢視磁碟組掛載情況,此處需要兩個節點都要掛載:
Oracle RAC搭建(三)
資料庫檔案管理方式採用磁碟組模式:
Oracle RAC搭建(三)
此處對恢復區先不做配置:
Oracle RAC搭建(三)
資料庫內容,此處選擇預設,繼續下一步:
Oracle RAC搭建(三)
資料庫服務,此處選擇預設,繼續下一步:

Oracle RAC搭建(三)
安裝成功介面:
Oracle RAC搭建(三)
Oracle RAC搭建(三)

驗證:使用資料庫例項登入資料庫

[oracle@rac1 ~]$ export ORACLE_SID=orcl1
[oracle@rac1 ~]$ sqlplus / as sysdba

SQL*Plus: Release 10.2.0.4.0 - Production on Thu May 15 11:47:03 2014

Copyright (c) 1982, 2007, Oracle.  All Rights Reserved.


Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Production
With the Partitioning, Real Application Clusters, OLAP, Data Mining
and Real Application Testing options

SQL> select instance_name,status from v$instance;

INSTANCE_NAME    STATUS
---------------- ------------
orcl1            OPEN
[oracle@rac2 ~]$ export ORACLE_SID=orcl2
[oracle@rac2 ~]$ sqlplus / as sysdba

SQL*Plus: Release 10.2.0.4.0 - Production on Thu May 15 11:48:20 2014

Copyright (c) 1982, 2007, Oracle.  All Rights Reserved.


Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Production
With the Partitioning, Real Application Clusters, OLAP, Data Mining
and Real Application Testing options

SQL> select instance_name,status from v$instance;

INSTANCE_NAME    STATUS
---------------- ------------
orcl2            OPEN

補充:對於已經建立了資料庫,想從低版本升級到高版本,要先對原有資料庫進行備份,然後刪除資料庫,先對crs進行升級,然後對資料庫進行升級。
注意,在對資料庫進行的升
級的時候lsnrctl和ASM要處於offline狀態,否則無法完成資料庫的升級,這是筆者親身經歷過得事情。

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

相關文章