[20200218]ENABLE=BROKEN在連線串中4.txt

lfree發表於2020-02-18

[20200218]ENABLE=BROKEN在連線串中4.txt

--//上午測試在連線串中加入與不加入ENABLE=BROKEN的情況,測試有點亂,我下午換1個角度測試:

1.環境:
SCOTT@book> @ ver1
PORT_STRING                    VERSION        BANNER
------------------------------ -------------- --------------------------------------------------------------------------------
x86_64/Linux 2.4.xx            11.2.0.4.0     Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production

# echo /proc/sys/net/ipv4/tcp_keepalive* | xargs   -n 1  strings -1 -f
/proc/sys/net/ipv4/tcp_keepalive_intvl: 10
/proc/sys/net/ipv4/tcp_keepalive_probes: 4
/proc/sys/net/ipv4/tcp_keepalive_time: 20

2.測試連線串有ENABLE=BROKEN的情況:

$ rlwrap sqlplus  scott/book@"(DESCRIPTION=(ENABLE=BROKEN)(CONNECT_DATA=(SERVICE_NAME=book)(SERVER = DEDICATED))(ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=1521)))"

SCOTT@book> @ spid

       SID    SERIAL# PROCESS                  SERVER    SPID       PID  P_SERIAL# C50
---------- ---------- ------------------------ --------- ------ ------- ---------- --------------------------------------------------
         3        919 58548                    DEDICATED 58550       24         52 alter system kill session '3,919' immediate;

--//可以從這裡確定sqlplus程式號=58548(對應顯示PROCESS),oraclebook程式號=58550(對應顯示SPID).

$ seq 1000 | xargs -IQ bash -c "netstat -npo 2>/dev/null | egrep '58550|58548'| egrep 'oraclebook|sqlplus'| ts.awk ;sleep 1"
[2020-02-18 16:44:37] tcp        0      0 127.0.0.1:1521              127.0.0.1:6750              ESTABLISHED 58550/oraclebook    keepalive (3.64/0/0)
[2020-02-18 16:44:37] tcp        0      0 127.0.0.1:6750              127.0.0.1:1521              ESTABLISHED 58548/sqlplus       keepalive (3.61/0/0)
[2020-02-18 16:44:38] tcp        0      0 127.0.0.1:1521              127.0.0.1:6750              ESTABLISHED 58550/oraclebook    keepalive (2.62/0/0)
[2020-02-18 16:44:38] tcp        0      0 127.0.0.1:6750              127.0.0.1:1521              ESTABLISHED 58548/sqlplus       keepalive (2.59/0/0)
[2020-02-18 16:44:39] tcp        0      0 127.0.0.1:1521              127.0.0.1:6750              ESTABLISHED 58550/oraclebook    keepalive (1.60/0/0)
[2020-02-18 16:44:39] tcp        0      0 127.0.0.1:6750              127.0.0.1:1521              ESTABLISHED 58548/sqlplus       keepalive (1.56/0/0)
[2020-02-18 16:44:41] tcp        0      0 127.0.0.1:1521              127.0.0.1:6750              ESTABLISHED 58550/oraclebook    keepalive (0.58/0/0)
[2020-02-18 16:44:41] tcp        0      0 127.0.0.1:6750              127.0.0.1:1521              ESTABLISHED 58548/sqlplus       keepalive (0.54/0/0)
[2020-02-18 16:44:42] tcp        0      0 127.0.0.1:1521              127.0.0.1:6750              ESTABLISHED 58550/oraclebook    keepalive (9.57/0/0)
[2020-02-18 16:44:42] tcp        0      0 127.0.0.1:6750              127.0.0.1:1521              ESTABLISHED 58548/sqlplus       keepalive (9.53/0/0)
[2020-02-18 16:44:43] tcp        0      0 127.0.0.1:1521              127.0.0.1:6750              ESTABLISHED 58550/oraclebook    keepalive (8.54/0/0)
[2020-02-18 16:44:43] tcp        0      0 127.0.0.1:6750              127.0.0.1:1521              ESTABLISHED 58548/sqlplus       keepalive (8.51/0/0)
[2020-02-18 16:44:44] tcp        0      0 127.0.0.1:1521              127.0.0.1:6750              ESTABLISHED 58550/oraclebook    keepalive (7.52/0/0)
[2020-02-18 16:44:44] tcp        0      0 127.0.0.1:6750              127.0.0.1:1521              ESTABLISHED 58548/sqlplus       keepalive (7.49/0/0)
[2020-02-18 16:44:45] tcp        0      0 127.0.0.1:1521              127.0.0.1:6750              ESTABLISHED 58550/oraclebook    keepalive (6.50/0/0)
[2020-02-18 16:44:45] tcp        0      0 127.0.0.1:6750              127.0.0.1:1521              ESTABLISHED 58548/sqlplus       keepalive (6.47/0/0)
[2020-02-18 16:44:46] tcp        0      0 127.0.0.1:1521              127.0.0.1:6750              ESTABLISHED 58550/oraclebook    keepalive (5.48/0/0)
[2020-02-18 16:44:46] tcp        0      0 127.0.0.1:6750              127.0.0.1:1521              ESTABLISHED 58548/sqlplus       keepalive (5.44/0/0)
--//注意最後1列。伺服器程式對應的是keepalive,而客戶端程式對應的是keepalive。我的理解就是雙向檢測。

