SlideShare a Scribd company logo
MySQL Database
MySQL 5.7
1
Lalit Choudhary
Agenda
2
1 MySQL History
2 MySQL Architecture
3 MySQL Installation
4 MySQL Storage engines and configuration
5 MySQL Administration and Monitoring
6 MySQL Replication
7 MySQL backup and restore
8 Upgrade and Downgrade
MySQL History
 The initial release in 1995 had a SQL interface and a dual license model, a free and an embedded
version. David Axmark, Monty and Allen Larrson founded MySQL AB in 1995, it was taken over by
Sun Microsystems in 2008 and Sun itself was taken by Oracle in 2010
 MyISAM engine
 InnoDB transactional engine
 MySQL 5.0 store procedure, triggers etc.
 MySQL 5.1 row-based replication, partitioning
 MySQL development boots in oracle, Including adding and improving existing features.
 MySQL comes with different choices depending on your needs.
- Community Server (GPL License)
- Standard Edition
- Enterprise Edition
3
MySQL Architecture
• Physical view of the MySQL (5.7) server architecture
Directory location will be different as per OS and type of installation.
4
MySQL Architecture
• Physical view of the MySQL (5.7) server architecture
Data directory
• Server log files
• Status file
• Innodb log files
• Innodb system tablespace
• Innodb log buffer
• Innodb tmp tablespace
Program executable files
Data sub-directory (Per Database)
• Data and index files (.ibd)
• Object structure files(.frm,.opt)
Program log files
5
6
 Configuration files:
◦ data_dir/auto.cnf : Contains server_uuid
◦ /etc/my.cnf : MySQL Configuration file.
 Misc:
• --basedir=dir_name
◦ The path to the MySQL installation directory.
• --datadir=dir_name
◦ The path to the MySQL data directory.
• --pid-file=file_name
◦ The path name of the file in which the server should write its process ID.
• --socket=file_name, -S file_name
◦ On Unix, the name of the Unix socket file to use, for connections made using a named pipe to a local server.
• --log-error=file_name
◦ Log errors and startup messages to this file.
MySQL Architecture
MySQL Architecture
• Logical view of the MySQL server architecture
PLUGIN Connectors : ODBC, JDBC, NET,PHP, Python etc.
Connections/Thread handling
Query Cache
Parser
Optimizer
Table Metadata
Cache
Keys Cache
[MyISAM]
inInnoDB MyISAM NDB MEMORY ……
SERVER
Storage Engines
CLIENT
7
[ Storage Engines
buffer/s]
MySQL Installation
 Ways to install MySQL
• Source code
• Binaries : ref http://dev.mysql.com/doc/refman/5.7/en/binary-installation.html
• Packages : Ref: http://dev.mysql.com/doc/refman/5.7/en/linux-installation-rpm.html
• MySQL Installer MSI and ZIP Archive
• Yum repository
 Configuration
• Storage engine
• Server Variables
• User management and Access control
8
Storage Engines
InnoDB:
• Fully transactional ACID.
• Offers REDO and UNDO for transactions.
• Data storage in tablespace :
 Multiple data files
 Logical object structure using innodb data and log buffer
• Row level locking.
9
InnoDB Architecture
10
Log files
Tablespace
MEMORY DISK
Innodb_buffer_pool
[Buffered data
pages,MVCC,UNDO,etc.]
Innodb_log_buffer
[Buffered logs record]
[tablespace IDs and page IDs]
TABLESPACE
ibdata1
ibdata2
ib_logfile0
ib_logfile1
ib_logfile2
REDO
LOG
FILES
Checkpoint
Checkpoint
Commit
Other Memory pools
Ib_buffer_pool file
R
e
c
o
v
e
r
y
MySQL Architecture
InnoDB
Ref: http://dev.mysql.com/doc/refman/5.7/en/innodb-storage-engine.html
 Tablespace : ibdata
◦ The file ibdata is the system tablespace for the InnoDB engine. Apart from the table data storage, InnoDB's functionality
requires looking for table metadata and storing and retrieving MVCC info to support ACID compliance and Transaction
Isolation. It contains several types for information for InnoDB objects.
• Table Data Pages
• Table Index Pages
• Data Dictionary
• MVCC Control Data
• Undo Space
• Rollback Segments
• Double Write Buffer (Pages Written in the Background to avoid OS caching)
• Insert Buffer (Changes to Secondary Indexes)
◦ Example:
innodb_data_file_path = /ibdata/ibdata1:10M:autoextend
innodb_data_file_path = /ibdata/ibdata1:988M;/disk2/ibdata2:50M:autoextend
11
MySQL Architecture
 Innodb redo log file : ib_logfile
