环境:
os:linux redhat 7.9
oracel:11.2.0.4
服务器:192.168.10.50
客户端:192.168.10.53
1. on 192.168.10.50
----建表和存储过程
sqlplus test/test
create table as_test_exception (error_message varchar2(4000), tmstamp timestamp);
create or replace procedure log_error (sErrorMessage in varchar2)
is
pragma autonomous_transaction;
begin
insert into as_test_exception (error_message, tmstamp) values (sErrorMessage, systimestamp);
commit;
end;
/
select * from as_test_exception;
2. on 192.168.10.53
建立连接:sqlplus test/test@192.168.10.50/orcl
3. on 192.168.10.50,查到10.53 连接过来的端口是 42072
[root@host123 yum.repos.d]# netstat -nap|grep "10.53"|grep "oracle"
tcp 0 0 192.168.10.50:1521 192.168.10.53:42072 ESTABLISHED 16713/oracleorcl
[root@host123 yum.repos.d]#
[root@host123 yum.repos.d]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
2: ens192: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether 00:50:56:a8:a0:0a brd ff:ff:ff:ff:ff:ff
inet 192.168.10.50/24 brd 192.168.10.255 scope global ens192
valid_lft forever preferred_lft forever
4. on 192.168.10.53,执行存储过程
begin
dbms_lock.sleep(60);
exception
when others then
log_error(sqlerrm);
raise;
end;
/
5. on 192.168.10.50 ,使用tcpkill关闭查到的端口(42072)
"-i" 后面的bond0是网卡,可以通过ifconfig找到
"-9" 表示关闭连接的迫切程度,越大表示越强制,默认是3
"port 42072" 是指定连接的表达式,这个和iptables差不多
[root@host123 yum.repos.d]# tcpkill -i ens192 -9 port 42072
tcpkill: listening on ens192 [port 42072]
6. on 192.168.10.53,报错ORA-03135断开
SQL> begin
dbms_lock.sleep(60);
exception
2 3 4 when others then
5 log_error(sqlerrm);
6 raise;
7 end;
8 /
begin
*
ERROR at line 1:
ORA-03135: connection lost contact
Process ID: 21147
Session ID: 2833 Serial number: 55307
SQL>
7. on 192.168.10.50 ,netstat已经观察不到这个tcp连接
[oracle@host123 ~]$ netstat -nap|grep "10.53"|grep "oracle"
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
[oracle@host123 ~]$
----tcpkill捕获到此tcp交换,并关闭tcp连接
[root@host123 yum.repos.d]# tcpkill -i ens192 -9 port 42072
tcpkill: listening on ens192 [port 42072]
192.168.10.50:1521 > 192.168.10.53:42072: R 22759912:22759912(0) win 0
192.168.10.50:1521 > 192.168.10.53:42072: R 22759978:22759978(0) win 0
192.168.10.50:1521 > 192.168.10.53:42072: R 22760110:22760110(0) win 0
192.168.10.50:1521 > 192.168.10.53:42072: R 22760308:22760308(0) win 0
192.168.10.50:1521 > 192.168.10.53:42072: R 22760572:22760572(0) win 0
192.168.10.50:1521 > 192.168.10.53:42072: R 22760902:22760902(0) win 0
192.168.10.50:1521 > 192.168.10.53:42072: R 22761298:22761298(0) win 0
192.168.10.50:1521 > 192.168.10.53:42072: R 22761760:22761760(0) win 0
192.168.10.50:1521 > 192.168.10.53:42072: R 22762288:22762288(0) win 0
192.168.10.53:42072 > 192.168.10.50:1521: R 4230768170:4230768170(0) win 0
192.168.10.53:42072 > 192.168.10.50:1521: R 4230768229:4230768229(0) win 0
192.168.10.53:42072 > 192.168.10.50:1521: R 4230768347:4230768347(0) win 0
192.168.10.53:42072 > 192.168.10.50:1521: R 4230768524:4230768524(0) win 0
192.168.10.53:42072 > 192.168.10.50:1521: R 4230768760:4230768760(0) win 0
192.168.10.53:42072 > 192.168.10.50:1521: R 4230769055:4230769055(0) win 0
192.168.10.53:42072 > 192.168.10.50:1521: R 4230769409:4230769409(0) win 0
192.168.10.53:42072 > 192.168.10.50:1521: R 4230769822:4230769822(0) win 0
192.168.10.53:42072 > 192.168.10.50:1521: R 4230770294:4230770294(0) win 0
----查看as_test_exception无记录
select * from as_test_exception;