ようへい

2020年1月7日火曜日

MySQL Enterprise 5.6 -> 5.7 -> 8.0 へのアップグレード手順

  • MySQL-server-advanced-5.6.46-1.el7.x86_64.rpm
  • MySQL-client-advanced-5.6.46-1.el7.x86_64.rpm
などがインストールされているRHEL7の環境

MySQL 5.7

  • mysql-commercial-server-5.7.28-1.1.el7.x86_64.rpm
  • mysql-commercial-client-5.7.28-1.1.el7.x86_64.rpm

MySQL 8.0

  • mysql-commercial-server-8.0.18-1.1.el7.x86_64.rpm
  • mysql-commercial-client-8.0.18-1.1.el7.x86_64.rpm
などが入った zip を Oracle のサポートサイトから取得
VM 上でやるため、バックアップとかは取得せずやります

MySQL 5.6 -> 5.7

# rpm -qa | grep MySQL
MySQL-devel-advanced-5.6.46-1.el7.x86_64
MySQL-shared-compat-advanced-5.6.46-1.el7.x86_64
MySQL-server-advanced-5.6.46-1.el7.x86_64
MySQL-client-advanced-5.6.46-1.el7.x86_64
MySQL-shared-advanced-5.6.46-1.el7.x86_64
# systemctl stop mysql
# rpm -Uvh mysql-commercial-*
警告: mysql-commercial-client-5.7.28-1.1.el7.x86_64.rpm: ヘッダー V3 DSA/SHA1 Signature、鍵 ID 5072e1f5: NOKEY
準備しています...              ################################# [100%]
更新中 / インストール中...
   1:mysql-commercial-common-5.7.28-1.################################# [ 11%]
   2:mysql-commercial-libs-5.7.28-1.1.################################# [ 22%]
   3:mysql-commercial-client-5.7.28-1.################################# [ 33%]
   4:mysql-commercial-server-5.7.28-1.################################# [ 44%]
   5:mysql-commercial-libs-compat-5.7.################################# [ 56%]
整理中 / 削除中...
   6:MySQL-server-advanced-5.6.46-1.el################################# [ 67%]
   7:MySQL-shared-compat-advanced-5.6.################################# [ 78%]
   8:MySQL-shared-advanced-5.6.46-1.el################################# [ 89%]
   9:MySQL-client-advanced-5.6.46-1.el################################# [100%]
# systemctl start mysql
Warning: mysql.service changed on disk. Run 'systemctl daemon-reload' to reload units.
Job for mysql.service failed because the control process exited with error code. See "systemctl status mysql.service" and "journalctl -xe" for details.
# systemctl daemon-reload
# systemctl start mysql
Failed to start mysql.service: Unit mysql.service failed to load: No such file or directory.
mysql が無いらしい。
# systemctl list-units --type=service --all | grep mysql
● mysql.service                          not-found failed   failed  mysql.service
  mysqld.service                         loaded    inactive dead    MySQL Server
mysqld になってた。
# systemctl disable mysql
# systemctl start mysqld
# systemctl status mysqld
● mysqld.service - MySQL Server
   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
   Active: active (running) since 金 2019-11-15 12:13:09 JST; 23s ago
     Docs: man:mysqld(8)
           http://dev.mysql.com/doc/refman/en/using-systemd.html
  Process: 2401 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid $MYSQLD_OPTS (code=exited, status=0/SUCCESS)
  Process: 2384 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
 Main PID: 2405 (mysqld)
   CGroup: /system.slice/mysqld.service
           mq2405 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid

