15
EffectiveMySQL.com - Performance, Scalability, Site Reliability Managing MySQL Version Upgrades Ronald Bradford http://ronaldbradford.com @RonaldBradford 2015.08 EffectiveMySQL.com - Performance, Scalability, Site Reliability About the Author 16 years with MySQL / 26 years with RDBMS Senior Consultant at MySQL Inc (06-08) Consultant for Oracle Corporation (96-99) Published author of 4 MySQL books Ronald BRADFORD http://ronaldbradford.com/presentations/ EffectiveMySQL.com - Performance, Scalability, Site Reliability OTN TOUR 2015 Uruguay www.uyoug.org.uy Argentina www.aroug.org Chile www.cloug.cl Peru www.peoug.org Latin America Oracle User Groups Community www.laouc.net EffectiveMySQL.com - Performance, Scalability, Site Reliability Operating Systems

Managing MySQL Senior Consultant at MySQL Inc …...2015.08 EffectiveMySQL.com - Performance, Scalability, Site Reliability About the Author 16 years with MySQL / 26 years with RDBMS

  • Upload
    others

  • View
    5

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Managing MySQL Senior Consultant at MySQL Inc …...2015.08 EffectiveMySQL.com - Performance, Scalability, Site Reliability About the Author 16 years with MySQL / 26 years with RDBMS

EffectiveMySQL.com - Performance, Scalability, Site Reliability

Managing MySQL Version Upgrades

Ronald Bradfordhttp://ronaldbradford.com

@RonaldBradford

2015.08

EffectiveMySQL.com - Performance, Scalability, Site Reliability

About the Author

16 years with MySQL / 26 years with RDBMS

Senior Consultant at MySQL Inc (06-08)

Consultant for Oracle Corporation (96-99)

Published author of 4 MySQL books

Ronald BRADFORD

http://ronaldbradford.com/presentations/

EffectiveMySQL.com - Performance, Scalability, Site Reliability

OTN TOUR 2015

Uruguay www.uyoug.org.uy

Argentina www.aroug.org

Chile www.cloug.cl

Peru www.peoug.org

Latin America Oracle User Groups Community www.laouc.net

EffectiveMySQL.com - Performance, Scalability, Site Reliability

Operating Systems

Page 2: Managing MySQL Senior Consultant at MySQL Inc …...2015.08 EffectiveMySQL.com - Performance, Scalability, Site Reliability About the Author 16 years with MySQL / 26 years with RDBMS

EffectiveMySQL.com - Performance, Scalability, Site Reliability

Operating Systems

In this presentation will only be discussing RHEL/OL/CentOS versions

MySQL is also available on

Ubuntu/Debian

Windows

Solaris

Mac OS X

FreeBSD

SuSE

...

EffectiveMySQL.com - Performance, Scalability, Site Reliability

MySQL versions

MySQL version history

EOL - 3.23, 4.0, 4.1, 5.0, 5.1

GA - 5.5, 5.6

DMR - 5.7

EffectiveMySQL.com - Performance, Scalability, Site Reliability

https://en.wikipedia.org/wiki/MySQL

1994

1996MySQL (.com)

1998

2001v3.23

v4.02003

2004v4.1

v5.02005

Sun (.com)

2008

BEFORE Oracle

1995Innobase

Oracle (.com)

2005

Page 3: Managing MySQL Senior Consultant at MySQL Inc …...2015.08 EffectiveMySQL.com - Performance, Scalability, Site Reliability About the Author 16 years with MySQL / 26 years with RDBMS

MySQL (.com)

2008v5.1

v5.02005

Sun (.com)

2008

DURING SUN

v5.2

v6.0

X X

4/21/2009v5.4 beta

X

Oracle (.com)4/20/2009Acquisition announcement

Proven Scaling

Our Delta

2006 2009

2008 2011

Now

Oracle (.com)12/2010

v5.53/2013

v5.6

Sun (.com)

Percona Server

Maria DB

2006

2009

4/2011v5.5

4/2009v1.0.3

7/2010v5.1

July 2015

10/13v5.6

4/2009 1/2010

4/12v5.5

11/10v5.2

2/12V5.3

2/10v5.1

