成人国产在线小视频_日韩寡妇人妻调教在线播放_色成人www永久在线观看_2018国产精品久久_亚洲欧美高清在线30p_亚洲少妇综合一区_黄色在线播放国产_亚洲另类技巧小说校园_国产主播xx日韩_a级毛片在线免费

資訊專欄INFORMATION COLUMN

Oracle最佳連接方式之service最佳實踐及測試(下)

IT那活兒 / 1954人閱讀
Oracle最佳連接方式之service最佳實踐及測試(下)

點擊上方“IT那活兒”公眾號,關(guān)注后了解更多內(nèi)容,不管IT什么活兒,干就完了!?。?/strong>


文章前言

本章內(nèi)容包含測試六個場景:

  • 主庫節(jié)點1宕庫
  • 主庫節(jié)點1宕機
  • 備庫節(jié)點1宕庫
  • 備庫節(jié)點1宕機
  • 主備switch over
  • 主備failover

需要回顧早前發(fā)布的文章,可點擊文章標題跳轉(zhuǎn)原文查看:

oracle最佳連接方式之service簡介及創(chuàng)建(上)

oracle最佳連接方式之service維護(中)

service測試相關(guān)腳本

2.1 先主庫建測試表及測試用戶

  • 創(chuàng)建讀測試表
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;
  • 創(chuàng)建寫測試表
create table dbauser.test_write(id number);
  • 循環(huán)寫測試腳本
#!/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

2.2 連接測試腳本

  • 監(jiān)控讀
#!/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
  • 監(jiān)控寫
#!/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

2.3 主備庫tnsnames.ora 配置

說明:

  • 192.168.8.110為主庫的SCAN IP
  • 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)
)
)
)

2.4 session監(jiān)控腳本

#!/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



測試場景

場景一:主庫節(jié)點1宕庫

1)測試過程說明

  • session 1運行連接測試service.sh腳本;

  • session 2 運行session監(jiān)控session.sh 腳本;

  • session 3關(guān)閉節(jié)點1數(shù)據(jù)庫shutdown immediate;

  • 監(jiān)控service會不會漂移。

結(jié)論:service會漂移到節(jié)點2上,數(shù)據(jù)庫啟動之后service不會自動回切至節(jié)點1,需要手動relocate;客戶端無需更改任何配置。
注意:如果使用srvctl stop instance關(guān)閉數(shù)據(jù)庫service不會漂移,需要加-f選項。
srvctl stop instance –d  –n  –f -failover
示例:
srvctl stop instance –d  -n  -f -failover
2)場景一測試如下
測試主機:備庫兩個節(jié)點
VIP :10.30.69.18 && 10.30.69.19
SCAN: 192.168.8.111
  • 節(jié)點1 session1 運行循環(huán)查詢腳本,連接串為STD_ORCL1(優(yōu)先連接備庫的節(jié)點1)。
    預期效果:正常shutdown,節(jié)點1的service可以漂移到節(jié)點2上面,營業(yè)無需修改配置。
    測試結(jié)果:達到預期效果。
#!/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
  • 節(jié)點2 運行session監(jiān)控腳本如下:
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
說明:此時通過STD_ORCL1連接的session全部在節(jié)點1上面。
  • 節(jié)點1 session 2執(zhí)行shutdown immediate關(guān)閉數(shù)據(jù)庫。

shutdown immedaite;
  • 會話監(jiān)控如下:

session已經(jīng)動態(tài)的漂移到了節(jié)點2上面。
  • 節(jié)點1 session 3 執(zhí)行啟動數(shù)據(jù)庫。
    startup;
  • session 監(jiān)控還是在節(jié)點2上面。
節(jié)點1啟庫后service還是在節(jié)點2上面,沒有漂回節(jié)點1,此時需要手動relocate到節(jié)點1。
srvctl relocate service -db DGORCL -service ORCL_rd_s1 -oldinst orcl2 -newinst orcl1
  • session 監(jiān)控已經(jīng)飄回節(jié)點1。

場景二:主庫節(jié)點1宕機

1)測試場景說明

  • 節(jié)點2 session 1運行連接測試service.sh腳本;
  • 節(jié)點2 session 2 運行session監(jiān)控session.sh 腳本;
  • 節(jié)點1 session 1關(guān)閉節(jié)點1主機,執(zhí)行重啟reboot;
  • 監(jiān)控service會不會漂移。
