這是第一次安裝RAC,參考了國外一位大神的安裝文檔,在安裝過程中,也遇到了一些問題,從網上查了相關問題的解決方法,在此感謝。 操作系統是 Oracle Enterprise Linux 5,兩個節點 rac1和rac2,網卡eth0作為public,eth1作為private,假設之前已添加一塊20 ...
這是第一次安裝RAC,參考了國外一位大神的安裝文檔,在安裝過程中,也遇到了一些問題,從網上查了相關問題的解決方法,在此感謝。
操作系統是 Oracle Enterprise Linux 5,兩個節點 rac1和rac2,網卡eth0作為public,eth1作為private,假設之前已添加一塊20G容量的共用磁碟。
關於Oracle Enterprise Linux 下載,可以在https://edelivery.oracle.com/osdc/faces/Home.jspx登陸後下載。
主機配置
所有命令在root用戶下執行。
配置共用存儲。共用存儲可視為/dev/sdb設備。將使用fdisk命令創建兩個10G大小的兩個分區。 兩個新的分區將用於ASM。
--list devices ls /dev/sd* /dev/sda /dev/sda1 /dev/sda2 /dev/sdb
--add two partitions fdisk /dev/sdb The number of cylinders for this disk is set to 2610. 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): n Command action e extended p primary partition (1-4) p Partition number (1-4): 1 First cylinder (1-2610, default 1): Using default value 1 Last cylinder or +size or +sizeM or +sizeK (1-2610, default 2610): +10240M Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (1-4): 2 First cylinder (1247-2610, default 1247): Using default value 1247 Last cylinder or +size or +sizeM or +sizeK (1247-2610, default 2610): Using default value 2610 Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks.
--list new partitions fdisk -l /dev/sdb Disk /dev/sdb: 21.4 GB, 21474836480 bytes 255 heads, 63 sectors/track, 2610 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/sdb1 1 1246 10008463+ 83 Linux /dev/sdb2 1247 2610 10956330 83 Linux
添加組
--required groups /usr/sbin/groupadd -g 501 oinstall /usr/sbin/groupadd -g 502 dba /usr/sbin/groupadd -g 503 oper
添加Oracle用戶
/usr/sbin/useradd -u 502 -g oinstall -G dba oracle
修改Oracle用戶密碼
passwd oracle
在 /etc/sysctl.conf下添加內核參數
#kernel parameters for 11g installation kernel.shmmni = 4096 kernel.shmmax = 4398046511104 kernel.shmall = 1073741824 kernel.sem = 250 32000 100 128 fs.aio-max-nr = 1048576 fs.file-max = 6815744 net.ipv4.ip_local_port_range = 9000 65500 net.core.rmem_default = 262144 net.core.rmem_max = 4194304 net.core.wmem_default = 262144 net.core.wmem_max = 1048586
應用內核參數
/sbin/sysctl -p
為用戶Oracle在/etc/security/limits.conf文件中添加以下行以設置shell限制
--shell limits for users oracle 11gR2 oracle soft nproc 131072 oracle hard nproc 131072 oracle soft nofile 131072 oracle hard nofile 131072 oracle soft core unlimited oracle hard core unlimited oracle soft memlock 50000000 oracle hard memlock 50000000
“/ etc / hosts”文件必須包含伺服器的完全限定名稱。
<IP-address> <fully-qualified-machine-name> <machine-name>
“/ etc / hosts”下輸入以下數據
127.0.0.1 localhost.localdomain localhost #public 192.168.0.50 rac1.dbaora.com rac1 192.168.0.51 rac2.dbaora.com rac2 #private 192.168.1.60 rac1-priv.dbaora.com rac1-priv 192.168.1.61 rac2-priv.dbaora.com rac2-priv #virtual 192.168.0.70 rac1-vip.dbaora.com rac1-vip 192.168.0.71 rac2-vip.dbaora.com rac2-vip #scan 192.168.0.20 rac-scan.dbaora.com rac-scan
驗證rac1.dbaora.com上的th0和eth1的網路響應
[root@rac1 ~]# ping rac1 -c 1 PING rac1.dbaora.com (192.168.0.50) 56(84) bytes of data. 64 bytes from rac1.dbaora.com (192.168.0.50): icmp_seq=1 ttl=64 time=0.032 ms --- rac1.dbaora.com ping statistics --- 1 packets transmitted, 1 received, 0% packet loss, time 0ms rtt min/avg/max/mdev = 0.032/0.032/0.032/0.000 ms [root@rac1 ~]# ping rac1-priv -c 1 PING rac1-priv.dbaora.com (192.168.1.60) 56(84) bytes of data. 64 bytes from rac1-priv.dbaora.com (192.168.1.60): icmp_seq=1 ttl=64 time=0.036 ms --- rac1-priv.dbaora.com ping statistics --- 1 packets transmitted, 1 received, 0% packet loss, time 0ms rtt min/avg/max/mdev = 0.036/0.036/0.036/0.000 ms
檢查哪些軟體包已安裝,哪些軟體包缺失
rpm -q --qf '%{NAME}-%{VERSION}-%{RELEASE}(%{ARCH})\n' binutils \ compat-libstdc++-33 \ elfutils-libelf \ elfutils-libelf-devel \ gcc \ gcc-c++ \ glibc \ glibc-common \ glibc-devel \ glibc-headers \ ksh \ libaio \ libaio-devel \ libgcc \ libstdc++ \ libstdc++-devel \ make \ sysstat \ unixODBC \ unixODBC-devel
安裝缺失的包。 這隻是一個例子:
#directory with mounted Oracle Enterprise Linux 5 install disk cd <path with Oracle Enterprise Linux 5>/Server/Packages #install missed packages (example for package unixODBC*) rpm -Uvh unixODBC*
禁用Secure Linux
要禁用Secure Linux編輯“/etc/selinux/config”文件,確保SELINUX設置如下,它需要重啟才能有效。
SELINUX=disabled
禁用Firewall
可以在圖形模式下或手動禁用防火牆。
執行下麵的命令手動禁用
service iptables stop
chkconfig iptables off
更改NTP
需要禁用NTP(Network Time Protocol)或修改其設置,以便Oracle Cluster Time Synchronization Service(ctssd)可以同步RAC節點的時間。
選項1 - 禁用NTP
service ntpd stop Shutting down ntpd: [ OK ] chkconfig ntpd off mv /etc/ntp.conf /etc/ntp.conf.orig rm /var/run/ntpd.pid
選項2 - 更改NTP
如果要保留NTP,請在“/etc/sysconfig/ntpd”文件中添加“-x”選項。
OPTIONS="-x -u ntp:ntp -p /var/run/ntpd.pid"
並重新啟動NTP
# service ntpd restart
在操作系統安裝過程中,可以禁用 SElinux、Firewall,不啟動NTP,這樣在主機配置中可省略。
目錄
創建ORACLE_BASE
mkdir -p /ora01/app/oracle
為grid和database軟體創建ORACLE_HOME
mkdir -p /ora01/app/oracle/product/11.2.0/db_1 mkdir -p /ora01/app/grid/product/11.2.0/grid chown oracle:oinstall -R /ora01 chmod 775 /ora01/app/oracle
Oracle用戶新的配置文件
修改Oracle配置文件 /home/oracle/.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 alias genv='. /home/oracle/.bash_profile_grid;envo' alias denv='. /home/oracle/.bash_profile_database;envo' . /home/oracle/.bash_profile_database envo
這裡添加了兩個別名:genv和denv,這樣可以方便地切換grid和database軟體環境。
為Oracle用戶添加新的配置文件 /home/oracle/.bash_profile_grid。此配置文件將用於grid軟體。
# Oracle Settings export TMP=/tmp export ORACLE_HOSTNAME=rac1.dbaora.com export ORACLE_UNQNAME=+ASM export ORACLE_BASE=/ora01/app/oracle export ORACLE_HOME=/ora01/app/grid/product/11.2.0/grid export ORACLE_SID=+ASM1 PATH=/usr/sbin:$PATH:$ORACLE_HOME/bin export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib; export CLASSPATH=$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib; alias cdob='cd $ORACLE_BASE' alias cdoh='cd $ORACLE_HOME' alias tns='cd $ORACLE_HOME/network/admin' alias envo='env | grep ORACLE'
為Oracle用戶添加新的參數文件 /home/oracle/.bash_profile_database. 此配置文件將用於database軟體。
# Oracle Settings export TMP=/tmp export ORACLE_HOSTNAME=rac1.dbaora.com export ORACLE_UNQNAME=ORA11G export ORACLE_BASE=/ora01/app/oracle export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1 export ORACLE_SID=ORA11G1 PATH=/usr/sbin:$PATH:$ORACLE_HOME/bin export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib; export CLASSPATH=$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib; alias cdob='cd $ORACLE_BASE' alias cdoh='cd $ORACLE_HOME' alias tns='cd $ORACLE_HOME/network/admin' alias envo='env | grep ORACLE' umask 022
在rac2中,將兩個參數文件的ORACLE_HOSTNAME和ORACLE_SID更改為本伺服器的參數值。
記住修改所有配置文件的所有者
chown oracle:oinstall /home/oracle/.bash* chmod 750 oracle:oinstall /home/oracle/.bash*
作為oracle用戶解壓database和grid軟體。 創建2個目錄:
- database – database software
- grid – grid software
切換到grid軟體環境,以root用戶身份安裝軟體包cvuqdisk-1.0.9-1.rpm
cd <install grid software>/rpm [root@rac1 rpm]# rpm -Uvh cvuqdisk-1.0.9-1.rpm Preparing... ############################## [100%] Using default group oinstall to install package 1:cvuqdisk ############################## [100%]
配置ASM設備
要配置ASMlib,首先需要從OTN下載ASMLib rpms。 如果使用的是UEK內核,則所有必需的rpms都已安裝。
- oracleasm-support-2.1.8-1.el5.i386.rpm
- oracleasmlib-2.0.4-1.el5.i386.rpm
- oracleasm-[your-kernel-version].rpm
關於oracleasm-supper和orcleasmlib軟體包版本,可以根據操作系統版本從http://www.oracle.com/technetwork/server-storage/linux/asmlib/index-101839.html下載軟體包。
而oracleasm軟體包要根據操作系統內核參數來決定:
name -a
這裡是Oracle通過配置YUM來安裝oracleasm軟體包的鏈接:
http://www.oracle.com/technetwork/server-storage/linux/downloads/rhel5-084877.html
使用以下命令安裝軟體包
rpm -Uvh oracleasm*.rpm
安裝完成後可以通過rpm -qa | grep oracleasm命令驗證。
配置SMlib
[root@rac1 ~]# /usr/sbin/oracleasm configure -i 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 Scan for Oracle ASM disks on boot (y/n) [y]: Writing Oracle ASM library driver configuration: done
載入asm內核模塊
[root@rac1 ~]# /usr/sbin/oracleasm init Loading module "oracleasm": oracleasm Mounting ASMlib driver filesystem: /dev/oracleasm
添加ASM磁碟
[root@rac1 ~]# /usr/sbin/oracleasm createdisk DISK1 /dev/sdb1 Writing disk header: done Instantiating disk: done [root@rac1 ~]# /usr/sbin/oracleasm createdisk DISK2 /dev/sdb2 Writing disk header: done Instantiating disk: done
掃描ASM磁碟
[root@rac1 ~]# /usr/sbin/oracleasm scandisks Reloading disk partitions: done Cleaning any stale ASM disks... Scanning system for ASM disks...
列出ASM磁碟
[root@rac1 ~]# /usr/sbin/oracleasm listdisks
DISK1
DISK2
這裡是使用oracleasm配置ASM磁碟,也可以同過udev來配置,在使用oracleasm時遇到一些bug,推薦使用udev。
現在在每個節點上運行下麵命令驗證網路:rac1.dbaora.com和rac2.dbaora.com
hostname ping rac1 -c 1 ping rac2 -c 1 ping rac1-priv -c 1 ping rac2-priv -c 1
安裝grid軟體
以用戶oracle啟動grid軟體安裝,在此之前以root身份運行命令xhost +。
xhost +
access control disabled, clients can connect from any host
設置grid環境並運行grid安裝軟體
su - oracle [oracle@rac1 ~]$ genv ORACLE_UNQNAME=+ASM ORACLE_SID=+ASM1 ORACLE_BASE=/ora01/app/oracle ORACLE_HOSTNAME=rac1.dbaora.com ORACLE_HOME=/ora01/app/grid/product/11.2.0/grid --run installation cd <install grid software> ./runInstall
關於安裝過程,可以根據實際需要選擇,這裡省略。
這裡如果是使用linux 6以上版本,在最後執行root.sh腳本時,會用一個BUG,具體解決方法如下
1.刪除配置:
/ora01/app/grid/product/11.2.0/gridl/roothas.pl -deconfig -force-verbose
路徑是grid環境的ORACLE_HOME。
再次執行root.sh腳本,出現Adding daemon to inittab這條信息的時候執行dd命令
/bin/dd if=/var/tmp/.oracle/npohasd of=/dev/null bs=1024 count=1
如果是安裝11.2.0.1的話,還是建議 使用 linux 5的版本。
ASM configuration assistant
到目前為止,只創建了一個ASM組DATA。下麵展示如何快速添加額外的組到ASM實例。
在以Oracle用戶啟動ASMCA之前, 切換到root用戶執行xhost +命令。
ASMCA - ASM configuration assistant是grid軟體的一部分,因此必須設置正確的環境
su - oracle [oracle@rac1 ~]$ genv ORACLE_UNQNAME=+ASM ORACLE_SID=+ASM1 ORACLE_BASE=/ora01/app/oracle ORACLE_HOSTNAME=rac1.dbaora.com ORACLE_HOME=/ora01/app/grid/product/11.2.0/grid [oracle@rac1 ~]$ asmca
根據需要一步步執行就可以了,安裝步驟省略。
在你可以在sqlplus中驗證你有2個ASM組。
[oracle@rac1 ~]$ sqlplus SQL*Plus: Release 11.2.0.3.0 Production on Sun Jun 16 22:39:11 2013 Copyright (c) 1982, 2011, Oracle. All rights reserved. Enter user-name: / as sysasm Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production With the Automatic Storage Management option SQL> select name from v$asm_diskgroup; NAME ------------------------------ DATA BACKUP
安裝Database軟體
作為Oracle用戶開始database軟體安裝。設置database軟體愛你環境
su - oracle [oracle@rac1 ~]$ denv ORACLE_UNQNAME=ORA11G ORACLE_SID=ORA11G1 ORACLE_BASE=/ora01/app/oracle ORACLE_HOSTNAME=rac1.dbaora.com ORACLE_HOME=/ora01/app/oracle/product/11.2.0/db_1 --run installation cd <install database software> ./runInstall
安裝步驟省略。
在安裝過程中,遇到一個有關監聽器的問題,提示
default listener is not configured in grid infrastructure home
解決方法鏈接http://www.cnblogs.com/jimeper/p/3746301.html
驗證RAC安裝
[root@rac1 ~]# su - oracle [oracle@rac1 ~]$ genv ORACLE_UNQNAME=+ASM ORACLE_SID=+ASM1 ORACLE_BASE=/ora01/app/oracle ORACLE_HOSTNAME=rac1.dbaora.com ORACLE_HOME=/ora01/app/grid/product/11.2.0/grid [oracle@rac1 ~]$ srvctl config database -d ORA11G Database unique name: ORA11G Database name: ORA11G Oracle home: /ora01/app/oracle/product/11.2.0/db_1 Oracle user: oracle Spfile: +DATA/ORA11G/spfileORA11G.ora Domain: dbaora.com Start options: open Stop options: immediate Database role: PRIMARY Management policy: AUTOMATIC Server pools: ORA11G Database instances: ORA11G1,ORA11G2 Disk Groups: DATA Mount point paths: Services: Type: RAC Database is administrator managed [oracle@rac1 ~]$ srvctl status listener Listener LISTENER is enabled Listener LISTENER is running on node(s): rac2,rac1 [oracle@rac1 ~]$ srvctl status asm ASM is running on rac2,rac1 [oracle@rac1 ~]$ srvctl status database -d ORA11G Instance ORA11G1 is running on node rac1 Instance ORA11G2 is running on node rac2
葡萄美酒夜光杯,欲飲琵琶馬上催;
醉卧沙場君莫笑,古來征戰幾人回。