ORACLE 中 PROFILE的管理

PROFILE的管理(资源文件)
      当需要设置资源限制时,必须设置数据库系统启动参数RESOURCE_LIMIT,此参数默认值为FALSE
      可以使用如下命令来启动当前资源限制:
      alter system set RESOURCE_LIMIT=true;
      当需要以后启动时也启动限制,必须在init<SID>.ora中设置
      RESOURCE_LIMIT=true

建立语法:
CREATE PROFILE profile LIMIT
{ resource_parameters | password_parameters }
[ resource_parameters | password_parameters ]...;

{ { SESSIONS_PER_USER | CPU_PER_SESSION | CPU_PER_CALL | CONNECT_TIME | IDLE_TIME    
     | LOGICAL_READS_PER_SESSION | LOGICAL_READS_PER_CALL | COMPOSITE_LIMIT }
     { integer | UNLIMITED | DEFAULT }
| PRIVATE_SGA { integer [ K | M ] | UNLIMITED | DEFAULT }
}

{ { FAILED_LOGIN_ATTEMPTS | PASSWORD_LIFE_TIME | PASSWORD_REUSE_TIME
     | PASSWORD_REUSE_MAX | PASSWORD_LOCK_TIME | PASSWORD_GRACE_TIME }
     { expr | UNLIMITED | DEFAULT }
| PASSWORD_VERIFY_FUNCTION { function | NULL | DEFAULT }
}

CREATE PROFILE new_profile
     LIMIT PASSWORD_REUSE_MAX DEFAULT
           PASSWORD_REUSE_TIME UNLIMITED;

CREATE PROFILE app_user LIMIT
      SESSIONS_PER_USER             UNLIMITED
      CPU_PER_SESSION               UNLIMITED
      CPU_PER_CALL                  3000
      CONNECT_TIME                  45
      LOGICAL_READS_PER_SESSION     DEFAULT
      LOGICAL_READS_PER_CALL        1000
      PRIVATE_SGA                   15K
      COMPOSITE_LIMIT               5000000;

CREATE PROFILE app_user2 LIMIT
      FAILED_LOGIN_ATTEMPTS 5
      PASSWORD_LIFE_TIME 60
      PASSWORD_REUSE_TIME 60
      PASSWORD_REUSE_MAX UNLIMITED
      PASSWORD_VERIFY_FUNCTION verify_function
      PASSWORD_LOCK_TIME 1/24
      PASSWORD_GRACE_TIME 10;
          
一、PROFILE的管理内容:
       1、CPU的时间
       2、I/O的使用
       3、IDLE TIME(空闲时间)
       4、CONNECT TIME(连接时间)
       5、并发会话数量
       6、口令机制:

二、DEFAULT PROFILE:
       1、所有的用户创建时都会被指定这个PROFILE
       2、DEFAULT PROFILE的内容为空,无限制

三、PROFILE的划分:
       If a user attempts to perform an operation that exceeds the limit for other session resources,
Oracle aborts the operation, rolls back the current statement, and immediately returns an error.
The user can then commit or roll back the current transaction, and must then end the session.
       that exceeds the limit(超过限制) for other session resources(范围之外的其他资源)
       被理解为:连接控制资源范围之外的其他资源。
    
       当一个用户试图操作超过限制的资源时,Oracle终止当前操作,取消正在执行的处理,并且返回一个错误,
用户可以提交或回滚当前事物,之后必须断开会话。

       如果一个用户试图操作一个超出他限制的资源,Oracle将放弃这个操作,取消正在执行的处理,并立即返
回一个错误。这个用户然后提交或回滚当前的处理,之后必须终止这个会话。

       如果是调用限制时,Oracle终止当前操作,取消正在执行的处理,并且返回一个错误,回滚整个事务。

       1、CALL级LIMITE:
          对象是语句:
          当该语句资源使用溢出时:
          A、该语句终止
          B、事物回退
          C、SESSION连接保持

       2、SESSION级LIMITE:
          对象是:整个会话过程
          溢出时:连接终止