結(jié)論:service會漂移到節(jié)點2上,數(shù)據(jù)庫啟動之后service不會自動回切至節(jié)點1需要手動relocate。
2)節(jié)點2  session1運行循環(huán)查詢腳本
#!/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
3)節(jié)點2  session2 運行session監(jiān)控腳本
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

場景三:備庫節(jié)點1宕庫

  • 同場景一。

場景四:備庫節(jié)點1宕機

  • 同場景二。

場景五:主備switch over

  • 主備切換之后,主備要啟動相應的service,應用無需更改配置。

場景六:主備failover

  • 主備切換之后,主備要啟動相應的service,應用無需更改配置。

最佳實踐配置

4.1 MAA架構(gòu)最佳配置

# Primary Node1 優(yōu)先連接主庫節(jié)點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 優(yōu)先連接主庫節(jié)點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 優(yōu)先連接備庫節(jié)點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 優(yōu)先連接主庫節(jié)點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)
)
)
)

4.2 RAC最佳配置(無ADG)

# Primary Node1 優(yōu)先連接主庫節(jié)點1
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)
)
)
)
# Primary Node2 優(yōu)先連接主庫節(jié)點2
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)
)
)
)


本文作者:王爾貴(上海新炬王翦團隊)

本文來源:“IT那活兒”公眾號

文章版權(quán)歸作者所有,未經(jīng)允許請勿轉(zhuǎn)載,若此文章存在違規(guī)行為,您可以聯(lián)系管理員刪除。

轉(zhuǎn)載請注明本文地址:http://systransis.cn/yun/129308.html

相關(guān)文章

  • 全球企業(yè)走向多元化的最佳實踐

    摘要:不幸的是,他不斷變化要求嚴格充滿活力的環(huán)境不適合許多組織仍然依賴的年歷史的廣域網(wǎng)。企業(yè)在上市時間上的變化很短,這對于推動廣域網(wǎng)轉(zhuǎn)型計劃的來說是一個很大的禁忌。全球企業(yè)轉(zhuǎn)向多云環(huán)境的最佳實踐:sd-wan如何幫助tweet您擁有多云環(huán)境-現(xiàn)在怎么辦?無論他們是否開始使用多個云,今天的大型企業(yè)最終都會使用多個云供應商。事實上,很難找到一家不使用Microsoft Azure、Amazon AWS...

    番茄西紅柿 評論0 收藏0
  • Spring Boot 最流行的 16 條實踐解讀!

    摘要:來源是最流行的用于開發(fā)微服務的框架。以下依次列出了最佳實踐,排名不分先后。這非常有助于避免可怕的地獄。推薦使用構(gòu)造函數(shù)注入這一條實踐來自的項目負責人。保持業(yè)務邏輯免受代碼侵入的一種方法是使用構(gòu)造函數(shù)注入。 showImg(https://mmbiz.qpic.cn/mmbiz_jpg/R3InYSAIZkHQ40ly9Oztiart2lESCyjCH0JwFRp3oErlYobhibM...

    Ethan815 評論0 收藏0
  • 高性能Java代碼的最佳實踐

    摘要:高性能代碼的最佳實踐前言在這篇文章中,我們將討論幾個有助于提升應用程序性能的方法。要獲得有關(guān)應用程序需求的最好最可靠的方法是對應用程序執(zhí)行實際的負載測試,并在運行時跟蹤性能指標。 showImg(https://segmentfault.com/img/bVbtgk4?w=256&h=254); 高性能Java代碼的最佳實踐前言 在這篇文章中,我們將討論幾個有助于提升Java應用程序性...

    stackfing 評論0 收藏0
  • 甲骨文通過創(chuàng)新技術(shù)擴展開放集成的云平臺

    摘要:年月日甲骨文今日發(fā)布了最新的集成產(chǎn)品,以幫助企業(yè)更便利地運用變革性技術(shù)。甲骨文提供下一代用戶體驗,包括基于個人角色使用所有功能,同時通過預先制作的集成模板加速產(chǎn)品上市時間,為企業(yè)創(chuàng)造更多的價值。2017年10月11日 –甲骨文今日發(fā)布了最新的集成PaaS產(chǎn)品,以幫助企業(yè)更便利地運用變革性技術(shù)。除了最新的自治數(shù)據(jù)管理云服務、大數(shù)據(jù)分析和人工智能功能之外,甲骨文宣布在其應用程序開發(fā)平臺、數(shù)據(jù)集成...

    lordharrd 評論0 收藏0

發(fā)表評論

0條評論

IT那活兒

|高級講師

TA的文章

閱讀更多
最新活動
閱讀需要支付1元查看
<