DB2 Universal and

1 Topics

Linux distributions Why DB2 UDB for Linux DB2 UDB on Linux for S/390 and DB2 Connect Multipartition on Linux (Intel) Installing DB2 UDB for Linux Application Development Documentation

2 What is Linux?

Popular -like Developed by in 1991 Developed & tested by Open Source community communicating via Internet Open Source Software distributed under terms of the GNU Public License (GPL) Packaged and distributed by distributors which offer support: SuSE Caldera TurboLinux United Linux et. al.

3 Supported Linux Distributions

DB2 UDB V7.1 for Linux on Intel/32: Caldera OpenLinux V2.3 Red Hat Linux 6.1 SuSE Linux 6.3 and 7 TurboLinux Workstation/Server V6.0 DB2 UDB V7.2 for Linux on Intel/32: Any distribution with Kernel 2.2.12, 2.4 or higher and Libraries glibc 2.1.2 or higher and libstdc++ 2.9.0 or higher SuSE Linux 6 (zSeries) Red Hat 7.2 (zSeries) TurboLinux Workstation/Server V6.0 (zSeries)

4 Supported Linux Distributions

DB2 UDB V8.1 for Linux on Intel/32: Any distribution with Kernel 2.4.18 and Libraries glibc 2.2.4 or Entry in distribution validation list DB2 UDB V8.1 for Linux on Intel/64: Red Hat 7.2 SuSE SLES-7 for Linux on IA64 DB2 UDB V8.1 for Linux on S/390: RedHat v7.2 SuSE SLES-7 for Linux on S/390

see http://www.ibm.com/db2/linux/validate

5 2.4 Improvements

Large Filesystem Support File sizes (tablespace container) > 2 GByte install glibc 2.2 or higher Raw Device I/O DB2 database tablespaces can use raw devices Support for Large RAM Increased Maximum Number of Processes Kernel allows more than 1,024 processes Support for applications with thousands of concurrent users Better SMP scalability

6 Raw Device Tablespaces on Linux

Raw partition example: /dev/sda5 Step 1 - calculate the size in 4K pages Step 2 - bind an unused raw device node # raw /dev/raw/raw1 /dev/sda5 Step 3 - set appropriate permissions Step 4 - create database tablespace

CREATE TABLESPACE dms1 MANAGED BY DATABASE USING (DEVICE '/dev/raw/raw1' )

7 Why DB2 UDB for Linux (1)

Robust Enterprise Database Server for Linux Reliability, Scalability, High-Availability (HA) and Performance SMP support, OLAP functions, Support for Binary Large Objects Embedded-to-enterprise industrial strength Linux database solution DB2 is Easy to Manage Web based central control point (called "Control Center") for managing DB2 servers Control Center presents a single GUI interface to all DBA tasks DB2 has broad support of Web Standards Java (JDBC, SQLJ support for static SQL) and HTTP server access Information is easily accessible, available, and secure over the Web DB2 is a High Performance database Leader in query optimization technology and performance Leverages JVM (Java Virtual Machine) enabling DB2 to optimize its performance for each operating environment.

8 Why DB2 UDB for Linux (2)

DB2 has bulletproof reliability A 24x7 database availability as required by mission critical Web applications DB2 provides a scalable e-business framework Handles large data requirements and also high and frequently unpredictable concurrent usage requirements of e-business Net.Search high speed in-memory search capability DB2 Replication (Capture and Apply) Fully Web-enabled DBD::DB2 interface for Perl Developers Standard database access API for Perl PHP Support Multi-platform Support DB2 runs on the most UNIX, Intel platforms and on Linux for S/390! DB2 supports all major industry standards relevant to distributed data DB2 has universal access from almost any client workstation

9 Why DB2 UDB for Linux (3)

DB2 lower development costs DB2 query optimizer automatically updates queries for best performance Net.Data provides quick access to DB2 data from Web servers DB2 has Lower Total Cost of Ownership DB2 UDB provides the most comprehensive data management solution in the industry at lower total cost of ownership DB2 UDB leads the industry in providing a solution-based packaging by integrating tools, host connectivity, greater scalability, superior performance DB2's per-processor and new ASP pricing brings revolutionary simplicity to customers as they determine the possible cost of their DB2 UDB implementation TCO consultant reports are available for viewing at: http://www-4.ibm.com/software/data/pubs/tech-consult.html

10 Why DB2 UDB for Linux (4)

DB2 has extensive business partner support programs Extensive technical enablement and co-marketing programs to support business partner success with IBM technologies DB2 has breadth and depth of IBM and Business Partner applications support world wide Provide vision, consulting, technology, applications, service and worldwide support required to productively and efficiently deploy any Web based solutions DB2 is the soul of e-business More than one million DB2 server licenses and 40 million users world wide DB2 is powering the world's e-business solutions, e.g., electronic commerce, Enterprise Resource Planning (ERP), Customer Relationship Management (CRM) Supply Chain Management (SCM), Web Self-service, Enterprise Information Portal (EIP), and Business Intelligence (BI)

