使用 resource_limit 及 profile 限制使用者串連

來源:互聯網
上載者:User

資料庫效能是一個永恒的話題,那就是如何使用更少的資源以達到更高效的效能。Oracle系統參數RESOURCE_LIMIT是一個用於控制使用者對於資料庫資源使用的參數,當值為true的時候即為啟用,否則禁用。該參數結合profile來可以控制多種資源的使用,如CPU_PER_SESSION, CONNECT_TIME,LOGICAL_READS_PER_SESSION,
PRIVATE_SGA等等從而達到到節省資源來實現高效效能。本文描述了資料資源限制並示範了IDLE_TIME及SESSIONS_PER_USER的用法。

1、資料庫資源限制的主要步驟
Implemented by
    * Setting RESOURCE_LIMIT = TRUE in the database startup parameter file (spfile or pfile)
    * Creating or modifying existing user profiles (DBA_PROFILES) to have one or more resource limit
    * Assigning a profile to a user whose resources are wished to be limited

It could happen that if the idle_time has been set on the DEFAULT profile, this can lead to an MTS dispatchers being set to 'sniped' and then getting 'cleaned up' via the shell script.

The removal of the dispatcher will result in other sessions 'dying' .In that case, If you are to implement resource limits, may be advisable to create new profiles that be assigned to users and not to change the characteristics of DEFAULT.
Alternatively, if you do change DEFAULT, ensure that all the properties that you have affected have been fully tested in a development environment.

使用者超出限制後的完成的動作
When a resource limit is exceeded (for example IDLE_TIME) ... PMON does the following
    * Mark the V$SESSION as SNIPED
    * Clean up the database resources for the session
    * Remove the V$SESSION entry

2、資源限制的配置

--示範環境
SQL> select * from v$version where rownum<2;

BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production

--查看參數resource_limit
SQL> show parameter resource_limit

NAME                                TYPE        VALUE
------------------------------------ ----------- ------------------------------
resource_limit                      boolean    FALSE

--修改參數resource_limit為true
SQL> alter system set resource_limit=true;

System altered.

SQL> show parameter resource_limit

NAME                                TYPE        VALUE
------------------------------------ ----------- ------------------------------
resource_limit                      boolean    TRUE

--建立profile,其idle_time為3分鐘
SQL> create profile app_user limit idle_time 3;

Profile created.

--修改profile,限制每個使用者只能開一個session
SQL> alter profile app_user limit sessions_per_user 1;

Profile altered.

--將使用者指派給特定的profile
SQL> alter user scott profile app_user;

User altered.

--查看剛剛建立的profile,查詢結果中的RESOURCE_NAME都可以作相應的設定或修改
SQL> select * from dba_profiles where profile='APP_USER';

PROFILE                        RESOURCE_NAME                    RESOURCE LIMIT
------------------------------ -------------------------------- -------- ----------------------------------------
APP_USER                      COMPOSITE_LIMIT                  KERNEL  DEFAULT
APP_USER                      SESSIONS_PER_USER                KERNEL  1
APP_USER                      CPU_PER_SESSION                  KERNEL  DEFAULT
APP_USER                      CPU_PER_CALL                    KERNEL  DEFAULT
APP_USER                      LOGICAL_READS_PER_SESSION        KERNEL  DEFAULT
APP_USER                      LOGICAL_READS_PER_CALL          KERNEL  DEFAULT
APP_USER                      IDLE_TIME                        KERNEL  3
APP_USER                      CONNECT_TIME                    KERNEL  DEFAULT
APP_USER                      PRIVATE_SGA                      KERNEL  DEFAULT
APP_USER                      FAILED_LOGIN_ATTEMPTS            PASSWORD DEFAULT
APP_USER                      PASSWORD_LIFE_TIME              PASSWORD DEFAULT
APP_USER                      PASSWORD_REUSE_TIME              PASSWORD DEFAULT
APP_USER                      PASSWORD_REUSE_MAX              PASSWORD DEFAULT
APP_USER                      PASSWORD_VERIFY_FUNCTION        PASSWORD DEFAULT
APP_USER                      PASSWORD_LOCK_TIME              PASSWORD DEFAULT
APP_USER                      PASSWORD_GRACE_TIME              PASSWORD DEFAULT

16 rows selected.

  • 1
  • 2
  • 下一頁

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.