Oracle-dblink improper use


1. Symptom

RAC cluster statistics on the number of sessions to a very large difference, and each database server node initiates a session high as 400+.

-- 查询会话数信息
select /*+ rule */  inst_id,count(*) cnt from gv$session group by inst_id;

select /*+ rule */  inst_id,username,machine,count(*) cnt from gv$session
group by inst_id,username,machine
order by 4;


2. Reasons

1) Check the session where there is a common use dblink, then check information dblink found a preferred example of the above connection string using dblink connection, although added load_balance parameters, not the expected result.

SELECT /*+ ORDERED */
 S.KSUSEMNM "O_HOSTNAME",S.KSUSEPID "O_SPID",--操作dblink用户信息
 G.K2GTITID_ORA "O_TXID",
 S.INDX "S_SID",S.KSUSESER "S_SERIAL#",--dblink session信息
 DECODE(BITAND(KSUSEIDL, 11),
               1,
               'ACTIVE',
               0,
               DECODE(BITAND(KSUSEFLG, 4096), 0, 'INACTIVE', 'CACHED'),
               2,
               'SNIPED',
               3,
               'SNIPED',
               'KILLED') "S_STATUS",
                S.KSUUDNAM "DBLINK_USER"
  FROM SYS.X$K2GTE G, SYS.X$KTCXB T, SYS.X$KSUSE S
 WHERE G.K2GTDXCB = T.KTCXBXBA
   AND G.K2GTDSES = T.KTCXBSES
   AND S.ADDR = G.K2GTDSES;

- dblink information

image


3. treatment program

1) on the application side dblink close the connection session;

2) Use tnsnames.ora modify the configuration tns dblink connector disposed on the database server, and the node corresponding to the address to write over the vip other remote nodes in VIP.

Guess you like

Origin www.cnblogs.com/binliubiao/p/12516741.html