Bo's Oracle Station

查看: 2990|回复: 0

课程第46/47次(2017-07-01星期六上下午)

[复制链接]

1005

主题

1469

帖子

1万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
12012
发表于 2017-7-1 15:58:47 | 显示全部楼层 |阅读模式
上完1Z0-05316Resource Manager
进行1Z0-052第7章
1Z0-052
19章(上完13章),1Z0-05321章(上完17章)和1Z0-063多租户部分共9章(上完0章)
总共上完全部49章中的30

Screenshot1.png Screenshot.png
TOAD连接12c:
  1. BEGIN
  2. dbms_resource_manager.clear_pending_area();
  3. dbms_resource_manager.create_pending_area();
  4. dbms_resource_manager.update_plan_directive(
  5.     plan => 'PLAN1',
  6.     group_or_subplan => 'GROUP1',
  7.     new_active_sess_pool_p1 => -1,
  8.     new_queueing_p1 => -1  

  9. );
  10. dbms_resource_manager.submit_pending_area();
  11. END;


  12. select * from dba_rsrc_plan_directives d where d.PLAN='PLAN1';

  13. BEGIN
  14. dbms_resource_manager.clear_pending_area();
  15. dbms_resource_manager.create_pending_area();
  16. dbms_resource_manager.update_plan_directive(
  17.     plan => 'PLAN1',
  18.     group_or_subplan => 'GROUP1',
  19.     new_undo_pool => 8
  20.    

  21. );
  22. dbms_resource_manager.submit_pending_area();
  23. END;

  24. select * from dba_rsrc_plan_directives d where d.PLAN='PLAN1' and
  25.   d.GROUP_OR_SUBPLAN='GROUP1';
  26.   
  27.   select  s.USERNAME,s.TERMINAL, s.RESOURCE_CONSUMER_GROUP
  28.     from v$session s
  29.         where s.TERMINAL in ('pts/2','pts/3')
  30.         ;
  31.         
  32.         DECLARE
  33. spfileValue VARCHAR2(1000);
  34. execText VARCHAR2(1000);
  35. scopeValue VARCHAR2(30) := 'MEMORY';
  36. planName VARCHAR2(100) :='PLAN1';
  37. BEGIN
  38. dbms_resource_manager.clear_pending_area();
  39. dbms_resource_manager.create_pending_area();
  40. dbms_resource_manager.update_plan_directive(
  41.     plan => 'PLAN1',
  42.     group_or_subplan => 'GROUP1',
  43.     new_comment => '',
  44.     new_switch_elapsed_time => NULL,
  45.     new_mgmt_p1 => 20, new_mgmt_p2 => NULL, new_mgmt_p3 => NULL, new_mgmt_p4 => NULL,
  46.     new_mgmt_p5 => NULL, new_mgmt_p6 => NULL, new_mgmt_p7 => NULL, new_mgmt_p8 => NULL ,
  47.     new_parallel_degree_limit_p1 => NULL ,
  48.     new_parallel_target_percentage => NULL ,
  49.     new_parallel_queue_timeout => NULL ,
  50.     new_parallel_stmt_critical => 'false' ,
  51.     new_switch_io_logical => NULL ,
  52.     new_switch_io_reqs => NULL,
  53.     new_switch_io_megabytes => NULL ,
  54.     new_active_sess_pool_p1 => NULL,
  55.     new_queueing_p1 => NULL,
  56.     new_switch_group => 'GROUP2',
  57.     new_switch_time => NULL,
  58.     new_switch_estimate =>true,
  59.     new_undo_pool => NULL ,
  60.     new_max_idle_time => NULL,
  61.     new_max_idle_blocker_time => NULL,
  62.     new_switch_for_call => true
  63. );
  64. dbms_resource_manager.submit_pending_area();
  65. END;

  66. ---
  67. select * from dba_rsrc_plan_directives d where d.PLAN='PLAN1'
  68. and d.GROUP_OR_SUBPLAN='GROUP1';

  69. ----

  70. SELECT value FROM
  71.     v$parameter WHERE
  72.       name = 'cpu_count' AND (isdefault = 'FALSE' OR ismodified != 'FALSE');
  73. ----
  74. SELECT name FROM v$rsrc_plan
  75. WHERE is_top_plan = 'TRUE' AND cpu_managed = 'ON';
  76. ----

  77. SELECT begin_time, consumer_group_name, cpu_consumed_time, cpu_wait_time
  78. FROM v$rsrcmgrmetric_history
  79. ORDER BY begin_time;
  80. ------
  81. SELECT name, consumed_cpu_time, cpu_wait_time
  82. FROM v$rsrc_consumer_group;

  83. ----
  84. select  * from dba_rsrc_group_mappings;


  85. ----
  86. BEGIN
  87. dbms_resource_manager.clear_pending_area();
  88. dbms_resource_manager.create_pending_area();
  89. dbms_resource_manager.set_consumer_group_mapping(
  90.     dbms_resource_manager.client_os_user,
  91.     'oracle',
  92.     'GROUP2'
  93. );
  94. dbms_resource_manager.submit_pending_area();
  95. END;
  96. ----
  97. select  * from dba_rsrc_mapping_priority;

  98. ---
  99.   select  s.USERNAME,s.TERMINAL, s.RESOURCE_CONSUMER_GROUP
  100.     from v$session s
  101.         where s.TERMINAL in ('pts/2','pts/3')
  102.         ;
  103.         ----
  104.         BEGIN
  105. dbms_resource_manager.clear_pending_area();
  106. dbms_resource_manager.create_pending_area();
  107. dbms_resource_manager.set_consumer_group_mapping_pri(
  108.     EXPLICIT => 1,  CLIENT_OS_USER => 2,
  109.     SERVICE_MODULE_ACTION => 3,
  110.     SERVICE_MODULE => 4,
  111.     MODULE_NAME_ACTION => 5,
  112.     MODULE_NAME => 6,
  113.     SERVICE_NAME => 7,
  114.     ORACLE_USER => 8,
  115.     CLIENT_PROGRAM => 9,
  116.     CLIENT_MACHINE => 10,
  117.     CLIENT_ID => 11
  118. );
  119. dbms_resource_manager.submit_pending_area();
  120. END;

  121. ---
  122.         select  * from dba_rsrc_mapping_priority;
  123.         ---
  124.         
  125.         BEGIN
  126. dbms_resource_manager.clear_pending_area();
  127. dbms_resource_manager.create_pending_area();
  128. dbms_resource_manager.set_consumer_group_mapping_pri(
  129.     EXPLICIT => 1,  SERVICE_MODULE_ACTION => 2,
  130.     SERVICE_MODULE => 3,
  131.     MODULE_NAME_ACTION => 4,
  132.     MODULE_NAME => 5,
  133.     SERVICE_NAME => 6,
  134.     ORACLE_USER => 7,
  135.     CLIENT_OS_USER => 8,
  136.     CLIENT_PROGRAM => 9,
  137.     CLIENT_MACHINE => 10,
  138.     CLIENT_ID => 11
  139. );
  140. dbms_resource_manager.submit_pending_area();
  141. END;
  142. ----
