41
THE PROPER CARE AND FEEDING OF A MYSQL SERVER FOR BUSY LINUX ADMINS DAVE STOKES MYSQL COMMUNITY MANAGER, ORACLE

The Peoper Care and Feeding of a MySQL Server for Busy Linux Admin

Embed Size (px)

Citation preview

Page 1: The Peoper Care and Feeding of a MySQL Server for Busy Linux Admin

THE PROPER CARE AND FEEDING OF A MYSQL SERVER FOR BUSY LINUX ADMINS

DAVE STOKES MYSQL COMMUNITY MANAGER, ORACLE

Page 2: The Peoper Care and Feeding of a MySQL Server for Busy Linux Admin

ORACLE SAFE HARBOR AGREEMENT

» The following is intended to outline Oracle’s general

product direction. It is intended for information purposes

only, and may not be incorporated into any contract. It is

not a commitment to deliver any material, code, or

functionality, and should not be relied upon in making

purchasing decision. The development, release, and

timing of any features or functionality described for

Oracle’s products remains at the sole discretion of

Oracle.

Page 3: The Peoper Care and Feeding of a MySQL Server for Busy Linux Admin

SO TAKE ANYTHING ON FUTURE

PRODUCTS WITH A GRAIN OF

Page 4: The Peoper Care and Feeding of a MySQL Server for Busy Linux Admin

HAPPY BIRTHDAY TO MYSQL

Page 5: The Peoper Care and Feeding of a MySQL Server for Busy Linux Admin

DAVE STOKES

• Former MySQL Certification Manager

• System Admin/Systems Programmer

• TOPS-10, Vax/VMS, UNIX → Linux

• Worked for companies ranging alphabetically from the American

Heart Association to Xerox

• Email: [email protected]

• Twiter: @Stoker

• Slides: slideshare.net/davidmstokes

M Y S Q L C O M M U N I T Y M AN A G E R @ O R AC L E

Page 6: The Peoper Care and Feeding of a MySQL Server for Busy Linux Admin

YOU, YES, YOU!

» Linux Admin

» Many responsibilities

» Many systems

Real, Virtual, Containers, …

» Also have DBA duties

» But no DBA training

Page 7: The Peoper Care and Feeding of a MySQL Server for Busy Linux Admin

DATABASES ARE…

» Selfish • Want entire system to self

» Messy • Suck up memory, disk space, bandwidth, sanity

» Growing all the time • Needs updates

» Suck up a good part of your life

Page 8: The Peoper Care and Feeding of a MySQL Server for Busy Linux Admin

DATABASES ARE

NASTY TODDLERS!!

Page 9: The Peoper Care and Feeding of a MySQL Server for Busy Linux Admin

THE PREVIOUS OPINIONS ARE

● The views of most admins (and developers) who also

have DBA duties added to all their other regular tasks to

help fill all their lavish spare time*

Page 10: The Peoper Care and Feeding of a MySQL Server for Busy Linux Admin

HAPPY MYSQL DATABASES

● Hardware

● Software

● Backups & Replication

● Tools to make life easier

● Configuration suggestions

● Q&A

Page 11: The Peoper Care and Feeding of a MySQL Server for Busy Linux Admin

HARDWARE HAPPINESS

● Databases LOVE memory

● Spend money on good memory

● Lots of it

● More important than cores

Page 12: The Peoper Care and Feeding of a MySQL Server for Busy Linux Admin

WHY MEMORY?

● Reading from memory is 100,000 faster than reading

from disk

● 100K miles is four times plus around the world

● At one situp a second, it would take 27.78 hours to do

100K

Page 13: The Peoper Care and Feeding of a MySQL Server for Busy Linux Admin

DISKS OR DISK LIKE THINGS

● Move data to separate controller/disk from logs

● Do not log on slow devices

● RAID to your favorite level – RAID 10 Minimum

● DO NOT USE Consumer Grade Disks

● Use disks that are designed for 7/24/365 operation not a price point

● CACHES – disk and controller

● Write through or write back caches

● Both lie

● Make sure they don't auto tune during production hours

● FusionIO cards

● Atomic writes = No Double buffering, therefore SPEED!!

Page 14: The Peoper Care and Feeding of a MySQL Server for Busy Linux Admin

NETWORK

● Never expose your instances to outside world

● SCRUB rigorously all user data

● Keep separate net for replication and/or backup

● MySQL authentications uses host, user & password • Boss@Home May not equal Boss@Work

• Overly enthusiastic, first match in table gets in!!!

• Configure server to use IP addresses instead of names

● Bad DNS zone transfers should not bring down database access

Page 15: The Peoper Care and Feeding of a MySQL Server for Busy Linux Admin

SLAVE SERVERS

● Slaves need to have bigger/badder hardware than

master

● Do more work

● Use MySQL Utilities to clone masters, set up slaves

