首页 > 解决方案 > Worpress(真的)自托管:mysql问题

问题描述

我制作了一个 Wordpress 网站,首先由 Flywheel 在本地托管。

我正在尝试使用个人服务器(运行 ubuntu 18.04)完全自托管它,而不是使用一些在线 ftp。我没有在网上找到关于如何做到这一点的文档,只有那些试图用现成的 Wordpress 环境出售他们的 ftp 服务的人......我设法安装了一些东西,当我输入静态 IP 地址时网站,它有效!

问题:

一段时间后,出现这样的消息:Error while trying to connect to the database并且网站已关闭。

如果我/etc/init.d/mysql start再次运行,该网站将再次运行!30 分钟后,它再次中断,显示上面的消息......

这就是我所做的:

我使用 Duplicator 制作了网站的图像,并将其传输到服务器。我已经安装了:

我的登录名wp-config.php是正确的

你能帮我吗 ?


失败的事情:

Failed to reload mysql.service: Job type reload is not applicable for unit mysql.service.
See system logs and 'systemctl status mysql.service' for details.
Job for mysql.service failed because the control process exited with error code.
See "systemctl status mysql.service" and "journalctl -xe" for details.
mysql.service - MySQL Community Server
   Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Wed 2020-04-22 10:07:23 UTC; 24min ago
  Process: 10681 ExecStart=/usr/sbin/mysqld —daemonize —pid-file=/run/mysqld/mysqld.pid (code=exited, status=1/FAILURE)
  Process: 10659 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
 Main PID: 10433 (code=exited, status=0/SUCCESS)

Apr 22 10:07:23 ewenvm systemd[1]: mysql.service: Failed with result 'exit-code'.
Apr 22 10:07:23 ewenvm systemd[1]: Failed to start MySQL Community Server.
Apr 22 10:07:23 ewenvm systemd[1]: mysql.service: Service hold-off time over, scheduling restart.
Apr 22 10:07:23 ewenvm systemd[1]: mysql.service: Scheduled restart job, restart counter is at 5.
Apr 22 10:07:23 ewenvm systemd[1]: Stopped MySQL Community Server.
Apr 22 10:07:23 ewenvm systemd[1]: mysql.service: Start request repeated too quickly.
Apr 22 10:07:23 ewenvm systemd[1]: mysql.service: Failed with result 'exit-code'.
Apr 22 10:07:23 ewenvm systemd[1]: Failed to start MySQL Community Server.
— Support: http://www.ubuntu.com/support
— 
— Unit mysql.service has failed.
— 
— The result is RESULT.
Apr 22 10:07:23 name-of-my-server systemd[1]: mysql.service: Service hold-off time over, scheduling restart.
Apr 22 10:07:23 name-of-my-server systemd[1]: mysql.service: Scheduled restart job, restart counter is at 5.
— Subject: Automatic restarting of a unit has been scheduled
— Defined-By: systemd
— Support: http://www.ubuntu.com/support
— 
— Automatic restarting of the unit mysql.service has been scheduled, as the result for
— the configured Restart= setting for the unit.
Apr 22 10:07:23 name-of-my-server systemd[1]: Stopped MySQL Community Server.
— Subject: Unit mysql.service has finished shutting down
— Defined-By: systemd
— Support: http://www.ubuntu.com/support
— 
— Unit mysql.service has finished shutting down.
Apr 22 10:07:23 name-of-my-server systemd[1]: mysql.service: Start request repeated too quickly.
Apr 22 10:07:23 name-of-my-server systemd[1]: mysql.service: Failed with result 'exit-code'.
Apr 22 10:07:23 name-of-my-server systemd[1]: Failed to start MySQL Community Server.
— Subject: Unit mysql.service has failed
— Defined-By: systemd
— Support: http://www.ubuntu.com/support
— 
— Unit mysql.service has failed.
— 
— The result is RESULT.
Apr 22 10:09:01 name-of-my-server CRON[10701]: pam_unix(cron:session): session opened for user root by (uid=0)
Apr 22 10:09:01 name-of-my-server CRON[10702]: (root) CMD (  [ -x /usr/lib/php/sessionclean ] && if [ ! -d /run/systemd/system ]; then /usr/lib/php/sessionclean; fi)
Apr 22 10:09:01 name-of-my-server CRON[10701]: pam_unix(cron:session): session closed for user root
Apr 22 10:09:03 name-of-my-server systemd[1]: Starting Clean php session files...
— Subject: Unit phpsessionclean.service has begun start-up
— Defined-By: systemd
— Support: http://www.ubuntu.com/support
— 
— Unit phpsessionclean.service has begun starting up.
Apr 22 10:09:04 name-of-my-server systemd[1]: Started Clean php session files.
— Subject: Unit phpsessionclean.service has finished start-up
— Defined-By: systemd
— Support: http://www.ubuntu.com/support
— 
— Unit phpsessionclean.service has finished starting up.
— 
— The start-up result is RESULT.
Apr 22 10:13:11 name-of-my-server sshd[10770]: Did not receive identification string from 182.182.22.159 port 52155
Apr 22 10:15:31 name-of-my-server systemd-timesyncd[2721]: Timed out waiting for reply from 91.189.89.199:123 (ntp.ubuntu.com).
Apr 22 10:15:41 name-of-my-server systemd-timesyncd[2721]: Timed out waiting for reply from 91.189.89.198:123 (ntp.ubuntu.com).
Apr 22 10:15:51 name-of-my-server systemd-timesyncd[2721]: Timed out waiting for reply from 91.189.91.157:123 (ntp.ubuntu.com).
Apr 22 10:16:01 name-of-my-server systemd-timesyncd[2721]: Timed out waiting for reply from 91.189.94.4:123 (ntp.ubuntu.com).
Apr 22 10:17:01 name-of-my-server CRON[10779]: pam_unix(cron:session): session opened for user root by (uid=0)
Apr 22 10:17:01 name-of-my-server CRON[10780]: (root) CMD (   cd / && run-parts —report /etc/cron.hourly)
Apr 22 10:17:01 name-of-my-server CRON[10779]: pam_unix(cron:session): session closed for user root