复制代码
PL/SQL连接11g:
  1. select  * from dba_rsrc_plan_directives  p
  2. where p.plan='DEFAULT_MAINTENANCE_PLAN';

  3. select  * from dba_rsrc_plan_directives  p
  4. where p.plan='ORA$AUTOTASK_SUB_PLAN';

  5. select s.USERNAME,s.SID,s.RESOURCE_CONSUMER_GROUP
  6.   from v_$session s
  7.   where s.TERMINAL='pts/15';

  8. select  * from dba_rsrc_plan_directives  pd
  9.   where pd.plan='PLAN1' and pd.group_or_subplan='GROUP1';
  10.   
  11.   ----------
  12.   ------------
  13.   
  14.   BEGIN
  15. dbms_resource_manager.clear_pending_area();
  16. dbms_resource_manager.create_pending_area();
  17. dbms_resource_manager.update_plan_directive(
  18.     plan => 'PLAN1',
  19.     group_or_subplan => 'GROUP1',
  20.     new_undo_pool => 8192
  21.    

  22. );
  23. dbms_resource_manager.submit_pending_area();
  24. END;
  25.   
  26.   ----
  27.   SELECT value FROM
  28.     v$parameter WHERE
  29.       name = 'cpu_count' AND (isdefault = 'FALSE' OR ismodified != 'FALSE');
  30. ----
  31. SELECT name FROM v$rsrc_plan
  32. WHERE is_top_plan = 'TRUE' AND cpu_managed = 'ON';
  33. ---
  34. dba_rsrc_group_mappings
  35. ---
  36. dba_rsrc_mapping_priority;
