목차

    Order Entry 수행하기 

     

    수행하기 앞서 ,

    1. Data Tablespace 증설 

    -> 최소 40G (미리 생성하자 )

     

    2. Temporary Tablespace 증설

     

    3. user 생성을 해야한다 

    -> SOE_10G 

     

    4. 스키마와 데이터를 넣어야한다 

    ->  oewizard.bat 

     

    tablespace 생성 

    $ sqlplus '/as sysdba'
    
    SQL> CREATE BIGFILE TABLESPACE SOE_10G
    DATAFILE 
      '/opt/oracle/oradata/ORCL/soe_10g_01.dbf' SIZE 60G 
    AUTOEXTEND ON NEXT 64M MAXSIZE UNLIMITED
    EXTENT MANAGEMENT LOCAL UNIFORM SIZE 1M
    ;
    [oracle@sua-03 ORCL]$ pwd
    /opt/oracle/oradata/ORCL
    
    [oracle@sua-03 ORCL]$ ls -lh | grep soe
    -rw-rw----. 1 oracle oinstall  61G Feb 23 10:47 soe_10g_01.dbf

    실제 oradata 경로에 파일이 생성되는 것을 알 수 있다 

     

    CREATE BIGFILE TABLESPACE SOE_10G
    *
    ERROR at line 1:
    ORA-19502: write error on file "/opt/oracle/oradata/ORCL/soe_10g_01.dbf", block
    number 7362560 (block size=8192)
    ORA-27061: waiting for async I/Os failed
    Linux-x86_64 Error: 28: No space left on device
    Additional information: 4294967295
    Additional information: 1048576

    filesystem 이 모자르다-> disk 추가 하고 vm 다시 재생성한다

     

     

    ALTER DATABASE TEMPFILE 
    '/opt/oracle/oradata/ORCL/temp01.dbf' 
    RESIZE 10G;
    
    Database altered.

    temp 추가 (굉장히 빨리 끝남)

     

     

     

    oewizard.bat 실행 

    DBA 권한이 필요하다고 나온다 

     

    version 2.0 으로 선택  

     

     

    select task - Order Entry 스키마 생성하겠다 

     

    JDBC connection 부분

    - oraclelinux 부분에 IP 입력 

     

     

     

    생성될 user config 

    - tablespace 를 앞에서 생성한 tbs로 설정 

     

    database 옵션 - default를 따름

     - 파티션 없고, 압축모드도 아니며. tablespace는 bigfile 

    size 결정 

    - 1.3G로 잡으면 OLTP 용으로 cpu intensive  

    -  61G로 잡으면 I/O를  크게 설정할 수 있다. 

     

    10G로 설정 (이전에 tbs를 10G로 생성하였음)

    - tablespace size = 32G

    - temp tablespace size = 6G

     

     

    leve of paralleism : 16정도 잡음 

     

    굉장히 오래 걸림 .. (1시간 반정도 )

     

     

    별다른 finish 버튼은 없다. - x버튼 누르자 

     

     

    oracle 에 접속해보면 user 생성되어있다 

    SQL> select * from all_users where username like '%SOE%'
      2  ;
    
    USERNAME   USER_ID CREATED   COM O INH DEFAULT_COLLATION    IMP ALL
    -------------------------------------------------------------------------------------------------------------------------------- ---------- --------- --- - --- ---------------------------------------------------------------------------------------------------- --- ---
    SOE											 107 25-FEB-24 NO  N NO	USING_NLS_COMP    NO  NO

     

    window client 쪽에서도 접속 가능 

    [oracle@sua-05 ~]$ sqlplus soe/soe
    
    SQL*Plus: Release 19.0.0.0.0 - Production on Sun Feb 25 08:56:55 2024
    Version 19.3.0.0.0
    
    Copyright (c) 1982, 2019, Oracle.  All rights reserved.
    
    Last Successful login time: Sun Feb 25 2024 08:56:49 +00:00
    
    Connected to:
    Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
    Version 19.3.0.0.0
    
    SQL>

     

    SQL> colum tname format a30
    SQL> set linesize 1000
    SQL> select tname, tabtype from tab;
    
    TNAME                          TABTYPE
    ------------------------------ --------------------------
    CUSTOMERS                      TABLE
    ADDRESSES                      TABLE
    CARD_DETAILS                   TABLE
    WAREHOUSES                     TABLE
    ORDER_ITEMS                    TABLE
    ORDERS                         TABLE
    INVENTORIES                    TABLE
    PRODUCT_INFORMATION            TABLE
    LOGON                          TABLE
    PRODUCT_DESCRIPTIONS           TABLE
    ORDERENTRY_METADATA            TABLE
    PRODUCTS                       VIEW
    PRODUCT_PRICES                 VIEW

    soe 가 사용하는 13개의 table이 생성되어있다 . 

     

     

     

     

     

     

    SwingBench 구동

     

    SwingBench 실행

     

     

    SOE_Server_Side_V2 선택

     

     

    Connection 정보 입력 (IP/ id-passwd)

     

     

    위에 초록색 play 버튼을 누를 경우, 상단오른쪽에 있는 tranaction 부분에 부하가 들어간다. 

    config는 저장한다 

    참고)number of users : 동시 접속자 

     

     

    SwingBench 보는 법

     

    event 부분 확인

    event 부분을 확인한다 

    event 부분 빨간 connection error 는 TNS name 을 ORCL이 아닌 ORACL로 줘서 난 에러..

     

     

     

    tps 확인

    사진에서 볼수 있듯, tps 는 32 가 나온다 

     

     

    statement 별 확인

    statement 별 작업량도 알 수 있다. 

     

     

    Load Ratio 로 부하Control 

    total : 131 에서 'Browse Product' 가 50으로 제일 많이 호출되게 설정되어있다 

    -  비지니스 로직에 맞춰서 ratio를 조정한다 (호출빈도수 조절)

     -  sale 부분에서 상품을 보는 부분이 가장 빈도가 높을 테니 'Browse Product'  가 가장 높으며 

     - 그 다움 주문하는 Order Product 부분을 40으로 설정 

     -  Sales Rep Query 와 / Warehouse Query , Warehouse Activity Query는 쿼리가 크기에 IO를 많이 사용하고 느리기에 비율을 낮춰놓는다. (나머지 tx작업은 CPU를 많이 사용한다 )

     

    Class Name 은 무엇인가?

     

    Class Name 보면 java 코드인게 보이고, plsql 이 실행되며, order entry 가 실행되고 있음을 알 수 있다. 

    실제 돌아가려는 코드를 보려면

     

     swingbench > sql > orderentry 에 들어가면, soedgpackage,sql 에서 확인 할 수 있다. 

     

    sql 안에는 패키지 생성 구문이 있으며, 패키지엔 현재 order entry 에서 돌아가는 트랜잭션이 사용하는 sql 구문을 볼수 있다 

    구문을 살짝 맛보기로 본다면 아래와 같다 

    drop package ORDERENTRY;
    
    
    create or replace
    PACKAGE ORDERENTRY   
    AS   
      /*   
      * Package     : Order Entry Package Spec  
      * Version     : 1.2  
      * Author      : Dominic Giles   
      * Last Update : 12 June 2011   
      * Description : Used in stress test of Oracle by swingbench test harness;   
      *   
      */
    PROCEDURE setPLSQLCOMMIT(commitInPLSQL varchar2);  
    FUNCTION browseProducts   
      (   
        cust_id customers.customer_id%type,   
        min_sleep INTEGER,   
        max_sleep INTEGER)   
      RETURN varchar;   
    FUNCTION newOrder   
      (   
        cust_id customers.customer_id%type,   
        min_sleep INTEGER,   
        max_sleep INTEGER)   
      RETURN varchar;   
    FUNCTION newCustomer   
      (   
        fname customers.cust_first_name%type,   
        lname customers.cust_last_name%type,   
        nls_lang customers.nls_language%type,   
        nls_terr customers.nls_territory%type,   
        min_sleep INTEGER,   
        max_sleep INTEGER)   
      RETURN varchar;   
    FUNCTION processOrders   
      (   
        min_sleep INTEGER,   
        max_sleep INTEGER)   
      return varchar;  
    function processOrders   
      ( warehouse orders.warehouse_id%type,  
        min_sleep integer,   
        max_sleep integer  
        )   
      RETURN varchar;   
    FUNCTION browseAndUpdateOrders   
      (   
        cust_id customers.customer_id%type,   
        min_sleep INTEGER,   
        max_sleep INTEGER)   
      RETURN varchar;
    FUNCTION SalesRepsQuery   
      (   
        salesRep orders.sales_rep_id%type,    
        min_sleep integer,    
        max_sleep integer
        )   
      RETURN varchar;
      
      ....(중략)
      
      
      function processorders (warehouse orders.warehouse_id%type,   
                              min_sleep integer,    
                              max_sleep integer   
                              ) return varchar is    
        cursor order_cursor is WITH need_to_process AS    
                              (SELECT order_id,    
                                /* we're only looking for unprocessed orders */    
                                customer_id    
                              FROM orders    
                              where order_status <= 4   
                              and warehouse_id = warehouse  
                              AND rownum         <  10  
                              )    
                            SELECT o.order_id,       
                              oi.line_item_id,       
                              oi.product_id,       
                              oi.unit_price,       
                              oi.quantity,       
                              o.order_mode,       
                              o.order_status,       
                              o.order_total,       
                              o.sales_rep_id,       
                              o.promotion_id,       
                              c.customer_id,       
                              c.cust_first_name,       
                              c.cust_last_name,       
                              c.credit_limit,       
                              c.cust_email,       
                              o.order_date    
                            FROM orders o,    
                              need_to_process ntp,    
                              customers c,    
                              order_items oi    
                            WHERE ntp.order_id = o.order_id    
                            AND c.customer_id  = o.customer_id    
                            and oi.order_id (+) = o.order_id;    
        order_proc_rec order_cursor%rowtype;    
        begin    
        dbms_application_info.set_module('Process Orders',null);    
        init_info_array();    
        open order_cursor;    
        fetch order_cursor into order_proc_rec;    
        increment_selects(1);    
        sleep(min_sleep, max_sleep);    
        update /*+ index(orders, order_pk) */    
        orders    
        set order_status = floor(dbms_random.value(AWAITING_PROCESSING + 1, ORDER_PROCESSED))    
        where order_id = order_proc_rec.order_id;    
        increment_updates(1);    
        oecommit;    
        increment_commits(1);    
        dbms_application_info.set_module(null,null);    
        return getdmlarrayasstring(info_array);   
        exception when others then    
          rollback;    
          increment_rollbacks(1);    
          close order_cursor;    
          dbms_application_info.set_module(null,null);    
          return getdmlarrayasstring(info_array);    
      end processorders;

     

     

    결과 보는 법 

    output 탭을 누르면 , 수행 결과를 볼 수 있다. 

    수행 시 configuration 을 확인 할 수 있고 

     

    transaction 별 결과를 알 수가 있다 

    Costomer Registration 이 49ms 걸린걸 알 수 있다. 

     

     

     

     

     

     

     

     

     

    부하 추가하는 법 

    동시 접속자를 늘려서 부하를 더 준다 

     

    현재 oracle DB 서버는 cpu 8core 이다 

    sar 3 1000 명령으로 cpu 모니터링을 한다 . 

     

    -- 아무 작업이 없을 경우
    
    
    [oracle@sua-05 ~]$ sar 3 3
    Linux 3.10.0-1160.45.1.el7.x86_64 (sua-05.novalocal) 	02/25/2024 	_x86_64_	(8 CPU)
    
    09:32:05 AM     CPU     %user     %nice   %system   %iowait    %steal     %idle
    09:32:08 AM     all      0.17      0.00      0.13      0.00      0.00     99.71
    09:32:11 AM     all      0.21      0.00      0.13      0.00      0.04     99.62
    09:32:14 AM     all      0.17      0.00      0.13      0.00      0.00     99.71
    Average:        all      0.18      0.00      0.13      0.00      0.01     99.68

    작업이 없을 경우  sar 값이다 

    user : 사용자가 쓰는 cpu percent 

    system 

    iowait  : cpu가 io sub system에 읽어달라는 명령을 내리고 , 대기를 하는 percent

     

    -- swingbench 수행하는 중 
    09:37:20 AM     CPU     %user     %nice   %system   %iowait    %steal     %idle
    09:37:23 AM     all      4.93      0.00      1.06     36.97      0.13     56.91
    09:37:26 AM     all      5.60      0.00      1.19     35.55      0.13     57.53
    09:37:29 AM     all      6.41      0.00      1.27     34.42      0.13     57.77
    09:37:32 AM     all      5.99      0.00      1.27     35.95      0.17     56.61
    09:37:35 AM     all      5.52      0.00      1.10     36.01      0.13     57.24
    09:37:38 AM     all      6.21      0.00      1.15     37.39      0.17     55.08
    09:37:41 AM     all      6.14      0.00      1.19     36.61      0.13     55.93

    작업이 있을 경우 sar 값이다 

     

     

    -- 성능이 줄더니 sat 도 줄었다 
    09:41:50 AM     CPU     %user     %nice   %system   %iowait    %steal     %idle
    09:41:53 AM     all      0.17      0.00      0.42     12.07      0.00     87.34
    09:41:56 AM     all      0.17      0.00      0.34     12.58      0.04     86.87
    09:41:59 AM     all      0.21      0.00      0.34     12.33      0.04     87.08
    09:42:02 AM     all      0.21      0.00      0.46     12.24      0.00     87.09
    09:42:05 AM     all      0.13      0.00      0.38     12.18      0.04     87.27
    09:42:08 AM     all      2.16      0.00      0.63     21.86      0.08     75.26
    09:42:11 AM     all      1.14      0.00      0.38     16.66      0.04     81.78