mysql to mariadband back again - percona...11 step 0: backup! step -1: check yoself •partition...

27
MySQL to MariaDB and Back Again benny Vasquez -- cPanel, Inc. Santa Clara, California | April 23th – 25th, 2018

Upload: others

Post on 19-Sep-2020

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: MySQL to MariaDBand Back Again - Percona...11 Step 0: Backup! Step -1: Check yoself •Partition space is important df; df–I Step 0.1: Full dumpsofyourdatabase (scheme optional)

MySQL to MariaDB and Back Again

benny Vasquez -- cPanel, Inc.Santa Clara, California | April 23th – 25th, 2018

Page 2: MySQL to MariaDBand Back Again - Percona...11 Step 0: Backup! Step -1: Check yoself •Partition space is important df; df–I Step 0.1: Full dumpsofyourdatabase (scheme optional)

2

hi, I'm benny.

Page 3: MySQL to MariaDBand Back Again - Percona...11 Step 0: Backup! Step -1: Check yoself •Partition space is important df; df–I Step 0.1: Full dumpsofyourdatabase (scheme optional)

3

right now

Page 4: MySQL to MariaDBand Back Again - Percona...11 Step 0: Backup! Step -1: Check yoself •Partition space is important df; df–I Step 0.1: Full dumpsofyourdatabase (scheme optional)

4

before cPanel

Page 5: MySQL to MariaDBand Back Again - Percona...11 Step 0: Backup! Step -1: Check yoself •Partition space is important df; df–I Step 0.1: Full dumpsofyourdatabase (scheme optional)

5

boring

Page 6: MySQL to MariaDBand Back Again - Percona...11 Step 0: Backup! Step -1: Check yoself •Partition space is important df; df–I Step 0.1: Full dumpsofyourdatabase (scheme optional)

6

boring

Page 7: MySQL to MariaDBand Back Again - Percona...11 Step 0: Backup! Step -1: Check yoself •Partition space is important df; df–I Step 0.1: Full dumpsofyourdatabase (scheme optional)

7

enough about me, though

Page 8: MySQL to MariaDBand Back Again - Percona...11 Step 0: Backup! Step -1: Check yoself •Partition space is important df; df–I Step 0.1: Full dumpsofyourdatabase (scheme optional)

Migrating your data safely

Page 9: MySQL to MariaDBand Back Again - Percona...11 Step 0: Backup! Step -1: Check yoself •Partition space is important df; df–I Step 0.1: Full dumpsofyourdatabase (scheme optional)

Migrating your data safelySTOP

Page 10: MySQL to MariaDBand Back Again - Percona...11 Step 0: Backup! Step -1: Check yoself •Partition space is important df; df–I Step 0.1: Full dumpsofyourdatabase (scheme optional)

10

Step 0: Backup!

Page 11: MySQL to MariaDBand Back Again - Percona...11 Step 0: Backup! Step -1: Check yoself •Partition space is important df; df–I Step 0.1: Full dumpsofyourdatabase (scheme optional)

11

Step 0: Backup!Step -1: Check yo self• Partition space is important

df ; df –I

Step 0.1: Full dumps of your database (scheme optional)• Use mysqldump

[root: ~]# mysqldump -u root -p mysql user > `date +%Y%m%d`.user_table_dump.sql[root: ~]# mysqldump -u root -p --all-databases --skip-lock-tables > `date +%Y%m%d`.alldb.sql

Step 0.2: backup of the folder(s) and configurations• Use cp, rsync, etc- cp -a /var/lib/mysql{,.back. `date +%Y%m%d`} ; cp -a /etc/my.cnf{,.back.`date +%Y%m%d`}

Step 0.3: full server backups• Wherever possible, hot-spare is your best bet.

Page 12: MySQL to MariaDBand Back Again - Percona...11 Step 0: Backup! Step -1: Check yoself •Partition space is important df; df–I Step 0.1: Full dumpsofyourdatabase (scheme optional)

The Environment(s)Let’s get on the same page

Page 13: MySQL to MariaDBand Back Again - Percona...11 Step 0: Backup! Step -1: Check yoself •Partition space is important df; df–I Step 0.1: Full dumpsofyourdatabase (scheme optional)

13

Env{1}

* CentOS 6.9

* Installed MySQL 5.5

* Installed Apache & PHP

* Added WordPress Site

The Environment(s)

Env{2}

* CentOS 6.9

* Installed cPanel & WHM

* installed w/MySQL 5.5

* Added WordPress Site

Page 14: MySQL to MariaDBand Back Again - Percona...11 Step 0: Backup! Step -1: Check yoself •Partition space is important df; df–I Step 0.1: Full dumpsofyourdatabase (scheme optional)

MySQL à MariaDBFo’ reals this time.

Page 15: MySQL to MariaDBand Back Again - Percona...11 Step 0: Backup! Step -1: Check yoself •Partition space is important df; df–I Step 0.1: Full dumpsofyourdatabase (scheme optional)

15

6 easy steps• Install the MariaDB repos

https://mariadb.com/kb/en/library/yum/• Stop MySQL and remove it

service mysqld stop; yum remove mysql-community-server• Install MariaDB with your package manager

yum install MariaDB-server MariaDB-client • Ensure MariaDB is running

service mysql startmysql -Vservice mysql status

• Run mysql_upgradeFinish the conversion

Things to keep in mind• Migrate to the same version

- MySQL 5.1 -> MariaDB 5.1- MySQL 5.5 -> MariaDB 5.5