四、如何管理一个PROFILE
       1、CREATE PROFILE
       2、分配给一个用户
       3、象开关一样打开限制。

五、如何创建一个PROFILE:
       1、命令:
          CREATE PROFILE 名称
          LIMIT
          SESSION_PER_USER 2
          CPU_PER_SESSION 1000
          IDLE_TIME 60     用户在数据库终止前,可以让连接空闲多长时间(分钟)
          CONNECT_TIME 480
       
六、限制参数:
       0、UNLIMITED 取消资源限制
          DEFAULT      缺剩资源限制,即使用default资源限制

       1、CONNECT_TIME        :一个连接会话的最长连接时间(分钟)
                             当用户会话时间超过CONNECT_TIME指定的时间,Oracle将回滚当前事务,并且结束他的会话
          IDLE_TIME           :一个连接会话的最长连接时间
                             当用户空闲时间超过IDLE_TIME指定的时间,Oracle将回滚当前事务,并且结束他的会话

       2、SESSIONS_PER_USER:一个用户允许同时(并发)会话的总数,超过后系统禁止该用户的后续会话,并返回错误:
                             ORA-02391 exceeded simultaneous SESSIONS_PER_USER limit


       3、SESSION级LIMITE:
          CPU_PER_SESSION:定义了一个SESSION占用的CPU的时间(1/100 秒),当达到这个限制用户不能在此会话中执行任何操作,
                           此时必须先断开连接,再连接才行。
          CPU_PER_CALL      :限制每次调用SQL语句期间(parse、execute、fetch)可用的CPU时间总量,单位是百分之一秒。达到限制时
                           语句以报错结束。不同于CPU_PER_SESSION的是,没达到CPU_PER_SESSION限制,还可以进行新的查询。
    
       4、LOGICAL_READS_PER_SESSION: 一个会话允许读写的逻辑块的数量限制
    
       5、CALL级LIMITE
          CPU_PER_CALL:每个语句占用的CPU时间
          LOGICAL_READS_PER_CALL:一次调用的SQL期间,允许读数据库块数限制
       6、PRIVATE_SGA:一个会话允许分配的最大SGA大小,使用K/M定义
          COMPOSITE_LIMIT:一个会话的资源成本限制,CPU_PER_SESSION, CONNECT_TIME, LOGICAL_READS_PER_SESSION, and PRIVATE_SGA
       
七、分配给一个用户:
       CREATE USER 名称。。。。。。
       PROFILE 名称
       ALTER USER 名称 PROFILE 名称

八、打开资源限制:
       1、RESOURCE_LIMT:资源文件中含有
       2、ALTER SYSTEM SET RESOURCE_LIMIT=TRUE;
       3、默认不打开

九、修改PROFIE的内容:
       1、ALTER PROFILE 名称参数      新值
       2、对于当前连接修改不生效。

       DROP一个PROFILE
       1、DROP PROFILE 名称
          删除一个新的尚未分配给用户的PROFILE,
       2、DROP PROFILE 名称 CASCADE
       3、注意事项
          A、一旦PROFILE被删除,用户被自动加载DEFAULT PROFILE
          B、对于当前连接无影响
          C、DEFAULT PROFILE不可以被删除

十、信息获取:
       1、DBA_USERS:
          用户名,PROFILE
       2、DBA_PROFILES:
          PROFILE及各种限制参数的值
          每个用户的限制:PROFILE(关键字段)

