点击上方“IT那活儿”公众号,关注后了解更多内容,不管IT什么活儿,干就完了!!!
文章前言
本章内容包含测试六个场景:
需要回顾早前发布的文章,可点击文章标题跳转原文查看:
《oracle最佳连接方式之service简介及创建(上)》
service测试相关脚本
2.1 先主库建测试表及测试用户
create user dbauser identified by oracle account unlock;
grant dba to dbauser;
create table dbauser.test_read(id number);
insert into dbauser.test_read values(1);
insert into dbauser.test_read values(2);
insert into dbauser.test_read values(3);
commit;
create table dbauser.test_write(id number);
#!/bin/bash
#Autor:Wangergui
#Description:test write
i=0
while true;do
sqlplus dbauser/oracle@PRI_EMREP1< insert into dbauser.test_write values ($i);
commit;
exec dbms_lock.sleep(5);
quit
EOF
sleep 2 && i=$(($i+1))
done
#!/bin/bash
#Autor:Wangergui
#Description:test read
i=0
while true;do
sqlplus -S dbauser/oracle@PRI_EMREP1 < select * from dbauser.test;
exec dbms_lock.sleep(5);
quit
EOF
sleep 1 && i=$(($i+1))
done
#!/bin/bash
#Autor:Wangergui
#Description:Monitor write
i=0
while true;do
sqlplus dbauser/oracle@PRI_EMREP1 < select * from dbauser.test_write;
exec dbms_lock.sleep(5);
quit
EOF
sleep 2 && i=$(($i+1))
done
说明:
192.168.8.111为备库的SCAN IP
# Primary Node1
PRI_EMREP1 =
(DESCRIPTION =
(ADDRESS_LIST =
(LOAD_BALANCE = off)
(FAILOVER = ON)
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.8.110)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.8.111)(PORT = 1521))
)
(CONNECT_DATA =
(service_name = EMREP_R_S1)
(FAILOVER_MODE =
(type = session)
(method = basic)
(retries = 10)
(delay = 5)
)
)
)
# Primary Node2
PRI_EMREP2 =
(DESCRIPTION =
(ADDRESS_LIST =
(LOAD_BALANCE = off)
(FAILOVER = ON)
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.8.110)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.8.111)(PORT = 1521))
)
(CONNECT_DATA =
(service_name = EMREP_R_S2)
(FAILOVER_MODE =
(type = session)
(method = basic)
(retries = 10)
(delay = 5)
)
)
)
# Standby Node1
STD_EMREP1 =
(DESCRIPTION =
(ADDRESS_LIST =
(LOAD_BALANCE = off)
(FAILOVER = ON)
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.8.111)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.8.110)(PORT = 1521))
)
(CONNECT_DATA =
(service_name = EMREP_RD_S1)
(FAILOVER_MODE =
(type = session)
(method = basic)
(retries = 10)
(delay = 5)
)
)
)
# Standy Node2
STD_EMREP2 =
(DESCRIPTION =
(ADDRESS_LIST =
(LOAD_BALANCE = off)
(FAILOVER = ON)
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.8.111)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.8.110)(PORT = 1521))
)
(CONNECT_DATA =
(service_name = EMREP_RD_S2)
(FAILOVER_MODE =
(type = session)
(method = basic)
(retries = 10)
(delay = 5)
)
)
)
#!/bin/bash
#Autor:Wangergui
#Description: Montor service_name
while true;do sqlplus -S / as sysdba < alter session set nls_date_format=YYYY-MM-DD HH24:MI:SS;
set linesize 500 pagesize 100 echo off feedback off trims on newpage none;
set lines 400 pages 1000
col username for a15;
col machine for a25;
col program for a45;
col service_name for a20;
select inst_id,
sid,
username,
machine,
program,
service_name,
status,
logon_time
from gv$session where username=DBAUSER;
quit;
EOF
echo && sleep 1
done
测试场景
1)测试过程说明
session 1运行连接测试service.sh脚本;
session 2 运行session监控session.sh 脚本;
session 3关闭节点1数据库shutdown immediate;
监控service会不会漂移。
srvctl stop instance –d –n –f -failover
srvctl stop instance –d -n -f -failover
#!/bin/bash
#Autor:Wangergui
#Description:test read
i=0
while true;do
sqlplus -S wangergui/oracle@STD_ORCL1 < select * from wangergui.test_read;
exec dbms_lock.sleep(5);
quit
EOF
sleep 1 && i=$(($i+1))
done
while true;do sqlplus -S / as sysdba < alter session set nls_date_format=YYYY-MM-DD HH24:MI:SS;
set linesize 500 pagesize 100 echo off feedback off trims on newpage none;
set lines 400 pages 1000
col username for a15;
col machine for a25;
col program for a45;
col service_name for a20;
select inst_id,
sid,
username,
machine,
program,
service_name,
status,
logon_time
from gv$session where username=WANGERGUI;
quit;
EOF
echo && sleep 1
done
节点1 session 2执行shutdown immediate关闭数据库。
shutdown immedaite;
会话监控如下:
srvctl relocate service -db DGORCL -service ORCL_rd_s1 -oldinst orcl2 -newinst orcl1
1)测试场景说明
#!/bin/bash
#Autor:Wangergui
#Description:test read
i=0
while true;do
sqlplus -S wangergui/oracle@STD_ORCL1 < select * from wangergui.test_read;
exec dbms_lock.sleep(5);
quit
EOF
sleep 1 && i=$(($i+1))
done
while true;do sqlplus -S / as sysdba < alter session set nls_date_format=YYYY-MM-DD HH24:MI:SS;
set linesize 500 pagesize 100 echo off feedback off trims on newpage none;
set lines 400 pages 1000
col username for a15;
col machine for a25;
col program for a45;
col service_name for a20;
select inst_id,
sid,
username,
machine,
program,
service_name,
status,
logon_time
from gv$session where username=WANGERGUI;
quit;
EOF
echo && sleep 1
done
同场景一。
同场景二。
最佳实践配置
#
Primary Node1 优先连接主库节点1
PRI_ORCL1 =
(DESCRIPTION =
(ADDRESS_LIST =
(LOAD_BALANCE = off)
(FAILOVER = ON)
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.8.110)(PORT = 1521)) #主库SCAN IP
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.8.111)(PORT = 1521)) #备库SCAN IP
)
(CONNECT_DATA =
(service_name = ORCL_R_S1)
(FAILOVER_MODE =
(type = session)
(method = basic)
(retries = 10)
(delay = 5)
)
)
)
# Primary Node2 优先连接主库节点2
PRI_ORCL2 =
(DESCRIPTION =
(ADDRESS_LIST =
(LOAD_BALANCE = off)
(FAILOVER = ON)
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.8.110)(PORT = 1521)) #主库SCAN IP
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.8.111)(PORT = 1521)) #备库SCAN IP
)
(CONNECT_DATA =
(service_name = ORCL_R_S2)
(FAILOVER_MODE =
(type = session)
(method = basic)
(retries = 10)
(delay = 5)
)
)
)
# Standby Node1 优先连接备库节点1
STD_ORCL1 =
(DESCRIPTION =
(ADDRESS_LIST =
(LOAD_BALANCE = off)
(FAILOVER = ON)
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.8.111)(PORT = 1521)) #备库SCAN IP
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.8.110)(PORT = 1521)) #主库SCAN IP
)
(CONNECT_DATA =
(service_name = ORCL_RD_S1)
(FAILOVER_MODE =
(type = session)
(method = basic)
(retries = 10)
(delay = 5)
)
)
)
# Standy Node2 优先连接主库节点2
STD_ORCL2 =
(DESCRIPTION =
(ADDRESS_LIST =
(LOAD_BALANCE = off)
(FAILOVER = ON)
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.8.111)(PORT = 1521)) #备库SCAN IP
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.8.110)(PORT = 1521)) #主库SCAN IP
)
(CONNECT_DATA =
(service_name = ORCL_RD_S2)
(FAILOVER_MODE =
(type = session)
(method = basic)
(retries = 10)
(delay = 5)
)
)
)
PRI_ORCL1 =
(DESCRIPTION =
(ADDRESS_LIST =
(LOAD_BALANCE = off)
(FAILOVER = ON)
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.8.110)(PORT = 1521)) #主库SCAN IP
)
(CONNECT_DATA =
(service_name = ORCL_R_S1)
(FAILOVER_MODE =
(type = session)
(method = basic)
(retries = 10)
(delay = 5)
)
)
)
PRI_ORCL2 =
(DESCRIPTION =
(ADDRESS_LIST =
(LOAD_BALANCE = off)
(FAILOVER = ON)
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.8.110)(PORT = 1521)) #主库SCAN IP
)
(CONNECT_DATA =
(service_name = ORCL_R_S2)
(FAILOVER_MODE =
(type = session)
(method = basic)
(retries = 10)
(delay = 5)
)
)
)
文章版权归作者所有,未经允许请勿转载,若此文章存在违规行为,您可以联系管理员删除。
转载请注明本文地址:https://www.ucloud.cn/yun/129308.html
摘要:不幸的是,他不断变化要求严格充满活力的环境不适合许多组织仍然依赖的年历史的广域网。企业在上市时间上的变化很短,这对于推动广域网转型计划的来说是一个很大的禁忌。全球企业转向多云环境的最佳实践:sd-wan如何帮助tweet您拥有多云环境-现在怎么办?无论他们是否开始使用多个云,今天的大型企业最终都会使用多个云供应商。事实上,很难找到一家不使用Microsoft Azure、Amazon AWS...
摘要:来源是最流行的用于开发微服务的框架。以下依次列出了最佳实践,排名不分先后。这非常有助于避免可怕的地狱。推荐使用构造函数注入这一条实践来自的项目负责人。保持业务逻辑免受代码侵入的一种方法是使用构造函数注入。 showImg(https://mmbiz.qpic.cn/mmbiz_jpg/R3InYSAIZkHQ40ly9Oztiart2lESCyjCH0JwFRp3oErlYobhibM...
摘要:高性能代码的最佳实践前言在这篇文章中,我们将讨论几个有助于提升应用程序性能的方法。要获得有关应用程序需求的最好最可靠的方法是对应用程序执行实际的负载测试,并在运行时跟踪性能指标。 showImg(https://segmentfault.com/img/bVbtgk4?w=256&h=254); 高性能Java代码的最佳实践前言 在这篇文章中,我们将讨论几个有助于提升Java应用程序性...
摘要:年月日甲骨文今日发布了最新的集成产品,以帮助企业更便利地运用变革性技术。甲骨文提供下一代用户体验,包括基于个人角色使用所有功能,同时通过预先制作的集成模板加速产品上市时间,为企业创造更多的价值。2017年10月11日 –甲骨文今日发布了最新的集成PaaS产品,以帮助企业更便利地运用变革性技术。除了最新的自治数据管理云服务、大数据分析和人工智能功能之外,甲骨文宣布在其应用程序开发平台、数据集成...
阅读 1249·2023-01-11 13:20
阅读 1557·2023-01-11 13:20
阅读 1011·2023-01-11 13:20
阅读 1680·2023-01-11 13:20
阅读 3971·2023-01-11 13:20
阅读 2517·2023-01-11 13:20
阅读 1310·2023-01-11 13:20
阅读 3481·2023-01-11 13:20