SlideShare a Scribd company logo
The Proper Care and Feeding
of MySQL Databases
For Busy Linux Admins
Dave Stokes
MySQL Community Manager
Started programming with
FORTRAN on Punch Cards
Forced to UNIX/BSD/Linux
Please buy my book
2
MySQL
MySQL is 23 years old
Old timers prefer β€˜My - ess - queue - ell’
Own by Oracle for eight years
MySQL 8 is current Generally Available Release --
talk at 10:30 in Room A
3
Databases are ...
Selfish
Want entire system to self
Messy
Suck up memory, disk space, bandwidth, sanity
Growing all the time
Suck up a good part of your life!
4
Databases are the toddlers of software!!
5
Disclaimer
And it is also the view of most admins
(and developers) who also have DBA
duties added to all their other regular
tasks to help fill all their lavish spare
timeThe last slide was my opinion
6
So What Makes a Happy MySQL Database?
● Hardware
● Software
● Backups & Replication
● Tools to make life easier
● Configuration suggestions
● Q&A
7
Hardware
8
Hardware Happiness
Databases LOVE memory
● Spend money on good memory
● Lots of it
● Second comes cores
β—‹ Databases now also love cores, but not as much as memory
9
Why memory?
Reading from memory is 100,000 faster than reading from disk
● 100k miles is four times around the earth
● 100,000 days is 273.9726 years
● 100,000 seconds is 27.7777 hours
So 100,000 is a lot!
10
Disks or disk like things
● Move data to separate controller/disk, especially from logs
● Do not log on slow devices
● RAID to your favorite level (RAID 10 minimum) or go to the cloud
β—‹ Going to the cloud moves some of the labor onto someone else (maybe)
● Do not use consumer grade disks
β—‹ Use disks designed for 7/24/365 operation, not by price point
● CACHES - disk and controller
β—‹ Write through or write back caches
β–  Both lie
β–  Make sure they do not auto tune during production hours
● Faster devices are on their way!!
11
Network
● Never expose your instances to the outside world
● SCRUB rigorously all user data
● Keep separate net for replication, and/or backups
12
Understand MySQL Authentication Process
1. Is the host allowed to talk to the MySQL server
a. Is the ip address or domain whitelisted in the mysql.user table
2. Is the user allowed to talk to the MySQL server
a. In the mysql.user table?
b. Not restricted by some other constraint?
3. Password or User Authentication string valid?
Designed to be overly enthusiastic - first match gets in
● Caution: boss@192.168.1.10 may not equal boss@home
● Set configuration to not do DNS lookup incase DNS gets overloaded
β—‹ Zone updates can make your server crawl
13
Replication Servers
MySQL async or semi-sync replication needs to have bigger, badder hardware slave
servers than masters
Do more work
Use the MySQL Utilities to clone servers, set up replication
Use a dedicated network to avoid network contentions
14
MySQL Group Replication
MySQL Group Replication provides distributed
state machine replication with strong coordination
between servers.
Servers coordinate themselves automatically when
they are part of the same group.
The group can operate in a single-primary mode
with automatic primary election, where only one
server accepts updates at a time.
Alternatively, for more advanced users the group
can be deployed in multi-primary mode, where all
servers can accept updates, even if they are issued
concurrently.
15
Software
Run the latest, greatest version of MySQL that you can
● Performance
● Bug fixes
● Features
● Security
Keep MySQL by itself
● Databases do not play well with others
● Contention for resources
● Swapping
● Maybe use a caching layer but watch memory user 16
Database Deltas
BTW your corporate legal will
probably ask you this question in the
future
17
What do you do if you have to
restore data from an old dataset
with a schema that is no longer
around?
Proxies
18
MySQL Router is part of InnoDB
cluster, and is lightweight middleware
that provides transparent routing
between your application and
back-end MySQL Servers. It can be
used for a wide variety of use cases,
such as providing high availability
and scalability by effectively routing
database traffic to appropriate
back-end MySQL Servers.
Containers
docker pull mysql/mysql-server:tag
The tag is the label for the image version you want to pull (for example, 5.5, 5.6, 5.7, 8.0, or latest). If :tag
is omitted, the latest label is used, and the image for the latest GA version of MySQL Community Server is
downloaded
19
Backups and Replication
20
Thou shalt make backups
Make sure you backup your data so frequently it verges on being painful and then look
for ways to increase that!
Know how to restore entire instances, entire databases, or a table. Save views,
functions, stored procedures, and etc. And others on your staff need to be able to do
this too (cross training)!
Keep backups off site and test randomly
Nobody has ever been fired for doing too many backups!
-- Paranoia should be your friend
21
Replication
22
MySQL Replications is easy to set up
Three types:
1. Async - slave grabs copy of changes from master and applies those changes to own
set of data, master unaware of what slave is doing
2. Semi-sync - master waits for acknowledgement from at least one slave before
proceeding
a. Both async and sync have three forms -- Statement, Row, and mixed
b. Single threaded before 5.6, multi threaded for different databases in 5.6, and multi threaded within
a database with 5.7
3. Group replication
23
Async/Semi Sync Replication Filters
● You do not need to replicate everything
β—‹ Check churn of data, maybe 1x day backup (plus make sure to save binary logs)
● Filter tables
● You can change tables on the fly starting with MySQL 5.7
β—‹ β€œSomething is going on in manufacturing, can we get ALL of their data copied someplaces?”
24
Global Transactions IDs
● Introduced in MySQL 5.6
● Each transaction has a unique GTID
β—‹ Easy for slaves to get caught up to master
β—‹ No longer have to look at file offsets on master and slave to get start position
β–  Saves time, $, and sanity. Easy to automate
● Storing replication data in InnoDB tables plus checksums make it crash safe
● Row based replication can exploit only sending key and changed items, not entire
row
25
Replication for Backup
● Async/semi uses three threads on slave server
β—‹ Feed data from master
β—‹ To Log
β—‹ Log to data
● Shot down log to data thread, run backup, then restart log to data
β—‹ Data from master will be stored but not applied during backup
26
In an Oracle Database Shop??
If you also have a big Oracle DB shop:
● You can backup to big Oracle STB backup devices
● MySQL works with Oracle Audit Vault, Database Firewall, and Key Manager
β—‹ Need to have a support contract for these three
27
Tools to make life easier
28
There are lots of tools for DBA chores
● Monitoring
β—‹ Yes, you need to monitor
● Administration
β—‹ Command line versus GUI
β—‹ Document instances
β—‹ Backups
29
Monitoring
● Active
β—‹ Watched instances and sends alerts
β–  MySQL Enterprise (support customers)
β–  Percona Monitor
β–  Nagios, Cacti, etc.
β–  Your favorite (not mentioned)
β–  Helps to be able to comb historical data
● Semi-active
β—‹ MySQL Workbench
β–  Dashboard and SYS Schema
β—‹ PHPMyAdmin
β—‹ Your favorite (still not mentioned)
30
MySQL Workbench
● Query tool
β—‹ Visual explain to help in optimization
● Admin tool
β—‹ User setup, backups, imports, change settings
β—‹ No more fat finger β€˜UPDATE user SET SELECT_PRIV=’Y’, UPDATE_PRIV=’Y’,...
● Dashboard
β—‹ SYS Schema
● Entity Relationship Matter
● Migration tool
● More
● Free!
31
And more
● Percona toolkit
● Toad for MySQL from Dell
● Your Favorite Tool (again not mentioned)
32
Config settings
33
These are suggestions!!!
● Turn off DNS lookups
β—‹ Use skip-name-resolve
● Save/Load statistics
β—‹ Use innodb_stats_persistent
β—‹ innodb_buffer_pool_dump=ON
β—‹ innodb_buffer_pool_dump_at_shutdown=ON
β—‹ innodb_buffer_pool_load_at_startup=ON
β–  See Config Persistent Optimizer Statistics Parameters in the MySQL Manual
34
Suggestions continued
● Use SET PERSIST (MySQL 8)
35
Suggestions continued
● Tune log level (MySQL 5.7+)
β—‹ Log_error_verbostiy - errors, errors & warnings, E&W + notes
β—‹ Send to syslog
● Turn off query cache (5.7 default, 8.0 deprecated)
β—‹ Single threaded
β—‹ Free up memory
● Set innodb_buffer_pool_size = 75-80% physical ram
36
Big Hints!
37
Big Hint #1
BE DAMN STINGY with permissions and grants!!
● Easier to say β€˜no’ than constantly be restoring
● Use --safe-updates or --I-am-a-dummy in ~/.my.cnf
β—‹ No more β€˜opps, I forgot the where clause’
38
BIG Hint #2
Please use SYS Schema
View, functions, and stored procedures on top of performance schema and
information schema
● Who is hogging resources
● Indexes not being users
● Problematic queries
● Other routine PITAs
39
Big Hint #3
Security
● Secure by default install (5.7+)
β—‹ Forced root password
β—‹ No more anonymous accounts, no test db
● Password rotation
● Password rules
β—‹ Length, characters
40
Big Hint #4
Take Advantage of the new MySQL shell
mysql-js> util.checkForServerUpgrade("root@localhost:3306");
1) Usage of db objects with names conflicting with reserved keywords in 8.0
2) Usage of utf8mb3 charset
Warning: The following objects use the utf8mb3 character set. It is recommended to convert them to use utf8mb4 instead, for improved
Unicode support.
simple_schema.city.name - column's default character set: utf8
3) Usage of use ZEROFILL/display length type attributes
Notice: The following table columns specify a ZEROFILL/display length attributes. Please be aware that they will be ignored in MySQL 8.0
test.big_table.ORDINAL_POSITION - bigint(21) unsigned
4) Issues reported by 'check table x for upgrade' command
No issues found
5) Table names in the mysql schema conflicting with new tables in 8.0
No issues found
6) Usage of old temporal type
No issues found
7) Foreign key constraint names longer than 64 characters
No issues found
No fatal errors were found that would prevent a MySQL 8 upgrade, but some potential issues were detected. Please ensure that the
reported issues are not significant before upgrading.
41
Websites of note
Forums.mysql.com
Planet.mysql.com
dev.mysql.com
42
Q/A
@stoker
slideshare.net/davidmstokes
david.stokes@oracle.com
43