以下是登录信息/var/log/mysql/error/log

2020-04-22T09:46:51.409203Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use —explicit_defaults_for_timestamp server option (see documentation for more details).
2020-04-22T09:46:51.413886Z 0 [Note] /usr/sbin/mysqld (mysqld 5.7.29-0ubuntu0.18.04.1) starting as process 10312 ...
2020-04-22T09:46:51.480012Z 0 [Note] InnoDB: PUNCH HOLE support available
2020-04-22T09:46:51.480056Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2020-04-22T09:46:51.480062Z 0 [Note] InnoDB: Uses event mutexes
2020-04-22T09:46:51.480079Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
2020-04-22T09:46:51.480086Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
2020-04-22T09:46:51.480091Z 0 [Note] InnoDB: Using Linux native AIO
2020-04-22T09:46:51.480890Z 0 [Note] InnoDB: Number of pools: 1
2020-04-22T09:46:51.481899Z 0 [Note] InnoDB: Using CPU crc32 instructions
2020-04-22T09:46:51.487169Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
2020-04-22T09:46:51.490733Z 0 [ERROR] InnoDB: mmap(137428992 bytes) failed; errno 12
2020-04-22T09:46:51.490760Z 0 [ERROR] InnoDB: Cannot allocate memory for the buffer pool
2020-04-22T09:46:51.490768Z 0 [ERROR] InnoDB: Plugin initialization aborted with error Generic error
2020-04-22T09:46:51.490778Z 0 [ERROR] Plugin 'InnoDB' init function returned error.
2020-04-22T09:46:51.492322Z 0 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
2020-04-22T09:46:51.492337Z 0 [ERROR] Failed to initialize builtin plugins.
2020-04-22T09:46:51.492342Z 0 [ERROR] Aborting

2020-04-22T09:46:51.494236Z 0 [Note] Binlog end
2020-04-22T09:46:51.495643Z 0 [Note] Shutting down plugin 'CSV'
2020-04-22T09:46:51.508165Z 0 [Note] /usr/sbin/mysqld: Shutdown complete

标签: phpmysqlwordpress

解决方案


这很奇怪。安装在 Ubuntu 上sudo apt install mysql-server的 MySQL 通常是防弹的。

当我阅读您的错误日志时,这是您失败的根本原因。

2020-04-22T09:46:51.490733Z 0 [ERROR] InnoDB: mmap(137 428 992 bytes) failed; errno 12

当 MySQL(特别是 InnoDB“访问方法”)启动时,它无法将 137 兆字节的内存映射到文件系统中的文件。

Do you have enough RAM on your Ubuntu instance? Is the disk or SSD almost full? If you have a separate disk partition for your /tmp directory is it big enough? (Avoid RAMDISK for /tmp when you're running MySQL.) Does it have other heavy applications running on it?

If this were my project and I was working with a VM, I would erase it and start over at this point.

I'm a big fan of Digital Ocean's step by step tutorials. I know they're a server-rental company, but their tutorials work for local installs too. https://www.digitalocean.com/community/tutorials/how-to-install-wordpress-with-lamp-on-ubuntu-18-04


推荐阅读