我在RackSpace上的CentOS 6.6和MySQL版本5.5.40上安装并运行了MySQL。运行大量查询时,我总是遇到这个错误。
以下是my.cnf
[mysqld]
2 datadir=/mnt/data/mysql
3 tmpdir=/mnt/data/temp
4 socket=/var/lib/mysql/mysql.sock
5 bind-address=0.0.0.0
6 port=3306
7 wait_timeout=432000
8 max_allowed_packet=1G
9 max_connections=500
10 query-cache-size=0
11 query-cache-type=0
12 #query_cache_size=64M
13 #query_cache_limit=64M
14 key_buffer_size=1G
15 sort_buffer_size=16M
16 tmp_table_size=32M
17 max_heap_table_size=32M
18 read_buffer_size=512K
19 read_rnd_buffer_size=512K
20 thread_cache_size=50
21
22 innodb_buffer_pool_size=12G
23 innodb_buffer_pool_instance=2
24 innodb_read_io_threads=12
25 innodb_write_io_threads=12
26 innodb_io_capacity=300
27 innodb_log_file_size=128M
28 innodb_thread_concurrency=0
这是我在崩溃后遇到的错误日志:
150820 13:46:26 mysqld_safe Number of processes running now: 0
150820 13:46:26 mysqld_safe mysqld restarted
150820 13:46:26 [Note] Plugin 'FEDERATED' is disabled.
150820 13:46:26 [Warning] Using unique option prefix innodb_buffer_pool_instance instead of innodb-buffer-pool-instances is deprecated and will be removed in a future release. Please use the full name instead.
150820 13:46:26 InnoDB: The InnoDB memory heap is disabled
150820 13:46:26 InnoDB: Mutexes and rw_locks use GCC atomic builtins
150820 13:46:26 InnoDB: Compressed tables use zlib 1.2.3
150820 13:46:26 InnoDB: Using Linux native AIO
150820 13:46:26 InnoDB: Initializing buffer pool, size = 12.0G
InnoDB: mmap(6593445888 bytes) failed; errno 12
150820 13:46:27 InnoDB: Completed initialization of buffer pool
150820 13:46:27 InnoDB: Fatal error: cannot allocate memory for the buffer pool
150820 13:46:27 [ERROR] Plugin 'InnoDB' init function returned error.
150820 13:46:27 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
150820 13:46:27 [ERROR] Unknown/unsupported storage engine: InnoDB
150820 13:46:27 [ERROR] Aborting
150820 13:46:27 [Note] /usr/libexec/mysqld: Shutdown complete
150820 13:46:27 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended
编辑:
RackSpace VM的规格是:
CPU:Intel(R)Xeon(R)CPU E5-2670 0 @ 2.60GHz 内存:8GB
答案 0 :(得分:1)
您的服务器只有8 GB RAM,并且您已经为mysql分配了太多ram。
即使您需要更改许多变量的配置,但首先要解决您的问题,请执行以下更改 -
innodb_buffer_pool_instance = 2#暂时告知我们以后可以设置它。
innodb_buffer_pool_size = 6G
key_buffer_size = 20M#如果您的服务器是innodb,但如果您还使用myisam表,请保持原样。
sort_buffer_size = 2M#我们可以稍后更改。
read_buffer_size = 512K#暂时评论它。
read_rnd_buffer_size = 512K #comment it for time of each session in
tmp_table_size = 1G#这可能是你问题的原因所以增加它。
max_heap_table_size = 1G#这可能是你问题的原因所以增加它。
如果可能的话,每个连接使用服务器资源时,将max_connections从500减少到400。
尝试并分享结果。
答案 1 :(得分:0)
如果它有用,这就是我解决这个问题的方法。在我的例子中,问题是由于查询对于发送到服务器的数据包来说太大了。
对服务器运行以下命令后,大型查询处理正常
SET GLOBAL max_allowed_packet=1073741824;