11月 15 12:12:59 localhost.localdomain systemd[1]: Starting MySQL Server...
11月 15 12:13:09 localhost.localdomain systemd[1]: Started MySQL Server.
# mysql_upgrade -uroot -p
Enter password:
Checking if update is needed.
Checking server version.
Running queries to upgrade MySQL server.
Checking system database.
mysql.columns_priv                                 OK
mysql.db                                           OK
mysql.engine_cost                                  OK
mysql.event                                        OK
mysql.func                                         OK
mysql.general_log                                  OK
mysql.gtid_executed                                OK
mysql.help_category                                OK
mysql.help_keyword                                 OK
mysql.help_relation                                OK
mysql.help_topic                                   OK
mysql.innodb_index_stats                           OK
mysql.innodb_table_stats                           OK
mysql.ndb_binlog_index                             OK
mysql.plugin                                       OK
mysql.proc                                         OK
mysql.procs_priv                                   OK
mysql.proxies_priv                                 OK
mysql.server_cost                                  OK
mysql.servers                                      OK
mysql.slave_master_info                            OK
mysql.slave_relay_log_info                         OK
mysql.slave_worker_info                            OK
mysql.slow_log                                     OK
mysql.tables_priv                                  OK
mysql.time_zone                                    OK
mysql.time_zone_leap_second                        OK
mysql.time_zone_name                               OK
mysql.time_zone_transition                         OK
mysql.time_zone_transition_type                    OK
mysql.user                                         OK
Upgrading the sys schema.
Checking databases.
<DB名>.<Table名>                                   OK
Upgrade process completed successfully.
Checking if update is needed.
# systemctl restart mysqld
# systemctl status mysqld
● mysqld.service - MySQL Server
   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
   Active: active (running) since 金 2019-11-15 12:20:24 JST; 2s ago
     Docs: man:mysqld(8)
           http://dev.mysql.com/doc/refman/en/using-systemd.html
  Process: 2608 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid $MYSQLD_OPTS (code=exited, status=0/SUCCESS)
  Process: 2590 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
 Main PID: 2612 (mysqld)
   CGroup: /system.slice/mysqld.service
           mq2612 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid

11月 15 12:20:23 localhost.localdomain systemd[1]: Starting MySQL Server...
11月 15 12:20:24 localhost.localdomain systemd[1]: Started MySQL Server.
# mysqlcheck -uroot -p --all-databases
Enter password:
mysql.columns_priv                                 OK
mysql.db                                           OK
mysql.engine_cost                                  OK
mysql.event                                        OK
mysql.func                                         OK
mysql.general_log                                  OK
mysql.gtid_executed                                OK
mysql.help_category                                OK
mysql.help_keyword                                 OK
mysql.help_relation                                OK
mysql.help_topic                                   OK
mysql.innodb_index_stats                           OK
mysql.innodb_table_stats                           OK
mysql.ndb_binlog_index                             OK
mysql.plugin                                       OK
mysql.proc                                         OK
mysql.procs_priv                                   OK
mysql.proxies_priv                                 OK
mysql.server_cost                                  OK
mysql.servers                                      OK
mysql.slave_master_info                            OK
mysql.slave_relay_log_info                         OK
mysql.slave_worker_info                            OK
mysql.slow_log                                     OK
mysql.tables_priv                                  OK
mysql.time_zone                                    OK
mysql.time_zone_leap_second                        OK
mysql.time_zone_name                               OK
mysql.time_zone_transition                         OK
mysql.time_zone_transition_type                    OK
mysql.user                                         OK
<DB名>.<Table名>                                   OK
sys.sys_config                                     OK

MySQL 5.7 -> 8.0

# rpm -qa | grep mysql
mysql-commercial-server-5.7.28-1.1.el7.x86_64
mysql-commercial-common-5.7.28-1.1.el7.x86_64
mysql-commercial-client-5.7.28-1.1.el7.x86_64
mysql-commercial-libs-compat-5.7.28-1.1.el7.x86_64
mysql-commercial-libs-5.7.28-1.1.el7.x86_64
# systemctl stop mysqld
# rpm -Fvh mysql-commercial-*-8.0*
警告: mysql-commercial-backup-8.0.18-1.1.el7.x86_64.rpm: ヘッダー V3 DSA/SHA1 Signature、鍵 ID 5072e1f5: NOKEY
準備しています...              ################################# [100%]
更新中 / インストール中...
   1:mysql-commercial-common-8.0.18-1.################################# [  9%]
   2:mysql-commercial-libs-8.0.18-1.1.################################# [ 18%]
   3:mysql-commercial-client-8.0.18-1.################################# [ 27%]
   4:mysql-commercial-server-8.0.18-1.################################# [ 36%]
   5:mysql-commercial-libs-compat-8.0.################################# [ 45%]
   6:mysql-commercial-backup-8.0.18-1.################################# [ 55%]