[2020-02-18 16:46:11] tcp        0      0 127.0.0.1:1521              127.0.0.1:6750              ESTABLISHED 58550/oraclebook    keepalive (0.70/0/0)
[2020-02-18 16:46:11] tcp        0      0 127.0.0.1:6750              127.0.0.1:1521              ESTABLISHED 58548/sqlplus       keepalive (0.67/0/0)
# iptables -I INPUT 1 -p tcp --dport 6750 -j REJECT
[2020-02-18 16:46:12] tcp        0      0 127.0.0.1:1521              127.0.0.1:6750              ESTABLISHED 58550/oraclebook    keepalive (9.69/0/1)
[2020-02-18 16:46:12] tcp        0      0 127.0.0.1:6750              127.0.0.1:1521              ESTABLISHED 58548/sqlplus       keepalive (9.66/0/1)
[2020-02-18 16:46:13] tcp        0      0 127.0.0.1:1521              127.0.0.1:6750              ESTABLISHED 58550/oraclebook    keepalive (8.67/0/1)
[2020-02-18 16:46:13] tcp        0      0 127.0.0.1:6750              127.0.0.1:1521              ESTABLISHED 58548/sqlplus       keepalive (8.64/0/1)
[2020-02-18 16:46:14] tcp        0      0 127.0.0.1:1521              127.0.0.1:6750              ESTABLISHED 58550/oraclebook    keepalive (7.65/0/1)
[2020-02-18 16:46:14] tcp        0      0 127.0.0.1:6750              127.0.0.1:1521              ESTABLISHED 58548/sqlplus       keepalive (7.62/0/1)
[2020-02-18 16:46:15] tcp        0      0 127.0.0.1:1521              127.0.0.1:6750              ESTABLISHED 58550/oraclebook    keepalive (6.63/0/1)
[2020-02-18 16:46:15] tcp        0      0 127.0.0.1:6750              127.0.0.1:1521              ESTABLISHED 58548/sqlplus       keepalive (6.59/0/1)
[2020-02-18 16:46:16] tcp        0      0 127.0.0.1:1521              127.0.0.1:6750              ESTABLISHED 58550/oraclebook    keepalive (5.60/0/1)
[2020-02-18 16:46:16] tcp        0      0 127.0.0.1:6750              127.0.0.1:1521              ESTABLISHED 58548/sqlplus       keepalive (5.57/0/1)
[2020-02-18 16:46:17] tcp        0      0 127.0.0.1:1521              127.0.0.1:6750              ESTABLISHED 58550/oraclebook    keepalive (4.58/0/1)
[2020-02-18 16:46:17] tcp        0      0 127.0.0.1:6750              127.0.0.1:1521              ESTABLISHED 58548/sqlplus       keepalive (4.55/0/1)
[2020-02-18 16:46:18] tcp        0      0 127.0.0.1:1521              127.0.0.1:6750              ESTABLISHED 58550/oraclebook    keepalive (3.56/0/1)
[2020-02-18 16:46:18] tcp        0      0 127.0.0.1:6750              127.0.0.1:1521              ESTABLISHED 58548/sqlplus       keepalive (3.53/0/1)
[2020-02-18 16:46:19] tcp        0      0 127.0.0.1:1521              127.0.0.1:6750              ESTABLISHED 58550/oraclebook    keepalive (2.54/0/1)
[2020-02-18 16:46:19] tcp        0      0 127.0.0.1:6750              127.0.0.1:1521              ESTABLISHED 58548/sqlplus       keepalive (2.50/0/1)
[2020-02-18 16:46:20] tcp        0      0 127.0.0.1:1521              127.0.0.1:6750              ESTABLISHED 58550/oraclebook    keepalive (1.51/0/1)
[2020-02-18 16:46:20] tcp        0      0 127.0.0.1:6750              127.0.0.1:1521              ESTABLISHED 58548/sqlplus       keepalive (1.48/0/1)
[2020-02-18 16:46:21] tcp        0      0 127.0.0.1:1521              127.0.0.1:6750              ESTABLISHED 58550/oraclebook    keepalive (0.49/0/1)
[2020-02-18 16:46:21] tcp        0      0 127.0.0.1:6750              127.0.0.1:1521              ESTABLISHED 58548/sqlplus       keepalive (0.46/0/1)
[2020-02-18 16:46:22] tcp        0      0 127.0.0.1:1521              127.0.0.1:6750              ESTABLISHED 58550/oraclebook    keepalive (9.48/0/2)
[2020-02-18 16:46:22] tcp        0      0 127.0.0.1:6750              127.0.0.1:1521              ESTABLISHED 58548/sqlplus       keepalive (9.45/0/2)
[2020-02-18 16:46:23] tcp        0      0 127.0.0.1:1521              127.0.0.1:6750              ESTABLISHED 58550/oraclebook    keepalive (8.46/0/2)
[2020-02-18 16:46:23] tcp        0      0 127.0.0.1:6750              127.0.0.1:1521              ESTABLISHED 58548/sqlplus       keepalive (8.43/0/2)
[2020-02-18 16:46:24] tcp        0      0 127.0.0.1:1521              127.0.0.1:6750              ESTABLISHED 58550/oraclebook    keepalive (7.44/0/2)
[2020-02-18 16:46:24] tcp        0      0 127.0.0.1:6750              127.0.0.1:1521              ESTABLISHED 58548/sqlplus       keepalive (7.40/0/2)
[2020-02-18 16:46:25] tcp        0      0 127.0.0.1:1521              127.0.0.1:6750              ESTABLISHED 58550/oraclebook    keepalive (6.41/0/2)
[2020-02-18 16:46:25] tcp        0      0 127.0.0.1:6750              127.0.0.1:1521              ESTABLISHED 58548/sqlplus       keepalive (6.38/0/2)
[2020-02-18 16:46:26] tcp        0      0 127.0.0.1:1521              127.0.0.1:6750              ESTABLISHED 58550/oraclebook    keepalive (5.39/0/2)
[2020-02-18 16:46:26] tcp        0      0 127.0.0.1:6750              127.0.0.1:1521              ESTABLISHED 58548/sqlplus       keepalive (5.36/0/2)
[2020-02-18 16:46:27] tcp        0      0 127.0.0.1:1521              127.0.0.1:6750              ESTABLISHED 58550/oraclebook    keepalive (4.37/0/2)
[2020-02-18 16:46:27] tcp        0      0 127.0.0.1:6750              127.0.0.1:1521              ESTABLISHED 58548/sqlplus       keepalive (4.34/0/2)
[2020-02-18 16:46:28] tcp        0      0 127.0.0.1:1521              127.0.0.1:6750              ESTABLISHED 58550/oraclebook    keepalive (3.35/0/2)
[2020-02-18 16:46:28] tcp        0      0 127.0.0.1:6750              127.0.0.1:1521              ESTABLISHED 58548/sqlplus       keepalive (3.31/0/2)
[2020-02-18 16:46:29] tcp        0      0 127.0.0.1:1521              127.0.0.1:6750              ESTABLISHED 58550/oraclebook    keepalive (2.32/0/2)
[2020-02-18 16:46:29] tcp        0      0 127.0.0.1:6750              127.0.0.1:1521              ESTABLISHED 58548/sqlplus       keepalive (2.29/0/2)
[2020-02-18 16:46:30] tcp        0      0 127.0.0.1:1521              127.0.0.1:6750              ESTABLISHED 58550/oraclebook    keepalive (1.30/0/2)
[2020-02-18 16:46:30] tcp        0      0 127.0.0.1:6750              127.0.0.1:1521              ESTABLISHED 58548/sqlplus       keepalive (1.27/0/2)
[2020-02-18 16:46:31] tcp        0      0 127.0.0.1:1521              127.0.0.1:6750              ESTABLISHED 58550/oraclebook    keepalive (0.28/0/2)
[2020-02-18 16:46:31] tcp        0      0 127.0.0.1:6750              127.0.0.1:1521              ESTABLISHED 58548/sqlplus       keepalive (0.24/0/2)
[2020-02-18 16:46:32] tcp        0      0 127.0.0.1:1521              127.0.0.1:6750              ESTABLISHED 58550/oraclebook    keepalive (9.27/0/3)
[2020-02-18 16:46:32] tcp        0      0 127.0.0.1:6750              127.0.0.1:1521              ESTABLISHED 58548/sqlplus       keepalive (9.24/0/3)
[2020-02-18 16:46:33] tcp        0      0 127.0.0.1:1521              127.0.0.1:6750              ESTABLISHED 58550/oraclebook    keepalive (8.25/0/3)
[2020-02-18 16:46:33] tcp        0      0 127.0.0.1:6750              127.0.0.1:1521              ESTABLISHED 58548/sqlplus       keepalive (8.21/0/3)
[2020-02-18 16:46:34] tcp        0      0 127.0.0.1:1521              127.0.0.1:6750              ESTABLISHED 58550/oraclebook    keepalive (7.22/0/3)
[2020-02-18 16:46:34] tcp        0      0 127.0.0.1:6750              127.0.0.1:1521              ESTABLISHED 58548/sqlplus       keepalive (7.19/0/3)
[2020-02-18 16:46:35] tcp        0      0 127.0.0.1:1521              127.0.0.1:6750              ESTABLISHED 58550/oraclebook    keepalive (6.20/0/3)
[2020-02-18 16:46:35] tcp        0      0 127.0.0.1:6750              127.0.0.1:1521              ESTABLISHED 58548/sqlplus       keepalive (6.17/0/3)
[2020-02-18 16:46:36] tcp        0      0 127.0.0.1:1521              127.0.0.1:6750              ESTABLISHED 58550/oraclebook    keepalive (5.18/0/3)
[2020-02-18 16:46:36] tcp        0      0 127.0.0.1:6750              127.0.0.1:1521              ESTABLISHED 58548/sqlplus       keepalive (5.14/0/3)
[2020-02-18 16:46:37] tcp        0      0 127.0.0.1:1521              127.0.0.1:6750              ESTABLISHED 58550/oraclebook    keepalive (4.15/0/3)
[2020-02-18 16:46:37] tcp        0      0 127.0.0.1:6750              127.0.0.1:1521              ESTABLISHED 58548/sqlplus       keepalive (4.12/0/3)
[2020-02-18 16:46:38] tcp        0      0 127.0.0.1:1521              127.0.0.1:6750              ESTABLISHED 58550/oraclebook    keepalive (3.13/0/3)
[2020-02-18 16:46:38] tcp        0      0 127.0.0.1:6750              127.0.0.1:1521              ESTABLISHED 58548/sqlplus       keepalive (3.10/0/3)
[2020-02-18 16:46:39] tcp        0      0 127.0.0.1:1521              127.0.0.1:6750              ESTABLISHED 58550/oraclebook    keepalive (2.11/0/3)
[2020-02-18 16:46:39] tcp        0      0 127.0.0.1:6750              127.0.0.1:1521              ESTABLISHED 58548/sqlplus       keepalive (2.08/0/3)
[2020-02-18 16:46:40] tcp        0      0 127.0.0.1:1521              127.0.0.1:6750              ESTABLISHED 58550/oraclebook    keepalive (1.09/0/3)
[2020-02-18 16:46:40] tcp        0      0 127.0.0.1:6750              127.0.0.1:1521              ESTABLISHED 58548/sqlplus       keepalive (1.05/0/3)
[2020-02-18 16:46:41] tcp        0      0 127.0.0.1:1521              127.0.0.1:6750              ESTABLISHED 58550/oraclebook    keepalive (0.06/0/3)
[2020-02-18 16:46:41] tcp        0      0 127.0.0.1:6750              127.0.0.1:1521              ESTABLISHED 58548/sqlplus       keepalive (0.03/0/3)
[2020-02-18 16:46:42] tcp        0      0 127.0.0.1:1521              127.0.0.1:6750              ESTABLISHED 58550/oraclebook    keepalive (9.06/0/4)
[2020-02-18 16:46:42] tcp        0      0 127.0.0.1:6750              127.0.0.1:1521              ESTABLISHED 58548/sqlplus       keepalive (9.02/0/4)
[2020-02-18 16:46:43] tcp        0      0 127.0.0.1:1521              127.0.0.1:6750              ESTABLISHED 58550/oraclebook    keepalive (8.03/0/4)
[2020-02-18 16:46:43] tcp        0      0 127.0.0.1:6750              127.0.0.1:1521              ESTABLISHED 58548/sqlplus       keepalive (8.00/0/4)
[2020-02-18 16:46:44] tcp        0      0 127.0.0.1:1521              127.0.0.1:6750              ESTABLISHED 58550/oraclebook    keepalive (7.01/0/4)
[2020-02-18 16:46:44] tcp        0      0 127.0.0.1:6750              127.0.0.1:1521              ESTABLISHED 58548/sqlplus       keepalive (6.98/0/4)
[2020-02-18 16:46:45] tcp        0      0 127.0.0.1:1521              127.0.0.1:6750              ESTABLISHED 58550/oraclebook    keepalive (5.99/0/4)
[2020-02-18 16:46:45] tcp        0      0 127.0.0.1:6750              127.0.0.1:1521              ESTABLISHED 58548/sqlplus       keepalive (5.95/0/4)
[2020-02-18 16:46:46] tcp        0      0 127.0.0.1:1521              127.0.0.1:6750              ESTABLISHED 58550/oraclebook    keepalive (4.96/0/4)
[2020-02-18 16:46:46] tcp        0      0 127.0.0.1:6750              127.0.0.1:1521              ESTABLISHED 58548/sqlplus       keepalive (4.93/0/4)
[2020-02-18 16:46:47] tcp        0      0 127.0.0.1:1521              127.0.0.1:6750              ESTABLISHED 58550/oraclebook    keepalive (3.94/0/4)
[2020-02-18 16:46:47] tcp        0      0 127.0.0.1:6750              127.0.0.1:1521              ESTABLISHED 58548/sqlplus       keepalive (3.91/0/4)
[2020-02-18 16:46:48] tcp        0      0 127.0.0.1:1521              127.0.0.1:6750              ESTABLISHED 58550/oraclebook    keepalive (2.92/0/4)
[2020-02-18 16:46:48] tcp        0      0 127.0.0.1:6750              127.0.0.1:1521              ESTABLISHED 58548/sqlplus       keepalive (2.89/0/4)
[2020-02-18 16:46:49] tcp        0      0 127.0.0.1:1521              127.0.0.1:6750              ESTABLISHED 58550/oraclebook    keepalive (1.90/0/4)
[2020-02-18 16:46:49] tcp        0      0 127.0.0.1:6750              127.0.0.1:1521              ESTABLISHED 58548/sqlplus       keepalive (1.86/0/4)
[2020-02-18 16:46:50] tcp        0      0 127.0.0.1:1521              127.0.0.1:6750              ESTABLISHED 58550/oraclebook    keepalive (0.87/0/4)
[2020-02-18 16:46:50] tcp        0      0 127.0.0.1:6750              127.0.0.1:1521              ESTABLISHED 58548/sqlplus       keepalive (0.84/0/4)
--//16:46:12 - 16:46:50 = 38秒,兩個程式同時消失。

SCOTT@book> select sysdate from dual ;
select sysdate from dual
*
ERROR at line 1:
ORA-03135: connection lost contact
Process ID: 58550
Session ID: 3 Serial number: 919

總結:
可以看出在連線串中加入ENABLE=BROKEN是不錯的選擇。


來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/267265/viewspace-2676093/,如需轉載,請註明出處,否則將追究法律責任。

相關文章