● Dedicated network to avoid network contention

Page 16: The Peoper Care and Feeding of a MySQL Server for Busy Linux Admin

SOFTWARE

● Run the latest greatest version of MySQL you can

● Performance

● Bug fixes

● Features

● Keep MySQL by itself

● Databases do not play well with other services

● Contention for resources

● Swapping

● Maybe a caching layer but watch memory use!!

Page 17: The Peoper Care and Feeding of a MySQL Server for Busy Linux Admin

BACKUPS & REPLICATION

● 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, etc. And others on staff

need to be able to do this too (cross train)

● Keep off site backups off site and test randomly

● Make sure multiple people can get to off site

backups

● Nobody ever got fired for doing too many backups –

Paranoia should be your friend!!!!

Page 18: The Peoper Care and Feeding of a MySQL Server for Busy Linux Admin

REPLICATION

● MySQL replication is easy to set up and misunderstand

● Two types of replications

● Async – slave grabs copy of changes from master and applies

them to own set of data, master unaware of what slave is doing

● Semi-sync – master waits for acknowledgment from at least

one slave before proceeding

● Three forms – Statement, Row, and Mixed

● Single threaded before 5.6, multi threaded for different

databases in 5.6, multi infra databases threaded for 5.7

Page 19: The Peoper Care and Feeding of a MySQL Server for Busy Linux Admin

REPLICATION FILTERS

● Do not need to replicate everything

● Check churn of data, maybe 1x day backup

● Filter tables

● Can change filters on the fly with 5.7

● “Something going on in manufacturing, can we get ALL of their

data copied someplace?'

Page 20: The Peoper Care and Feeding of a MySQL Server for Busy Linux Admin

GLOBAL TRANSACTION IDS

● Each transaction has unique GTID starting 5.6

● 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 $ and sanity

● Storing replication data in InnoDB tables plus adding

check sums make crash safe

● Row based can exploit only sending key and changed

items, not entire row of data

Page 21: The Peoper Care and Feeding of a MySQL Server for Busy Linux Admin

MULTIMASTER AND MULTISOURCE

● Multimaster

● Not recommended but many do it

● System A auto_increment odd numbers and System B

auto_increment even numbers

● Needs to be watched

● Multi source – MySQL 5.7

● Multiple masters send data to one slave for master backup

● Make sure sharded data does not overlap

Page 22: The Peoper Care and Feeding of a MySQL Server for Busy Linux Admin

GROUP REPLICATION MYSQL 5.7

Page 23: The Peoper Care and Feeding of a MySQL Server for Busy Linux Admin

ORACLE DATABASE SHOPS!

IF you also have a big Oracle DB shop:

● You can backup to the big Oracle STB backup devices

● Great if you are in an Oracle shop

● MySQL can use oracle Database Firewall & Audit Vault

● Enterprise Customers

● Audit Vault, Database Firewall, and more

Page 24: The Peoper Care and Feeding of a MySQL Server for Busy Linux Admin

REPLICATION FOR BACKUP

● Replication uses three threads

● Master to slave

● Slave to log

● Log to data

● Shut down log to data thread, run backup, then restart

log to data

● Data from master still stored but not written during backup

but applied when backup is done

Page 25: The Peoper Care and Feeding of a MySQL Server for Busy Linux Admin

REPLICATION FOR BACKUP

Turn off SQL thread on Slave for backups for a point in time snapshot of your data

Page 26: The Peoper Care and Feeding of a MySQL Server for Busy Linux Admin

TOOLS TO MAKE LIFE EASIER

● There are lots of tools to make life easier for DBA chores

● Monitoring

● Yes, you need to monitor

● Administration

● Yes, you can type everything by hand on the command

line but don't you have better things to do!?

● Documentation of instances

● Backup

Page 27: The Peoper Care and Feeding of a MySQL Server for Busy Linux Admin

MONITORING

● Active

● Watches instances and send alerts

● MySQL Enterprise Monitor (supported customers, free trial)

● SolarWinds Database Performance Manager (free trial)

● Nagios, cacti, etc.

● Percona has plugins

● Vivid Cortex

● Helps to be able to comb historical data

● Semi-active

● MySQL Workbench

● Dashboard & SYS Schema

● PhpMyAdmin

● Your favorite tool that is not mentioned

Page 28: The Peoper Care and Feeding of a MySQL Server for Busy Linux Admin

YOU CAN'T SEE THE FULL SIZE OF A

PROBLEM AT FIRST GLANCE!!

Page 29: The Peoper Care and Feeding of a MySQL Server for Busy Linux Admin

MYSQL WORKBENCH

● Query tool

● Visual Explain to aid in optimization

● Admin tool

● Users, backup, imports, change settings

● No more fat finger 'UPDATE user set 'SELECT_PRIV='Y',....