3/14v10.0

EffectiveMySQL.com - Performance, Scalability, Site Reliability

installation types

Installation types for RHEL/OL

Distro repo

3rd Party repo

Webtatic, Remi

Oracle repo

tar.gz

SourceEffectiveMySQL.com - Performance, Scalability, Site Reliability

RHEL/OL Installation

Page 4: Managing MySQL Senior Consultant at MySQL Inc …...2015.08 EffectiveMySQL.com - Performance, Scalability, Site Reliability About the Author 16 years with MySQL / 26 years with RDBMS

EffectiveMySQL.com - Performance, Scalability, Site Reliability

RHEL/OL 6 default ISO

Oracle Linux 6 default iso

mysql-libs-5.1 package

EffectiveMySQL.com - Performance, Scalability, Site Reliability

default install

# Install MySQLcd /tmpwget http://dev.mysql.com/get/mysql-community-release-el6-5.noarch.rpmyum localinstall -y mysql-community-release-el6-5.noarch.rpmrm -f mysql-community-release-el6-5.noarch.rpmsudo yum-config-manager --disable mysql56-communitysudo yum-config-manager --enable mysql55-communityyum repolist enabled | grep mysqlyum install -y mysql-community-serverrpm -qa | grep mysqlservice mysqld startchkconfig mysqld onmysql -uroot -e "SELECT VERSION()"

MySQL 5.5

Minimum installed

Additional packages exist

EffectiveMySQL.com - Performance, Scalability, Site Reliability

default rpms

$ rpm -qa | grep mysqlmysql-community-client-5.5.44-2.el6.x86_64mysql-community-common-5.5.44-2.el6.x86_64mysql-community-libs-compat-5.5.44-2.el6.x86_64mysql-community-libs-5.5.44-2.el6.x86_64mysql-community-server-5.5.44-2.el6.x86_64

EffectiveMySQL.com - Performance, Scalability, Site Reliability

Oracle yum repo

Oracle yum repo supports

MySQL 5.5

MySQL 5.6

MySQL 5.7

MySQL workbench/connectors/utilities

Page 5: Managing MySQL Senior Consultant at MySQL Inc …...2015.08 EffectiveMySQL.com - Performance, Scalability, Site Reliability About the Author 16 years with MySQL / 26 years with RDBMS

EffectiveMySQL.com - Performance, Scalability, Site Reliability

distro conflict

RHEL/OL Distro

mysql-server

Oracle Distro

mysql-community-server

EffectiveMySQL.com - Performance, Scalability, Site Reliability

package names

$ yum info mysql-serverLoaded plugins: securityAvailable PackagesName : mysql-serverArch : x86_64Version : 5.1.73Release : 5.el6_6Size : 8.6 MRepo : public_ol6_latestSummary : The MySQL server and related filesURL : http://www.mysql.comLicense : GPLv2 with exceptionsDescription : MySQL is a multi-user, multi-threaded SQL database server. MySQL is a : client/server implementation consisting of a server daemon (mysqld) : and many different client programs and libraries. This package contains : the MySQL server and some accompanying files and directories.

RHEL/OL Default

RHEL/OL 6MySQL 5.1EOL 2013

EffectiveMySQL.com - Performance, Scalability, Site Reliability

package names

$ yum info mysql-community-server

Available PackagesName : mysql-community-serverArch : x86_64Version : 5.6.25Release : 2.el6Size : 53 MRepo : mysql56-communitySummary : A very fast and reliable SQL database serverURL : http://www.mysql.com/

Oracle Repo

EffectiveMySQL.com - Performance, Scalability, Site Reliability

RHEL/OL Upgrade

Page 6: Managing MySQL Senior Consultant at MySQL Inc …...2015.08 EffectiveMySQL.com - Performance, Scalability, Site Reliability About the Author 16 years with MySQL / 26 years with RDBMS

EffectiveMySQL.com - Performance, Scalability, Site Reliability

default upgrade

$ mysql -e "SELECT VERSION()"+-----------+| VERSION() |+-----------+| 5.5.44 |+-----------+$ sudo yum-config-manager --disable mysql55-community$ sudo yum-config-manager --enable mysql56-community$ sudo yum update mysql-community-server$ mysql -e "SELECT VERSION()"+-----------+| VERSION() |+-----------+| 5.6.25 |+-----------+

