Top Banner
Copyright 2016 Severalnines AB How to upgrade to MySQL 5.7 - best practices March 15, 2016 Krzysztof Książek Severalnines [email protected] 1
31

Webinar slides: How To Upgrade to MySQL 5.7 - The Best Practices

Jan 22, 2018

Download

Internet

Severalnines
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Webinar slides: How To Upgrade to MySQL 5.7 - The Best Practices

Copyright 2016 Severalnines AB

How to upgrade to MySQL 5.7 - best practices

March 15, 2016

Krzysztof Książek

Severalnines

[email protected]

1

Page 2: Webinar slides: How To Upgrade to MySQL 5.7 - The Best Practices

2

Your host & some logistics

I'm Jean-Jérôme from the Severalnines Team and I'm your host for today's webinar!

Feel free to ask any questions in the Questions section of this application or via the Chat box.

You can also contact me directly via the chat box or via email: [email protected] during or after the webinar.

Page 3: Webinar slides: How To Upgrade to MySQL 5.7 - The Best Practices

Copyright 2016 Severalnines AB

! Preparing an upgrade - changes between MySQL 5.6 and 5.7

! Information_schema

! SQL modes

! Authentication model

! Testing for upgrade

! Designing test environment

! Building test environment

! Executing tests

! Upgrade process

! Tools which may help you with upgrade process

3

Agenda

Page 4: Webinar slides: How To Upgrade to MySQL 5.7 - The Best Practices

Copyright 2016 Severalnines AB

Why upgrading to MySQL 5.7?

4

Page 5: Webinar slides: How To Upgrade to MySQL 5.7 - The Best Practices

Copyright 2016 Severalnines AB

! Better performance

! New features

! Multi source replication

! Intra-schema parallel replication

! Online buffer pool resize!!!

! Improved optimizer cost model

! Access to security and bugfix releases

! 5.5 ended its ‘Premier’ support, ‘Extended’ will end in 2018

5

Why upgrading to MySQL 5.7?

Page 6: Webinar slides: How To Upgrade to MySQL 5.7 - The Best Practices

Copyright 2016 Severalnines AB

Preparing an upgrade - reviewing changes

6

Page 7: Webinar slides: How To Upgrade to MySQL 5.7 - The Best Practices

Copyright 2016 Severalnines AB

! Information schema changes

! global_status, session_status, global_variables and session_variables moved to the performance_schema

! You can restore the original behavior by setting:SET GLOBAL show_compatibility_56=1

! This may affect different monitoring solutions

7

Preparing an upgrade - reviewing changes

Page 8: Webinar slides: How To Upgrade to MySQL 5.7 - The Best Practices

Copyright 2016 Severalnines AB

! SQL mode changes

! STRICT_TRANS_TABLES mode is used by default

! No more inserting of invalid data like zeroed date or skipping column in INSERT when column doesn’t have explicit DEFAULT value

! This may cause issues if application relies on previous (definitely not so good) defaults

8

Preparing an upgrade - reviewing changes

Page 9: Webinar slides: How To Upgrade to MySQL 5.7 - The Best Practices

Copyright 2016 Severalnines AB

! Authentication model changes

! Pre-4.1 passwords have been removed

! Password expiration has been added

