通过测试验证得出结论:
1.mysql 8.0.18 升级8.0.20 较 8.0.16之前的版本更为简洁,直接安装好二进制软件后,使用8.0.20 二进制起库即可
2.从8.0.18升级到8.0.20 之后,不能回退
升级步骤1.安装软件包 2.停库 查看processlist 是否有正在执行的会话,如果有确认是否可以kill mysql -h $ip -p $port -u $username -p $pwd -D $database -e 'select concat('kill connection ', id, ';') from information_schema.processlist where user not in ('root');' port=5518 /mysql/base/bin/mysqladmin --login-path=root --socket=/var/mysql.sock shutdown ps -ef |grep $port |grep -v grep 备份数据目录 cp -rp data data_$(date +'%Y%m%d')_bak ll -rth data_$(date +'%Y%m%d')_bak 3.起库 修改conf 文件 cp my.cnf my.cnf_$(date +'%Y%m%d')_bak 确认cpoy 成功 sed -i '/basedir/ s#8.0.18#8.0.20#g' my.cnf cat my.cnf |grep basedir cd /mysql/8.0.20 && ./bin/mysqld_safe --defaults-file=/var/my.cnf & 查看日志 tail -30f log/error.log
输出日志如 下:
2021-01-19T22:11:44.183128+08:00 5303798 [System] [MY-013172] [Server] Received SHUTDOWN from user root. Shutting down mysqld (Version: 8.0.18). 2021-01-19T22:11:48.975960+08:00 0 [System] [MY-010910] [Server] /var/mysql/8.0.18/bin/mysqld: Shutdown complete (mysqld 8.0.18) MySQL Community Server - GPL. 2021-01-19T23:30:32.879167+08:00 0 [System] [MY-010116] [Server] /var/mysql/8.0.20/bin/mysqld (mysqld 8.0.20) starting as process 25328 2021-01-19T23:30:32.896221+08:00 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started. 2021-01-19T23:30:41.292984+08:00 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended. 2021-01-19T23:30:44.913587+08:00 0 [System] [MY-011323] [Server] X Plugin ready for connections. Socket: '/tmp/mysqlx.sock' 2021-01-19T23:30:47.376901+08:00 4 [System] [MY-013381] [Server] Server upgrade from '80018' to '80020' started. 2021-01-19T23:31:01.649605+08:00 4 [System] [MY-013381] [Server] Server upgrade from '80018' to '80020' completed. 2021-01-19T23:31:02.135700+08:00 0 [System] [MY-010931] [Server] /var/mysql/8.0.20/bin/mysqld: ready for connections.
测试回退
1.清理事务日志文件 cd /var/mysql/data rm ib_logfile* 2.修改my.cnf 文件 sed -i '/basedir/ s#8.0.20#8.0.18#g' my.cnf && my.cnf |grep basedir 3.起库 cd /var/mysql/8.0.18 && ./bin/mysqld_safe --defaults-file=/var/mysql/my.cnf &
用低版本直接起库后日志输出如下:
2021-01-23T21:59:54.935400+08:00 0 [Warning] [MY-000081] [Server] option 'server_id': unsigned value 183792737317 adjusted to 4294967295. 2021-01-23T21:59:54.935574+08:00 0 [Note] [MY-010098] [Server] --secure-file-priv is set to NULL. Operations related to importing and exporting data are disabled 2021-01-23T21:59:54.935670+08:00 0 [Note] [MY-010949] [Server] Basedir set to /var/mysql/8.0.18/. 2021-01-23T21:59:54.935687+08:00 0 [System] [MY-010116] [Server] /var/mysql/8.0.18/bin/mysqld (mysqld 8.0.18) starting as process 19916 2021-01-23T21:59:54.951436+08:00 0 [Note] [MY-012366] [InnoDB] Using Linux native AIO 2021-01-23T21:59:54.951590+08:00 0 [Warning] [MY-013267] [InnoDB] The setting INNODB_UNDO_TABLESPACES is deprecated and is no longer used. InnoDB always creates 2 undo tablespaces to start with. If you need more, please use CREATE UNDO TABLESPACE. 2021-01-23T21:59:54.951845+08:00 0 [Note] [MY-010747] [Server] Plugin 'FEDERATED' is disabled. 2021-01-23T21:59:54.954741+08:00 1 [Note] [MY-012932] [InnoDB] PUNCH HOLE support available 2021-01-23T21:59:54.954865+08:00 1 [Note] [MY-012943] [InnoDB] Mutexes and rw_locks use GCC atomic builtins 2021-01-23T21:59:54.954946+08:00 1 [Note] [MY-012944] [InnoDB] Uses event mutexes 2021-01-23T21:59:54.955024+08:00 1 [Note] [MY-012945] [InnoDB] GCC builtin __atomic_thread_fence() is used for memory barrier 2021-01-23T21:59:54.955113+08:00 1 [Note] [MY-012948] [InnoDB] Compressed tables use zlib 1.2.11 2021-01-23T21:59:54.960381+08:00 1 [Note] [MY-013251] [InnoDB] Number of pools: 1 2021-01-23T21:59:54.960635+08:00 1 [Note] [MY-012951] [InnoDB] Using CPU crc32 instructions 2021-01-23T21:59:54.961339+08:00 1 [Note] [MY-012203] [InnoDB] Directories to scan './;/paic/my5518/data;./' 2021-01-23T21:59:54.961529+08:00 1 [Note] [MY-012204] [InnoDB] Scanning './' 2021-01-23T21:59:54.983783+08:00 1 [Note] [MY-012208] [InnoDB] Completed space ID check of 869 files. 2021-01-23T21:59:54.989486+08:00 1 [Note] [MY-012955] [InnoDB] Initializing buffer pool, total size = 2.000000G, instances = 8, chunk size =128.000000M 2021-01-23T21:59:55.101794+08:00 1 [Note] [MY-012957] [InnoDB] Completed initialization of buffer pool 2021-01-23T21:59:55.111964+08:00 0 [Note] [MY-011952] [InnoDB] If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority(). 2021-01-23T21:59:55.123867+08:00 1 [Note] [MY-012887] [InnoDB] Setting log file ./ib_logfile101 size to 2048 MB 2021-01-23T21:59:55.124727+08:00 1 [Note] [MY-012651] [InnoDB] Progress in MB: 100 200 300 400 500 600 700 800 900 1000 1100 1200 1300 1400 1500 1600 1700 1800 1900 2000 2021-01-23T22:03:20.951181+08:00 1 [Note] [MY-012887] [InnoDB] Setting log file ./ib_logfile1 size to 2048 MB 2021-01-23T22:03:20.952103+08:00 1 [Note] [MY-012651] [InnoDB] Progress in MB: 100 200 300 400 500 600 700 800 900 1000 1100 1200 1300 1400 1500 1600 1700 1800 1900 2000 2021-01-23T22:06:46.775773+08:00 1 [Note] [MY-012887] [InnoDB] Setting log file ./ib_logfile2 size to 2048 MB 2021-01-23T22:06:46.776165+08:00 1 [Note] [MY-012651] [InnoDB] Progress in MB: 100 200 300 400 500 600 700 800 900 1000 1100 1200 1300 1400 1500 1600 1700 1800 1900 2000 2021-01-23T22:10:12.584709+08:00 1 [Note] [MY-012887] [InnoDB] Setting log file ./ib_logfile3 size to 2048 MB 2021-01-23T22:10:12.585137+08:00 1 [Note] [MY-012651] [InnoDB] Progress in MB: 100 200 300 400 500 600 700 800 900 1000 1100 1200 1300 1400 1500 1600 1700 1800 1900 2000 2021-01-23T22:13:38.495334+08:00 1 [Note] [MY-012892] [InnoDB] Renaming log file ./ib_logfile101 to ./ib_logfile0 2021-01-23T22:13:38.495737+08:00 1 [Note] [MY-012893] [InnoDB] New log files created, LSN=16537961996 2021-01-23T22:13:38.496158+08:00 1 [Note] [MY-013086] [InnoDB] Starting to parse redo log at lsn = 16537961996, whereas checkpoint_lsn = 16537961996 2021-01-23T22:13:38.549654+08:00 1 [Note] [MY-013083] [InnoDB] Log background threads are being started... 2021-01-23T22:13:38.550174+08:00 1 [Note] [MY-012532] [InnoDB] Applying a batch of 0 redo log records ... 2021-01-23T22:13:38.550390+08:00 1 [Note] [MY-012535] [InnoDB] Apply batch completed! 2021-01-23T22:13:38.551744+08:00 1 [Note] [MY-013252] [InnoDB] Using undo tablespace './undo_001'. 2021-01-23T22:13:38.565849+08:00 1 [Note] [MY-013252] [InnoDB] Using undo tablespace './undo_002'. 2021-01-23T22:13:38.575598+08:00 1 [Note] [MY-012910] [InnoDB] Opened 2 existing undo tablespaces. 2021-01-23T22:13:38.575854+08:00 1 [Note] [MY-011980] [InnoDB] GTID recovery trx_no: 41865346 2021-01-23T22:13:40.031163+08:00 1 [Note] [MY-012923] [InnoDB] Creating shared tablespace for temporary tables 2021-01-23T22:13:40.031577+08:00 1 [Note] [MY-012265] [InnoDB] Setting file '/paic/my5518/data/ibtmp1' size to 64 MB. Physically writing the file full; Please wait ... 2021-01-23T22:13:46.460283+08:00 1 [Note] [MY-012266] [InnoDB] File '/var/mysql/data/ibtmp1' size is now 64 MB. 2021-01-23T22:13:46.460750+08:00 1 [Note] [MY-011825] [InnoDB] Scanning temp tablespace dir:'./#innodb_temp/' 2021-01-23T22:13:46.656390+08:00 1 [Note] [MY-013018] [InnoDB] Created 128 and tracked 128 new rollback segment(s) in the temporary tablespace. 128 are now active. 2021-01-23T22:13:46.656977+08:00 0 [Note] [MY-011953] [InnoDB] Page cleaner took 831546ms to flush 0 and evict 0 pages 2021-01-23T22:13:46.657715+08:00 1 [Note] [MY-012976] [InnoDB] 8.0.18 started; log sequence number 16537961996 2021-01-23T22:13:46.658113+08:00 1 [ERROR] [MY-013171] [InnoDB] Cannot boot server version 80018 on data directory built by version 80020. Downgrade is not supported mysqld: Can't open file: 'mysql.ibd' (errno: 0 - ) 2021-01-23T22:13:51.657471+08:00 1 [Note] [MY-012255] [InnoDB] Removed temporary tablespace data file: "ibtmp1" 2021-01-23T22:13:51.657863+08:00 1 [ERROR] [MY-010334] [Server] Failed to initialize DD Storage Engine 2021-01-23T22:13:51.658389+08:00 0 [ERROR] [MY-010020] [Server] Data Dictionary initialization failed. 2021-01-23T22:13:51.659092+08:00 0 [ERROR] [MY-010119] [Server] Aborting 2021-01-23T22:13:51.659155+08:00 0 [Note] [MY-010120] [Server] Binlog end 2021-01-23T22:13:51.659271+08:00 0 [Note] [MY-010733] [Server] Shutting down plugin 'MyISAM' 2021-01-23T22:13:51.659316+08:00 0 [Note] [MY-010733] [Server] Shutting down plugin 'InnoDB' 2021-01-23T22:13:51.659364+08:00 0 [Note] [MY-010733] [Server] Shutting down plugin 'CSV' 2021-01-23T22:13:51.662487+08:00 0 [System] [MY-010910] [Server] /var/mysql/8.0.18/bin/mysqld: Shutdown complete (mysqld 8.0.18) MySQL Community Server - GPL.
关键信息:
2021-01-23T22:13:46.658113+08:00 1 [ERROR] [MY-013171] [InnoDB] Cannot boot server version 80018 on data directory built by version 80020. Downgrade is not supported
mysqld: Can't open file: 'mysql.ibd' (errno: 0 - )