This is not a completed upgrade

EffectiveMySQL.com - Performance, Scalability, Site Reliability

standard upgrade

yum update is not enough$ tail -20 /var/log/mysqld.log...2015-07-24 17:28:31 31214 [ERROR] Native table 'performance_schema'.'events_statements_summary_by_account_by_event_name' has the wrong structure2015-07-24 17:28:31 31214 [ERROR] Native table 'performance_schema'.'events_statements_summary_by_user_by_event_name' has the wrong structure2015-07-24 17:28:31 31214 [ERROR] Native table 'performance_schema'.'events_statements_summary_by_host_by_event_name' has the wrong structure2015-07-24 17:28:31 31214 [ERROR] Native table 'performance_schema'.'events_statements_summary_global_by_event_name' has the wrong structure2015-07-24 17:28:31 31214 [ERROR] Native table 'performance_schema'.'events_statements_summary_by_digest' has the wrong structure2015-07-24 17:28:31 31214 [ERROR] Native table 'performance_schema'.'users' has the wrong structure2015-07-24 17:28:31 31214 [ERROR] Native table 'performance_schema'.'accounts' has the wrong structure2015-07-24 17:28:31 31214 [ERROR] Native table 'performance_schema'.'hosts' has the wrong structure2015-07-24 17:28:31 31214 [ERROR] Native table 'performance_schema'.'socket_instances' has the wrong structure2015-07-24 17:28:31 31214 [ERROR] Native table 'performance_schema'.'socket_summary_by_instance' has the wrong structure2015-07-24 17:28:31 31214 [ERROR] Native table 'performance_schema'.'socket_summary_by_event_name' has

Always check the error log

EffectiveMySQL.com - Performance, Scalability, Site Reliability

mysql_upgrade

$ sudo mysql_upgradeLooking for 'mysql' as: mysqlLooking for 'mysqlcheck' as: mysqlcheckRunning 'mysqlcheck with default connection argumentsWarning: Using a password on the command line interface can be insecure.Running 'mysqlcheck with default connection argumentsWarning: Using a password on the command line interface can be insecure.mysql.columns_priv OKmysql.db OKmysql.event OKmysql.func OKmysql.general_log OKmysql.help_category OKmysql.help_keyword OKmysql.help_relation OKmysql.help_topic OKmysql.host OKmysql.ndb_binlog_index OKmysql.plugin OKmysql.proc OKmysql.procs_priv OKmysql.proxies_priv OKmysql.servers OKmysql.slow_log OKmysql.tables_priv OK

mysql_upgrade must also be run

on a running instance

EffectiveMySQL.com - Performance, Scalability, Site Reliability

Repo Change

Page 7: Managing MySQL Senior Consultant at MySQL Inc …...2015.08 EffectiveMySQL.com - Performance, Scalability, Site Reliability About the Author 16 years with MySQL / 26 years with RDBMS

EffectiveMySQL.com - Performance, Scalability, Site Reliability

Legacy installation

No Oracle yum repo before 5.5

No path from non-Oracle repo to Oracle repo

DB data structure is compatible

Software removal and re-installation required

http://ronaldbradford.com/blog/updating-mysql-using-official-repositories-2013-11-05/

EffectiveMySQL.com - Performance, Scalability, Site Reliability

Compatibility

EffectiveMySQL.com - Performance, Scalability, Site Reliability

MySQL 5.5 to 5.6

Reserved Words

Legacy TIMESTAMP usage

FULLTEXT Indexes

Client libraries

Query Optimizer

Clear text password warnings

EffectiveMySQL.com - Performance, Scalability, Site Reliability

reserved words

http://dev.mysql.com/doc/refman/5.6/en/keywords.html

Page 8: Managing MySQL Senior Consultant at MySQL Inc …...2015.08 EffectiveMySQL.com - Performance, Scalability, Site Reliability About the Author 16 years with MySQL / 26 years with RDBMS

EffectiveMySQL.com - Performance, Scalability, Site Reliability

reserved words