11 Why DB2 UDB for Linux (5)

DB2 grows as your business grows! Migration (Not!) - It's all the same code base! CClusterluster You don't have to worry about running out of steam with DB2! PC Server PC Server 320 320

"EEE"

PC Server 320

PC Server "EE" 320 Symmetric MultiprMultiprocessorocessor (SMP) Enterprise Server Edition UUniprocessorniprocessor Workgroup Edition Personal Edition

12 High Availability - Hot Standby

Zero Data Loss Standby Raid 1 - Mirroring HACMP Split Mirror Backup w/ dual logging

Primary Hot Standby Heartbeat signal backup database with no primary impact crash recovery for reporting continuous rollforward to keep in

Logs Dual Logging Mirrored

Data Continuous Rollforward

Split Mirror Copy 13 DB2 HA Clustering Solutions

AIX HACMP and HACMP/ES Sun Solaris Sun Cluster Veritas Cluster Server Windows Microsoft Cluster Services (MSCS) HP-UX MC/Service Guard Linux SteelEye Mission Critical Linux Step-by-step Whitepaper at: http://www.ibm.com/software/data/pubs/papers/

14 DB2 UDB on Linux for S/390 and zSeries

15 DB2 Connect - Before and After

Middle tier of gateway servers was needed

ClClientsients DB2 for OS/390,OS/390, VM, VSEVSE

PPersonalersonal EEditiondition DB2 Connect for UNIX,IX, Wininddoowws,s, OOS/2S/2 BeforeBefore

Eliminate middle tier with DB2 Connect on S/390 and zSeries

DB2 CConnonnect fforor Liinunuxx - S/3S/390 Clients DB2 fforor OSS/3/390,90, VM, VSE

PersPersonalonal EEditiondition AfterAfter

16 Multi-partition Databases on Linux

Shared Nothing architecture

Transactions

T 1 T 2 T 3 T 4 T 5 T 6 T 7 T 8 T 9

DB2 UDB ESE

CPU CPU CPU CPU CPU CPU CPU CPU

CPU CPU CPU CPU CPU CPU CPU CPU

Memory Memory Memory Memory

17 DB2 UDB Enterprise Server Edition

IBM delivered the industry's first database support of Linux Clusters

Start small & grow Easy to add nodes to the cluster Investment in skill set maintained L L L Not locked into proprietary OS I I I Customers can get high-end clustering for N N N U U U web and data warehouse apps for low TCO X X X Commodity hardware Not locked into a proprietary OS DB2 DB2 DB2 ESE ESE ESE DB2 Enterprise Server Edition Leading benchmarks Terabyte Club Shared nothing architecture Single database Scale & performance image High availability Near linear scaling Management tools

18 Types of Query Parallelism

Inter-transaction parallelism Simultaneous running of more than one transaction Known as Concurrency Intra-partition parallelism (Intra-PP) Possibility of splitting a query into multiple parts, which are executed in parallel: Scans Joins Sorts ... Inter-partition parallelism (Inter-PP) Possibility of splitting a query into multiple parts over multiple partitions of a database DB2 supports all three types of parallelism!

19 Types of Query Parallelism

Inter-partition SELECT ... FROM ... parallelism

Worker Worker Worker Worker

Data Data Data Data

DB Partition DB Partition DB Partition DB Partition

Intra-partition SELECT ... FROM ... parallelism

Worker Worker Worker Worker

Data

DB Partition 20 What is an Instance? - Linux Version -

"Something" associated to one Linux user the so called "instance owner", i.e. db2inst1 instance (owner) home directory, i.e. /home/db2inst1 "Something" I must create after installing the product in /opt/IBM/db2/V8.1 db2setup (semi-graphic) db2icrt (command line) i.e. db2icrt creates /home/db2inst1/sqllib/... "Something" I must start like a web server, ADSM, ... only the instance owner can start and stop it "Something" that contains databases one or more databases are under the control of one instance ...but without an instance, there is no database!

21 Installing a DB2 V8.1 Instance on Linux

HW requirements DB2 Workgroup Edition (DB2 WE) Intel 32-bit machines DB2 Enterprise Server Edition (DB2 ESE) Intel 32-bit machines Intel 64-bit machines S/390 9672 G5 or higher, Multiprise 3000 or eServer z-Series Distribution and kernel requirements Previous page SW requirements JDK 1.3.1 Will be installed from CD if necessary Install directory /opt/IBM/db2/V8.1

22 Installing a DB2 V8.1 Instance on Linux