◦ It will read across ib_logfile0 and ib_logfile1 to check for any data changes that were not posted to the double
write buffer in ibdata1. It will replay (redo) those changes. Once they are replayed and stored, mysqld becomes
ready for new DB Connections.
◦ Example :Innodb_log_file_in_group=3
Innodb_log_file_size=150M
 Innodb buffer pool file : ib_buffer_pool
◦ At the time of mysqld startup to reduce the warmup period after restarting the server, it loads few percent of most
recently used pages for each buffer pool at server shutdown and this data i.e. tablespace ID and page ID data
information is derived from the INNODB_BUFFER_PAGE_LRU INFORMATION_SCHEMA table. Tablespace ID and
page ID data is saved in a file named ib_buffer_pool under InnoDB data directory.
◦ The file name and location can be modified using the innodb_buffer_pool_filename configuration parameter.
12
MySQL Architecture
 Transactional logs: Binary logs
◦ Variable name : --log-bin
◦ Enable binary logging. The server logs all statements that change data to the binary log, which is used for backup
and replication.
◦ Using mysqlbinlog client tool we can extract and view binlog contents in text format.
13
Storage Engines
NDB:
• Fully Transactional and ACID Storage engine.
• Distribution execution of data and using multiple mysqld.
• NDB use logical data with own buffer for each NDB engine.
• Offers REDO and UNDO for transactions.
• Row level locking.
14
Storage Engines
MyISAM:
• Non transactional storage engine
• Speed for read
• Data storage in files and use key ,metadata and query cache
 .FRM for table structure
 .MYI for table index
 .MYD for table data
• Table level locking.
15
Storage Engines
Memory:
• Non transactional storage engine
• All data store in memory other then table metadata and structure.
• Table level locking.
16
Storage Engines
Archive:
• Non transactional storage engine,
• Store large amounts of compressed and unindexed data.
• Allow INSERT, REPLACE, and SELECT, but not DELETE or UPDATE sql operations.
• Table level locking.
17
Storage Engines
CSV:
• Stores data in flat files using comma-separated values format.
• Table structure needs be create within MySQL server (.frm)
18
MySQL Production ready configuration
 Hardware
• Storage and file types : SSD/HDD and EXT4 or XFS on Linux
• Memory : Optimal performance, Large transaction ,indexes, faster response time for ongoing changes and utilize Disk
IO
• CPU : Faster processors with many cores provide better throughput
 MySQL configuration
◦ innodb_file_per_table
◦ innodb_buffer_pool_size
◦ innodb_buffer_pool_instances
◦ innodb_log_file_size
◦ innodb_data_file_path
◦ Innodb_log_file_in_group
◦ innodb_flush_log_at_trx_commit
◦ innodb_thread_concurrency
◦ innodb_flush_method
19
MySQL Administration and Monitoring
 MySQL administrative tools
• Mysql : Login, database access/manipulation ,
• Mysqladmin : Administration purpose
• Mysqldump / mysqlpump : Logical backup utility
• Mysqlbinlog : Utility for processing binary log files and display binlog contents in text format.
• Mysql enterprise backup : Provides enterprise-grade backup and recovery for MySQL.
• Percona xtrabackup : Open source tool for mysql binary backup.
Ref: http://dev.mysql.com/doc/refman/5.7/en/programs-overview.html
 GUI tools
• MySQL enterprise monitor
• MySQL workbench/ SQLyog etc.
20
MySQL Administration and Monitoring
 Monitoring
• MySQL enterprise monitor : MySQL Enterprise Monitor provides real-time visibility into the performance and
availability of all your MySQL databases.
• Metadata and : From Information schema and mysql database.
• DB statistic: performance_schema databases we can get ongoing as well as historical database activities.
• SHOW PROCESSLIST
• Mysql utilities
• Audit logs & General logs, slow query logs
• Third-party tools : Percona tool kit , Nagios , cacti etc
21
MySQL Replication
Master Slave
● server_id
● log_bin
● binlog_format
● binlog-do-db
● binlog-ignore-db
● GTID (optional)
• server_id
• log_bin
• binlog_format
• log_slave_updates
• relay_log=file_name
• replicate-do-db=db_name
• replicate-ignore-db=db_name
ON MASTER:
Created replication user and grant privileges:
mysql> CREATE USER 'repl'@'%.mydomain.com' IDENTIFIED BY 'slavepass';
mysql> GRANT REPLICATION SLAVE ON *.* TO 'repl'@'%.mydomain.com';
Mysql> SHOW MASTER STATUS;
ON SLAVE:
mysql> CHANGE MASTER TO MASTER_HOST='master_host_name',MASTER_USER='replication_user_name',
MASTER_PASSWORD='replication_password',MASTER_LOG_FILE=‘master_log_file_name',
MASTER_LOG_POS=master_log_position;
22
MySQL Replication
23
MySQL Replication
 Best practices