http://dev.mysql.com/doc/refman/5.7/en/keywords.html

EffectiveMySQL.com - Performance, Scalability, Site Reliability

reserved words

mysql> SELECT VERSION();+-----------+| version() |+-----------+| 5.5.44 |+-----------+

mysql> CREATE TABLE mysql55(only CHAR(1));Query OK, 0 rows affected (0.01 sec)

mysql> INSERT INTO mysql55(only) VALUES('A');Query OK, 1 row affected (0.00 sec)

EffectiveMySQL.com - Performance, Scalability, Site Reliability

reserved words

mysql> SELECT VERSION();+-----------+| VERSION() |+-----------+| 5.6.25 |+-----------+

mysql> CREATE TABLE mysql56(only CHAR(1));

mysql> INSERT INTO mysql56(only) VALUES('A');

mysql> CREATE TABLE only(c1 CHAR(1));Query OK, 0 rows affected (0.01 sec)

Not all reserved words are affected in

table strucutre

EffectiveMySQL.com - Performance, Scalability, Site Reliability

reserved words

mysql> CREATE TABLE table(c1 CHAR(1));ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'table(c1 CHAR(1))' at line 1

mysql> CREATE TABLE `table`(c1 CHAR(1));Query OK, 0 rows affected (0.01 sec)

mysql> INSERT INTO `table`(c1) VALUES('A');Query OK, 1 row affected (0.01 sec)

Reserved words can be used with

