Data Management Global

 View Only

Steps to Create Traces for Different Db2 .NET Providers

By Naveenkumar N L posted Sun August 08, 2021 12:10 PM

  

Scenario-1

.NET RUNTIME FULL FRAMEWORK (DB2DSDRIVER) FOR ON-PREMISE

Open Command Prompt in Administrator Privilege and go to installed directory (i.e., clidriver/bin) and then perform the below steps.

Ex:   C:\sqllib\bin       (Note:  DS Driver is installed at SQLLIB directory.)
    1. Turn Db2 trace on.

            db2trc  on  -f   c:\<foldername>\db2trc.dmp

    2. Reproduce the issue.
    3. Turn Db2 trace off.

            db2trc  off

    4. Format the contents of Db2 trace binary data file into text file.

            db2trc    flw   c:\< foldername >\db2trc.dmp       c:\< foldername >\db2trc.flw

           db2trc    fmt   c:\< foldername >\db2trc.dmp      c:\< foldername >\db2trc.fmt

           db2trc    fmt  -cli  c:\< foldername >\db2trc.dmp      c:\< foldername >\db2trc.cli

           db2trc     fmt  -c   c:\< foldername >\db2trc.dmp    c:\< foldername >\db2trc.fmtc

      db2trc.flw, db2trc.fmt, db2trc.cli and db2trc.fmtc files created in the mentioned directory.

Scenario-2

.NET RUNTIME FULL FRAMEWORK PACKAGE FOR AZURE

  1. Create db2dsdriver.cfg file with below lines & then copy file to global cfg folder before deploying to azure and build the solution.

              <configuration>

                        <parameters>

                                   <parameter name="SwitchDb2trace" value="on -f D:\home\site\wwwroot\bin\clidriver\bin\db2trcAzr.dmp"/>

                                   <parameter name="TraceRefreshInterval" value="3"/>

                       </parameters>

             </configuration> 

    b. Steps to create db2dsdriver.cfg file in azure portal.

 Go to AppService>>click on deployed webapp>>click on AppServiceEditor (Preview) (available in Development Tools section) >> click on Go-> then new tab will open (Ex: https://<appname>.scm.azurewebsites.net/dev/wwwroot/ ) >> Click on Explorer>> WWWROOT> bin> clidriver> cfg. Create db2dsdriver.cfg file then add the lines mentioned in (a). 

    c. Steps to create traces.

    • Assume application is deployed to azure portal and above either (a) or (b) steps performed. Azure App service is stopped.
    • SwitchDb2trace value is on and dump file creating path is mentioned in the db2dsdriver.cfg file.
    • Start the Azure AppService then open webapp and perform to re-create problem statement.
    • Now go to AppServiceEditor (Preview) and update the SwitchDb2trace value in db2dsdriver.cfg file as like below.

              <parameter name="SwitchDb2trace" value="off"/>

    • Wait few seconds and close the webapp and stop the Azure AppService.
    • Dump file is created at mentioned directory.
    • Now create flw,fmt,cli and fmtc files. Open Azure Console in the same web app and change the directory path to “D:\home\site\wwwroot\bin\clidriver\bin” and perform below steps.
                   db2trc flw          db2trcAzr.dmp        db2trcAzr.flw
                   db2trc fmt         db2trcAzr.dmp        db2trcAzr.fmt
                   db2trc fmt  -cli  db2trcAzr.dmp        db2trcAzr.cli
                   db2trc fmt  -c    db2trcAzr.dmp        db2trcAzr.fmtc
    • flow,fmt,cli and fmtc files are created at “D:\home\site\wwwroot\bin\clidriver\bin”.

Note:

  • Directly can create and update db2dsdriver.cfg file in azure portal.

Using console, create directory and can save all files for better analysis.

Scenario-3

WINDOWS CORE PACKAGE ON-PREMISE

  • Clean and build the project.
  • Open command prompt in administrative privilege.
  • Go to application bin folder >>clidriver>> bin and perform below steps.
  1. Turn Db2 trace on.

            db2trc  on  -f   c:\<foldername>\db2trc.dmp

    2.Reproduce the issue (Perform to create problem statement).
    3.  Turn Db2 trace off.

            db2trc  off

    4.Format the contents of Db2 trace binary data file into text file.

            db2trc    flw   c:\< foldername >\db2trc.dmp       c:\< foldername >\db2trc.flw

           db2trc    fmt   c:\< foldername >\db2trc.dmp      c:\< foldername >\db2trc.fmt

           db2trc    fmt  -cli  c:\< foldername >\db2trc.dmp      c:\< foldername >\db2trc.cli

           db2trc    fmt  -c   c:\< foldername >\db2trc.dmp    c:\< foldername >\db2trc.fmtc

 Note: 
  1) .Net core 3.1 clidriver bin directory path is as

            “<Application path>\bin\x64\Debug\netcoreapp3.1\clidriver\bin”

  2) .Net 6.0 clidriver bin directory path is as

            “<Application path>\bin\x64\Debug\net6.0\clidriver\bin”

  3) .Net 8.0 clidriver bin directory path is as

            “<Application path>\bin\x64\Debug\net8.0\clidriver\bin”