● Dashboard and System Monitoring

● Sys Schema

● Entity Relationship Mapper

● Great tool for investigating new schemas

● Print schema for documentation

● Migration tool

● And more!

Page 30: The Peoper Care and Feeding of a MySQL Server for Busy Linux Admin

MYSQL UTILITIES

● Written in Python, easy to extend

● Setup replication and automatic fail over

● Copy user settings

● Copy data

● Look for bad processed and kill 'em

● Move binary logs

● Grep for a column name in a schema

● And much more

Page 31: The Peoper Care and Feeding of a MySQL Server for Busy Linux Admin

AND MORE

● Percona tool kit

● Toad for MySQL from Dell

● Your favorite tool that is not mentioned

Page 32: The Peoper Care and Feeding of a MySQL Server for Busy Linux Admin

CONFIG SUGGESTIONS

● Turn off DNS lookups – zone transfer dies

● Use skip-name-resolve

● Save/Load statistics

● Use innodb_stats_persistent

● See 14.13.16.1 Configuring Persistent Optimizer Statistics

Parameters in the MySQL Manual

● innodb_buffer_pool_dump=ON

● innodb_buffer_pool_dump_at_shutdown=ON &

innodb_buffer_pool_load_at_startup=ON

Page 33: The Peoper Care and Feeding of a MySQL Server for Busy Linux Admin

CONFIG CONTINUED

● Tune log level (5.7)

● log_error_verbosity – errors, errors & warnings, E&W

+ notes

● Send to SYSLOG

● Turn off query cache (5.7 Default)

● Single threaded, use memcached/redis

● Free up memory

● InnoDB buffer pool size

● 75-80% of RAM

Page 34: The Peoper Care and Feeding of a MySQL Server for Busy Linux Admin

BIG HINT #1

● BE DAMN STINGY with permissions & grants

● Easier to say no than to constantly be restoring

● --safe-updates or –i-am-a-dummy

● No more 'oops, I forgot the where clause' and

deleting the entire table instead of 'WHERE

customer_id = 12345'

Page 35: The Peoper Care and Feeding of a MySQL Server for Busy Linux Admin

BIG HINT #2

● Sys_schema – please use

● Views, functions, and procedures on top of the

Performance_schema and Information_schema

● Who is hogging resources

● Indexes not being used

● Problematic queries

● Other routine PITAs

Page 36: The Peoper Care and Feeding of a MySQL Server for Busy Linux Admin

BIG HINT #3

● 5.7 Security

● Secure install becomes the default

● Forced root password

● No anonymous account, no test DB

● Password rotation

● Configure rules

● Length, characters

● mysql_config_editor (5.6.6)

● Store encrypted auth credentials (no clear text)

● Use mysql --login-path=finance

Page 37: The Peoper Care and Feeding of a MySQL Server for Busy Linux Admin

MYSQL USER GROUPS

● https://community.oracle.com/docs/DOC-917215

● APAC, EMEA, NA, and LA

● Not one near you? Start one!

● Contact me at [email protected]

● Network, Learning, Certification study groups, find a

mentor

Page 38: The Peoper Care and Feeding of a MySQL Server for Busy Linux Admin

MORE INFO?

● Slides: slideshare.net/davidmstokes

● Twitter: @Stoker

● Email: [email protected]

● Blog: OpenSourceDBA.wordpress.com

Page 39: The Peoper Care and Feeding of a MySQL Server for Busy Linux Admin

QUESTIONS?

© 2015 SOLARWINDS WORLDWIDE, LLC. ALL RIGHTS RESERVED. 39

Page 40: The Peoper Care and Feeding of a MySQL Server for Busy Linux Admin

FREE TRIAL

• Try Database Performance Analyzer FREE for 14 days

• Improve root cause of slow performance

• Quickly identify root cause of issues that impact end-user response time

• See historical trends over days, months, and years

• Understand impact of VMware® performance

• Agentless architecture, installs in minutes

40

R E S O LV E P E R F O R M A N C E I S S U E S Q U I C K LY

© 2015 SOLARWINDS WORLDWIDE, LLC. ALL RIGHTS RESERVED.

www.solarwinds.com/dpa-download/

Page 41: The Peoper Care and Feeding of a MySQL Server for Busy Linux Admin

THANK YOU

© 2015 SOLARWINDS WORLDWIDE, LLC. ALL RIGHTS RESERVED.

The SOLARWINDS and SOLARWINDS & Design marks are the exclusive property of SolarWinds Worldwide, LLC, are registered with the U.S.

Patent and Trademark Office, and may be registered or pending registration in other countries. All other SolarWinds trademarks, service marks,

and logos may be common law marks, registered or pending registration in the United States or in other countries. All other trademarks

mentioned herein are used for identification purposes only and may be or are trademarks or registered trademarks of their respective companies.

41