复制代码
  1. BEGIN
  2. dbms_resource_manager.clear_pending_area();
  3. dbms_resource_manager.create_pending_area();
  4. dbms_resource_manager.update_plan_directive(
  5.     plan => 'PLAN1',
  6.     group_or_subplan => 'GROUP1',
  7.     new_active_sess_pool_p1 => 1,
  8.     new_queueing_p1 => 5

  9. );
  10. dbms_resource_manager.submit_pending_area();
  11. END;


  12. select * from dba_rsrc_plan_directives d where d.PLAN='PLAN1'
  13.   and d.GROUP_OR_SUBPLAN='GROUP1';
  14.   
  15. select s.USERNAME,s.SID,s.RESOURCE_CONSUMER_GROUP, terminal
  16.   from v_$session s
  17.   where s.TERMINAL in ('pts/2', 'pts/3');
复制代码
关于表空间:
  1. select  * from dba_segments s
  2. where s.SEGMENT_NAME='EMPLOYEES'
  3.   and s.OWNER='HR';
  4.   
  5. select  * from dba_extents s
  6. where s.SEGMENT_NAME='EMPLOYEES'
  7.   and s.OWNER='HR';
  8.   
  9.   select  * from dba_tables t
  10.    where t.TABLE_NAME='EMPLOYEES' and t.OWNER='HR';
  11.    
  12.    select   i.PCT_FREE     from dba_indexes i
  13.    where i.TABLE_NAME='EMPLOYEES' and i.OWNER='HR'
  14.     and  i.index_name='EMP_NAME_IX';
  15.         ---
  16.         
  17.         
  18.    
  19.    ---
  20.    
  21.    select  * from dba_segments s
  22. where s.SEGMENT_NAME='EMP_NAME_IX'
  23.   and s.OWNER='HR';
  24.   -----------------
  25.   
  26.   
  27. select  * from dba_extents s
  28. where s.SEGMENT_NAME='EMP_NAME_IX'
  29.   and s.OWNER='HR';
  30.   
  31.   -----
  32.   
  33.   CREATE SMALLFILE TABLESPACE "TBS1"
  34.    DATAFILE '/u01/app/oracle/oradata/orcl/tbs1' SIZE 5M
  35.    AUTOEXTEND ON NEXT 2M MAXSIZE 1G
  36.    LOGGING
  37.    EXTENT MANAGEMENT DICTIONARY
  38.    DEFAULT STORAGE
  39.     ( INITIAL 512K NEXT 512K MINEXTENTS 1
  40.          MAXEXTENTS UNLIMITED PCTINCREASE 150) MINIMUM EXTENT 512K;
  41.          
  42.          ---
  43.          select  * from dba_tablespaces t
  44.          where t.TABLESPACE_NAME in ('TBS1','USERS');
  45.          ----
  46.          select  * from dba_extents e
  47.           where e.SEGMENT_NAME='T04209_UNAME' and e.OWNER='HR';
  48.           ----
  49.          
  50.           select  sum(f.BYTES)/1024/1024
  51.            from dba_data_files f
  52.            where f.TABLESPACE_NAME='SYSTEM';
  53.            
  54.            
  55.           select sum(s.BYTES)/1024/1024
  56.            from dba_free_space s
  57.            where s.TABLESPACE_NAME='SYSTEM';
  58.          
  59.                     select  sum(f.BYTES)/1024/1024
  60.            from dba_data_files f
  61.            where f.TABLESPACE_NAME='UNDOTBS1';
  62.            
  63.            
  64.           select sum(s.BYTES)/1024/1024
  65.            from dba_free_space s
  66.            where s.TABLESPACE_NAME='UNDOTBS1';
  67.            
  68.            select  sum(e.BYTES)/1024/1024
  69.             from dba_undo_extents e
  70.                 where e.TABLESPACE_NAME='UNDOTBS1'
  71.                  and e.STATUS <> 'EXPIRED';
  72.                  -------
  73. select  sum(f.BYTES)/1024/1024
  74.            from dba_temp_files f
  75.            where f.TABLESPACE_NAME='TEMP';                 
  76.           -----------
  77.          
  78.           select (t.bytes_used)/1024/1024 from V$TEMP_EXTENT_POOL t;
  79.          
复制代码

做映射:
  1. begin
  2.   dbms_resource_manager.clear_pending_area;
  3.   dbms_resource_manager.create_pending_area;
  4.   dbms_resource_manager.set_consumer_group_mapping(
  5.     dbms_resource_manager.client_machine,'192.168.0.37','group2');
  6.        
  7. dbms_resource_manager.submit_pending_area;
  8. end;
复制代码




回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|手机版|Bo's Oracle Station   

GMT+8, 2024-11-22 05:29 , Processed in 0.040716 second(s), 27 queries .

快速回复 返回顶部 返回列表