! By default it’s not affecting 5.6 users ( >=5.7.11) but this default may change in the future (http://mysqlserverteam.com/an-update-on-default_password_lifetime)

! You should manually set the desired expiration policy for every user, after you upgraded to MySQL 5.7

9

Preparing an upgrade - reviewing changes

Page 10: Webinar slides: How To Upgrade to MySQL 5.7 - The Best Practices

Copyright 2016 Severalnines AB

! Redo and undo log format changed - use innodb_fast_shutdown=0 when you stop 5.6 for upgrade

! YEAR(2) format has been removed

! User-defined locks system has changed - multiple locks are now possible

! ‘derived_merge’ optimizer switch may trigger SQL incompatibility

! For full list of changes look at: http://dev.mysql.com/doc/refman/5.7/en/upgrading-from-previous-series.html

10

Preparing an upgrade - reviewing changes

Page 11: Webinar slides: How To Upgrade to MySQL 5.7 - The Best Practices

Copyright 2016 Severalnines AB

Testing for upgrade

11

Page 12: Webinar slides: How To Upgrade to MySQL 5.7 - The Best Practices

Copyright 2016 Severalnines AB

Testing for upgrade

12

Page 13: Webinar slides: How To Upgrade to MySQL 5.7 - The Best Practices

Copyright 2016 Severalnines AB

! First step - design your test environment

! It should be as close to the production as possible

! Weaker hardware will lead to incorrect results

! Queries may be slower on weaker CPU and I/O subsystem

! or you will not catch a real regression - thinking it’s the hardware’s fault

13

Testing for upgrade

Page 14: Webinar slides: How To Upgrade to MySQL 5.7 - The Best Practices

Copyright 2016 Severalnines AB

! Dataset should be as close to the real data as possible

! Scrubbing dataset or cleaning confidential data may impact query execution plans - if you don’t have to, don’t clean your data

! You should be using real-world queries to test the performance

! Ideally, use your application for testing the logic and making sure all processes work as expected.

14

Testing for upgrade

Page 15: Webinar slides: How To Upgrade to MySQL 5.7 - The Best Practices

Copyright 2016 Severalnines AB

! Simplest way of building a test environment:

! create a slave from production master

! and then cut off replication

! Once we have 5.6 node with current dataset, we need to create another 5.6 node with a copy of this data

! Finally, we want to upgrade one of them to MySQL 5.7

! It’s nice as we can test the upgrade process while building test hosts

15

Testing for upgrade

Page 16: Webinar slides: How To Upgrade to MySQL 5.7 - The Best Practices

Copyright 2016 Severalnines AB

! We have hosts but we need to collect data for tests

! tcpdump or just slow query log would do

! both have some impact on the overall performance

! tcpdump can be executed outside of the database, to minimize the impact

! You want to collect all the queries - if you have some processes scheduled to run at a particular time, collect those queries too when they happen

16

Testing for upgrade

Page 17: Webinar slides: How To Upgrade to MySQL 5.7 - The Best Practices

Copyright 2016 Severalnines AB

! Once you have data, you can run some preliminary regression testing using pt-upgrade

! Run twice, first time using the ‘—save-results’ flag - it’ll save your time

! Generate report, investigate any reported issues

! pt-upgrade compares performance and result set

! Make sure you execute tests locally on the hosts, network latency may cause some impact

! Make sure both nodes are in the same state - cold or warmed up in exactly the same way

17

Testing for upgrade

Page 18: Webinar slides: How To Upgrade to MySQL 5.7 - The Best Practices

Copyright 2016 Severalnines AB

! pt-upgrade is not enough to cover all issues - yes, it’ll check performance and some obvious issues but you need to run more detailed tests

! If you have a set of acceptance tests you use to test new releases (you should have them), you can use those tests to check if upgrade affected core functions of your app

! Test application logic, make sure all operations work correctly, check all of the processes and APIs you may have in your app

18

Testing for upgrade

Page 19: Webinar slides: How To Upgrade to MySQL 5.7 - The Best Practices

Copyright 2016 Severalnines AB

! Once you have completed your tests, there's one more thing to check

! Rebuild your 5.7 node

! provision it again

! run mysql_upgrade, as you did earlier

! set it up as a slave

! Allow it to work as a slave for couple of days - it’ll confirm replication works fine between old and new versions

19

Testing for upgrade

Page 20: Webinar slides: How To Upgrade to MySQL 5.7 - The Best Practices

Copyright 2016 Severalnines AB

Upgrade process

20

Page 21: Webinar slides: How To Upgrade to MySQL 5.7 - The Best Practices

Copyright 2016 Severalnines AB

! Start with a single slave and upgrade it:

! Disable innodb_fast_shutdown

! Shut down MySQL

! Upgrade binaries to MySQL 5.7

! Start MySQL

! Run mysql_upgrade

! Restart MySQL

! Make sure replication is working and if needed, fix it

21

Upgrade process

Page 22: Webinar slides: How To Upgrade to MySQL 5.7 - The Best Practices

Copyright 2016 Severalnines AB

! Before upgrade - make sure you took the node out of rotation in a proxy layer or in your application

! After upgrade - if possible, put some limited traffic on the new host

! Observe how it behaves under real-world traffic

! CPU

! I/O

! Memory utilization

22

Upgrade process

Page 23: Webinar slides: How To Upgrade to MySQL 5.7 - The Best Practices

Copyright 2016 Severalnines AB

! Step by step increase the load to a normal level

! If everything is ok, proceed with upgrade on remaining slaves

! Once all of the slaves are upgraded, pick one of them as a new master

! Set it in a master-master replication with current, 5.6 master

23

Upgrade process

Page 24: Webinar slides: How To Upgrade to MySQL 5.7 - The Best Practices

Copyright 2016 Severalnines AB

! Perform a switchover to the new master

! If the old master keeps replicating, that’s great - upgrade it in a regular way

! If the old master replication breaks (i.e. incompatibilities in binlog format between old and new MySQL versions), rebuild it:

! Wipe the data

! Perform binary upgrade to MySQL 5.7

! Provision the data from slave and set up the replication

24

Upgrade process

Page 25: Webinar slides: How To Upgrade to MySQL 5.7 - The Best Practices

Copyright 2016 Severalnines AB

Tools which may help you with upgrade process

25

Page 26: Webinar slides: How To Upgrade to MySQL 5.7 - The Best Practices

Copyright 2016 Severalnines AB

! tcpdump

! tcpdump -s 65535 -x -nn -q -tttt -i any port 3306 > mysql.tcp.txt

! Helps you to collect queries exchanged between application hosts and database server

! Minimizes the impact caused by data collection (when executed outside of database node)

26

Tools which may help you with upgrade process

Page 27: Webinar slides: How To Upgrade to MySQL 5.7 - The Best Practices

Copyright 2016 Severalnines AB

! pt-upgrade, Percona Playback

! pt-upgrade is designed to check for performance and basic result set regressions

! Points you to queries which are not performing on the new version or they return different data

! Percona Playback is designed for load testing - replays slow log, trying to simulate real-world workload

27

Tools which may help you with upgrade process

Page 28: Webinar slides: How To Upgrade to MySQL 5.7 - The Best Practices

Copyright 2016 Severalnines AB

! MaxScale and ProxySQL

! Database-aware proxies help you through the upgrade process

! They route the traffic off the node when it goes down

! Help you with a warm-up period - use lower weight for new hosts to allow them to warm up properly

! ProxySQL can handle graceful switchover when used with external tool (for example, mysqlrpladmin, MHA or ClusterControl)

28

Tools which may help you with upgrade process

Page 29: Webinar slides: How To Upgrade to MySQL 5.7 - The Best Practices

Copyright 2016 Severalnines AB

! mysqlrpladmin, MHA

! Those tools can perform a switchover for you

! No need to make the changes in manual and error prone way - just run a script

! Those tools can be integrated with ProxySQL for graceful switchovers

29

Tools which may help you with upgrade process

Page 30: Webinar slides: How To Upgrade to MySQL 5.7 - The Best Practices

Copyright 2016 Severalnines AB

! ClusterControl

! Helps with provisioning of new nodes

! Perform a switchover for you

! Gives you clear insight into replication status

! Gives you clear insight into all database operations

30

Tools which may help you with upgrade process

Page 31: Webinar slides: How To Upgrade to MySQL 5.7 - The Best Practices

Copyright 2015 Severalnines AB

! More blogs covering different aspects of MySQL operations:

! http://severalnines.com/blog-categories/db-ops

! An ebook focused on upgrade process to MySQL 5.7 will become available soon

! Step-by-step guide through each part of the process

! Detailed explanations of different issues you may run into

! We’ll be at Percona Live in April, see you there!

! Contact: [email protected]

31

Thank You!