十一、PROFILE的口令机制限制
       1、限制内容
          A、限制连续多少次登录失败,用户被加锁
          B、限制口令的生命周期
          C、限制口令的使用间隔
       2、限制生效的前提:
          A、RESOURCE_LIMIT:=TRUE
          B、ORACLE\RDBMS\ADMIN\UTLPWDMG.SQL
       3、如何创建口令机制:
          CREATE PROFILE 名称
          SESSIONS_PER_USER
          .....
          password_life_time 30
          failed_log_attempts 3
          password_reuse_time 3
       4、参数的含义:
          A、FAILED_LOGIN_ATTEMPTS      :当连续登陆失败次数达到该参数指定值时,用户被加锁;
                                       经过DBA解锁(或PASSWORD_LOCK_TIME天)后可继续使用
          B、PASSWORD_LIFE_TIME         :口令的有效期(天),默认为UNLIMITED
          C、PASSWORD_LOCK_TIME         :帐户因FAILED_LOGIN_ATTEMPTS锁定时,加锁天数
          D、PASSWORD_GRACE_TIME        :口令修改的宽限期(天)
          E、PASSWORD_REUSE_TIME        :口令被修改后原有口令隔多少天被重新使用,默认为UNLIMITED
          F、PASSWORD_REUSE_MAX         :口令被修改后原有口令被修改多少次才允许被重新使用。
          G、PASSWORD_VERIFY_FUNCTION:口令效验函数

十二、错误信息及解决方法
ORA-02390 exceeded COMPOSITE_LIMIT, you are being logged off
Cause: The COMPOSITE_LIMIT for the profile is exceeded. That is, the weighted sum of the connection time, logical reads per session, CPU usage per session, and private SGA space used during the session exceeded the limit set by the COMPOSITE_LIMIT clause set in the user profile.
Action: If this happens often, ask the database administrator to raise the COMPOSITE_LIMIT of the user profile, or determine which resource is used the most and raise the limit on that resource.

ORA-02391 exceeded simultaneous SESSIONS_PER_USER limit
Cause: An attempt was made to exceed the maximum number of concurrent sessions allowed by the SESSIONS_PER_USER clause of the user profile.
Action: End one or more concurrent sessions or ask the database administrator to increase the SESSIONS_PER_USER limit of the user profile. For more information about SESSIONS_PER_USER and the database administrator's specific tasks of adjusting concurrent sessions, see the Oracle9i SQL Reference and the Oracle9i Database Administrator's Guide.

ORA-02392 exceeded session limit on CPU usage, you are being logged off
Cause: An attempt was made to exceed the maximum CPU usage allowed by the CPU_PER_SESSION clause of the user profile.
Action: If this happens often, ask the database administrator to increase the CPU_PER_SESSION limit of the user profile.

ORA-02393 exceeded call limit on CPU usage
Cause: An attempt was made to exceed the maximum CPU time for a call, a parse, execute, or fetch, allowed by the CPU_PER_CALL clause of the user profile.
Action: If this happens often, ask the database administrator to increase the CPU_PER_CALL limit of the user profile.

ORA-02394 exceeded session limit on IO usage, you are being logged off
Cause: An attempt was made to exceed the maximum I/O allowed by the LOGICAL_READS_PER_SESSION clause of the user profile.
Action: If this happens often, ask the database administrator to increase the LOGICAL_READS_PER_SESSION limit of the user profile.

ORA-02395 exceeded call limit on IO usage
Cause: An attempt was made to exceed the maximum I/O for a call, a parse, execute, or fetch, allowed by the LOGICAL_READS_PER_CALL clause of the user profile.
Action: If this happens often, ask the database administrator to increase the LOGICAL_READS_PER_CALL limit of the user profile.

ORA-02396 exceeded maximum idle time, please connect again
Cause: A user has exceeded the maximum time allowed to remain idle.
Action: The user must reconnect to the database.

ORA-02397 exceeded PRIVATE_SGA limit, you are being logged off
Cause: This error occurs only when using a multi-threaded server.
Action: Contact the database administrator to expand the PRIVATE_SGA limit.
posted on 2008-10-29 10:39  一江水  阅读(4615)  评论(0编辑  收藏  举报