backquotes (`)

Page 9: Managing MySQL Senior Consultant at MySQL Inc …...2015.08 EffectiveMySQL.com - Performance, Scalability, Site Reliability About the Author 16 years with MySQL / 26 years with RDBMS

EffectiveMySQL.com - Performance, Scalability, Site Reliability

timestamp defaults

$ tail /var/log/mysqld.log

[Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).

TIMESTAMP datatype

DEFAULT CURRENT_TIMESTAMP

ON UPDATE CURRENT_TIMESTAMP

EffectiveMySQL.com - Performance, Scalability, Site Reliability

timestamp column

https://dev.mysql.com/doc/refman/5.0/en/timestamp-initialization.htmlhttps://dev.mysql.com/doc/refman/5.1/en/timestamp-initialization.htmlhttps://dev.mysql.com/doc/refman/5.5/en/timestamp-initialization.htmlhttps://dev.mysql.com/doc/refman/5.6/en/timestamp-initialization.htmlhttps://dev.mysql.com/doc/refman/5.7/en/timestamp-initialization.html

EffectiveMySQL.com - Performance, Scalability, Site Reliability

fulltext

MySQL 5.5 default storage engine changed to InnoDB

CREATE TABLE without ENGINE=MyISAM fails in 5.5

MySQL 5.6 InnoDB now supports FTS

Search results differ between MyISAM and InnoDB

EffectiveMySQL.com - Performance, Scalability, Site Reliability

optimizer

Some queries will have a different QEP

Testing is necessary to validate if query is worse in performance

Some queries are definitely better

Page 10: Managing MySQL Senior Consultant at MySQL Inc …...2015.08 EffectiveMySQL.com - Performance, Scalability, Site Reliability About the Author 16 years with MySQL / 26 years with RDBMS

EffectiveMySQL.com - Performance, Scalability, Site Reliability

clear text password

$ mysql -uuser -ppasswordWarning: Using a password on the command line interface can be insecure.

mysql> CHANGE MASTER ...;mysql> SHOW WARNINGS\G************************** 1. row *************************** Level: Note Code: 1759Message: Sending passwords in plain text without SSL/TLS is extremely insecure.*************************** 2. row *************************** Level: Note Code: 1760Message: Storing MySQL user name or password information in the master.info repository is not secure and is therefore not recommended. Please see the MySQL Manual for more about this issue and possible alternatives.

EffectiveMySQL.com - Performance, Scalability, Site Reliability

Configuration

EffectiveMySQL.com - Performance, Scalability, Site Reliability

new configuration

Upgrade configuration path

Inherit new configuration or keep legacy from prior version?

EffectiveMySQL.com - Performance, Scalability, Site Reliability

new defaults

https://dev.mysql.com/doc/refman/5.6/en/upgrading-from-previous-series.html

MySQL 5.6

Page 11: Managing MySQL Senior Consultant at MySQL Inc …...2015.08 EffectiveMySQL.com - Performance, Scalability, Site Reliability About the Author 16 years with MySQL / 26 years with RDBMS

EffectiveMySQL.com - Performance, Scalability, Site Reliability

https://dev.mysql.com/doc/refman/5.6/en/server-default-changes.htmlEffectiveMySQL.com - Performance, Scalability, Site Reliability

https://dev.mysql.com/doc/refman/5.6/en/server-default-changes.html

EffectiveMySQL.com - Performance, Scalability, Site Reliability

configuration

innodb_file_per_table

0 - Global tablespace (with multiple data files)

1 - Per table tablespace

EffectiveMySQL.com - Performance, Scalability, Site Reliability

configuration

innodb_file_per_table

Benefit

Reclaim diskspace when deleting data

Disadvantage

Higher amount fsyncs

Page 12: Managing MySQL Senior Consultant at MySQL Inc …...2015.08 EffectiveMySQL.com - Performance, Scalability, Site Reliability About the Author 16 years with MySQL / 26 years with RDBMS

EffectiveMySQL.com - Performance, Scalability, Site Reliability

configuration

There is no only migration path to move tables to innodb_file_per_table=1

Must dump, drop, clear files, restart and reload all data to reset global tablespace

Unprepared, you can be left with tables in old and new formats together

EffectiveMySQL.com - Performance, Scalability, Site Reliability

configuration

performance_schema

5.5 default is OFF

5.6 default is ON

Performance overhead

Overhead is worth it for not well tuned systems

EffectiveMySQL.com - Performance, Scalability, Site Reliability

configuration

innodb_log_file_size

Generally increased for tuning systems

Improvement helps in concurrency of untuned default system

Restart required to implement new default (no additional work needed)

EffectiveMySQL.com - Performance, Scalability, Site Reliability

configuration

max_connections

5.6 now supports more concurrent connections and more cores

Page 13: Managing MySQL Senior Consultant at MySQL Inc …...2015.08 EffectiveMySQL.com - Performance, Scalability, Site Reliability About the Author 16 years with MySQL / 26 years with RDBMS

EffectiveMySQL.com - Performance, Scalability, Site Reliability

Recommendations

EffectiveMySQL.com - Performance, Scalability, Site Reliability

sys

Install the ‘sys’ schema in MySQL 5.6

Now included by default in MySQL 5.7

https://github.com/MarkLeith/mysql-sys/

EffectiveMySQL.com - Performance, Scalability, Site Reliability

Upgrading Options

EffectiveMySQL.com - Performance, Scalability, Site Reliability

upgrading

MySQL recommends upgrading to each version separately

The also suggest to dump and load data

This is impractical

Can you upgrade from 5.0 to 5.5?

It is [technically] possible, not recommended

Page 14: Managing MySQL Senior Consultant at MySQL Inc …...2015.08 EffectiveMySQL.com - Performance, Scalability, Site Reliability About the Author 16 years with MySQL / 26 years with RDBMS

EffectiveMySQL.com - Performance, Scalability, Site Reliability

replication

MySQL replication is the easiest way to perform rolling upgrades

A read replica can be a newer version

Validates all writes (via binary log)

Test reads via replay

EffectiveMySQL.com - Performance, Scalability, Site Reliability

replication

Do not use new replication configuration features until entire topology is upgraded.

e.g. crash safe replication

Issues with checksum in binary log

EffectiveMySQL.com - Performance, Scalability, Site Reliability

Conclusion

EffectiveMySQL.com - Performance, Scalability, Site Reliability

conclusion

Moving from non Oracle yum repo is important first step

Moving to 5.5 is the best base version

A 3-6 month upgrade cadence is best

MySQL replication is key for testing

Page 15: Managing MySQL Senior Consultant at MySQL Inc …...2015.08 EffectiveMySQL.com - Performance, Scalability, Site Reliability About the Author 16 years with MySQL / 26 years with RDBMS

http://ronaldbradford.com [email protected]

@RonaldBradford

Ronald Bradford