More Related Content

PDF
MySQL Performance Tuning Variables
PPTX
MySQL DBA
PDF
MySQL Backup and Security Best Practices
PDF
NoSQL with MySQL
PDF
"Advanced MySQL 5 Tuning" by Michael Monty Widenius @ eLiberatica 2007
PDF
Linuxfest Northwest Proper Care and Feeding Of a MySQL for Busy Linux Admins
PDF
Discard inport exchange table & tablespace
PDF
PERFORMANCE_SCHEMA and sys schema
MySQL Performance Tuning Variables
MySQL DBA
MySQL Backup and Security Best Practices
NoSQL with MySQL
"Advanced MySQL 5 Tuning" by Michael Monty Widenius @ eLiberatica 2007
Linuxfest Northwest Proper Care and Feeding Of a MySQL for Busy Linux Admins
Discard inport exchange table & tablespace
PERFORMANCE_SCHEMA and sys schema

What's hot (20)

PDF
MySQL overview
PDF
MySQL cluster 72 in the Cloud
PDF
MySQL Server Backup, Restoration, and Disaster Recovery Planning
PDF
Oracle to MySQL 2012
PDF
InnoDB Performance Optimisation
KEY
Perf Tuning Short
PDF
Proper Care and Feeding of a MySQL Database for Busy Linux Administrators
PPTX
Consistency between Engine and Binlog under Reduced Durability
PDF
My First 100 days with an Exadata (WP)
PDF
Highly efficient backups with percona xtrabackup
PDF
Percona Xtrabackup - Highly Efficient Backups
PDF
Introduction Mysql
PDF
The Proper Care and Feeding of a MySQL Database for Busy Linux Admins -- SCaL...
PPTX
MySQL database
PDF
MySQL for Large Scale Social Games
PDF
InnoDB Cluster Experience (MySQL User Camp)
PDF
MySQL Advanced Administrator 2021 - λ„€μ˜€ν΄λ‘œλ°”
PDF
MySQL Backup & Recovery
PDF
MySQL For Oracle Developers
PDF
MySQL 5.5&5.6 new features summary
MySQL overview
MySQL cluster 72 in the Cloud
MySQL Server Backup, Restoration, and Disaster Recovery Planning
Oracle to MySQL 2012
InnoDB Performance Optimisation
Perf Tuning Short
Proper Care and Feeding of a MySQL Database for Busy Linux Administrators
Consistency between Engine and Binlog under Reduced Durability
My First 100 days with an Exadata (WP)
Highly efficient backups with percona xtrabackup
Percona Xtrabackup - Highly Efficient Backups
Introduction Mysql
The Proper Care and Feeding of a MySQL Database for Busy Linux Admins -- SCaL...
MySQL database
MySQL for Large Scale Social Games
InnoDB Cluster Experience (MySQL User Camp)
MySQL Advanced Administrator 2021 - λ„€μ˜€ν΄λ‘œλ°”
MySQL Backup & Recovery
MySQL For Oracle Developers
MySQL 5.5&5.6 new features summary
Ad

