分类 IT运维 下的文章

racle 查看锁表sql语句(导致锁表的sql)、解锁语句
--查看锁表进程SQL语句1:

--被锁对象表、数据库对象表、数据session表关联来获取被锁对象对应的是那个session;
select sess.sid,
sess.serial#,
lo.oracle_username,
lo.os_user_name,
ao.object_name,
lo.locked_mode
from v$locked_object lo,
dba_objects ao,
v$session sess
where ao.object_id = lo.object_id and lo.session_id = sess.sid;

--查看锁表进程SQL语句2:
select * from v$session t1, v$locked_object t2 where t1.sid = t2.SESSION_ID;

--查看导致锁表的sql语句是那一条

select l.session_id sid,
s.serial#,
l.locked_mode,
l.oracle_username,
s.user#,
l.os_user_name,
s.machine,
s.terminal,
a.sql_text,
a.action
from v$sqlarea a, v$session s, v$locked_object l
where l.session_id = s.sid
and s.prev_sql_addr = a.address
order by sid, s.serial#;

--杀掉锁表进程:

--通过上面的查询获取SID和serial#,替换下面的x,y,就可以解除被锁的状态
alter system kill session 'x,y';

1、上午用户反馈dg数据和生产数据不一致
检查发现mpr进行已停止
select * from v$managed_standby;
2、检查alert.log
发现告警:ORA 00494 ENQUEUE[CF] held for too long (more than 900 seconds) by 'inst 1,osid 469226'
incident details in:/u01/app/....../sid_pr00_258815_i240250.trc

打开trace文件,发现loadAVG: 16.9,15.22,10.59
cat /proc/cpuinfo | grpe proc |wc -l 4 4个cpu,明显压力过大
经分析发现mrp0 进程停止的时间为备份软件启动时间。且主库的cpu、内存配置是备库的2倍,由此可以断点,是因为cpu过大,导致产生了长时间CF控制文件锁,导致恢复进程停止。
3、手动启动应用进程
alter database recover managed standby database using current logfile disconnect from session
提示相应的未找到归档日志
检查v$archived_log 发现name字段中存在备份一体机的备份的归档信息。
4、手动清理rman中,备份一体机的备份信息
delete archivelog like ‘%xxxxx.dbf%’
5、重新启动应用进程
alter database recover managed standby database using current logfile disconnect from session
6、检查发现
select * from v$managed_standby;
mrp0进行已经正常启动
7、检查应用执行情况

select thread#,sequance#,'last applied:' logs,to_char(next_time,'DD-MON-YYYY:HH24:MI:SS') TIME
from archived_log 
 where sequence#=(select max(sequence#) from v$archived_log where applied='YES') 
UNION 
SELECT THREAD#,sequence#,'las received:' logs,to_char(next_time,'DD-MON-YYYY:HH24:MI:SS') TIME 
FROM 
V$archived_log 
  where sequence#=(select max(sequence#) from v$archived_log);