亲爱的Stackers,您好!
我的 Debian 8 服务器VServer( 1GB Ram,CPU 2x1GHz )共享存在问题。的 MariaDB的即可。 我有三个需要继续运行的 Wordpress 安装,还有一个很少的其他网站。我无法弄清楚问题是什么,这种情况每隔几天发生一次,或者当一群客户端一次浏览Wordpress网站时。
我收到错误 Wordpress无法连接到数据库(因为数据库崩溃)。
我尝试了很多不同的东西,一个是禁用性能架构(=关闭),它不会改变任何东西。我还将 MySQL 更改为混合,这解决了一些警告(不确定是否有修复)。 Wordpress无法通过自动修复数据库来解决问题(未发现错误)。
提前致谢! :)
my.cnf的一部分:
(...)
max_connections = 100
connect_timeout = 5
wait_timeout = 600
max_allowed_packet = 16M
thread_cache_size = 128
sort_buffer_size = 4M
bulk_insert_buffer_size = 16M
tmp_table_size = 32M
max_heap_table_size = 32M
(...)
# * InnoDB
#
# InnoDB is enabled by default with a 10MB datafile in /var/lib/mysql/.
# Read the manual for more InnoDB related options. There are many!
default_storage_engine = InnoDB
# you can't just change log file size, requires special procedure
#innodb_log_file_size = 50M
innodb_buffer_pool_size = 256M
innodb_log_buffer_size = 8M
innodb_file_per_table = 1
innodb_open_files = 400
innodb_io_capacity = 400
innodb_flush_method = O_DIRECT
(...)
Journalctl
(...)
Apr 17 23:07:39 Debian-84-jessie-64-LAMP mysqld[618]: 2017-04-17 23:07:39 139847238380288 [Warning] Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe beca
Apr 17 23:20:33 Debian-84-jessie-64-LAMP mysqld[618]: 2017-04-17 23:20:33 139847221811968 [Warning] Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe beca
Apr 18 00:01:56 Debian-84-jessie-64-LAMP mysqld[618]: 2017-04-18 0:01:56 139847220599552 [Warning] Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe beca
Apr 18 00:07:46 Debian-84-jessie-64-LAMP systemd[1]: mariadb.service: main process exited, code=killed, status=9/KILL
Apr 18 00:07:46 Debian-84-jessie-64-LAMP systemd[1]: Unit mariadb.service entered failed state.
Apr 18 00:07:51 Debian-84-jessie-64-LAMP systemd[1]: mariadb.service holdoff time over, scheduling restart.
Apr 18 00:07:51 Debian-84-jessie-64-LAMP systemd[1]: Stopping MariaDB database server...
Apr 18 00:07:51 Debian-84-jessie-64-LAMP systemd[1]: Starting MariaDB database server...
Apr 18 00:07:51 Debian-84-jessie-64-LAMP mysqld[2956]: 2017-04-18 0:07:51 140160371898304 [Note] /usr/sbin/mysqld (mysqld 10.1.14-MariaDB-1~jessie) starting as process 2956 ...
Apr 18 00:07:52 Debian-84-jessie-64-LAMP mysqld[2956]: 2017-04-18 0:07:52 140160371898304 [Note] InnoDB: Using mutexes to ref count buffer pool pages
Apr 18 00:07:52 Debian-84-jessie-64-LAMP mysqld[2956]: 2017-04-18 0:07:52 140160371898304 [Note] InnoDB: The InnoDB memory heap is disabled
Apr 18 00:07:52 Debian-84-jessie-64-LAMP mysqld[2956]: 2017-04-18 0:07:52 140160371898304 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
Apr 18 00:07:52 Debian-84-jessie-64-LAMP mysqld[2956]: 2017-04-18 0:07:52 140160371898304 [Note] InnoDB: Memory barrier is not used
Apr 18 00:07:52 Debian-84-jessie-64-LAMP mysqld[2956]: 2017-04-18 0:07:52 140160371898304 [Note] InnoDB: Compressed tables use zlib 1.2.8
Apr 18 00:07:52 Debian-84-jessie-64-LAMP mysqld[2956]: 2017-04-18 0:07:52 140160371898304 [Note] InnoDB: Using Linux native AIO
Apr 18 00:07:52 Debian-84-jessie-64-LAMP mysqld[2956]: 2017-04-18 0:07:52 140160371898304 [Note] InnoDB: Using SSE crc32 instructions
Apr 18 00:07:52 Debian-84-jessie-64-LAMP mysqld[2956]: 2017-04-18 0:07:52 140160371898304 [Note] InnoDB: Initializing buffer pool, size = 256.0M
Apr 18 00:07:52 Debian-84-jessie-64-LAMP mysqld[2956]: InnoDB: mmap(276824064 bytes) failed; errno 12
Apr 18 00:07:52 Debian-84-jessie-64-LAMP mysqld[2956]: 2017-04-18 0:07:52 140160371898304 [ERROR] InnoDB: Cannot allocate memory for the buffer pool
Apr 18 00:07:52 Debian-84-jessie-64-LAMP mysqld[2956]: 2017-04-18 0:07:52 140160371898304 [ERROR] Plugin 'InnoDB' init function returned error.
Apr 18 00:07:52 Debian-84-jessie-64-LAMP mysqld[2956]: 2017-04-18 0:07:52 140160371898304 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
Apr 18 00:07:52 Debian-84-jessie-64-LAMP mysqld[2956]: 2017-04-18 0:07:52 140160371898304 [ERROR] mysqld: Out of memory (Needed 128663552 bytes)
Apr 18 00:07:52 Debian-84-jessie-64-LAMP mysqld[2956]: 2017-04-18 0:07:52 140160371898304 [Note] Plugin 'FEEDBACK' is disabled.
Apr 18 00:07:52 Debian-84-jessie-64-LAMP mysqld[2956]: 2017-04-18 0:07:52 140160371898304 [ERROR] Unknown/unsupported storage engine: InnoDB
Apr 18 00:07:52 Debian-84-jessie-64-LAMP mysqld[2956]: 2017-04-18 0:07:52 140160371898304 [ERROR] Aborting
Apr 18 00:07:52 Debian-84-jessie-64-LAMP systemd[1]: mariadb.service: main process exited, code=exited, status=1/FAILURE
Apr 18 00:07:52 Debian-84-jessie-64-LAMP systemd[1]: Failed to start MariaDB database server.
Apr 18 00:07:52 Debian-84-jessie-64-LAMP systemd[1]: Unit mariadb.service entered failed state.
(MANUALLY RESTARTED SERVER)
答案 0 :(得分:2)
这些天1 GB并不多。您仍然可以在1G主机上运行MariaDB 10.1,但是您需要对配置文件进行一些调整。
以下是如何减少MariaDB 服务器启动上的内存使用量的一些示例。
请注意,有不同的参数会影响客户端连接和查询执行时的内存使用情况,但是您的错误日志表明您在启动时遇到了问题。
请注意,并非所有这些变量都可以立即减少,并且您无法始终选择最小值。没有一对一的建议,这取决于您使用的引擎以及如何使用它们。检查您要调整的每个变量的文档,以了解它究竟对其产生的影响。
最后,由于您没有引用整个配置,因此您可能有其他一些实际上会增加内存使用量的选项。以下注释基于硬编码默认值。
这是我的10.1.21服务器在新的干净数据库上以所有默认值(无配置选项)启动:
所有默认选项
VIRT RES SHR COMMAND
747040 95108 14756 mysqld
它是以下所有内存使用示例的基线。
10.1中的默认值为128M。你把它增加到256M,所以你输了128M:
所有默认选项+ --innodb_buffer_pool_size=256M
VIRT RES SHR COMMAND
888608 104856 14820 mysqld
相反,您可以减少它,最小可能值为5M:
所有默认选项+ --innodb_buffer_pool_size=5M
VIRT RES SHR COMMAND
606752 85928 14848 mysqld
默认值为128M,最小值为128K:
所有默认选项+ --aria-pagecache-buffer-size=128K
VIRT RES SHR COMMAND
611872 90004 14932 mysqld
默认值为128M,最小值根据文档为8(虽然在我的机器上,4K以下的所有内容都调整为0 ):
所有默认选项+ --key_buffer_size=8
VIRT RES SHR COMMAND
611872 71264 14748 mysqld
默认值为16M,最小值为256K:
所有默认选项+ --innodb_log_buffer_size=256K
VIRT RES SHR COMMAND
718368 74980 14756 mysqld
你提到你已经将MySQL改为混合"并且它允许摆脱一些警告。显然,这意味着您设置了binlog_format=mixed
,并且您已启用log-bin
(默认情况下已禁用)。将二进制日志格式调整为MIXED
很好,但二进制日志记录本身使用了一些内存,即使在默认配置中也是如此:
所有默认选项+ --log-bin
VIRT RES SHR COMMAND
747312 95240 14820 mysqld
如果你不需要它,你可以禁用它,它会为你节省一点内存,并且会提高性能。
如果您根本不需要InnoDB,可以禁用它,它会为您节省大量内存:
所有默认选项+ --skip-innodb --default-storage-engine=MyISAM
VIRT RES SHR COMMAND
383948 55696 12668 mysqld
所以,假设,如果你一次完成所有这些(你应该不!),你可以显着减少初始内存分配:
所有默认选项+ --aria-pagecache-buffer-size=128K --innodb_log_buffer_size=256K --key_buffer_size=8 --innodb_buffer_pool_size=5M --skip-innodb --default-storage-engine=MyISAM
VIRT RES SHR COMMAND
113612 26572 12784 mysqld