11g R2 RAC客户端负载均衡配置
11g R2 RAC客户端负载均衡配置
1、在服务端查看数据库版本和service_name:
[oracle@rac121 ~]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.3.0 Production on Tue Jun 26 10:44:24 2012
Copyright (c) 1982, 2011, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Data Mining and Real Application Testing options
SQL> select * from v$version;
BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
PL/SQL Release 11.2.0.3.0 - Production
CORE 11.2.0.3.0 Production
TNS for Linux: Version 11.2.0.3.0 - Production
NLSRTL Version 11.2.0.3.0 - Production
SQL> show parameter service_name
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
service_names string racdb
SQL>
2、查看服务端数据库RAC配置:
SQL> host 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
#202.106.199.39 rac121
#Public
10.1.252.121 rac121
10.1.252.122 rac122
#Private
192.168.123.1 rac121-priv
192.168.123.2 rac122-priv
#Virtual IP
10.1.252.75 rac121-vip
10.1.252.76 rac122-vip
10.1.252.68 rac-scan
SQL>
3、在客户端配置tnsnames.ora ,添加内容如下:
racdb=
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 10.1.252.75)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = 10.1.252.76)(PORT = 1521))
(LOAD_BALANCE = on)
)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = racdb)
)
)
4、在客户端打开SQLPLUS测试:
开启第1个sqlplus:
SQL> conn sys/system@racdb as sysdba
已连接。
SQL> show parameter instance_name
NAME TYPE VALUE
------------- -------------- -----------
instance_name string racdb2
开启第2个sqlplus:
SQL> conn sys/system@racdb as sysdba
已连接。
SQL> show parameter instance_name
NAME TYPE VALUE
--------------- --------------- ---------------
instance_name string racdb1
SQL>
开启第3个sqlplus:
SQL> conn sys/system@racdb as sysdba
已连接。
SQL> show parameter instance_name
NAME TYPE VALUE
--------------- --------------- ---------------
instance_name string racdb2
SQL>
开启第4个sqlplus:
SQL> conn sys/system@racdb as sysdba
已连接。
SQL> show parameter instance_name
NAME TYPE VALUE
--------------- --------------- ---------------
instance_name string racdb1
SQL>
这样当客户端连接RAC数据库时,会随机在TNS里面挑个监听地址进行连接
目录 返回
首页