Oracle rac连接负载均衡配置,也就是说,如果连接rac,一般会连接负载较小的主机,很直白
服务器端:
1、在rac所有节点中的tnsnames.ora中添加类似如下信息
remote_rac =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.9.114)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.9.115)(PORT = 1521))
)
2、配置系统参数(登陆数据库):
alter system set remote_listener='remote_rac' scope=both sid='*';
3、重启监听,lsnrctl stop/start
这里我重启节点1的时候出现了:
TNS-12542: TNS:address already in use
TNS-12560: TNS:protocol adapter error
TNS-00512: Address already in use
Linux Error: 98: Address already in use
这里解决方法如下
1) 使用srvctl关闭监听
[oracle@rac1 admin]$ srvctl stop listener -n rac1
PRCC-1017 : LISTENER \u5df2\u5728 rac1 \u4e0a\u505c\u6b62
2) 关闭scan监听
[oracle@rac1 admin]$ srvctl stop scan_listener -i 1
3) 然后在启动
[oracle@rac1 admin]$ srvctl start listener -n rac1
[oracle@rac1 admin]$ srvctl start scan_listener -i 1
[oracle@rac1 admin]$ lsnrctl status
部分内容如下
Services Summary...
Service "rac.localdomain" has 2 instance(s).
Instance "rac1", status READY, has 2 handler(s) for this service...
Instance "rac2", status READY, has 1 handler(s) for this service...
正常了,呵呵
客户端配置:
在客户端中tnsnames.ora中添加如下内容
RAC =
(DESCRIPTION =
(LOAD_BALANCE=on)
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.9.114)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.9.115)(PORT = 1521))
)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = rac.localdomain)
)
)
测试:
Vi test.sh
#!/bin/sh
sqlplus "center/vion@RAC" <<EOF
select instance_name from v\$instance;
exit
EOF
执行,我执行的时候出现了问题:-bash: ./test.sh: Permission denied
修改权限:
Chmod u+x *.sh
执行:
。/test.sh
[oracle@localhost admin]$ ./test.sh
SQL*Plus: Release 11.2.0.1.0 Production on Mon Dec 16 17:39:59 2013
Copyright (c) 1982, 2009, 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>
INSTANCE_NAME
--------------------------------
rac2
SQL> Disconnected from 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
[oracle@localhost admin]$ ./test.sh
SQL*Plus: Release 11.2.0.1.0 Production on Mon Dec 16 17:40:01 2013
Copyright (c) 1982, 2009, 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>
INSTANCE_NAME
--------------------------------
rac1
SQL> Disconnected from 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