VPS侦探论坛

 找回密码
 注册
查看: 3920|回复: 2

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

[复制链接]
发表于 2020-8-4 17:00:31 | 显示全部楼层 |阅读模式

本帖最后由 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` 如下:

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

  5. cc1: out of memory allocating 65536 bytes after a total of 575221760 bytes
  6. 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
  7. make[2]: *** [storage/mroonga/vendor/groonga/lib/CMakeFiles/libgroonga.dir/expr.c.o] Error 1
  8. CMakeFiles/Makefile2:6534: recipe for target 'storage/mroonga/vendor/groonga/lib/CMakeFiles/libgroonga.dir/all' failed
  9. make[1]: *** [storage/mroonga/vendor/groonga/lib/CMakeFiles/libgroonga.dir/all] Error 2
  10. Makefile:162: recipe for target 'all' failed
  11. make: *** [all] Error 2
  12. include/upgrade_mysql2mariadb.sh: line 204: /usr/local/mariadb/scripts/mysql_install_db: No such file or directory
  13. Synchronizing state of mariadb.service with SysV service script with /lib/systemd/systemd-sysv-install.
  14. Executing: /lib/systemd/systemd-sysv-install enable mariadb
  15. Add mariadb service at system startup...
  16. Synchronizing state of mariadb.service with SysV service script with /lib/systemd/systemd-sysv-install.
  17. Executing: /lib/systemd/systemd-sysv-install enable mariadb
  18. Starting mariadb (via systemctl): mariadb.service.
  19. Restarting mariadb (via systemctl): mariadb.service.
  20. include/mariadb.sh: line 42: /usr/local/mariadb/bin/mysqladmin: No such file or directory
  21. Restarting mariadb (via systemctl): mariadb.service.
  22. include/main.sh: line 744: /usr/local/mysql/bin/mysql: No such file or directory
  23. failed, try other way...
  24. Restarting mariadb (via systemctl): mariadb.service.
  25. include/mariadb.sh: line 59: /usr/local/mariadb/bin/mysql: No such file or directory
  26. Set password failed!
  27. include/mariadb.sh: line 62: /usr/local/mariadb/bin/mysql: No such file or directory
  28. FLUSH PRIVILEGES failed!
  29. include/main.sh: line 744: /usr/local/mysql/bin/mysql: No such file or directory
  30. Update root password...
  31. include/main.sh: line 744: /usr/local/mysql/bin/mysql: No such file or directory
  32. ... Failed!
  33. Remove anonymous users...
  34. include/main.sh: line 744: /usr/local/mysql/bin/mysql: No such file or directory
  35. include/main.sh: line 744: /usr/local/mysql/bin/mysql: No such file or directory
  36. ... Failed!
  37. Disallow root login remotely...
  38. include/main.sh: line 744: /usr/local/mysql/bin/mysql: No such file or directory
  39. ... Failed!
  40. Remove test database...
  41. include/main.sh: line 744: /usr/local/mysql/bin/mysql: No such file or directory
  42. ... Failed!
  43. Reload privilege tables...
  44. include/main.sh: line 744: /usr/local/mysql/bin/mysql: No such file or directory
  45. ... Failed!
  46. Stopping mariadb (via systemctl): mariadb.service.
  47. Starting mariadb (via systemctl): mariadb.service.
  48. Restore backup databases...
  49. include/upgrade_mysql2mariadb.sh: line 214: /usr/local/mariadb/bin/mysql: No such file or directory
  50. MariaDB databases import failed,Please import databases manually!
  51. Repair databases...
  52. include/upgrade_mysql2mariadb.sh: line 218: /usr/local/mariadb/bin/mysql_upgrade: No such file or directory
  53. Add to autostart...
  54. Add mariadb service at system startup...
  55. Synchronizing state of mariadb.service with SysV service script with /lib/systemd/systemd-sysv-install.
  56. Executing: /lib/systemd/systemd-sysv-install enable mariadb
  57. Stopping MariaDB...
  58. Stopping mariadb (via systemctl): mariadb.service.
  59. +-------------------------------------------+
  60. |    Manager for LNMP, Written by Licess    |
  61. +-------------------------------------------+
  62. |              https://lnmp.org             |
  63. +-------------------------------------------+
  64. Starting LNMP...
  65. Starting nginx... nginx: [warn] the "ssl" directive is deprecated, use the "listen ... ssl" directive instead in /usr/local/nginx/conf/vhost/domian1.foo.conf:46
  66. nginx: [warn] the "ssl" directive is deprecated, use the "listen ... ssl" directive instead in /usr/local/nginx/conf/vhost/domain2.foo.conf:46
  67. done
  68. Starting mariadb (via systemctl): mariadb.service.
  69. Starting php-fpm  done
  70. ^[[0;31m======== upgrade MySQL to MariaDB failed ======^[[0m
  71. ^[[0;31mupgrade MariaDB log: /root/upgrade_mysql2mariadb.log^[[0m
  72. You upload upgrade_mysql2mariadb.log to LNMP Forum for help.
复制代码

之后我按 LNMP 1.2/1.3或更高版本升级Nginx、MySQL/MariaDB、PHP教程 一文中 “三、MySQL升级至MariaDB脚本” 小节中描述尝试恢复,按描述依次进行:
  1. # 1 将 /usr/local/mysql2mariadb日期目录下面的 init.d.mysql2mariadb.bak.日期的文件拷贝到 /etc/init.d/ 目录下并重命名为 mysql
  2. cp /usr/local/mysql2mariadb20200804132615/init.dmysql2mariadb.bak.20200804132615 /etc/init.d/mysql

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

  5. # 3 将 /usr/local/ 下的 mysql2mariadb日期目录重命名为 mysql
  6. cp /usr/local/mysql2mariadb20200804132615 /usr/local/mysql -r
复制代码


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

  7. Aug 04 16:20:03 ubuntu-wordpress systemd[1]: Starting LSB: start and stop MySQL...
  8. Aug 04 16:20:03 ubuntu-wordpress mysql[31998]: Starting MySQL
  9. Aug 04 16:20:04 ubuntu-wordpress mysql[31998]: . * The server quit without updating PID file (/usr/local/mysql/var/ubuntu-wordpress.pid).
  10. Aug 04 16:20:04 ubuntu-wordpress systemd[1]: mysql.service: Control process exited, code=exited status=1
  11. Aug 04 16:20:04 ubuntu-wordpress systemd[1]: mysql.service: Failed with result 'exit-code'.
  12. Aug 04 16:20:04 ubuntu-wordpress systemd[1]: Failed to start LSB: start and stop MySQL.
复制代码


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




美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
发表于 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[2]: *** [storage/mroonga/vendor/groonga/lib/CMakeFiles/libgroonga.dir/expr.c.o] Error 1
CMakeFiles/Makefile2:6534: recipe for target 'storage/mroonga/vendor/groonga/lib/CMakeFiles/libgroonga.dir/all' failed
make[1]: *** [storage/mroonga/vendor/groonga/lib/CMakeFiles/libgroonga.dir/all] Error 2
Makefile:162: recipe for target 'all' failed


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

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



你没提供具体升级到什么版本没法确定具体要求,首先需要系统版本满足条件、再就是内存要求,这个2个要求再“安装要求”上都有说明
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
 楼主| 发表于 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,内存占用也一直比较稳定,没有很高。

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

再次感谢军哥创建的工具以及无私而周到的指导!
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|Archiver|VPS侦探 ( 鲁ICP备16040043号-1 )

GMT+8, 2024-11-27 01:34 , Processed in 0.026202 second(s), 16 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表