− Use GTID enabled replication
◦ log_bin
◦ log-slave-update
◦ expire_log_days
◦ gtid_mode
◦ Enforce-gtid-consistency
− Crash-safe slaves
◦ master-info-repository=TABLE
◦ Relay-log-info-repository=TABLE
◦ Relay-log-recovery
− Secure slave
◦ read-only
◦ Skip-slave-start
− Avoid replication Lag
◦ slave_compressed_protocol
◦ MTR replication
24
MySQL Replication
 Without GTID
◦ Need Master_Log_File and Master_Log_Pos
 GTID
− What problems GTID solves?
◦ It is possible to identify a transaction uniquely across the replication servers. Make the automation of failover process
much easier. There is no need to do calculations, inspect the binary log and so on. Just
MASTER_AUTO_POSITION=1.
− Enable GTID replication
◦ gtid_mode: It can be ON or OFF (not 1 or 0). It enables the GTID on the server.
◦ log_bin: Enable binary logs. Mandatory to create a replication environment.
◦ log-slave-updates: Slave servers must log the changes that comes from the master in its own binary log.
◦ Enforce-gtid-consistency : Statements that can’t be logged in a transactionally safe manner are denied by the server.
25
Backup and Restore
 Backup
Binary Backup
− MySQL Enterprise Backup
Logical Backup
− mysqldump / mysqlpump
eg. mysqldump [options] > dump.sql
Hot Backup
− Replication slave
Customized scripts
26
Backup and Restore
 Restore
Logical backup restore using mysql client
eg. mysql [options] < dump.sql
Binary backup restore : Replace old binaries or package and run mysql_upgrade script.
27
MySQL Upgrade and Downgrade
MySQL Upgrade
Supported upgrade methods include:
In-Place Upgrade: Involves shutting down the old MySQL version, replacing the old MySQL binaries or packages with the new
ones, restarting MySQL on the existing data directory, and running mysql_upgrade.
Logical Upgrade: Involves exporting existing data from the old MySQL version using mysqldump, installing the new MySQL
version, loading the dump file into the new MySQL version, and running mysql_upgrade.
MySQL Downgrade
Supported downgrade methods include:
In-Place Downgrade: Involves shutting down the new MySQL version, replacing the new MySQL binaries or packages with the
old ones, and restarting the old MySQL version on the existing data directory. In-place downgrades are supported for
downgrades between GA versions within the same release series. For example, in-place downgrades are supported for
downgrades from 5.7.10 to 5.7.9.
Logical Downgrade: Involves using mysqldump to dump all tables from the new MySQL version, and then loading the dump
file into the old MySQL version. Logical downgrades are supported for downgrades between GA versions within the same
release series and for downgrades between release levels. For example, logical downgrades are supported for downgrades
from 5.7.10 to 5.7.9 and for downgrades from 5.7 to 5.6.
28
Additional Resources
MySQL Tutorial: http://dev.mysql.com/doc/refman/5.7/en/tutorial.html
MySQL Administration: http://dev.mysql.com/doc/refman/5.7/en/server-administration.html
Blogs: https://planet.mysql.com/
29
THANK YOU
30

More Related Content

What's hot (14)

PDF
MySQL For Oracle Developers
Ronald Bradford
 
PDF
MySQL Advanced Administrator 2021 - 네오클로바
NeoClova
 
PDF
Dd and atomic ddl pl17 dublin
Ståle Deraas
 
PDF
Collaborate 2012 - Administering MySQL for Oracle DBAs
Nelson Calero
 
PDF
My First 100 days with a MySQL DBMS (WP)
Gustavo Rene Antunez
 
PDF
Collaborate 2012 - Administering MySQL for Oracle DBAs
Nelson Calero
 
PPS
Introduction to Mysql
Tushar Chauhan
 
PPTX
MySQL DBA OCP 1Z0-883
Kwaye Kant
 
PDF
MySQL Enterprise Backup (MEB)
Mydbops
 
PDF
My SQL conceptual architecture
M Vinay Kumar
 
PDF
MySQL Backup & Recovery
Mindfire Solutions
 
