Anders Karlsson Principal Sales Engineer, MySQL MySQL Embedded - Getting started with libmysqld.

Slides:



Advertisements
Similar presentations
Operating-System Structures
Advertisements

Windows XP Basics OVERVIEW Next.
LINUX-WINDOWS INTERACTION. One software allowing interaction between Linux and Windows is WINE. Wine allows Linux users to load Windows programs while.
IWay Service Manager 6.1 Product Update Scott Hathaway iWay Software Copyright 2010, Information Builders. Slide 1.
Technical Architectures
DRIVOLUTION: RETHINKING THE DATABASE DRIVER LIFECYCLE Emmanuel Cecchet (UMass Amherst) Joint work with George Candea ( )
1 Pertemuan 13 Servers for E-Business Matakuliah: M0284/Teknologi & Infrastruktur E-Business Tahun: 2005 Versi: >
15 Chapter 15 Web Database Development Database Systems: Design, Implementation, and Management, Fifth Edition, Rob and Coronel.
INTERNET DATABASE Chapter 9. u Basics of Internet, Web, HTTP, HTML, URLs. u Advantages and disadvantages of Web as a database platform. u Approaches for.
Software Frameworks for Acquisition and Control European PhD – 2009 Horácio Fernandes.
Systems Architecture, Fourth Edition1 Internet and Distributed Application Services Chapter 13.
Working with SQL and PL/SQL/ Session 1 / 1 of 27 SQL Server Architecture.
SQLite and the.NET Framework This PPT:
Hands-On Microsoft Windows Server 2008 Chapter 8 Managing Windows Server 2008 Network Services.
The Client/Server Database Environment
Introduction to Databases Transparencies 1. ©Pearson Education 2009 Objectives Common uses of database systems. Meaning of the term database. Meaning.
Building Library Web Site Using Drupal
Client/Server Architectures
Object Oriented Databases by Adam Stevenson. Object Databases Became commercially popular in mid 1990’s Became commercially popular in mid 1990’s You.
Microsoft Windows 2003 Server. Client/Server Environment Many client computers connect to a server.
A Free sample background from © 2001 By Default!Slide 1.NET Overview BY: Pinkesh Desai.
Getting connected.  Java application calls the JDBC library.  JDBC loads a driver which talks to the database.  We can change database engines without.
Module 10 Configuring and Managing Storage Technologies.
Chapter-4 Windows 2000 Professional Win2K Professional provides a very usable interface and was designed for use in the desktop PC. Microsoft server system.
FALL 2005CSI 4118 – UNIVERSITY OF OTTAWA1 Part 4 Web technologies: HTTP, CGI, PHP,Java applets)
ITN Wake Tech1 ITN270 Advanced Internet Databases Lecture 14. Introduction to MySQL Administration and the MySQL Data Directory Topics: –Overview.
WINDOWS SERVICES. Introduction You often need programs that run continuously in the background Examples: – servers –Print spooler You often need.
©Ian Sommerville 2006Software Engineering, 8th edition. Chapter 12 Slide 1 Distributed Systems Architectures.
SUSE Linux Enterprise Server Administration (Course 3037) Chapter 4 Manage Software for SUSE Linux Enterprise Server.
Understanding the CORBA Model. What is CORBA?  The Common Object Request Broker Architecture (CORBA) allows distributed applications to interoperate.
DATABASE PROGRAMMING Lecture on 16 – 05 – PREVIOUS LECTURE QUIZ: - Some students were very creative in transforming 2NF to 3NF. Excellent! - Some.
M1G Introduction to Database Development 6. Building Applications.
Microsoft Application Virtualization 5.0: Introduction Mohnish Chaturvedi & Ian Bartlett Premier Field Engineer WCL312.
9 Chapter Nine Compiled Web Server Programs. 9 Chapter Objectives Learn about Common Gateway Interface (CGI) Create CGI programs that generate dynamic.
Web Server Administration Chapter 7 Installing and Testing a Programming Environment.
CS 390- Unix Programming Environment CS 390 Unix Programming Environment Topics to be covered: Distributed Computing Fundamentals.
MySQL. Dept. of Computing Science, University of Aberdeen2 In this lecture you will learn The main subsystems in MySQL architecture The different storage.
DCE (distributed computing environment) DCE (distributed computing environment)
DEV325 Deploying Visual Studio.NET Applications Billy Hollis Author / Consultant.
MySQL Connection using ADO.Net Connecting to MySQL from.NET Languages.
CHAPTER TEN AUTHORING.
Open Solutions for a Changing World™ Copyright 2005, Data Access Worldwide June 6-9, 2005 Key Biscayne, Florida 1 Pervasive.SQL Version 9 - What’s New.
Component Technology. Challenges Facing the Software Industry Today’s applications are large & complex – time consuming to develop, difficult and costly.
Copyright 2002, Jeremy Zawodny MySQL Backup & Recovery O’Reilly Open Source Convention Jeremy Zawodny Yahoo! Finance July 24th, 2002.
Database Architectures Database System Architectures Considerations – Data storage: Where do the data and DBMS reside? – Processing: Where.
What’s new in Kentico CMS 5.0 Michal Neuwirth Product Manager Kentico Software.
CE Operating Systems Lecture 3 Overview of OS functions and structure.
Hands-On Microsoft Windows Server Implementing Microsoft Internet Information Services Microsoft Internet Information Services (IIS) –Software included.
Tool Integration with Data and Computation Grid GWE - “Grid Wizard Enterprise”
A Brief Documentation.  Provides basic information about connection, server, and client.
MySQL Gubbins Richard Sinclair HepSysMan – 11/05/2012.
CSI 3125, Preliminaries, page 1 SERVLET. CSI 3125, Preliminaries, page 2 SERVLET A servlet is a server-side software program, written in Java code, that.
What is MySQL? MySQL is a relational database management system (RDBMS) based on SQL (Structured Query Language). First released in January, Many.
Learningcomputer.com SQL Server 2008 –Views, Functions and Stored Procedures.
Database technology Introduction ER Modeling Database objects (intro) SQL.
SQL SERVER 2008 Installation Guide A Step by Step Guide Prepared by Hassan Tariq.
Tool Integration with Data and Computation Grid “Grid Wizard 2”
Text TCS INTERNAL Oracle PL/SQL – Introduction. TCS INTERNAL PL SQL Introduction PLSQL means Procedural Language extension of SQL. PLSQL is a database.
© N. Ganesan, Ph.D., All rights reserved. Windows Server Installation Nanda Ganesan, Ph.D.
COMP1321 Digital Infrastructure Richard Henson March 2016.
Computer System Structures
DEPTT. OF COMP. SC & APPLICATIONS
Component and Deployment Diagrams
Platform as a Service.
Principles of report writing
Chapter 2: System Structures
Software models - Software Architecture Design Patterns
Analysis models and design models
OurSQL = MySQL + Blockchain
Presentation transcript:

