历时2天终于将RAC环境搭建完成了,OS为CentOS 5.4 x64bit。主要分为三步
(1)、安装clusterware
(2)、安装rac
(3)、创建rac database
记录下以防后面再乱七八糟各种找!!
1、主机地址规划如下
hostname | rac1 | rac2 |
private | 172.20.3.1 | 172.20.3.2 |
public | 172.20.10.191 | 172.20.10.192 |
vip | 172.20.10.11 | 172.20.10.12 |
scan-name | 172.20.10.10 | rac-cluster |
RAC1和RAC2的hosts配置如下
/etc/hosts文件
#public network-eth0
172.20.10.191 rac1
172.20.10.192 rac2
#private network-eth1
172.20.3.1 rac1-priv
172.20.3.2 rac2-priv
#vip
172.20.10.11 rac1-vip
172.20.10.12 rac2-vip
172.20.10.10 rac-cluster
172.20.10.190 nas1
2、添加/etc/sysctl.conf如下
net.ipv4.ipfrag_high_thresh=524288
net.ipv4.ipfrag_low_thresh=393216
net.ipv4.tcp_rmem=4096 524288 16777216
net.ipv4.tcp_wmem=4096 524288 16777216
net.ipv4.tcp_timestamps=0
net.ipv4.tcp_sack=0
net.ipv4.tcp_window_scaling=1
net.core.optmem_max=524287
net.core.netdev_max_backlog=2500
sunrpc.tcp_slot_table_entries=128
sunrpc.udp_slot_table_entries=128
net.ipv4.tcp_mem=16384 16384 16384
fs.file-max=6815744
net.ipv4.ip_local_port_range=9000 65500
net.core.wmem_max=1048576
fs.aio-max-nr=1048576
3、安装各种软件yum -y install binutils compat-libstdc++ elfutils-libelf elfutils-libelf-devel elfutils-libelf-devel-static gcc gcc-c++ glibc glibc-common glibc-devel glibc-headers ksh libaio libaio-devel libgcc libgomp libstdc++ libstdc++-devel make sysstat unixODBC unixODBC-devel pdksh
rpm -ivh compat-libstdc++-33-3.2.3-61.*
4、修改oracle的.bashrc文件
ORACLE_HOSTNAME=rac1; export ORACLE_HOSTNAME
ORACLE_BASE=/u01/app/oracle; export ORACLE_BASE
ORACLE_HOME=$ORACLE_BASE/product/11.1.0/db_1; export ORACLE_HOME
ORACLE_SID=taotao1; export ORACLE_SID
export ORACLE_UNQNAME=$ORACLE_SID
PATH=$ORACLE_HOME/bin:$ORA_CRS_HOME/bin:/usr/sbin:$PATH; export PATH
LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib; export LD_LIBRARY_PATH
CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib; export CLASSPATH
5、安装中如果提示SWAP空间不足:
dd if=/dev/zero of=swapfile bs=1024 count=1000000
mkswap swapfile
swapon swapfile
6、继续安装
7、完成后启动监听器并看其状态
[oracle@RAC1 ~]$ lsnrctl status
LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 27-FEB-2012 10:51:53
Copyright (c) 1991, 2009, Oracle. All rights reserved.
Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 11.2.0.1.0 - Production
Start Date 24-FEB-2012 17:08:29
Uptime 2 days 17 hr. 43 min. 23 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/11.2.0/grid/network/admin/listener.ora
Listener Log File /u01/app/oracle/diag/tnslsnr/RAC1/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=LISTENER)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=172.20.10.191)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=172.20.10.11)(PORT=1521)))
Services Summary... Service "taotao" has 1 instance(s).
Instance "taotao1", status READY, has 1 handler(s) for this service...
Service "taotaoXDB" has 1 instance(s).
Instance "taotao1", status READY, has 1 handler(s) for this service...
The command completed successfully
[oracle@RAC2 admin]$ lsnrctl status
LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 27-FEB-2012 10:51:59
Copyright (c) 1991, 2009, Oracle. All rights reserved.
Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 11.2.0.1.0 - Production
Start Date 24-FEB-2012 17:08:28
Uptime 2 days 17 hr. 43 min. 31 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/11.2.0/grid/network/admin/listener.ora
Listener Log File /u01/app/oracle/diag/tnslsnr/RAC2/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=LISTENER)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=172.20.10.192)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=172.20.10.12)(PORT=1521)))
Services Summary... Service "taotao" has 1 instance(s).
Instance "taotao2", status READY, has 1 handler(s) for this service...
Service "taotaoXDB" has 1 instance(s).
Instance "taotao2", status READY, has 1 handler(s) for this service...
The command completed successfully
8、随便找个客户端
配置/oracle/app/oracle/product/10.1.0/Db_1/network/admin/tnsnames.ora如下
taotao =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = rac1-vip)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = rac2-vip)(PORT = 1521))
(LOAD_BALANCE = yes)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = taotao)
(FAILOVER_MODE =
(TYPE = session)
(METHOD = basic)
(RETRIES = 180)
(DELAY = 5)
)
)
)
9、在客户端上执行 [oracle@oracle oracle]$ sqlplus system/123456@taotao
SQL*Plus: Release 10.1.0.3.0 - Production on Mon Feb 27 10:46:11 2012
Copyright (c) 1982, 2004, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, Real Application Clusters, OLAP, Data Mining
and Real Application Testing options
SQL> show user
USER is "SYSTEM"
10、看此时是使用的哪个实例
SQL> select instance_name from v$instance;
INSTANCE_NAME
----------------
taotao1
11、重启rac1,看到切换到taotao2实例了
SQL>select instance_name from v$instance;
INSTANCE_NAME
----------------
taotao2
12、当rac1启动之后,又会变成taotao1
SQL>select instance_name from v$instance;
INSTANCE_NAME
----------------
taotao1