PDF
InnoDB Cluster Experience (MySQL User Camp)
Mydbops
 
PDF
MySQL Storage Engines
Karthik .P.R
 
PDF
Percona Xtrabackup - Highly Efficient Backups
Mydbops
 
MySQL For Oracle Developers
Ronald Bradford
 
MySQL Advanced Administrator 2021 - 네오클로바
NeoClova
 
Dd and atomic ddl pl17 dublin
Ståle Deraas
 
Collaborate 2012 - Administering MySQL for Oracle DBAs
Nelson Calero
 
My First 100 days with a MySQL DBMS (WP)
Gustavo Rene Antunez
 
Collaborate 2012 - Administering MySQL for Oracle DBAs
Nelson Calero
 
Introduction to Mysql
Tushar Chauhan
 
MySQL DBA OCP 1Z0-883
Kwaye Kant
 
MySQL Enterprise Backup (MEB)
Mydbops
 
My SQL conceptual architecture
M Vinay Kumar
 
MySQL Backup & Recovery
Mindfire Solutions
 
InnoDB Cluster Experience (MySQL User Camp)
Mydbops
 
MySQL Storage Engines
Karthik .P.R
 
Percona Xtrabackup - Highly Efficient Backups
Mydbops
 

Viewers also liked (20)

PDF
Backing Up the MySQL Database
Sanjay Manwani
 
ODP
Pdb my sql backup london percona live 2012
Pythian
 
PDF
MySQL Server Backup, Restoration, And Disaster Recovery Planning Presentation
Colin Charles
 
PDF
MySQL Backup and Recovery Essentials
Ronald Bradford
 
PDF
web programming UNIT VIII python by Bhavsingh Maloth
Bhavsingh Maloth
 
PDF
Build and deploy scientific Python Applications
Ramakrishna Reddy
 
PPT
Linux
Hema Prasanth
 
PDF
PythonIntro_pycon2010
Kannappan Sirchabesan
 
PDF
Tutorial on-python-programming
Chetan Giridhar
 
PPT
Php Ppt
Hema Prasanth
 
PPT
Web 2 0 Ppt
Hema Prasanth
 
PPT
Mysql Ppt
Hema Prasanth
 
PPT
Linux basic commands
MohanKumar Palanichamy
 
PPTX
Mysql an introduction
Mohd yasin Karim
 
PPT
MySQL Features & Implementation
OSSCube
 
PDF
Quick Guide with Linux Command Line
Anuchit Chalothorn
 
PPTX
Basic commands of linux
shravan saini
 
PDF
Linux Basic Commands
Hanan Nmr
 
PPTX
Linux Kernel Programming
Nalin Sharma
 
PPT
Basic 50 linus command
MAGNA COLLEGE OF ENGINEERING
 
Backing Up the MySQL Database
Sanjay Manwani
 
Pdb my sql backup london percona live 2012
Pythian
 
MySQL Server Backup, Restoration, And Disaster Recovery Planning Presentation
Colin Charles
 
MySQL Backup and Recovery Essentials
Ronald Bradford
 
web programming UNIT VIII python by Bhavsingh Maloth
Bhavsingh Maloth
 
Build and deploy scientific Python Applications
Ramakrishna Reddy
 
PythonIntro_pycon2010
Kannappan Sirchabesan
 
Tutorial on-python-programming
Chetan Giridhar
 
Php Ppt
Hema Prasanth
 
Web 2 0 Ppt
Hema Prasanth
 
Mysql Ppt
Hema Prasanth
 
Linux basic commands
MohanKumar Palanichamy
 
Mysql an introduction
Mohd yasin Karim
 
MySQL Features & Implementation
OSSCube
 
Quick Guide with Linux Command Line
Anuchit Chalothorn
 
Basic commands of linux
shravan saini
 
Linux Basic Commands
Hanan Nmr
 
Linux Kernel Programming
Nalin Sharma
 
Basic 50 linus command
MAGNA COLLEGE OF ENGINEERING
 
Ad

Similar to MySQL database (20)

PDF
MySQL for Oracle DBA -- Rocky Mountain Oracle User Group Training Days '15
Dave Stokes
 
PPT
My sql basic
Prabhat gangwar
 
PDF
MySQL overview
Mark Swarbrick
 
PDF
My sql crashcourse_intro_kdl
sqlhjalp
 
PDF
My sql susecon_crashcourse_2012
sqlhjalp
 
PDF
The Proper Care and Feeding of MySQL Databases
Dave Stokes
 
PDF
My First 100 days with a MySQL DBMS
Gustavo Rene Antunez
 
