eagleshi 发表于 2018-9-10 09:52:10

一个很简单测试oracle压力方法

  今天做了一个简单的测试数据库压力,把东西分享了一下。
  服务器情况:
  操作系统版本:CentOS 5.6 -64
  cpu:Intel(R) Xeon(R) CPUX5660@ 2.80GHz * 24
  内存:Mem:      16425876
  Swap:   32764556
  数据库版本:oracle10gR2
  节点个数:2
  测试方法如下:通过awr找出测试系统里面消耗比较多sql(可以是IO或者是执行时间)
  使用python写了如下脚本
  #! /usr/bin/python
  #coding=UTF-8
  import cx_Oracle
  import time
  def hello():
  '''''Hello cx_Oracle示例:
  1)打印数据库版本信息.
  2)查询表数据.'''
  conn = cx_Oracle.connect("jscn/jscn@192.168.100.199:1521/jscn")
  cur = conn.cursor()
  try:
  print "Oracle Version:%s" % conn.version
  print "Table SUB_POLICY rows:"
  interger = 1
  while interger   select count(*) from v$session where program='python.exe';
  COUNT(*)
  ----------
  24
  登录到第二个节点,查看python连接数
  SQL> select count(*) from v$session where program='python.exe';
  COUNT(*)
  ----------
  26
  查看总的连接数
  SQL>select count(*) from gv$session where program='python.exe';
  COUNT(*)
  ----------
  50
  2、查看每个用户的pga分配大小
  Select spid ,Value / 1024 / 1024 Mb
  From V$session s, V$sesstat St, V$statname Sn, V$process p
  Where St.Sid = s.Sid
  And St.Statistic# = Sn.Statistic#
  And Sn.Name Like 'session pga memory'
  And p.Addr = s.Paddr and s.program='python.exe'
  Order By Value Desc;
  SPID               MB
  ------------ ----------
  1936         0.73026275
  1906         0.73026275
  1955         0.73026275
  1940         0.73026275
  1953         0.73026275
  1946         0.73026275
  1934         0.73026275
  1942         0.73026275
  1972         0.73026275
  1959         0.73026275
  1900         0.73026275
  1961         0.73026275
  1970         0.73026275
  1968         0.73026275
  1957         0.73026275
  1902         0.73026275
  1904         0.73026275
  1919         0.73026275
  1938         0.73026275
  1923         0.73026275
  SPID               MB
  ------------ ----------
  1921         0.73026275
  1925         0.73026275
  1917         0.73026275
  1910         0.73026275
  1908         0.73026275
  1927         0.73026275
  这里0.73026275*用户数
页: [1]
查看完整版本: 一个很简单测试oracle压力方法