微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Oracle性能查看

Oracle数据库配置文件中更改最大连接数: http://www.2cto.com/database/201303/192758.html
Oracle日常性能查看 : http://www.jb51.cc/article/p-duayteqt-bek.html
使用命令行手工建立Oracle11gR2数据库http://www.cnblogs.com/beanbee/archive/2012/09/22/2697689.html
以下命令以管理员system用户测试,普通用户没有相关视图的权限:
当前的数据库连接数
select count(*) from v$process where program='Oracle.EXE(SHAD)';




数据库允许的最大连接数
select value from v$parameter where name ='processes';





当前的session连接数
select count(*) from v$session; 






并发连接数
select count(*) from v$session where status='ACTIVE';





最大连接
show parameter processes;  





查看当前有哪些用户正在使用数据
SELECT osuser,a.username,cpu_time/executions/1000000||'s',b.sql_text,machine
from v$session a,v$sqlarea b
where a.sql_address =b.address order by cpu_time/executions desc;





重启数据库
shutdown immediate;
startup;

修改最大连接数:
alter system set processes = 300 scope = spfile; 


修改数据库配置之前,尽量先备份数据库
这个谨慎使用:当时我把processes修改的太小,以至于oracle拒绝连接:
ERROR:
ORA-01034: ORACLE not available
ORA-27101: shared memory realm does not exist
进程 ID: 0
会话 ID: 0 序列号: 0


查看日志oradim.log:




Fri Feb 24 09:34:21 2017
D:\Oracle11g\app\oracle\product\11.2.0\server\bin\oradim.exe -startup -sid xe -usrpwd * -log oradim.log -nocheck 0
Fri Feb 24 09:34:33 2017
ORA-00444: background process "GEN0" Failed while starting
ORA-00020: maximum number of processes () exceeded


从上面可以看出,最大连接数太小导致启动是吧!

Oracle数据库配置文件中更改最大连接数: http://www.2cto.com/database/201303/192758.html



最好不要手动通过配置文件修改,因为配置文件是二进制格式的;最好通过命令行修改

oracle数据库启动目录:



初始化配置文件和密码文件

oracle实例配置目录:


实例配置文件init且全局,SPFILEXE为对应的实例XE的配置文件

创建用户

 create user donald identified by 123456; 


授权用户
 grant connect,resource to donald;



确定共享池中的命中率:(如果ratio1大于1时,需要加大共享池,如果ratio2大于10%时,需要加大共享池SHARED_POOL_SIZE)
select sum(pins) pins,sum(reloads) reloads,(sum(reloads) / sum(pins)) * 100 ratio1
from v$librarycache ;


select sum(gets) gets,sum(getmisses) getmisses,(sum(getmisses) / sum(gets)) * 100 ratio2
from v$rowcache ;


判断回滚段竞争的sql语句:(当Ratio大于2时存在回滚段竞争,需要增加更多的回滚段)
select rn.name,rs.GETS,rs.WAITS,(rs.WAITS / rs.GETS) * 100 ratio
from v$rollstat rs,v$rollname rn
where rs.USN = rn.usn ;


判断恢复日志竞争的sql语句:(immediate_contention或wait_contention的值大于1时存在竞争)
select name,(t.IMMEDIATE_MISSES /
decode((t.IMMEDIATE_GETS + t.IMMEDIATE_MISSES),-1,(t.IMMEDIATE_GETS + t.IMMEDIATE_MISSES))) * 100 immediate_contention,(t.MISSES / decode((t.GETS + t.MISSES),(t.GETS + t.MISSES))) * 100 wait_contention
from v$latch t
where name in ('redo copy','redo allocation') ;


判断表空间碎片:(如果最大空闲空间占总空间很大比例则可能不存在碎片,如果比例较小,且有许多空闲空间,则可能碎片很多)
select t.tablespace_name,sum(t.bytes),max(t.bytes),count(*),max(t.bytes) / sum(t.bytes) radio
from dba_free_space t
group by t.tablespace_name
order by t.tablespace_name ;


确定命中排序域的次数
select t.NAME,t.VALUE from v$sysstat t where t.NAME like 'sort%';



查询耗资源的进程(top session)
SELECT s.Schemaname Schema_Name,Decode(Sign(48 - Command),1,To_Char(Command),'Action Code #' || To_Char(Command)) Action,Status Session_Status,s.Osuser Os_User_Name,s.Sid,p.Spid,s.Serial# Serial_Num,Nvl(s.Username,'[Oracle process]') User_Name,s.Terminal Terminal,s.Program Program,St.VALUE Criteria_Value
FROM V$sesstat St,V$session s,V$process p
WHERE St.Sid = s.Sid
AND St.Statistic# = To_Number('38')
AND ('ALL' = 'ALL' OR s.Status = 'ALL')
AND p.Addr = s.Paddr
ORDER BY St.VALUE DESC,p.Spid ASC,s.Username ASC,s.Osuser ASC


查看锁(lock)情况
SELECT /*+ RULE */ Ls.Osuser Os_User_Name,Ls.Username User_Name,Decode(Ls.TYPE,'RW','Row wait enqueue lock','TM','DML enqueue lock','TX','Transaction enqueue lock','UL','User supplied lock') Lock_Type,o.Object_Name OBJECT,Decode(Ls.Lmode,NULL,2,'Row Share',3,'Row Exclusive',4,'Share',5,'Share Row Exclusive',6,'Exclusive',NULL) Lock_Mode,o.Owner,Ls.Sid,Ls.Serial# Serial_Num,Ls.Id1,Ls.Id2 FROM Sys.Dba_Objects o,(SELECT s.Osuser,s.Username,l.TYPE,l.Lmode,s.Serial#,l.Id1,l.Id2 FROM V$session s,V$lock l
WHERE s.Sid = l.Sid) Ls
WHERE o.Object_Id = Ls.Id1
AND o.Owner <> 'SYS'
ORDER BY o.Owner,o.Object_Name;


查看等待(wait)情况
SELECT Ws.CLASS,Ws.COUNT COUNT,SUM(Ss.VALUE) Sum_Value
FROM V$waitstat Ws,V$sysstat Ss
WHERE Ss.NAME IN ('db block gets','consistent gets')
GROUP BY Ws.CLASS,Ws.COUNT;

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