Anders Karlsson Principal Sales Engineer, MySQL MySQL Embedded - Getting started with libmysqld

Agenda Who am I? (Good question!) Why libmysqld? What is libmysqld? > What is MySQL Emmbedded? And is it different from libmysqld? Programming with libmysqld > API, Samples etc. Limitations of libmysqld Questions? Answers?

About Anders Karlsson Sales Engineer with Sun / MySQL for 5+ years I have been in the RDBMS business for 20+ years I have worked for many of the major vendors and with most of the vendor products I’ve been in roles as > Sales Engineer > Consultant > Porting engineer > Support engineer > Etc. Outside MySQL I build websites ( develop Open Source software (MyQuery, ndbtop etc), am a keen photographer and drives sub-standard cars, among other things. Also, I am pushing for ZFS to become GPL:

Why libmysqld? Libmysqld is compact and fast Libmysqld is easily integrated into an application Application installation is MUCH easier > No separate server to install or run > No need to run as service or daemon Low hardware requirements Zero maintenance MySQL hidden from end user

And why NOT libmysqld? Only ONE application can connect at the time! No server means less flexibility Application itself has larger footprint > Includes both the server and the application Certain limitations exist No Replication No Client / Server connection No authentication / security More functions must be implemented in the application > Any mysql Client operations such as dump, restore, check etc.

What is libmysqld and why is it different? “Normal” MySQL is a classic client/server based RDBMS > The database server is a separate process from the client application > The client and the sever communicates using standard networking (typically sockets or TCP/IP) > The Server may, and again may not, run in a separate hardware environment from the client > The client talks to the server using a MySQL defined protocol, typically implemented in a client interface or “driver” or Connector

What is libmysqld and why is it different? MySQL in Client / Server configuration > MySQL Server runs on machine on the network > Clients communicate with Server using the MySQL Protocol > Many clients talk to the same server Clients using MySQL Protocol Server Disk

What is libmysqld and why is it different? Libmysqld is a SQL database layer tightly integrated with the application or “client” > The database and the application runs in the same process space > No special means of communication is needed as both the application and the database are in the same process, calling MySQL is similar to calling any other library function > The interface between the Application or client is different, but the exposed component, the API, is the same as with Client / Server MySQL > Although the API looks the same, the implementation is different!

What is libmysqld and why is it different? Libmysqld configuration > The Application IS the server! > There is just 1 process > Data is stored on the local disk > NOTE: The API for the application is the same, but the implementation is different! There is just one implementation: In C > All data is local > Only one “client” Application process libmysqld Client system

So where do I find libmysqld? Libmysqld is part of the usual MySQL distribution Just download the MySQL Server and you find > On Windows : libmysqld is in the Embedded subdirectory, both debug and release versions are available, and in DLL and static builds > On Linux : libmysqld.a is in the lib subdirectory where MySQL is installed Includefiles: > Use the normal MySQL C API includefiles

Building libmysqld applications Develop applications in C > Add calls to mysql_library_init() etc. Compile as usual Link with libmysqld > Can be linked dynamically or statically > A dynamic link is easier, just as a dynamic link with the MySQL C Client library is easier Set up an option file Ship application, possibly the libmysqld shared library and option file

The libmysqld API VERY similar to the MySQL C API > Does NOT implement the MySQL Protocol! > Only looks the same, implementation is different! Key functions that are different > mysql_library_init() – Starts the internal “MySQL Server” > mysql_library_end() – Shuts down the internal “MySQL Server” gracefully > mysql_thread_init() / mysql_thread_end() > mysql_options() – Set MYSQL_OPT_USE_EMBEDDED_CONNECTION before connecting

The mysql_library_init() function Initializes the MySQL internal server Passes parameters to the server in that process Must be passed information on initialization files and sections in those > No server is already running! > This means all necessary server parameters needs to be specified! This means that this call is mostly different from when NOT using libmysqld! MUST be called before mysql_init()!

The mysql_library_init() parameters Argument count (argc) Arguments (argv) – Like the parameters to mysqld, the first argument (as in argv[0] beging name of the program) being ignored. A list of option file sections to read > If a -- defaults-file or any other argument with an option file is passed, the config files section specifies whicg sections in this file to read > The last section name is NULL > If no option file is passed, this argument may be NULL.

static char *server_options[] = { "mysql_test", "--datadir=C:/mydata", NULL}; static char *server_groups[] = { "libmysqld_server", NULL}; int main(argc, argv) { MYSQL mysql; mysql_library_init(sizeof(server_options)/ sizeof(char *) – 1, server_options, (char **) server_gropus); mysql = mysql_init(NULL); mysql_options(mysql, MYSQL_OPT_USE_EMBEDDED_CONNECTION, NULL); mysql_real_connect(mysql, NULL, NULL, NULL, "test", 0, NULL, 0); Initializing a libmysqld application

Configuring a libmysqld application Use a my.cnf file > Set server_options as per the previous slide, to include --defaults-file=my.cnf > Note that you must be careful with the path here! > Set up the my.cnf file Or set all options in the application itself > Set all options in the server_options variable

Dynamic linking of a libmysqld application As a shared object / DLL > An import library is provided to be linked with your application > Your application will need to be distributed with the libmysqld shared object / DLL > Not available on all platforms Application Libmysqld Import Library Libmysqld shared library

Static linking of a libmysqld application As a static library > The libmysqld library is linked directly into the application > No additional files needs to be distributed with the application > The only option on some platforms > Has a slight performance benefit Application Libmysqld Library

Linking a libmysqld application Note that dynamic linking does NOT necessarily allow you to update libmysqld by just changing the DLL / Shared object > Typically, an application linked with MySQL version X needs libmysqld version X, even with dynamic linking For Windows, I recommed dynamic linking > Windows static linking is complex, as the static library depends on a particular version of Visual C++ is used For Linux, I recommend static linking > Not the least because that is the only option right now. But it is less problematic than on windows, and has a slight performance advantage

Managing libmysqld data Data format are the same for libmysqld as it is for the MySQL Server mysqld > Hence: Data that can be freely copied with mysqld can be freely copied with libmysqld > This relates to most storage engines, but in some cases with limitations MyISAM may use compression (which is common) and other MyISAM variations Starting a libmysqld application with InnoDB enabled (not using --skip-innodb ) will create InnoDB data and transaction log files, as usual

Managing libmysqld data Offline tools for mysqld data may be used on libmysqld data > myisampack > myisamchk > etc Online tools need to be implemented as part of the application > mysqldump > mysqlshow > etc.

Libmysqld demo! The following demo application is available > On sourceforge: > On MySQL Forge: The application is Windows dialog-based and written in C using the Win32 API Should be self contained, except for libmysqld of course, and the language file

Limitations of libmysqld No replication No events InnoDB is single threaded No authentication / authorization Single application access > But that is the whole point of libmysqld Only C / C++

Libmysqld performance operations each, time in average after several runs INSERT UPDATE SELECT libmysqldmysqld 6.82 s 6.54 s 6.92 s s s s Note: This is very far from a scientific benchmark! The operations executed are simple single-row operations, searching on the PRIMARY KEY

Libmysqld performance So does this mean that libmysqld is faster than mysqld? > No, it means that libmysqld has less overhead, that performance is better is a side-effect of that So why is this useful data then > As it means that I need less OS and Hardware resources to achieve the same level of performance!

Resources and contacts me at: Read my blog at: MySQL Forum for Embedded systems: Contribute to the community with samples and ideas, we need more of those for libmysqld

Questions?