无法为缓冲池

时间:2016-09-10 15:31:47

标签: mysql mysql-error-1064 centos7

启动Mysql时,我们面临一个非常严重的问题。 我们正在使用数字海洋。

Droplet
RAM = 8GB 
CPU = 4Core
Mysql Version = 5.6

在my.cnf

    [mysql]
    # CLIENT #
    port                           = 3306
    socket                         = /var/lib/mysql/mysql.sock

    [mysqld]
    max_connections                = 300
    open_files_limit               = 1024000
    #interactive_timeout           = 30
    #wait_timeout              = 30
    # GENERAL #
    user                           = mysql
    default-storage-engine         = InnoDB
    socket                         = /var/lib/mysql/mysql.sock
    pid-file                       = /var/lib/mysql/mysql.pid

    # MyISAM #
    key-buffer-size                = 64M
    myisam-recover                 = FORCE,BACKUP

    # SAFETY #
    max-allowed-packet             = 16M
    max-connect-errors             = 1000000
    skip-name-resolve
    sysdate-is-now                 = 1
    innodb                         = FORCE

    # DATA STORAGE #
    datadir                        = /var/lib/mysql/

    # BINARY LOGGING #
    log-bin                        = /var/lib/mysql/mysql-bin
    expire_logs_days               = 10
    #expire-logs-days              = 14
    sync_binlog                    = 1

    # CACHES AND LIMITS #
    tmp-table-size                 = 500M
    max-heap-table-size            = 500M
    query-cache-type               = 0
    query-cache-size               = 64M
    #max-connections                = 300
    thread-cache-size              = 50
    #open_files_limit               = 65535
    table-definition-cache         = 1024M
    table_open_cache               = 600

    # INNODB #
    innodb-flush-method            = O_DIRECT
    innodb-log-files-in-group      = 2
    innodb-log-file-size           = 64M
    innodb-flush-log-at-trx-commit = 1
    innodb-file-per-table          = 1
    innodb-buffer-pool-size        = 12000M
    innodb-buffer-pool-instances   = 1
    join_buffer_size               = 6M

    # LOGGING #
    log-error                      = /var/lib/mysql/mysql-error.log
    log-queries-not-using-indexes  = 1
    slow-query-log                 = 1
    slow-query-log-file            = /var/lib/mysql/mysql-slow.log
    long-query-time            = 5
    log-queries-not-using-indexes

我们可以毫无错误地启动Mysql。

但是当我们将现有的Droplet从8Gb RAM和4个CPU调整为16GB和8个CPU并且没有对my.cnf进行任何更改但是无法启动MYSQL时。

在启动MySql期间,它消耗所有内存16GB RAM和5GB交换。

显示错误。

160910 18:15:03 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql/
    2016-09-10 18:15:32 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
    2016-09-10 18:15:32 0 [Note] /usr/sbin/mysqld (mysqld 5.6.31-log) starting as process 14643 ...
    2016-09-10 18:15:32 14643 [Warning] Buffered warning: option 'table_definition_cache': unsigned value 1073741824 adjusted to 524288

    2016-09-10 18:15:32 14643 [Warning] Buffered warning: Could not increase number of max_open_files to more than 1024 (request: 1024000)

2016-09-10 18:15:32 14643 [Warning] Buffered warning: Changed limits: max_connections: 214 (requested 300)

2016-09-10 18:15:32 14643 [Warning] Buffered warning: Changed limits: table_open_cache: 400 (requested 600)