Install SW prerequisites Modify the kernel parameters in /etc/sysctl.conf Installation steps Modify Kernel parameters for DB2 Install DB2 from CD (db2setup) Install directory /opt/IBM/db2/V8.1 Install latest FixPak Updates/adds files in /opt/IBM/db2/V8.1 Install DB2 online documentation from CD Steps to create non-partitioned first instance Create instance owner user ID (i.e. db2inst1) and home directory Create fenced user ID (i.e. db2fenc1) Create instance (i.e. db2icrt -u db2fenc1 db2inst1) New sub-directory sqllib in home directory of instance owner with links to files/directories in /opt/IBM/db2/V8.1

23 Installing a Multi-partition DB2 Instance

Install DB2 UDB V8.1 ESE and FixPak on all machines Steps to create a partitioned instance Create instance owner user ID (i.e. db2inst1) and home directory on first machine Export instance owner home directory using NFS Mount home directory on the remaining machines Create instance owner user IDs on the remaining machines, use the NFS mounted directory as the central home directory Create fenced user ID (i.e. db2fenc1) on all machines Create instance (i.e. db2icrt -u db2fenc1 db2inst1) on first machine Add remaining machines to 0 dbmachA 0 db2nodes.cfg 1 dbmachA 1 2 dbmachA 2 Restart instance 3 dbmachB 0 4 dbmachB 1

/home/db2inst1/sqllib/db2nodes.cfg

24 DB2 Client Installation

Run-Time Client Functionality required for an application to access a DB2 server Communication protocols (TCP/IP, NetBIOS, ...) Application interfaces (CLI, ODBC, JDBC, ...) CLI/ODBC administration GUI Administration Client All features of Run-Time Client Administration tools Support for Thin Clients Application Development All features of Run-Time Client Main tools of Administration Client Collection of tools to develop DB2 applications Development Center (Stored Procedure Builder) Colection of sample applications

25 DB2 UDB V8.1 for Developers

Try and Buy for 90 Days ESE (Intel and zSeries) http://www.ibm.com/software/data/db2/udb/downloads.html Linux Solution Evalution Kit Contains IBM key middleware for Linux including the Universal Developer's Edition (UDE) for DB2 on Linux UDE for Linux contains all the tools to develop e-business applications for DB2 http://www.ibm.com/linux

26 Supported C/C++ and Java Languages

DB2 UDB V8.1 for Linux for Intel x86: GNU/Linux gcc and g++ versions 2.95.3 and 2.96 IBM JDK/JRE 1.3.1 DB2 UDB V8.1 for Linux on IA64: GNU/Linux gcc version 3.0.2 (C) GNU/Linux g++ version 3.0.2 (C++) IBM zSeries JDK for Linux (at Sun 1.3.1 SDK level) DB2 32-bit applications or routines (stored procedures and user-defined functions) are not supported on Linux IA64. DB2 UDB V8.1 for Linux for S/390: GNU/Linux gcc and g++ versions 2.95.3 IBM JDK/JRE 1.3.1 (64-bit)

see http://www.ibm.com/db2/udb/ad/

27 Other Supported Languages

DB2 UDB V8.1 for Linux for Intel x86 and S/390: Perl 5.004_04 or later, DBI 0.93 or later DB2 interface is available for download provide by IBM www.ibm.com/db2/perl REXX Language level of DB2 UDB V5.2 Object REXX Interpreter for Linux/Intel Version 2.1 Object REXX 2.2.0 for Linux/390 DB2 UDB V8.1 for Linux on IA64: Perl 5.6 PHP Unified-ODBC method Communication directly to the DB2 CLI layer Fortran and Cobol Not supported on Linux

28 DB2 V8.1/Linux Application Interfaces

Application Application Application Embedded SQL JDBC ODBC X/Open Java C, C++ C/C++, Java (SQLJ, only static), Call Level Interface REXX (only dynamic), C/C++

Static SQL Dynamic SQL "Static" SQL

DB2 Client

Note: SQLJ applications can only embed static SQL statements. However, you can use JDBC to make dynamic calls in SQLJ applications.

29 Embedded SQL and SQLJ

ISO Standard (SQL92) Consists of static or dynamic SQL or a mixture of both DB2 UDB V8.1 for Linux C/C++, Java (SQLJ), REXX Precompiler Converts SQL statements (surrounded by special delimiters) into host language commands (source code file). Delimiters: EXEC SQL Binder Binds the SQL statements in the application to the database for the application to run (bind file). For Java (SQLJ): SQLJ translator Converts SQLJ clauses into JDBC statement.

30 ESQL and SQLJ Preparation Steps

B ESQL: P ID I R myapp.bnd N E D ID Package C E myapp.sqc O Bind File R with M DB embedded P C (each) SQL statements O I ID L L M ID I ID Source File E myapp.cmyapp.c P N with DB2 mymaypp.oapp.o mymyappapp C/C++, R with DB2 I K run-time L REXX run-tAPI cimallse E API calls E R R Object File Executable Modified File Source File DB2 Library Files DB2 Include Files