- MySQL 5.6 -> MariaDB 10.0- MySQL 5.7 -> MariaDB 10.2

MySQL to MariaDB; Env{1} Great Success

Env{1}: Success

Page 16: MySQL to MariaDBand Back Again - Percona...11 Step 0: Backup! Step -1: Check yoself •Partition space is important df; df–I Step 0.1: Full dumpsofyourdatabase (scheme optional)

16

3 easy steps• Navigate to MySQL/MariaDB Upgrade• Acknowledge the warnings• Click continue

MySQL to MariaDB; Env{2} Great Success

Env{2}: Success

Page 17: MySQL to MariaDBand Back Again - Percona...11 Step 0: Backup! Step -1: Check yoself •Partition space is important df; df–I Step 0.1: Full dumpsofyourdatabase (scheme optional)

MariaDB à MySQL under 5.6Easy peasy

Page 18: MySQL to MariaDBand Back Again - Percona...11 Step 0: Backup! Step -1: Check yoself •Partition space is important df; df–I Step 0.1: Full dumpsofyourdatabase (scheme optional)

18

6 easy steps• Stop MariaDB

service mysql stop • Remove MariaDB and its repos

yum remove MariaDB-server MariaDB-client • Install MySQL• Ensure MySQL is running• mysql_upgrade

Things to keep in mind• Migrate to the same version

- MariaDB 5.1 -> MySQL 5.1- MariaDB 5.5 -> MySQL 5.5

MariaDB to MySQL, when < 5.6 Env{1} Great Success

Env{1}: Success

Page 19: MySQL to MariaDBand Back Again - Percona...11 Step 0: Backup! Step -1: Check yoself •Partition space is important df; df–I Step 0.1: Full dumpsofyourdatabase (scheme optional)

19

2 easy steps• Manually adjust the mysql-version in /var/cpanel/cpanel.config

[root: ~]# grep mysql-version /var/cpanel/cpanel.configmysql-version=5.5

• Tell cPanel to check the installed RPMs and fix any problems it encounters/scripts/check_cpanel_rpms targets=MySQL55,MySQL56,MySQL57,MariaDB100 --fix

Env{2}: Success

MariaDB to MySQL, when < 5.6 Env{2} Great Success

Page 20: MySQL to MariaDBand Back Again - Percona...11 Step 0: Backup! Step -1: Check yoself •Partition space is important df; df–I Step 0.1: Full dumpsofyourdatabase (scheme optional)

MariaDB à MySQL over 5.6ugh

Page 21: MySQL to MariaDBand Back Again - Percona...11 Step 0: Backup! Step -1: Check yoself •Partition space is important df; df–I Step 0.1: Full dumpsofyourdatabase (scheme optional)

21

7 easy steps• DUMP. YOUR. DATABASES. And privileges.• Stop MariaDB

service mysql stop • Remove your databases

cp -a /var/lib/mysql{,.bak}; rm -rf /var/lib/mysql; chown mysql. /var/lib/mysql• Remove MariaDB and its repos

yum remove MariaDB-server MariaDB-client • Install MySQL

- Grab the community repo, and then yum install ithttps://dev.mysql.com/doc/mysql-installation-excerpt/5.7/en/linux-installation-yum-repo.html

• Ensure MySQL is runningservice mysql status

• Restore your databases- If you’ve done good, beer.

Warning: swapping in place WILL corrupt your databases

MariaDB to MySQL, when ≥ 5.6 Env{1} eh Success

Env{1}: Success?

Page 22: MySQL to MariaDBand Back Again - Percona...11 Step 0: Backup! Step -1: Check yoself •Partition space is important df; df–I Step 0.1: Full dumpsofyourdatabase (scheme optional)

22

6 easy steps• DUMP. YOUR. DATABASES. And privileges.• Remove your database files

cp -a /var/lib/mysql{,.bak}; rm -rf /var/lib/mysql; chown mysql. /var/lib/mysql

• Manually adjust the mysql-version in /var/cpanel/cpanel.config[root: ~]# grep mysql-version /var/cpanel/cpanel.config

mysql-version=5.7

• Tell cPanel to check the installed RPMs and fix any problems it encounters/scripts/check_cpanel_rpms –fix

• Ensure MySQL is runningservice mysql status

• Restore your databases- Also earns beer.

Warning: ”downgrading” in place WILL corrupt your databases, and WILL increase headaches.

MariaDB to MySQL, when ≥ 5.6 Env{2} eh Success

Env{2}: Success?

Page 23: MySQL to MariaDBand Back Again - Percona...11 Step 0: Backup! Step -1: Check yoself •Partition space is important df; df–I Step 0.1: Full dumpsofyourdatabase (scheme optional)

Conclusions and take-awaysugh

Page 24: MySQL to MariaDBand Back Again - Percona...11 Step 0: Backup! Step -1: Check yoself •Partition space is important df; df–I Step 0.1: Full dumpsofyourdatabase (scheme optional)

24

ugh.

• If you can, avoid changes after 5.7/10.2• Test, tinker, make notes• Be prepared for the suck, and maybe you’ll have over estimated.• Always reward yourself.

Page 25: MySQL to MariaDBand Back Again - Percona...11 Step 0: Backup! Step -1: Check yoself •Partition space is important df; df–I Step 0.1: Full dumpsofyourdatabase (scheme optional)

25

Page 27: MySQL to MariaDBand Back Again - Percona...11 Step 0: Backup! Step -1: Check yoself •Partition space is important df; df–I Step 0.1: Full dumpsofyourdatabase (scheme optional)

27

Rate My Session