2016-09-10 18:15:32 14643 [Warning] Using unique option prefix myisam-recover instead of myisam-recover-options is deprecated and will be removed in a future release. Please use the full name instead.
2016-09-10 18:15:32 14643 [Note] Plugin 'FEDERATED' is disabled.
2016-09-10 18:15:32 14643 [Warning] The option innodb (skip-innodb) is deprecated and will be removed in a future release
2016-09-10 18:15:32 14643 [Note] InnoDB: Using atomics to ref count buffer pool pages
2016-09-10 18:15:32 14643 [Note] InnoDB: The InnoDB memory heap is disabled
2016-09-10 18:15:32 14643 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2016-09-10 18:15:32 14643 [Note] InnoDB: Memory barrier is not used
2016-09-10 18:15:32 14643 [Note] InnoDB: Compressed tables use zlib 1.2.3
2016-09-10 18:15:32 14643 [Note] InnoDB: Using Linux native AIO
2016-09-10 18:15:32 14643 [Note] InnoDB: Using CPU crc32 instructions
2016-09-10 18:15:32 14643 [Note] InnoDB: Initializing buffer pool, size = 7.8G
InnoDB: mmap(8585216000 bytes) failed; errno 12
2016-09-10 18:15:32 14643 [ERROR] InnoDB: Cannot allocate memory for the buffer pool
2016-09-10 18:15:32 14643 [ERROR] Plugin 'InnoDB' init function returned error.
2016-09-10 18:15:32 14643 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
2016-09-10 18:15:32 14643 [ERROR] Failed to initialize plugins.
2016-09-10 18:15:32 14643 [ERROR] Aborting
2016-09-10 18:15:32 14643 [Note] Binlog end
2016-09-10 18:15:32 14643 [Note] Shutting down plugin 'partition'
2016-09-10 18:15:32 14643 [Note] Shutting down plugin 'PERFORMANCE_SCHEMA'
2016-09-10 18:15:32 14643 [Note] Shutting down plugin 'INNODB_SYS_DATAFILES'
2016-09-10 18:15:32 14643 [Note] Shutting down plugin 'INNODB_SYS_TABLESPACES'
2016-09-10 18:15:32 14643 [Note] Shutting down plugin 'INNODB_SYS_FOREIGN_COLS'
2016-09-10 18:15:32 14643 [Note] Shutting down plugin 'INNODB_SYS_FOREIGN'
2016-09-10 18:15:32 14643 [Note] Shutting down plugin 'INNODB_SYS_FIELDS'
2016-09-10 18:15:32 14643 [Note] Shutting down plugin 'INNODB_SYS_COLUMNS'
2016-09-10 18:15:32 14643 [Note] Shutting down plugin 'INNODB_SYS_INDEXES'
2016-09-10 18:15:32 14643 [Note] Shutting down plugin 'INNODB_SYS_TABLESTATS'
2016-09-10 18:15:32 14643 [Note] Shutting down plugin 'INNODB_SYS_TABLES'
2016-09-10 18:15:32 14643 [Note] Shutting down plugin 'INNODB_FT_INDEX_TABLE'
2016-09-10 18:15:32 14643 [Note] Shutting down plugin 'INNODB_FT_INDEX_CACHE'
2016-09-10 18:15:32 14643 [Note] Shutting down plugin 'INNODB_FT_CONFIG'
2016-09-10 18:15:32 14643 [Note] Shutting down plugin 'INNODB_FT_BEING_DELETED'
2016-09-10 18:15:32 14643 [Note] Shutting down plugin 'INNODB_FT_DELETED'
2016-09-10 18:15:32 14643 [Note] Shutting down plugin 'INNODB_FT_DEFAULT_STOPWORD'
2016-09-10 18:15:32 14643 [Note] Shutting down plugin 'INNODB_METRICS'
2016-09-10 18:15:32 14643 [Note] Shutting down plugin 'INNODB_BUFFER_POOL_STATS'
2016-09-10 18:15:32 14643 [Note] Shutting down plugin 'INNODB_BUFFER_PAGE_LRU'
2016-09-10 18:15:32 14643 [Note] Shutting down plugin 'INNODB_BUFFER_PAGE'
2016-09-10 18:15:32 14643 [Note] Shutting down plugin 'INNODB_CMP_PER_INDEX_RESET'
2016-09-10 18:15:32 14643 [Note] Shutting down plugin 'INNODB_CMP_PER_INDEX'
2016-09-10 18:15:32 14643 [Note] Shutting down plugin 'INNODB_CMPMEM_RESET'
2016-09-10 18:15:32 14643 [Note] Shutting down plugin 'INNODB_CMPMEM'
2016-09-10 18:15:32 14643 [Note] Shutting down plugin 'INNODB_CMP_RESET'
2016-09-10 18:15:32 14643 [Note] Shutting down plugin 'INNODB_CMP'
2016-09-10 18:15:32 14643 [Note] Shutting down plugin 'INNODB_LOCK_WAITS'
2016-09-10 18:15:32 14643 [Note] Shutting down plugin 'INNODB_LOCKS'
2016-09-10 18:15:32 14643 [Note] Shutting down plugin 'INNODB_TRX'
2016-09-10 18:15:32 14643 [Note] Shutting down plugin 'BLACKHOLE'
2016-09-10 18:15:32 14643 [Note] Shutting down plugin 'ARCHIVE'
2016-09-10 18:15:32 14643 [Note] Shutting down plugin 'MRG_MYISAM'
2016-09-10 18:15:32 14643 [Note] Shutting down plugin 'MyISAM'
2016-09-10 18:15:32 14643 [Note] Shutting down plugin 'MEMORY'
2016-09-10 18:15:32 14643 [Note] Shutting down plugin 'CSV'
2016-09-10 18:15:32 14643 [Note] Shutting down plugin 'sha256_password'
2016-09-10 18:15:32 14643 [Note] Shutting down plugin 'mysql_old_password'
2016-09-10 18:15:32 14643 [Note] Shutting down plugin 'mysql_native_password'
2016-09-10 18:15:32 14643 [Note] Shutting down plugin 'binlog'
2016-09-10 18:15:32 14643 [Note] /usr/sbin/mysqld: Shutdown complete
160910 18:15:33 mysqld_safe mysqld from pid file /var/lib/mysql/mysql.pid ended

我无法理解为什么mysql无法启动,即使任何设置都没有变化。

我有5GB的Swap内存。

根据我的说法,我认为它与DigitalOcean相同配置的问题是在8GB ram上工作,但它不适用于16Gb RAM,但他们声称16GB Droplet没有问题。

Free -m在启动MySQL之前说

 total        used        free      shared  buff/cache   available
Mem:          16047         122       15843           1          81       15792
Swap:          2047          38        2009
Total:        18095         160       17853

uname -a

3.10.0-327.10.1.el7.x86_64 #1 SMP Tue Feb 16 17:03:50 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux

另外我要提到的是,我们只安装了mysql,没有其他服务。

请帮助解决问题。

由于

1 个答案:

答案 0 :(得分:-1)

问题是Apache服务器不是mysql,实际上你需要将innodb-buffer-pool-size减少到大约300M

你从一开始就拥有mysql进程使用的1.2Gb + RAM,当Apache需要更多资源时,内核将从服务中清除RAM,这意味着停止mysql而不是崩溃服务器。

如果您不想更改为nginx或lighttp,还会添加一个CRON来检查db状态并重新启动它。