Similar to The Proper Care and Feeding of MySQL Databases (20)

PDF
The Peoper Care and Feeding of a MySQL Server for Busy Linux Admin
PDF
PhpTek Ten Things to do to make your MySQL servers Happier and Healthier
ODP
The care and feeding of a MySQL database
PDF
Congratsyourthedbatoo
PDF
Tx lf propercareandfeedmysql
PDF
My sql susecon_crashcourse_2012
PPTX
7 Database Mistakes YOU Are Making -- Linuxfest Northwest 2019
PDF
MySQL for Oracle DBA -- Rocky Mountain Oracle User Group Training Days '15
PPTX
MySQL Tech Tour 2015 - Manage & Tune
ODP
MySQL Scaling Presentation
PDF
MySQL Technology Overview
PDF
MySQL Day Paris 2016 - State Of The Dolphin
PDF
Scaling MySQL -- Swanseacon.co.uk
PPTX
MySQL 8 -- A new beginning : Sunshine PHP/PHP UK (updated)
PDF
My First 100 days with a MySQL DBMS
PDF
Running MySQL on Linux
PPT
My sql basic
PDF
MySQL overview
PDF
PHP Detroit -- MySQL 8 A New Beginning (updated presentation)
PPTX
MySQL 8.0 Featured for Developers
The Peoper Care and Feeding of a MySQL Server for Busy Linux Admin
PhpTek Ten Things to do to make your MySQL servers Happier and Healthier
The care and feeding of a MySQL database
Congratsyourthedbatoo
Tx lf propercareandfeedmysql
My sql susecon_crashcourse_2012
7 Database Mistakes YOU Are Making -- Linuxfest Northwest 2019
MySQL for Oracle DBA -- Rocky Mountain Oracle User Group Training Days '15
MySQL Tech Tour 2015 - Manage & Tune
MySQL Scaling Presentation
MySQL Technology Overview
MySQL Day Paris 2016 - State Of The Dolphin
Scaling MySQL -- Swanseacon.co.uk
MySQL 8 -- A new beginning : Sunshine PHP/PHP UK (updated)
My First 100 days with a MySQL DBMS
Running MySQL on Linux
My sql basic
MySQL overview
PHP Detroit -- MySQL 8 A New Beginning (updated presentation)
MySQL 8.0 Featured for Developers
Ad

