swingbenchメモ

# Swingbenchを使って、1TBのデータをさくっと作る

[Swingbenchのサイトからダウンロード](http://dominicgiles.com/downloads.html)

```
適当なディレクトリに展開
$ java -version
→ java8以上がインストールされていること

$ unzip -q swingbench*.zip

$ cd swingbench/bin

$ DB_ACCESS=//xxxx-scan:1521/servicename

$ SYS_PASSWORD=xxxxx

$ SOE_PASSWORD=xxxxx

$ ./oewizard -cl -create -cs ${DB_ACCESS} -ts swingbench -dbap ${SYS_PASSWORD} -u soe -p ${SOE_PASSWORD} -scale 100 -v

→ だいたい、↓くらいのサイズのセグメントが作成される
SQL> select SEGMENT_TYPE,SUM(BYTES)/1024/1024 MB from dba_segments where owner='SOE' group by SEGMENT_TYPE;

SEGMENT_TYPE               MB
------------------ ----------
INDEX                   62110
TABLE                   85902
```

# 負荷をかける

bin/swingbenchを起動して負荷をかける。

CUI実行したい場合は、設定ファイル(config.xml)をどこかに保存する

保存されたconfig.xmlは以下のような形式になっている

```
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<SwingBenchConfiguration xmlns="http://www.dominicgiles.com/swingbench/config">
    <Name>"Order Entry (PLSQL) V2"</Name>
    <Comment>Version 2 of the SOE Benchmark running in the database using PL/SQL</Comment>
    <Connection>
        <UserName>soe</UserName>
        <Password>★パスワードを入力★</Password>
        <ConnectString>//oraclelinux/orcl</ConnectString>
        <DriverType>Oracle jdbc Driver</DriverType>
        <Properties>
            <Property Key="StatementCaching">120</Property>
            <Property Key="FetchSize">20</Property>
        </Properties>
    </Connection>
    <Load>
        <NumberOfUsers>20</NumberOfUsers>
        <MinDelay>0</MinDelay>
        <MaxDelay>0</MaxDelay>
        <InterMinDelay>0</InterMinDelay>
        <InterMaxDelay>0</InterMaxDelay>
        <QueryTimeout>120</QueryTimeout>
        <MaxTransactions>-1</MaxTransactions>
        <RunTime>1:0</RunTime>
        <LogonGroupCount>1</LogonGroupCount>
        <LogonDelay>0</LogonDelay>
        <LogOutPostTransaction>false</LogOutPostTransaction>
        <WaitTillAllLogon>true</WaitTillAllLogon>
        <StatsCollectionStart>0:0</StatsCollectionStart>
        <StatsCollectionEnd>0:0</StatsCollectionEnd>
        <ConnectionRefresh>0</ConnectionRefresh>
        <TransactionList>
            <Transaction>
                <Id>Customer Registration</Id>
                <ShortName>NCR</ShortName>
                <ClassName>com.dom.benchmarking.swingbench.plsqltransactions.NewCustomerProcessV2</ClassName>
                <Weight>15</Weight>
                <Enabled>true</Enabled>
            </Transaction>
            <Transaction>
                <Id>Update Customer Details</Id>
                <ShortName>UCD</ShortName>
                <ClassName>com.dom.benchmarking.swingbench.plsqltransactions.UpdateCustomerDetailsV2</ClassName>
                <Weight>10</Weight>
                <Enabled>true</Enabled>
            </Transaction>
            <Transaction>
                <Id>Browse Products</Id>
                <ShortName>BP</ShortName>
                <ClassName>com.dom.benchmarking.swingbench.plsqltransactions.BrowseProducts</ClassName>
                <Weight>90</Weight>
                <Enabled>true</Enabled>
            </Transaction>
            <Transaction>
                <Id>Order Products</Id>
                <ShortName>OP</ShortName>
                <ClassName>com.dom.benchmarking.swingbench.plsqltransactions.NewOrderProcess</ClassName>
                <Weight>40</Weight>
                <Enabled>true</Enabled>
            </Transaction>
            <Transaction>
                <Id>Process Orders</Id>
                <ShortName>PO</ShortName>
                <ClassName>com.dom.benchmarking.swingbench.plsqltransactions.ProcessOrders</ClassName>
                <Weight>5</Weight>
                <Enabled>true</Enabled>
            </Transaction>
            <Transaction>
                <Id>Browse Orders</Id>
                <ShortName>BO</ShortName>
                <ClassName>com.dom.benchmarking.swingbench.plsqltransactions.BrowseAndUpdateOrders</ClassName>
                <Weight>15</Weight>
                <Enabled>true</Enabled>
            </Transaction>
            <Transaction>
                <Id>Sales Rep Query</Id>
                <ShortName>SQ</ShortName>
                <ClassName>com.dom.benchmarking.swingbench.plsqltransactions.SalesRepsOrdersQuery</ClassName>
                <Weight>2</Weight>
                <Enabled>true</Enabled>
            </Transaction>
            <Transaction>
                <Id>Warehouse Query</Id>
                <ShortName>WQ</ShortName>
                <ClassName>com.dom.benchmarking.swingbench.plsqltransactions.WarehouseOrdersQuery</ClassName>
                <Weight>1</Weight>
                <Enabled>true</Enabled>
            </Transaction>
            <Transaction>
                <Id>Warehouse Activity Query</Id>
                <ShortName>WA</ShortName>
                <ClassName>com.dom.benchmarking.swingbench.plsqltransactions.WarehouseActivityQuery</ClassName>
                <Weight>1</Weight>
                <Enabled>true</Enabled>
            </Transaction>
        </TransactionList>
        <EnvironmentVariables>
            <Variable Key="SOE_NLSDATA_LOC">data/nls.txt</Variable>
            <Variable Key="SOE_NAMESDATA_LOC">data/names.txt</Variable>
        </EnvironmentVariables>
    </Load>
    <Preferences>
        <StartMode>manual</StartMode>
        <Output>swingbench</Output>
        <JumpToEvents>true</JumpToEvents>
        <TimingsIncludeSleep>false</TimingsIncludeSleep>
        <TimingsIn>milliseconds</TimingsIn>
        <StatisticsLevel>simple</StatisticsLevel>
        <OutputFile>results.xml</OutputFile>
        <Charts DefaultChart="Overview">
            <Chart>
                <Name>DML Operations Per Minute</Name>
                <Autoscale>true</Autoscale>
                <MaximumValue>-1.0</MaximumValue>
                <Logarithmic>false</Logarithmic>
            </Chart>
            <Chart>
                <Name>Transaction Response Time</Name>
                <Autoscale>true</Autoscale>
                <MaximumValue>-1.0</MaximumValue>
                <Logarithmic>true</Logarithmic>
            </Chart>
            <Chart>
                <Name>Transactions Per Minute</Name>
                <Autoscale>true</Autoscale>
                <MaximumValue>-1.0</MaximumValue>
                <Logarithmic>false</Logarithmic>
            </Chart>
        </Charts>
        <AllowedErrorCodes>
            <ErrorCode Type="ORA">4063</ErrorCode>
        </AllowedErrorCodes>
        <RefreshRate>1</RefreshRate>
        <OverviewCharts>
            <OverviewChart>
                <Name>Transactions Per Minute</Name>
                <MinimumValue>2.147483647E9</MinimumValue>
                <MaximumValue>2.147483647E9</MaximumValue>
                <Displayed>true</Displayed>
            </OverviewChart>
            <OverviewChart>
                <Name>Transactions Per Second</Name>
                <MinimumValue>2.147483647E9</MinimumValue>
                <MaximumValue>2.147483647E9</MaximumValue>
                <Displayed>true</Displayed>
            </OverviewChart>
            <OverviewChart>
                <Name>Response Time</Name>
                <MinimumValue>2.147483647E9</MinimumValue>
                <MaximumValue>2.147483647E9</MaximumValue>
                <Displayed>true</Displayed>
            </OverviewChart>
            <OverviewChart>
                <Name>CPU</Name>
                <MinimumValue>0.0</MinimumValue>
                <MaximumValue>100.0</MaximumValue>
                <Displayed>true</Displayed>
            </OverviewChart>
            <OverviewChart>
                <Name>Disk</Name>
                <MinimumValue>2.147483647E9</MinimumValue>
                <MaximumValue>2.147483647E9</MaximumValue>
                <Displayed>false</Displayed>
            </OverviewChart>
            <OverviewChart>
                <Name>Users</Name>
                <MinimumValue>2.147483647E9</MinimumValue>
                <MaximumValue>2.147483647E9</MaximumValue>
                <Displayed>false</Displayed>
            </OverviewChart>
            <OverviewChart>
                <Name>Database Time</Name>
                <MinimumValue>2.147483647E9</MinimumValue>
                <MaximumValue>2.147483647E9</MaximumValue>
                <Displayed>true</Displayed>
            </OverviewChart>
            <OverviewChart>
                <Name>DML</Name>
                <MinimumValue>0.0</MinimumValue>
                <MaximumValue>9.223372036854776E18</MaximumValue>
                <Displayed>true</Displayed>
            </OverviewChart>
        </OverviewCharts>
    </Preferences>
</SwingBenchConfiguration>
```

以下のコマンドで実行する。(パラメータでconfig.xmlの値を上書きできる)

```
bin/charbench -c <config.xml配置先ディレクトリ>/config.xml -cs //<IP>:<PORT>/<SERVICE_NAME> -dt thin
```