一、概念
RAC的不同节点运行不同应用,访问不同的数据。否则,节点间不做应用控制而访问相同数据争用造成的global cache等待事件会导致整体RAC性能不佳,甚至不如单节点。
应用隔离可以通过服务器端监听服务实现,也可以通过客户端的连接串配置实现。
二、实现
服务端应用隔离配置:
2.1 创建集群服务
oracle用户执行:
srvctl add service -d cdfla -s singleser1 -r "cdfla1" -a "cdfla2" -P basic -m basic -e session -w 60 -z 5
测试手动迁移服务到节点2
srvctl relocate service -d cdfla -s singleser1 -i cdfla1 -t cdfla2
客户端配置tnsnames.ora
singleser1 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 10.128.19.75)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = singleser1)
)
)
2.2 测试
创建测试脚本:
[oracle@wkq_nbu_test:/home/oracle]$ cat test100.sh
#!/bin/bash
count=0
while [ $count -lt $2 ]
do
count=`expr $count + 1`
sqlplus -s wkq/123456@$1 @test.sql
done
测试结果:
[oracle@wkq_nbu_test:/home/oracle]$ sh test100.sh singleser1 10
INSTANCE_NAME
----------------
cdfla2
INSTANCE_NAME
----------------
cdfla2
INSTANCE_NAME
----------------
cdfla2
INSTANCE_NAME
----------------
cdfla2
INSTANCE_NAME
----------------
cdfla2
INSTANCE_NAME
----------------
cdfla2
关闭节点2后测试结果:
[oracle@wkq_nbu_test:/home/oracle]$ sh test100.sh singleser1 10
INSTANCE_NAME
----------------
cdfla1
INSTANCE_NAME
----------------
cdfla1
INSTANCE_NAME
----------------
cdfla1
INSTANCE_NAME
----------------
cdfla1
INSTANCE_NAME
----------------
cdfla1
INSTANCE_NAME
----------------
cdfla1
INSTANCE_NAME
----------------
cdfla1
INSTANCE_NAME
----------------
cdfla1
INSTANCE_NAME
----------------
cdfla1
INSTANCE_NAME
----------------
cdfla1
客户端应用隔离配置:
singleser1 =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = rac1)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = rac2)(PORT = 1521))
)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = or11g)
)
)
测试结果:
SQL> select INST_ID,username from gv$session where username='SCOTT';
no rows selected
SQL> /
INST_ID USERNAME
---------- ------------------------------ ---------- ----------
1 SCOTT
SQL> /
INST_ID USERNAME
---------- ------------------------------ ---------- ----------
1 SCOTT
1 SCOTT
SQL> /
INST_ID USERNAME
---------- ------------------------------ ---------- ----------
1 SCOTT
1 SCOTT
1 SCOTT
三、总结
应用隔离配置简单,属于RAC的常用优化方式。
参考文章:
https://www.cnblogs.com/timlong/p/7834961.html
https://blog.csdn.net/daf380/article/details/89225316
https://blog.csdn.net/jnrjian/article/details/123785649