More from Dave Stokes (20)

PDF
Valkey 101 - SCaLE 22x March 2025 Stokes.pdf
PPTX
Locking Down Your MySQL Database.pptx
PPTX
Linuxfest Northwest 2022 - MySQL 8.0 Nre Features
PDF
MySQL Indexes and Histograms - RMOUG Training Days 2022
PDF
MySQL 8.0 Features -- Oracle CodeOne 2019, All Things Open 2019
PDF
Windowing Functions - Little Rock Tech fest 2019
PDF
MySQL Baics - Texas Linxufest beginners tutorial May 31st, 2019
PPTX
Develop PHP Applications with MySQL X DevAPI
PDF
MySQL 8 Tips and Tricks from Symfony USA 2018, San Francisco
PDF
MySQL without the SQL -- Cascadia PHP
PDF
MySQL 8 Server Optimization Swanseacon 2018
PDF
MySQL Without The SQL -- Oh My! PHP[Tek] June 2018
PDF
Presentation Skills for Open Source Folks
PPTX
MySQL Without the SQL -- Oh My! Longhorn PHP Conference
PPTX
ConFoo MySQL Replication Evolution : From Simple to Group Replication
PDF
Advanced MySQL Query Optimizations
PPTX
Making MySQL Agile-ish
PPTX
PHP Database Programming Basics -- Northeast PHP
ODP
MySQL 101 PHPTek 2017
PPTX
MySQL Replication Evolution -- Confoo Montreal 2017
Valkey 101 - SCaLE 22x March 2025 Stokes.pdf
Locking Down Your MySQL Database.pptx
Linuxfest Northwest 2022 - MySQL 8.0 Nre Features
MySQL Indexes and Histograms - RMOUG Training Days 2022
MySQL 8.0 Features -- Oracle CodeOne 2019, All Things Open 2019
Windowing Functions - Little Rock Tech fest 2019
MySQL Baics - Texas Linxufest beginners tutorial May 31st, 2019
Develop PHP Applications with MySQL X DevAPI
MySQL 8 Tips and Tricks from Symfony USA 2018, San Francisco
MySQL without the SQL -- Cascadia PHP
MySQL 8 Server Optimization Swanseacon 2018
MySQL Without The SQL -- Oh My! PHP[Tek] June 2018
Presentation Skills for Open Source Folks
MySQL Without the SQL -- Oh My! Longhorn PHP Conference
ConFoo MySQL Replication Evolution : From Simple to Group Replication
Advanced MySQL Query Optimizations
Making MySQL Agile-ish
PHP Database Programming Basics -- Northeast PHP
MySQL 101 PHPTek 2017
MySQL Replication Evolution -- Confoo Montreal 2017

