pessoa 发表于 2020-8-4 17:00:31

MySQL升级至MariaDB失败,尝试恢复失败 (附log)

本帖最后由 pessoa 于 2020-8-4 17:10 编辑

军哥好!
今天我用 `upgrade1.x-1.7.sh` 脚本将 lnmp 1.5 升级至 lnmp 1.7,成功后又用 lnmp 1.7 的 `upgrade.sh` 脚本升级了 PHP for LNMP 和 Nginx,都成功了。

随后尝试将 MySQL 升级为 MariaDB,升级失败。升级日志 `upgrade_mysql2mariadb20200804132615.log` 如下:

[ 58%] Built target trnman-t
[ 58%] Built target ma_pagecache_single_8k-t
[ 58%] Built target ma_pagecache_single_64k-t
[ 58%] Building C object storage/mroonga/vendor/groonga/lib/CMakeFiles/libgroonga.dir/expr.c.o

cc1: out of memory allocating 65536 bytes after a total of 575221760 bytes
storage/mroonga/vendor/groonga/lib/CMakeFiles/libgroonga.dir/build.make:374: recipe for target 'storage/mroonga/vendor/groonga/lib/CMakeFiles/libgroonga.dir/expr.c.o' failed
make: *** Error 1
CMakeFiles/Makefile2:6534: recipe for target 'storage/mroonga/vendor/groonga/lib/CMakeFiles/libgroonga.dir/all' failed
make: *** Error 2
Makefile:162: recipe for target 'all' failed
make: *** Error 2
include/upgrade_mysql2mariadb.sh: line 204: /usr/local/mariadb/scripts/mysql_install_db: No such file or directory
Synchronizing state of mariadb.service with SysV service script with /lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install enable mariadb
Add mariadb service at system startup...
Synchronizing state of mariadb.service with SysV service script with /lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install enable mariadb
Starting mariadb (via systemctl): mariadb.service.
Restarting mariadb (via systemctl): mariadb.service.
include/mariadb.sh: line 42: /usr/local/mariadb/bin/mysqladmin: No such file or directory
Restarting mariadb (via systemctl): mariadb.service.
include/main.sh: line 744: /usr/local/mysql/bin/mysql: No such file or directory
failed, try other way...
Restarting mariadb (via systemctl): mariadb.service.
include/mariadb.sh: line 59: /usr/local/mariadb/bin/mysql: No such file or directory
Set password failed!
include/mariadb.sh: line 62: /usr/local/mariadb/bin/mysql: No such file or directory
FLUSH PRIVILEGES failed!
include/main.sh: line 744: /usr/local/mysql/bin/mysql: No such file or directory
Update root password...
include/main.sh: line 744: /usr/local/mysql/bin/mysql: No such file or directory
... Failed!
Remove anonymous users...
include/main.sh: line 744: /usr/local/mysql/bin/mysql: No such file or directory
include/main.sh: line 744: /usr/local/mysql/bin/mysql: No such file or directory
... Failed!
Disallow root login remotely...
include/main.sh: line 744: /usr/local/mysql/bin/mysql: No such file or directory
... Failed!
Remove test database...
include/main.sh: line 744: /usr/local/mysql/bin/mysql: No such file or directory
... Failed!
Reload privilege tables...
include/main.sh: line 744: /usr/local/mysql/bin/mysql: No such file or directory
... Failed!
Stopping mariadb (via systemctl): mariadb.service.
Starting mariadb (via systemctl): mariadb.service.
Restore backup databases...
include/upgrade_mysql2mariadb.sh: line 214: /usr/local/mariadb/bin/mysql: No such file or directory
MariaDB databases import failed,Please import databases manually!
Repair databases...
include/upgrade_mysql2mariadb.sh: line 218: /usr/local/mariadb/bin/mysql_upgrade: No such file or directory
Add to autostart...
Add mariadb service at system startup...
Synchronizing state of mariadb.service with SysV service script with /lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install enable mariadb
Stopping MariaDB...
Stopping mariadb (via systemctl): mariadb.service.
+-------------------------------------------+
|    Manager for LNMP, Written by Licess    |
+-------------------------------------------+
|            https://lnmp.org             |
+-------------------------------------------+
Starting LNMP...
Starting nginx... nginx: the "ssl" directive is deprecated, use the "listen ... ssl" directive instead in /usr/local/nginx/conf/vhost/domian1.foo.conf:46
nginx: the "ssl" directive is deprecated, use the "listen ... ssl" directive instead in /usr/local/nginx/conf/vhost/domain2.foo.conf:46
done
Starting mariadb (via systemctl): mariadb.service.
Starting php-fpmdone
^[[0;31m======== upgrade MySQL to MariaDB failed ======^[[0m
^[[0;31mupgrade MariaDB log: /root/upgrade_mysql2mariadb.log^[[0m
You upload upgrade_mysql2mariadb.log to LNMP Forum for help.
之后我按 LNMP 1.2/1.3或更高版本升级Nginx、MySQL/MariaDB、PHP教程 一文中 “三、MySQL升级至MariaDB脚本” 小节中描述尝试恢复,按描述依次进行:# 1 将 /usr/local/mysql2mariadb日期目录下面的 init.d.mysql2mariadb.bak.日期的文件拷贝到 /etc/init.d/ 目录下并重命名为 mysql
cp /usr/local/mysql2mariadb20200804132615/init.dmysql2mariadb.bak.20200804132615 /etc/init.d/mysql

# 2 将 /usr/local/mysql2mariadb日期目录下面的 my.cnf.mysql2mariadbbak.日期拷贝到 /etc/ 目录下并重命名为 my.cnf
cp /usr/local/mysql2mariadb20200804132615/my.cnf.mysql2mariadbbak.20200804132615 /etc/my.cnf

# 3 将 /usr/local/ 下的 mysql2mariadb日期目录重命名为 mysql
cp /usr/local/mysql2mariadb20200804132615 /usr/local/mysql -r

随后尝试用 systemctl 启动 mysql,失败:➜~ systemctl status mysql.service
● mysql.service - LSB: start and stop MySQL
   Loaded: loaded (/etc/init.d/mysql; generated)
   Active: failed (Result: exit-code) since Tue 2020-08-04 16:20:04 CST; 38min ago
   Docs: man:systemd-sysv-generator(8)
Process: 31998 ExecStart=/etc/init.d/mysql start (code=exited, status=1/FAILURE)

Aug 04 16:20:03 ubuntu-wordpress systemd: Starting LSB: start and stop MySQL...
Aug 04 16:20:03 ubuntu-wordpress mysql: Starting MySQL
Aug 04 16:20:04 ubuntu-wordpress mysql: . * The server quit without updating PID file (/usr/local/mysql/var/ubuntu-wordpress.pid).
Aug 04 16:20:04 ubuntu-wordpress systemd: mysql.service: Control process exited, code=exited status=1
Aug 04 16:20:04 ubuntu-wordpress systemd: mysql.service: Failed with result 'exit-code'.
Aug 04 16:20:04 ubuntu-wordpress systemd: Failed to start LSB: start and stop MySQL.

我现在想完成从 MySQL 至 MariaDB 的切换,请问我应该怎么做?




licess 发表于 2020-8-5 08:33:59

cc1: out of memory allocating 65536 bytes after a total of 575221760 bytes
storage/mroonga/vendor/groonga/lib/CMakeFiles/libgroonga.dir/build.make:374: recipe for target 'storage/mroonga/vendor/groonga/lib/CMakeFiles/libgroonga.dir/expr.c.o' failed
make: *** Error 1
CMakeFiles/Makefile2:6534: recipe for target 'storage/mroonga/vendor/groonga/lib/CMakeFiles/libgroonga.dir/all' failed
make: *** Error 2
Makefile:162: recipe for target 'all' failed

按你发的这部分日志,是内存不足导致的升级失败,升级mysql或mariadb版本越高对内存要求也越高

mysql恢复过程cp命令使用有误,cp命令必须加上 -a 保留原权限、属主属组信息,-r 删掉
mysql无法启动需要查看mysql日志才能确定具体原因



你没提供具体升级到什么版本没法确定具体要求,首先需要系统版本满足条件、再就是内存要求,这个2个要求再“安装要求”上都有说明

pessoa 发表于 2020-8-5 13:21:49

licess 发表于 2020-8-5 08:33
按你发的这部分日志,是内存不足导致的升级失败,升级mysql或mariadb版本越高对内存要求也越高

mysql恢 ...

多谢军哥!

我删除之前恢复的文件后重新用 `cp -a` 搞了一遍,再用 `systemctl start mysql.service` 成功启动了 mysql。WordPress 网页访问恢复了正常。

接着设置了 2G 的 Swapfile,再次进行 MySQL 到 MariaDB 的升级,是从 5.5.x 版本的 MySQL 到 10.3.23 版本的 MariaDB。这一次升级成功了。这次升级期间我时不时用 `htop` 看内存占用,发现这次 Swapfile 好像也就用了几十 M,内存占用也一直比较稳定,没有很高。 :lol

之前看了系统需求中说 “安装 MySQL 5.6或5.7及 MariaDB 10必须1G以上内存,更高版本至少要2G内存!。”,而我的 VPS 的内存是 1G,想升级到的 MariaDB 版本是 10.3.23,不知道算不算满足 “MariaDB 10必须1G以上内存”,就在创建 VPS 快照后试试了。

再次感谢军哥创建的工具以及无私而周到的指导!
页: [1]
查看完整版本: MySQL升级至MariaDB失败,尝试恢复失败 (附log)