C SQLJ: U S T T MyClass_ O Package R SJProfile0.ser M A I S N Z DB Q Serialized Profile S E myapp.sqlj L L R J A C T O Source File O M JAVA R myapp.java P myapp.class with JDBC calls I sqlj.zip L E JAVA Class Modified R File So31urce File Packages

DB2 uses package to execute statements produced during preparation time package contains one section per SQL statement package can be permanent, stored in the database temporary, stored in the db global memory (package cache) Static Embedded SQL and static CLI/ODBC/JDBC packages are permanent sections contain access plan (compiled form) of SQL statements Dynamic Embedded SQL packages are permanent sections are placeholder control structures for execution time Others packages are temporary sections contain access plan of SQL statements

32 Static Embedded SQL

General Syntax of SQL statements is fully known at precompile time. No parse errors at run-time. End user does not require direct privileges to execute the statements. Only information that can be specified at run time: Values for host variables. DB2 Packages are the result of a bind: A section is the compiled form of an SQL statement. An optimized access plan will be stored in the section. Optimized packages available at run-time. Packages need rebind in order to update access path

33 Dynamic Embedded SQL

General Syntax of SQL statements is not known until run time. Objects referenced by statements do not exist at precompile time. SQL statement is treated as a host variable at preparation time. Always use the most optimal access path, based on current statistics. Overhead for preparing each statement at run time DB2 Packages are the result of a bind: Sections are used as placeholders for SQL statements. No access plans in sections. Host variables are represented by ? (parameter markers) Access Control at package level (execute)

34 Static CLI/ODBC/JDBC

converting CLI/ODBC/JDBC queries into static SQL static profiling session configure db2cli.ini to activate capturing of CLI queries use db2cap to generate one or more static CLI packages configure db2cli.ini to activate reusing of static CLI queries

35 What are UDFs?

Mechanism to write your own extensions to SQL. Supplied built-in functions are a useful set of functions but may not satisfy all of your requirements. Extend SQL for the following reasons: Customization. Function does not exist in DB2 (simple transformation, a trivial calculation, or a complicated multivariate analysis). Flexibility. Built-in function does not quite permit the variations. Standardization. Build up same functions like Oracle... Object-relational support. Support UDTs, useful in extending the capability. Cast functions. You can now use SQL in DB2 UDFs

36 Writing UDFs

external: C, C++, Java or Visual Basic implemented in external libraries single SQL statement inline SQL Procedure language: SPL source code stored in the database in SYSCAT.ROUTINES implemented under-the-covers as an external C UDF using embedded SQL Implementing a UDF requires the following steps: Writing the UDF Compiling (and linking) the UDF Debugging the UDF Registering the UDF with DB2:

37 Stored Procedures

Client DB DB2 CAE Application Server Database

Network

Client Stored DB2 CAE Application Procedure

Reduced Network traffic

Improved performance of DB server intensive work Server Database Access to server-only features

38 Writing Stored Procedures

external: C, C++, Java, COBOL, FORTRAN, REXX and IBM VisualAge for Basic embedded SQL, CLI, JDBC and SQLJ (static, dynamic SQL and mixed) source and library code only exists outside the database!!! SQL Procedure Language (SPL): SPL source code is stored in the database in SYSCAT.ROUTINES implemented under-the-covers as an external C stored procedure using embedded SQL

39 Java Stored Procedures and UDFs

Compiler and JVM JDK 1.3.1 Environment Linux run-time linker must access certain Java shared libraries DB2 load theses libraries and the Java virtual machine Create symbolic links in /usr/lib cd /usr/lib ln -fs JAVAHOME/jre/bin/libjava.so . ln -fs JAVAHOME/jre/bin/classic/libjvm.so . ln -fs JAVAHOME/jre/bin/libhpi.so .

40 C/C++ Stored Procedures and UDFs

Compiler and libraries GNU/Linux C compiler Compile and link options Samples in sqllib/sample/c Build script: bldrtn [ ]

41 DB2 Development Center

Rapid, iterative development of Java and SQL stored procedures, user-defined functions, triggers, types for DB2 UDB, DB2/390 and DB2 400 portable SPs in Java or SQL/PSM WebSphere Studio Plug-in Integrated debugger

42 Documentation

IBM DB2 Online Documentation Web Site http://software.ibm.com/data/db2/library Application Development Guide Application Building Guide DB2 Home Page http://www.ibm.com/software/data/db2/ http://www.ibm.com/software/data/db2/linux Linux at IBM home page http://www.ibm.com/software/is/mp/linux/ IBM Redbooks http://www.redbooks.ibm.com IBM Data Management Certifications http://certify.torolab.ibm.com

43