Recently uploaded (20)

PDF
Sims 4 Historia para lo sims 4 para jugar
PPTX
international classification of diseases ICD-10 review PPT.pptx
PDF
WebRTC in SignalWire - troubleshooting media negotiation
PDF
Testing WebRTC applications at scale.pdf
PDF
Best Practices for Testing and Debugging Shopify Third-Party API Integrations...
PPTX
Module 1 - Cyber Law and Ethics 101.pptx
PDF
πŸ’° π”πŠπ“πˆ πŠπ„πŒπ„ππ€ππ†π€π πŠπˆππ„π‘πŸ’πƒ π‡π€π‘πˆ 𝐈𝐍𝐈 πŸπŸŽπŸπŸ“ πŸ’°
Β 
PPTX
Internet___Basics___Styled_ presentation
PDF
Automated vs Manual WooCommerce to Shopify Migration_ Pros & Cons.pdf
PDF
Paper PDF World Game (s) Great Redesign.pdf
PPTX
Digital Literacy And Online Safety on internet
PPTX
Introduction to Information and Communication Technology
PDF
Triggering QUIC, presented by Geoff Huston at IETF 123
Β 
PPTX
innovation process that make everything different.pptx
PDF
Centralized Business Email Management_ How Admin Controls Boost Efficiency & ...
PDF
Tenda Login Guide: Access Your Router in 5 Easy Steps
PPTX
CSharp_Syntax_Basics.pptxxxxxxxxxxxxxxxxxxxxxxxxxxxx
PPTX
presentation_pfe-universite-molay-seltan.pptx
PPTX
INTERNET------BASICS-------UPDATED PPT PRESENTATION
PPTX
ppt for upby gurvinder singh padamload.pptx
Sims 4 Historia para lo sims 4 para jugar
international classification of diseases ICD-10 review PPT.pptx
WebRTC in SignalWire - troubleshooting media negotiation
Testing WebRTC applications at scale.pdf
Best Practices for Testing and Debugging Shopify Third-Party API Integrations...
Module 1 - Cyber Law and Ethics 101.pptx
πŸ’° π”πŠπ“πˆ πŠπ„πŒπ„ππ€ππ†π€π πŠπˆππ„π‘πŸ’πƒ π‡π€π‘πˆ 𝐈𝐍𝐈 πŸπŸŽπŸπŸ“ πŸ’°
Β 
Internet___Basics___Styled_ presentation
Automated vs Manual WooCommerce to Shopify Migration_ Pros & Cons.pdf
Paper PDF World Game (s) Great Redesign.pdf
Digital Literacy And Online Safety on internet
Introduction to Information and Communication Technology
Triggering QUIC, presented by Geoff Huston at IETF 123
Β 
innovation process that make everything different.pptx
Centralized Business Email Management_ How Admin Controls Boost Efficiency & ...
Tenda Login Guide: Access Your Router in 5 Easy Steps
CSharp_Syntax_Basics.pptxxxxxxxxxxxxxxxxxxxxxxxxxxxx
presentation_pfe-universite-molay-seltan.pptx
INTERNET------BASICS-------UPDATED PPT PRESENTATION
ppt for upby gurvinder singh padamload.pptx