Scenario-4

WINDOWS CORE PACKAGE IN AZURE CLOUD

  • Create db2dsdriver.cfg file with below lines then copy file to the global cfg directory, build the solution & Deploy to Azure.  

           <configuration>

                      <parameters>

                                 <parameter name="SwitchDb2trace" value="on -f       D:\home\site\wwwroot\clidriver\bin\db2trcAzr.dmp"/>

                                 <parameter name="TraceRefreshInterval" value="3"/>

                      </parameters>

           </configuration>

    2.  Steps to create db2dsdriver.cfg file in azure portal.

Go to AppService>>click on deployed webapp>>click on AppServiceEditor (Preview) (available in Development Tools section) >> click on Go-> then new tab will open (Ex: https://<appname>.scm.azurewebsites.net/dev/wwwroot/ ) >> Click on Explorer>> WWWROOT> clidriver> cfg. Create db2dsdriver.cfg file then add the lines mentioned in (step 1).

     3.  Steps to create traces

    • Assume application is deployed to azure portal and above either (step-1) or (step-2) are performed. Azure App service is stopped.
    • SwitchDb2trace value is on and dump file creating path mentioned.
    • Start the Azure AppService then open webapp and perform to re-create problem statement.
    • Now go to AppServiceEditor (Preview) and update the SwitchDb2trace value in db2dsdriver.cfg file as like below.

                  <parameter name="SwitchDb2trace" value="off"/>

    • Wait few seconds and close the webapp and stop the Azure AppService.
    • Dump file is created at mentioned directory.
    • Now create flw,fmt,cli and fmtc files. Open Azure Console in the same web app and change the directory path to “D:\home\site\wwwroot\clidriver\bin” and perform below steps.
                    db2trc flw          db2trcAzr.dmp       db2trcAzr.flw
                    db2trc fmt         db2trcAzr.dmp       db2trcAzr.fmt
                    db2trc fmt  -cli  db2trcAzr.dmp       db2trcAzr.cli
                    db2trc fmt  -c    db2trcAzr.dmp       db2trcAzr.fmtc
    • flow,fmt, cli and fmtc files are created at “D:\home\site\wwwroot\clidriver\bin”.

Note:

  • Directly can create and update db2dsdriver.cfg file in azure portal.

Using console, create directory and can save all files for better analysis.

Scenario-5

WINDOWS NANO DRIVER PACKAGE IN DOCKER

Run the docker image in interactive mode and open one more command prompt to run below lines in the mentioned directory (\app\clidriver\bin).

            db2trc  on  -f   db2trc.dmp

            dotnet  <application.dll>  (Run the Application and create problem statement)

            db2trc  off

            db2trc  db2trc.dmp  db2trc.flw

          db2trc fmt  db2trc.dmp  db2trc.fmt

           db2trc fmt -cli db2trc.dmp db2trc.cli

          db2trc fmt -c db2trc.dmp db2trc.fmtc

Note: Here app is working directory in docker.

Create batch (Trace.bat) file, copy to docker file location and use ‘Pause’ statement in that batch file. Call this batch file in the docker file.

            ENTRYPOINT ["CMD", "Trace.bat"]

Scenario-6

LINUX ON-PREMISE

Login to Linux machine and change the directory to application path 

            <Application path>/bin/Debug/netcoreapp3.1 /clidriver/adm

  1. Turn Db2 trace on.

            ./db2trc  on  -f   db2trc.dmp

    2. Reproduce the issue.
    3.Turn Db2 trace off.

            ./db2trc  off

    4. Creating flw, fmt and fmtc file.

            ./db2trc    flw    db2trc.dmp       db2trc.flw

            ./db2trc    fmt   db2trc.dmp      db2trc.fmt

            ./db2trc   fmt -cli db2trc.dmp  db2trc.cli

           ./db2trc   fmt  -c db2trc.dmp   db2trc.fmtc

Scenario-7

LINUX PACKAGE IN DOCKER

Run the docker image in interactive mode and open one more command prompt to run below lines. Go to /app/clidriver/adm path and follow below steps.

            ./db2trc  on  -f   db2trc.dmp

            dotnet  <application.dll>   (Run the Application and create problem statement)

            ./db2trc  off

            ./db2trc  flow  db2trc.dmp   db2trc.flw

            ./db2trc fmt  db2trc.dmp  db2trc.fmt

           ./db2trc  fmt -cli db2trc.dmp db2trc.cli

          ./db2trc fmt -c db2trc.dmp  db2trc.fmtc

 

Note: Here app is working directory in docker.

Create shell (Trace.sh) file, copy to docker file location and use ‘read ’statement in that shell file. Call this shell file in the docker file and follow as below.

            RUN dos2unix  ./Trace.sh

            ENTRYPOINT ["CMD", "./Trace.sh "]

 

Scenario-8

Create Azure Function App Traces using .NET DB2 Windows Core Package

1. Do the deployment (Refer this link: https://community.ibm.com/community/user/hybriddatamanagement/blogs/vishwa-hs1/2021/08/06/azure-functions-using-db2-net-core-drivers?CommunityKey=f2e5dc34-896d-4e8e-9678-724907c4b9f5), Login to Azure portal and Go to the Deployed Application resource and then click on "Advanced Tool > go > Kudu  > Debug Console  > CMD option  > Go to the Location D:\home\site\wwwroot\bin\clidriver\cfg\   And modify the db2dsdriver.cfg file in azure environment (If db2dsdriver.cfg file not  there then create it):

Modify/Add the global section of db2dsdriver.cfg configuration file with below lines.

 

<configuration>

<parameters>

<parameter name="TraceRefreshInterval" value="3"/>

</parameters>

</configuration>

 

Reference info-center link for TraceRefreshInterval configuration keyword

: https://www.ibm.com/docs/en/db2/11.5?topic=keywords-tracerefreshinterval

2. Stop the azure function app service if it is already running.

3. Start the azure function app service.

4. Invoke the Azure Function through the web browser by selecting the link provided in the Azure Function
and then appending the function name e.g. <FunctionURL>\api\HttpExample

5. Azure function app will display the result/output in the web browser.

6. Modify the db2dsdriver.cfg configuration file by adding "SwitchDb2trace" parameter.
Here, D:\home\LogFiles\db2trc.dmp is the location, where we have write permission to capture db2trc dump.
Update the db2dsdriver.cfg file as below:

 

<configuration>

<parameters>

<parameter name="SwitchDb2trace" value="on -f

D:\home\LogFiles\db2trc.dmp"/>

<parameter name="TraceRefreshInterval" value="3"/>

</parameters>

</configuration>

 

Reference info-center link for SwitchDb2trace configuration keyword

: https://www.ibm.com/docs/en/db2/11.5?topic=keywords-switchdb2trace

7. Refresh the web browser by pressing F5 and reproduce the issue (Problem statement).

8. Once issue is created, Switch off the db2 trace by modifying the db2dsdriver.cfg configuration file as below.

 

<configuration>

<parameters>

<parameter name="SwitchDb2trace" value="off"/>

<parameter name="TraceRefreshInterval" value="3"/>

</parameters>

</configuration>

 

9. Refresh the web browser by pressing F5 again.

10. Go to Advanced Tool->go-> Kudu -> Debug Console -> CMD option .Then browse the D:\home\LogFiles\ directory.
db2trc.dmp file created, Format the db2trc dump file by executing the below command in Kudu CMD console:

For flow file:

D:\home\LogFiles>d:\home\site\wwwroot\bin\clidriver\bin\db2trc  flw  db2trc.dmp  db2trc.flw

 

For Format file:

D:\home\LogFiles>d:\home\site\wwwroot\bin\clidriver\bin\db2trc  fmt  db2trc.dmp  db2trc.fmt

 

For CLI trace:

D:\home\LogFiles>d:\home\site\wwwroot\bin\clidriver\bin\db2trc  fmt  -cli  db2trc.dmp  db2trc.cli

 

For DRDA trace:

 D:\home\LogFiles>d:\home\site\wwwroot\bin\clidriver\bin\db2trc  fmt  -c  db2trc.dmp  db2trc.fmtc

 


#DataManagementGlobal
#DataServerDrivers

0 comments
97 views

Permalink