PDF
iloug2015.Mysql.for.oracle.dba.V2
Baruch Osoveskiy
 
PPT
Fudcon talk.ppt
webhostingguy
 
PDF
MySQL Storage Engines Basics.
Remote MySQL DBA
 
PDF
MySQL 5.6, news in 5.7 and our HA options
Ted Wennmark
 
PDF
The Peoper Care and Feeding of a MySQL Server for Busy Linux Admin
Dave Stokes
 
PDF
Embracing Database Diversity: The New Oracle / MySQL DBA - UKOUG
Keith Hollman
 
PDF
My S Q L Introduction for 1 day training
Ivan Tu
 
PDF
My sql introduction for Bestcom
Ivan Tu
 
DOCX
My sql storage engines
Vasudeva Rao
 
PDF
mysql architecture.pdf
Rajendra Jain
 
PDF
Linuxfest Northwest Proper Care and Feeding Of a MySQL for Busy Linux Admins
Dave Stokes
 
PDF
MySQL 20 años: pasado, presente y futuro; conoce las nuevas características d...
GeneXus
 
PPTX
MySQL Quick Dive
Sudipta Kumar Sahoo
 
MySQL for Oracle DBA -- Rocky Mountain Oracle User Group Training Days '15
Dave Stokes
 
My sql basic
Prabhat gangwar
 
MySQL overview
Mark Swarbrick
 
My sql crashcourse_intro_kdl
sqlhjalp
 
My sql susecon_crashcourse_2012
sqlhjalp
 
The Proper Care and Feeding of MySQL Databases
Dave Stokes
 
My First 100 days with a MySQL DBMS
Gustavo Rene Antunez
 
iloug2015.Mysql.for.oracle.dba.V2
Baruch Osoveskiy
 
Fudcon talk.ppt
webhostingguy
 
MySQL Storage Engines Basics.
Remote MySQL DBA
 
MySQL 5.6, news in 5.7 and our HA options
Ted Wennmark
 
The Peoper Care and Feeding of a MySQL Server for Busy Linux Admin
Dave Stokes
 
Embracing Database Diversity: The New Oracle / MySQL DBA - UKOUG
Keith Hollman
 
My S Q L Introduction for 1 day training
Ivan Tu
 
My sql introduction for Bestcom
Ivan Tu
 
My sql storage engines
Vasudeva Rao
 
mysql architecture.pdf
Rajendra Jain
 
Linuxfest Northwest Proper Care and Feeding Of a MySQL for Busy Linux Admins
Dave Stokes
 
MySQL 20 años: pasado, presente y futuro; conoce las nuevas características d...
GeneXus
 
MySQL Quick Dive
Sudipta Kumar Sahoo
 
Ad

Recently uploaded (20)

PDF
Peak of Data & AI Encore AI-Enhanced Workflows for the Real World
Safe Software
 
PDF
“Voice Interfaces on a Budget: Building Real-time Speech Recognition on Low-c...
Edge AI and Vision Alliance
 
PDF
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
PPTX
Digital Circuits, important subject in CS
contactparinay1
 
DOCX
Cryptography Quiz: test your knowledge of this important security concept.
Rajni Bhardwaj Grover
 
PDF
SIZING YOUR AIR CONDITIONER---A PRACTICAL GUIDE.pdf
Muhammad Rizwan Akram
 
PDF
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
PPTX
The Project Compass - GDG on Campus MSIT
dscmsitkol
 
PDF
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
PDF
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
PDF
LOOPS in C Programming Language - Technology
RishabhDwivedi43
 
PDF
Kit-Works Team Study_20250627_한달만에만든사내서비스키링(양다윗).pdf
Wonjun Hwang
 
PDF
How do you fast track Agentic automation use cases discovery?
DianaGray10
 
PPTX
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
PPTX
Designing_the_Future_AI_Driven_Product_Experiences_Across_Devices.pptx
presentifyai
 
PDF
AI Agents in the Cloud: The Rise of Agentic Cloud Architecture
Lilly Gracia
 
PDF
UiPath DevConnect 2025: Agentic Automation Community User Group Meeting
DianaGray10
 
PPTX
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
PDF
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
PDF
“NPU IP Hardware Shaped Through Software and Use-case Analysis,” a Presentati...
Edge AI and Vision Alliance
 
Peak of Data & AI Encore AI-Enhanced Workflows for the Real World
Safe Software
 
“Voice Interfaces on a Budget: Building Real-time Speech Recognition on Low-c...
Edge AI and Vision Alliance
 
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
Digital Circuits, important subject in CS
contactparinay1
 
