V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
magicdu
V2EX  ›  问与答

阿里云 wordpress 博客从移动端访问 mysql 数据库就会挂掉

  •  
  •   magicdu · 2017-01-06 10:00:51 +08:00 · 2496 次点击
    这是一个创建于 2914 天前的主题,其中的信息可能已经有所发展或是发生改变。

    先说服务器:

    阿里云的 centos7x86_64 +nginx+php-fpm+mysql5.6

    1GB 内存

    博客用的 wordpress

    每次从手机浏览器里访问博客完 mysql 就挂了 监测了内存占用,发现 mysqld 占用的内存飙升, php-fpm 内存飙升

    然后重启 mysql 失败了

    service mysqld restart
    MySQL server PID file could not be found!                  [FAILED]
    Starting MySQL.The server quit without updating PID file (/alidata/server/mysql/data/iZ28o516t2sZ.pid).                                                    [FAILED]
    

    下面是 MySQL 的日志:

    2017-01-06 09:45:56 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
    2017-01-06 09:45:57 16722 [Note] Plugin 'FEDERATED' is disabled.
    2017-01-06 09:45:57 16722 [Note] InnoDB: Using atomics to ref count buffer pool pages
    2017-01-06 09:45:57 16722 [Note] InnoDB: The InnoDB memory heap is disabled
    2017-01-06 09:45:57 16722 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
    2017-01-06 09:45:57 16722 [Note] InnoDB: Memory barrier is not used
    2017-01-06 09:45:57 16722 [Note] InnoDB: Compressed tables use zlib 1.2.3
    2017-01-06 09:45:57 16722 [Note] InnoDB: Using Linux native AIO
    2017-01-06 09:45:57 16722 [Note] InnoDB: Using CPU crc32 instructions
    2017-01-06 09:45:58 16722 [Note] InnoDB: Initializing buffer pool, size = 8.0M
    InnoDB: mmap(8585216 bytes) failed; errno 12
    2017-01-06 09:45:58 16722 [ERROR] InnoDB: Cannot allocate memory for the buffer pool
    2017-01-06 09:45:58 16722 [ERROR] Plugin 'InnoDB' init function returned error.
    2017-01-06 09:45:58 16722 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
    2017-01-06 09:45:58 16722 [ERROR] Unknown/unsupported storage engine: InnoDB
    2017-01-06 09:45:58 16722 [ERROR] Aborting
    
    2017-01-06 09:45:58 16722 [Note] Binlog end
    2017-01-06 09:45:58 16722 [Note] Shutting down plugin 'partition'
    2017-01-06 09:45:58 16722 [Note] Shutting down plugin 'PERFORMANCE_SCHEMA'
    2017-01-06 09:45:58 16722 [Note] Shutting down plugin 'BLACKHOLE'
    2017-01-06 09:45:58 16722 [Note] Shutting down plugin 'INNODB_SYS_DATAFILES'
    2017-01-06 09:45:58 16722 [Note] Shutting down plugin 'INNODB_SYS_TABLESPACES'
    2017-01-06 09:45:58 16722 [Note] Shutting down plugin 'INNODB_SYS_FOREIGN_COLS'
    2017-01-06 09:45:58 16722 [Note] Shutting down plugin 'INNODB_SYS_FOREIGN'
    2017-01-06 09:45:58 16722 [Note] Shutting down plugin 'INNODB_SYS_FIELDS'
    2017-01-06 09:45:58 16722 [Note] Shutting down plugin 'INNODB_SYS_COLUMNS'
    2017-01-06 09:45:58 16722 [Note] Shutting down plugin 'INNODB_SYS_INDEXES'
    2017-01-06 09:45:58 16722 [Note] Shutting down plugin 'INNODB_SYS_TABLESTATS'
    2017-01-06 09:45:58 16722 [Note] Shutting down plugin 'INNODB_SYS_TABLES'
    2017-01-06 09:45:58 16722 [Note] Shutting down plugin 'INNODB_FT_INDEX_TABLE'
    2017-01-06 09:45:58 16722 [Note] Shutting down plugin 'INNODB_FT_INDEX_CACHE'
    2017-01-06 09:45:58 16722 [Note] Shutting down plugin 'INNODB_FT_CONFIG'
    2017-01-06 09:45:58 16722 [Note] Shutting down plugin 'INNODB_FT_BEING_DELETED'
    2017-01-06 09:45:58 16722 [Note] Shutting down plugin 'INNODB_FT_DELETED'
    2017-01-06 09:45:58 16722 [Note] Shutting down plugin 'INNODB_FT_DEFAULT_STOPWORD'
    2017-01-06 09:45:58 16722 [Note] Shutting down plugin 'INNODB_METRICS'
    2017-01-06 09:45:58 16722 [Note] Shutting down plugin 'INNODB_BUFFER_POOL_STATS'
    2017-01-06 09:45:58 16722 [Note] Shutting down plugin 'INNODB_BUFFER_PAGE_LRU'
    2017-01-06 09:45:58 16722 [Note] Shutting down plugin 'INNODB_BUFFER_PAGE'
    2017-01-06 09:45:58 16722 [Note] Shutting down plugin 'INNODB_CMP_PER_INDEX_RESET'
    2017-01-06 09:45:58 16722 [Note] Shutting down plugin 'INNODB_CMP_PER_INDEX'
    2017-01-06 09:45:58 16722 [Note] Shutting down plugin 'INNODB_CMPMEM_RESET'
    2017-01-06 09:45:58 16722 [Note] Shutting down plugin 'INNODB_CMPMEM'
    2017-01-06 09:45:58 16722 [Note] Shutting down plugin 'INNODB_CMP_RESET'
    2017-01-06 09:45:58 16722 [Note] Shutting down plugin 'INNODB_CMP'
    2017-01-06 09:45:58 16722 [Note] Shutting down plugin 'INNODB_LOCK_WAITS'
    2017-01-06 09:45:58 16722 [Note] Shutting down plugin 'INNODB_LOCKS'
    2017-01-06 09:45:58 16722 [Note] Shutting down plugin 'INNODB_TRX'
    2017-01-06 09:45:58 16722 [Note] Shutting down plugin 'ARCHIVE'
    2017-01-06 09:45:58 16722 [Note] Shutting down plugin 'MyISAM'
    2017-01-06 09:45:58 16722 [Note] Shutting down plugin 'CSV'
    2017-01-06 09:45:58 16722 [Note] Shutting down plugin 'MRG_MYISAM'
    2017-01-06 09:45:58 16722 [Note] Shutting down plugin 'MEMORY'
    2017-01-06 09:45:58 16722 [Note] Shutting down plugin 'sha256_password'
    2017-01-06 09:45:58 16722 [Note] Shutting down plugin 'mysql_old_password'
    2017-01-06 09:45:58 16722 [Note] Shutting down plugin 'mysql_native_password'
    2017-01-06 09:45:58 16722 [Note] Shutting down plugin 'binlog'
    2017-01-06 09:45:58 16722 [Note] /alidata/server/mysql/bin/mysqld: Shutdown complete
    
    170106 09:45:58 mysqld_safe mysqld from pid file /alidata/server/mysql/data/iZ28o516t2sZ.pid ended
    170106 09:46:45 mysqld_safe Starting mysqld daemon with databases from /alidata/server/mysql/data
    2017-01-06 09:46:45 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
    2017-01-06 09:46:46 17067 [Note] Plugin 'FEDERATED' is disabled.
    2017-01-06 09:46:46 17067 [Note] InnoDB: Using atomics to ref count buffer pool pages
    2017-01-06 09:46:46 17067 [Note] InnoDB: The InnoDB memory heap is disabled
    2017-01-06 09:46:46 17067 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
    2017-01-06 09:46:46 17067 [Note] InnoDB: Memory barrier is not used
    2017-01-06 09:46:46 17067 [Note] InnoDB: Compressed tables use zlib 1.2.3
    2017-01-06 09:46:46 17067 [Note] InnoDB: Using Linux native AIO
    2017-01-06 09:46:46 17067 [Note] InnoDB: Using CPU crc32 instructions
    2017-01-06 09:46:46 17067 [Note] InnoDB: Initializing buffer pool, size = 8.0M
    2017-01-06 09:46:46 17067 [Note] InnoDB: Completed initialization of buffer pool
    InnoDB: Error: pthread_create returned 11
    170106 09:46:46 mysqld_safe mysqld from pid file /alidata/server/mysql/data/iZ28o516t2sZ.pid ended
    

    是 php-fpm 的问题?还是 MySQL5.6 的问题 要怎么解决啊! 求大神

    第 1 条附言  ·  2017-01-06 14:06:17 +08:00

    mysql配置文件

    [client]
    port            = 3306
    socket          = /tmp/mysql.sock
    [mysqld]
    port            = 3306
    socket          = /tmp/mysql.sock
    skip-external-locking
    log-error=/alidata/log/mysql/error1.log
    #datadir=/alidata/server/mysql/data
    key_buffer_size = 16M
    max_allowed_packet = 1M
    table_open_cache = 64
    sort_buffer_size = 512K
    net_buffer_length = 8K
    read_buffer_size = 256K
    read_rnd_buffer_size = 512K
    myisam_sort_buffer_size = 8M
    innodb_buffer_pool_size=8M
    
    log-bin=mysql-bin
    binlog_format=mixed
    server-id       = 1
    
    sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
    
    [mysqldump]
    quick
    max_allowed_packet = 16M
    
    [mysql]
    no-auto-rehash
    
    [myisamchk]
    key_buffer_size = 20M
    sort_buffer_size = 20M
    read_buffer = 2M
    write_buffer = 2M
    
    [mysqlhotcopy]
    interactive-timeout
    expire_logs_days = 5
    max_binlog_size = 1000M 
    
    
    第 2 条附言  ·  2017-01-06 15:05:42 +08:00
    刚刚参考阿里云社区设置了 swap 分区,不知道会不会解决,暂时运行着看看吧,要是再挂掉,就换 Apache+mysql5.7 试试

    https://help.aliyun.com/knowledge_detail/42534.html
    7 条回复    2017-01-07 09:28:02 +08:00
    KenYang
        1
    KenYang  
       2017-01-06 12:10:04 +08:00 via iPhone
    出现了同样的问题 现在只能每次手动重启
    alect
        2
    alect  
       2017-01-06 12:14:40 +08:00
    Cannot allocate memory for the buffer pool
    内存不够用么
    lzhd24
        3
    lzhd24  
       2017-01-06 12:31:40 +08:00 via Android
    嗯,我也遇到过好多次, wordpress+mysql 配置,访问过多就会挂,阿里云论坛好像有解决办法。你可以搜搜
    cevincheung
        4
    cevincheung  
       2017-01-06 12:35:43 +08:00
    内存不够用。阿里云是不是没有 swap
    abc123ccc
        5
    abc123ccc  
       2017-01-06 13:58:54 +08:00
    可能配置也有点问题吧,贴上你的 mysql 的配置文件信息。
    icedream728
        6
    icedream728  
       2017-01-07 08:24:19 +08:00
    装 mysqltuner 看看 mysql 是不是要优化
    abc123ccc
        7
    abc123ccc  
       2017-01-07 09:28:02 +08:00
    InnoDB: The InnoDB memory heap is disabled
    2017-01-06 09:45:57 16722 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
    2017-01-06 09:45:57 16722 [Note] InnoDB: Memory barrier is not used
    2017-01-06 09:45:57 16722 [Note] InnoDB: Compressed tables use zlib 1.2.3
    2017-01-06 09:45:57 16722 [Note] InnoDB: Using Linux native AIO
    2017-01-06 09:45:57 16722 [Note] InnoDB: Using CPU crc32 instructions
    2017-01-06 09:45:58 16722 [Note] InnoDB: Initializing buffer pool, size = 8.0M
    InnoDB: mmap(8585216 bytes) failed; errno 12

    看这里:
    The InnoDB memory heap is disabled
    InnoDB: Memory barrier is not used
    InnoDB: Initializing buffer pool, size = 8.0M
    InnoDB: mmap(8585216 bytes) failed; errno 12


    到这里就挂了,而且你的配置里似乎没有 innodb 的配置, myisam 的也好少。还有你的 bin-log 日志,如果没有什么用,可以关掉。

    最好不要装高版本的 mysql ,除非你的内存大。好像 mysql5.6 及以上版本默认占内存好大。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   2781 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 24ms · UTC 14:49 · PVG 22:49 · LAX 06:49 · JFK 09:49
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.