整理中 / 削除中...
   7:mysql-commercial-server-5.7.28-1.################################# [ 64%]
   8:mysql-commercial-client-5.7.28-1.################################# [ 73%]
   9:mysql-commercial-libs-compat-5.7.################################# [ 82%]
  10:mysql-commercial-libs-5.7.28-1.1.################################# [ 91%]
  11:mysql-commercial-common-5.7.28-1.################################# [100%]
まぁまぁ時間かかります。
router とかは必要に合わせて入れる感じで。
# systemctl start mysqld
まぁまぁ時間かかります。
# systemctl status mysqld
● mysqld.service - MySQL Server
   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
   Active: active (running) since 金 2019-11-15 12:33:33 JST; 26s ago
     Docs: man:mysqld(8)
           http://dev.mysql.com/doc/refman/en/using-systemd.html
  Process: 3169 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
 Main PID: 3200 (mysqld)
   Status: "Server is operational"
   CGroup: /system.slice/mysqld.service
           mq3200 /usr/sbin/mysqld

11月 15 12:33:02 localhost.localdomain systemd[1]: Starting MySQL Server...
11月 15 12:33:33 localhost.localdomain systemd[1]: Started MySQL Server.
# mysql_upgrade -uroot -p
Enter password:
The mysql_upgrade client is now deprecated. The actions executed by the upgrade client are now done by the server.
To upgrade, please start the new MySQL binary with the older data directory. Repairing user tables is done automatically. Restart is not required after upgrade.
The upgrade process automatically starts on running a new MySQL binary with an older data directory. To avoid accidental upgrades, please use the --upgrade=NONE option with the MySQL binary. The option --upgrade=FORCE is also provided to run the server upgrade sequence on demand.
It may be possible that the server upgrade fails due to a number of reasons. In that case, the upgrade sequence will run again during the next MySQL server start. If the server upgrade fails repeatedly, the server can be started with the --upgrade=MINIMAL option to start the server without executing the upgrade sequence, thus allowing users to manually rectify the problem.
mysql_upgrade は非推奨になって、起動時に自動でアップグレードされるようになったらしい。
# mysqlcheck -uroot -p --all-databases
Enter password:
mysql.columns_priv                                 OK
mysql.component                                    OK
mysql.db                                           OK
mysql.default_roles                                OK
mysql.engine_cost                                  OK
mysql.func                                         OK
mysql.general_log                                  OK
mysql.global_grants                                OK
mysql.gtid_executed                                OK
mysql.help_category                                OK
mysql.help_keyword                                 OK
mysql.help_relation                                OK
mysql.help_topic                                   OK
mysql.innodb_index_stats                           OK
mysql.innodb_table_stats                           OK
mysql.ndb_binlog_index                             OK
mysql.password_history                             OK
mysql.plugin                                       OK
mysql.procs_priv                                   OK
mysql.proxies_priv                                 OK
mysql.role_edges                                   OK
mysql.server_cost                                  OK
mysql.servers                                      OK
mysql.slave_master_info                            OK
mysql.slave_relay_log_info                         OK
mysql.slave_worker_info                            OK
mysql.slow_log                                     OK
mysql.tables_priv                                  OK
mysql.time_zone                                    OK
mysql.time_zone_leap_second                        OK
mysql.time_zone_name                               OK
mysql.time_zone_transition                         OK
mysql.time_zone_transition_type                    OK
mysql.user                                         OK
<DB名>.<Table名>                                   OK
sys.sys_config                                     OK
# rpm -qa | grep mysql
mysql-commercial-client-8.0.18-1.1.el7.x86_64
mysql-commercial-libs-8.0.18-1.1.el7.x86_64
mysql-commercial-server-8.0.18-1.1.el7.x86_64
mysql-commercial-backup-8.0.18-1.1.el7.x86_64
mysql-commercial-common-8.0.18-1.1.el7.x86_64
mysql-commercial-libs-compat-8.0.18-1.1.el7.x86_6
特に問題なくアップグレードできました。
関連記事

0 件のコメント:

コメントを投稿