Cryptography Quiz: test your knowledge of this important security concept.
Rajni Bhardwaj Grover
 
SIZING YOUR AIR CONDITIONER---A PRACTICAL GUIDE.pdf
Muhammad Rizwan Akram
 
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
The Project Compass - GDG on Campus MSIT
dscmsitkol
 
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
LOOPS in C Programming Language - Technology
RishabhDwivedi43
 
Kit-Works Team Study_20250627_한달만에만든사내서비스키링(양다윗).pdf
Wonjun Hwang
 
How do you fast track Agentic automation use cases discovery?
DianaGray10
 
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
Designing_the_Future_AI_Driven_Product_Experiences_Across_Devices.pptx
presentifyai
 
AI Agents in the Cloud: The Rise of Agentic Cloud Architecture
Lilly Gracia
 
UiPath DevConnect 2025: Agentic Automation Community User Group Meeting
DianaGray10
 
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
“NPU IP Hardware Shaped Through Software and Use-case Analysis,” a Presentati...
Edge AI and Vision Alliance
 

MySQL database

  • 2. Agenda 2 1 MySQL History 2 MySQL Architecture 3 MySQL Installation 4 MySQL Storage engines and configuration 5 MySQL Administration and Monitoring 6 MySQL Replication 7 MySQL backup and restore 8 Upgrade and Downgrade
  • 3. MySQL History  The initial release in 1995 had a SQL interface and a dual license model, a free and an embedded version. David Axmark, Monty and Allen Larrson founded MySQL AB in 1995, it was taken over by Sun Microsystems in 2008 and Sun itself was taken by Oracle in 2010  MyISAM engine  InnoDB transactional engine  MySQL 5.0 store procedure, triggers etc.  MySQL 5.1 row-based replication, partitioning  MySQL development boots in oracle, Including adding and improving existing features.  MySQL comes with different choices depending on your needs. - Community Server (GPL License) - Standard Edition - Enterprise Edition 3
  • 4. MySQL Architecture • Physical view of the MySQL (5.7) server architecture Directory location will be different as per OS and type of installation. 4
  • 5. MySQL Architecture • Physical view of the MySQL (5.7) server architecture Data directory • Server log files • Status file • Innodb log files • Innodb system tablespace • Innodb log buffer • Innodb tmp tablespace Program executable files Data sub-directory (Per Database) • Data and index files (.ibd) • Object structure files(.frm,.opt) Program log files 5
  • 6. 6  Configuration files: ◦ data_dir/auto.cnf : Contains server_uuid ◦ /etc/my.cnf : MySQL Configuration file.  Misc: • --basedir=dir_name ◦ The path to the MySQL installation directory. • --datadir=dir_name ◦ The path to the MySQL data directory. • --pid-file=file_name ◦ The path name of the file in which the server should write its process ID. • --socket=file_name, -S file_name ◦ On Unix, the name of the Unix socket file to use, for connections made using a named pipe to a local server. • --log-error=file_name ◦ Log errors and startup messages to this file. MySQL Architecture
  • 7. MySQL Architecture • Logical view of the MySQL server architecture PLUGIN Connectors : ODBC, JDBC, NET,PHP, Python etc. Connections/Thread handling Query Cache Parser Optimizer Table Metadata Cache Keys Cache [MyISAM] inInnoDB MyISAM NDB MEMORY …… SERVER Storage Engines CLIENT 7 [ Storage Engines buffer/s]
  • 8. MySQL Installation  Ways to install MySQL • Source code • Binaries : ref http://dev.mysql.com/doc/refman/5.7/en/binary-installation.html • Packages : Ref: http://dev.mysql.com/doc/refman/5.7/en/linux-installation-rpm.html • MySQL Installer MSI and ZIP Archive • Yum repository  Configuration • Storage engine • Server Variables • User management and Access control 8
  • 9. Storage Engines InnoDB: • Fully transactional ACID. • Offers REDO and UNDO for transactions. • Data storage in tablespace :  Multiple data files  Logical object structure using innodb data and log buffer • Row level locking. 9
  • 10. InnoDB Architecture 10 Log files Tablespace MEMORY DISK Innodb_buffer_pool [Buffered data pages,MVCC,UNDO,etc.] Innodb_log_buffer [Buffered logs record] [tablespace IDs and page IDs] TABLESPACE ibdata1 ibdata2 ib_logfile0 ib_logfile1 ib_logfile2 REDO LOG FILES Checkpoint Checkpoint Commit Other Memory pools Ib_buffer_pool file R e c o v e r y
  • 11. MySQL Architecture InnoDB Ref: http://dev.mysql.com/doc/refman/5.7/en/innodb-storage-engine.html  Tablespace : ibdata ◦ The file ibdata is the system tablespace for the InnoDB engine. Apart from the table data storage, InnoDB's functionality requires looking for table metadata and storing and retrieving MVCC info to support ACID compliance and Transaction Isolation. It contains several types for information for InnoDB objects. • Table Data Pages • Table Index Pages • Data Dictionary • MVCC Control Data • Undo Space • Rollback Segments • Double Write Buffer (Pages Written in the Background to avoid OS caching) • Insert Buffer (Changes to Secondary Indexes) ◦ Example: innodb_data_file_path = /ibdata/ibdata1:10M:autoextend innodb_data_file_path = /ibdata/ibdata1:988M;/disk2/ibdata2:50M:autoextend 11
  • 12. MySQL Architecture  Innodb redo log file : ib_logfile ◦ It will read across ib_logfile0 and ib_logfile1 to check for any data changes that were not posted to the double write buffer in ibdata1. It will replay (redo) those changes. Once they are replayed and stored, mysqld becomes ready for new DB Connections. ◦ Example :Innodb_log_file_in_group=3 Innodb_log_file_size=150M  Innodb buffer pool file : ib_buffer_pool ◦ At the time of mysqld startup to reduce the warmup period after restarting the server, it loads few percent of most recently used pages for each buffer pool at server shutdown and this data i.e. tablespace ID and page ID data information is derived from the INNODB_BUFFER_PAGE_LRU INFORMATION_SCHEMA table. Tablespace ID and page ID data is saved in a file named ib_buffer_pool under InnoDB data directory. ◦ The file name and location can be modified using the innodb_buffer_pool_filename configuration parameter. 12
  • 13. MySQL Architecture  Transactional logs: Binary logs ◦ Variable name : --log-bin ◦ Enable binary logging. The server logs all statements that change data to the binary log, which is used for backup and replication. ◦ Using mysqlbinlog client tool we can extract and view binlog contents in text format. 13
  • 14. Storage Engines NDB: • Fully Transactional and ACID Storage engine. • Distribution execution of data and using multiple mysqld. • NDB use logical data with own buffer for each NDB engine. • Offers REDO and UNDO for transactions. • Row level locking. 14
  • 15. Storage Engines MyISAM: • Non transactional storage engine • Speed for read • Data storage in files and use key ,metadata and query cache  .FRM for table structure  .MYI for table index  .MYD for table data • Table level locking. 15
  • 16. Storage Engines Memory: • Non transactional storage engine • All data store in memory other then table metadata and structure. • Table level locking. 16
  • 17. Storage Engines Archive: • Non transactional storage engine, • Store large amounts of compressed and unindexed data. • Allow INSERT, REPLACE, and SELECT, but not DELETE or UPDATE sql operations. • Table level locking. 17
  • 18. Storage Engines CSV: • Stores data in flat files using comma-separated values format. • Table structure needs be create within MySQL server (.frm) 18
  • 19. MySQL Production ready configuration  Hardware • Storage and file types : SSD/HDD and EXT4 or XFS on Linux • Memory : Optimal performance, Large transaction ,indexes, faster response time for ongoing changes and utilize Disk IO • CPU : Faster processors with many cores provide better throughput  MySQL configuration ◦ innodb_file_per_table ◦ innodb_buffer_pool_size ◦ innodb_buffer_pool_instances ◦ innodb_log_file_size ◦ innodb_data_file_path ◦ Innodb_log_file_in_group ◦ innodb_flush_log_at_trx_commit ◦ innodb_thread_concurrency ◦ innodb_flush_method 19
  • 20. MySQL Administration and Monitoring  MySQL administrative tools • Mysql : Login, database access/manipulation , • Mysqladmin : Administration purpose • Mysqldump / mysqlpump : Logical backup utility • Mysqlbinlog : Utility for processing binary log files and display binlog contents in text format. • Mysql enterprise backup : Provides enterprise-grade backup and recovery for MySQL. • Percona xtrabackup : Open source tool for mysql binary backup. Ref: http://dev.mysql.com/doc/refman/5.7/en/programs-overview.html  GUI tools • MySQL enterprise monitor • MySQL workbench/ SQLyog etc. 20
  • 21. MySQL Administration and Monitoring  Monitoring • MySQL enterprise monitor : MySQL Enterprise Monitor provides real-time visibility into the performance and availability of all your MySQL databases. • Metadata and : From Information schema and mysql database. • DB statistic: performance_schema databases we can get ongoing as well as historical database activities. • SHOW PROCESSLIST • Mysql utilities • Audit logs & General logs, slow query logs • Third-party tools : Percona tool kit , Nagios , cacti etc 21
  • 22. MySQL Replication Master Slave ● server_id ● log_bin ● binlog_format ● binlog-do-db ● binlog-ignore-db ● GTID (optional) • server_id • log_bin • binlog_format • log_slave_updates • relay_log=file_name • replicate-do-db=db_name • replicate-ignore-db=db_name ON MASTER: Created replication user and grant privileges: mysql> CREATE USER 'repl'@'%.mydomain.com' IDENTIFIED BY 'slavepass'; mysql> GRANT REPLICATION SLAVE ON *.* TO 'repl'@'%.mydomain.com'; Mysql> SHOW MASTER STATUS; ON SLAVE: mysql> CHANGE MASTER TO MASTER_HOST='master_host_name',MASTER_USER='replication_user_name', MASTER_PASSWORD='replication_password',MASTER_LOG_FILE=‘master_log_file_name', MASTER_LOG_POS=master_log_position; 22
  • 24. MySQL Replication  Best practices − Use GTID enabled replication ◦ log_bin ◦ log-slave-update ◦ expire_log_days ◦ gtid_mode ◦ Enforce-gtid-consistency − Crash-safe slaves ◦ master-info-repository=TABLE ◦ Relay-log-info-repository=TABLE ◦ Relay-log-recovery − Secure slave ◦ read-only ◦ Skip-slave-start − Avoid replication Lag ◦ slave_compressed_protocol ◦ MTR replication 24
  • 25. MySQL Replication  Without GTID ◦ Need Master_Log_File and Master_Log_Pos  GTID − What problems GTID solves? ◦ It is possible to identify a transaction uniquely across the replication servers. Make the automation of failover process much easier. There is no need to do calculations, inspect the binary log and so on. Just MASTER_AUTO_POSITION=1. − Enable GTID replication ◦ gtid_mode: It can be ON or OFF (not 1 or 0). It enables the GTID on the server. ◦ log_bin: Enable binary logs. Mandatory to create a replication environment. ◦ log-slave-updates: Slave servers must log the changes that comes from the master in its own binary log. ◦ Enforce-gtid-consistency : Statements that can’t be logged in a transactionally safe manner are denied by the server. 25
  • 26. Backup and Restore  Backup Binary Backup − MySQL Enterprise Backup Logical Backup − mysqldump / mysqlpump eg. mysqldump [options] > dump.sql Hot Backup − Replication slave Customized scripts 26
  • 27. Backup and Restore  Restore Logical backup restore using mysql client eg. mysql [options] < dump.sql Binary backup restore : Replace old binaries or package and run mysql_upgrade script. 27
  • 28. MySQL Upgrade and Downgrade MySQL Upgrade Supported upgrade methods include: In-Place Upgrade: Involves shutting down the old MySQL version, replacing the old MySQL binaries or packages with the new ones, restarting MySQL on the existing data directory, and running mysql_upgrade. Logical Upgrade: Involves exporting existing data from the old MySQL version using mysqldump, installing the new MySQL version, loading the dump file into the new MySQL version, and running mysql_upgrade. MySQL Downgrade Supported downgrade methods include: In-Place Downgrade: Involves shutting down the new MySQL version, replacing the new MySQL binaries or packages with the old ones, and restarting the old MySQL version on the existing data directory. In-place downgrades are supported for downgrades between GA versions within the same release series. For example, in-place downgrades are supported for downgrades from 5.7.10 to 5.7.9. Logical Downgrade: Involves using mysqldump to dump all tables from the new MySQL version, and then loading the dump file into the old MySQL version. Logical downgrades are supported for downgrades between GA versions within the same release series and for downgrades between release levels. For example, logical downgrades are supported for downgrades from 5.7.10 to 5.7.9 and for downgrades from 5.7 to 5.6. 28
  • 29. Additional Resources MySQL Tutorial: http://dev.mysql.com/doc/refman/5.7/en/tutorial.html MySQL Administration: http://dev.mysql.com/doc/refman/5.7/en/server-administration.html Blogs: https://planet.mysql.com/ 29

Editor's Notes

  • #2: Tip: simple SEO adjustments can make your presentation more discoverable. Read this PDF for best practices:  http://seo.ges.symantec.com/seo-best-practices-for-file-optimization.pdf