The Proper Care and Feeding of MySQL Databases

  • 1. The Proper Care and Feeding of MySQL Databases For Busy Linux Admins
  • 2. Dave Stokes MySQL Community Manager Started programming with FORTRAN on Punch Cards Forced to UNIX/BSD/Linux Please buy my book 2
  • 3. MySQL MySQL is 23 years old Old timers prefer β€˜My - ess - queue - ell’ Own by Oracle for eight years MySQL 8 is current Generally Available Release -- talk at 10:30 in Room A 3
  • 4. Databases are ... Selfish Want entire system to self Messy Suck up memory, disk space, bandwidth, sanity Growing all the time Suck up a good part of your life! 4
  • 5. Databases are the toddlers of software!! 5
  • 6. Disclaimer And it is also the view of most admins (and developers) who also have DBA duties added to all their other regular tasks to help fill all their lavish spare timeThe last slide was my opinion 6
  • 7. So What Makes a Happy MySQL Database? ● Hardware ● Software ● Backups & Replication ● Tools to make life easier ● Configuration suggestions ● Q&A 7
  • 9. Hardware Happiness Databases LOVE memory ● Spend money on good memory ● Lots of it ● Second comes cores β—‹ Databases now also love cores, but not as much as memory 9
  • 10. Why memory? Reading from memory is 100,000 faster than reading from disk ● 100k miles is four times around the earth ● 100,000 days is 273.9726 years ● 100,000 seconds is 27.7777 hours So 100,000 is a lot! 10
  • 11. Disks or disk like things ● Move data to separate controller/disk, especially from logs ● Do not log on slow devices ● RAID to your favorite level (RAID 10 minimum) or go to the cloud β—‹ Going to the cloud moves some of the labor onto someone else (maybe) ● Do not use consumer grade disks β—‹ Use disks designed for 7/24/365 operation, not by price point ● CACHES - disk and controller β—‹ Write through or write back caches β–  Both lie β–  Make sure they do not auto tune during production hours ● Faster devices are on their way!! 11
  • 12. Network ● Never expose your instances to the outside world ● SCRUB rigorously all user data ● Keep separate net for replication, and/or backups 12
  • 13. Understand MySQL Authentication Process 1. Is the host allowed to talk to the MySQL server a. Is the ip address or domain whitelisted in the mysql.user table 2. Is the user allowed to talk to the MySQL server a. In the mysql.user table? b. Not restricted by some other constraint? 3. Password or User Authentication string valid? Designed to be overly enthusiastic - first match gets in ● Caution: [email protected] may not equal boss@home ● Set configuration to not do DNS lookup incase DNS gets overloaded β—‹ Zone updates can make your server crawl 13
  • 14. Replication Servers MySQL async or semi-sync replication needs to have bigger, badder hardware slave servers than masters Do more work Use the MySQL Utilities to clone servers, set up replication Use a dedicated network to avoid network contentions 14
  • 15. MySQL Group Replication MySQL Group Replication provides distributed state machine replication with strong coordination between servers. Servers coordinate themselves automatically when they are part of the same group. The group can operate in a single-primary mode with automatic primary election, where only one server accepts updates at a time. Alternatively, for more advanced users the group can be deployed in multi-primary mode, where all servers can accept updates, even if they are issued concurrently. 15
  • 16. Software Run the latest, greatest version of MySQL that you can ● Performance ● Bug fixes ● Features ● Security Keep MySQL by itself ● Databases do not play well with others ● Contention for resources ● Swapping ● Maybe use a caching layer but watch memory user 16
  • 17. Database Deltas BTW your corporate legal will probably ask you this question in the future 17 What do you do if you have to restore data from an old dataset with a schema that is no longer around?
  • 18. Proxies 18 MySQL Router is part of InnoDB cluster, and is lightweight middleware that provides transparent routing between your application and back-end MySQL Servers. It can be used for a wide variety of use cases, such as providing high availability and scalability by effectively routing database traffic to appropriate back-end MySQL Servers.
  • 19. Containers docker pull mysql/mysql-server:tag The tag is the label for the image version you want to pull (for example, 5.5, 5.6, 5.7, 8.0, or latest). If :tag is omitted, the latest label is used, and the image for the latest GA version of MySQL Community Server is downloaded 19
  • 21. Thou shalt make backups Make sure you backup your data so frequently it verges on being painful and then look for ways to increase that! Know how to restore entire instances, entire databases, or a table. Save views, functions, stored procedures, and etc. And others on your staff need to be able to do this too (cross training)! Keep backups off site and test randomly Nobody has ever been fired for doing too many backups! -- Paranoia should be your friend 21
  • 23. MySQL Replications is easy to set up Three types: 1. Async - slave grabs copy of changes from master and applies those changes to own set of data, master unaware of what slave is doing 2. Semi-sync - master waits for acknowledgement from at least one slave before proceeding a. Both async and sync have three forms -- Statement, Row, and mixed b. Single threaded before 5.6, multi threaded for different databases in 5.6, and multi threaded within a database with 5.7 3. Group replication 23
  • 24. Async/Semi Sync Replication Filters ● You do not need to replicate everything β—‹ Check churn of data, maybe 1x day backup (plus make sure to save binary logs) ● Filter tables ● You can change tables on the fly starting with MySQL 5.7 β—‹ β€œSomething is going on in manufacturing, can we get ALL of their data copied someplaces?” 24
  • 25. Global Transactions IDs ● Introduced in MySQL 5.6 ● Each transaction has a unique GTID β—‹ Easy for slaves to get caught up to master β—‹ No longer have to look at file offsets on master and slave to get start position β–  Saves time, $, and sanity. Easy to automate ● Storing replication data in InnoDB tables plus checksums make it crash safe ● Row based replication can exploit only sending key and changed items, not entire row 25
  • 26. Replication for Backup ● Async/semi uses three threads on slave server β—‹ Feed data from master β—‹ To Log β—‹ Log to data ● Shot down log to data thread, run backup, then restart log to data β—‹ Data from master will be stored but not applied during backup 26
  • 27. In an Oracle Database Shop?? If you also have a big Oracle DB shop: ● You can backup to big Oracle STB backup devices ● MySQL works with Oracle Audit Vault, Database Firewall, and Key Manager β—‹ Need to have a support contract for these three 27
  • 28. Tools to make life easier 28
  • 29. There are lots of tools for DBA chores ● Monitoring β—‹ Yes, you need to monitor ● Administration β—‹ Command line versus GUI β—‹ Document instances β—‹ Backups 29
  • 30. Monitoring ● Active β—‹ Watched instances and sends alerts β–  MySQL Enterprise (support customers) β–  Percona Monitor β–  Nagios, Cacti, etc. β–  Your favorite (not mentioned) β–  Helps to be able to comb historical data ● Semi-active β—‹ MySQL Workbench β–  Dashboard and SYS Schema β—‹ PHPMyAdmin β—‹ Your favorite (still not mentioned) 30
  • 31. MySQL Workbench ● Query tool β—‹ Visual explain to help in optimization ● Admin tool β—‹ User setup, backups, imports, change settings β—‹ No more fat finger β€˜UPDATE user SET SELECT_PRIV=’Y’, UPDATE_PRIV=’Y’,... ● Dashboard β—‹ SYS Schema ● Entity Relationship Matter ● Migration tool ● More ● Free! 31
  • 32. And more ● Percona toolkit ● Toad for MySQL from Dell ● Your Favorite Tool (again not mentioned) 32
  • 34. These are suggestions!!! ● Turn off DNS lookups β—‹ Use skip-name-resolve ● Save/Load statistics β—‹ Use innodb_stats_persistent β—‹ innodb_buffer_pool_dump=ON β—‹ innodb_buffer_pool_dump_at_shutdown=ON β—‹ innodb_buffer_pool_load_at_startup=ON β–  See Config Persistent Optimizer Statistics Parameters in the MySQL Manual 34
  • 35. Suggestions continued ● Use SET PERSIST (MySQL 8) 35
  • 36. Suggestions continued ● Tune log level (MySQL 5.7+) β—‹ Log_error_verbostiy - errors, errors & warnings, E&W + notes β—‹ Send to syslog ● Turn off query cache (5.7 default, 8.0 deprecated) β—‹ Single threaded β—‹ Free up memory ● Set innodb_buffer_pool_size = 75-80% physical ram 36
  • 38. Big Hint #1 BE DAMN STINGY with permissions and grants!! ● Easier to say β€˜no’ than constantly be restoring ● Use --safe-updates or --I-am-a-dummy in ~/.my.cnf β—‹ No more β€˜opps, I forgot the where clause’ 38
  • 39. BIG Hint #2 Please use SYS Schema View, functions, and stored procedures on top of performance schema and information schema ● Who is hogging resources ● Indexes not being users ● Problematic queries ● Other routine PITAs 39
  • 40. Big Hint #3 Security ● Secure by default install (5.7+) β—‹ Forced root password β—‹ No more anonymous accounts, no test db ● Password rotation ● Password rules β—‹ Length, characters 40
  • 41. Big Hint #4 Take Advantage of the new MySQL shell mysql-js> util.checkForServerUpgrade("root@localhost:3306"); 1) Usage of db objects with names conflicting with reserved keywords in 8.0 2) Usage of utf8mb3 charset Warning: The following objects use the utf8mb3 character set. It is recommended to convert them to use utf8mb4 instead, for improved Unicode support. simple_schema.city.name - column's default character set: utf8 3) Usage of use ZEROFILL/display length type attributes Notice: The following table columns specify a ZEROFILL/display length attributes. Please be aware that they will be ignored in MySQL 8.0 test.big_table.ORDINAL_POSITION - bigint(21) unsigned 4) Issues reported by 'check table x for upgrade' command No issues found 5) Table names in the mysql schema conflicting with new tables in 8.0 No issues found 6) Usage of old temporal type No issues found 7) Foreign key constraint names longer than 64 characters No issues found No fatal errors were found that would prevent a MySQL 8 upgrade, but some potential issues were detected. Please ensure that the reported issues are not significant before upgrading. 41