• MYSQL 的异常CRASH事件处理


    检查问题的过程
    ******************************************************************************************

    ps -ef|grep mysql

    kill -9 pid值

    然后才可以正常启动,要不就一直重启不停。

    1、 mysql -uroot -pD*********

    2、
    mysql> show variables like 'log_error';

    +---------------+----------------------------------------------+
    | Variable_name | Value                                        |
    +---------------+----------------------------------------------+
    | log_error     | /usr/local/db/mysql/data/AY130805143906Z.err |
    +---------------+----------------------------------------------+
    1 row in set (0.00 sec)
    =========================================================================================
    错误日志如下:
    150420 13:48:48 [ERROR] mysqld got signal 11 ;
    This could be because you hit a bug. It is also possible that this binary
    or one of the libraries it was linked against is corrupt, improperly built,
    or misconfigured. This error can also be caused by malfunctioning hardware.

    To report this bug, see http://kb.askmonty.org/en/reporting-bugs

    We will try our best to scrape up some info that will hopefully help
    diagnose the problem, but since we have already crashed,
    something is definitely wrong and this may fail.

    Server version: 5.5.39-MariaDB
    key_buffer_size=16384
    read_buffer_size=262144
    max_used_connections=34
    max_threads=1002
    thread_count=18
    It is possible that mysqld could use up to
    key_buffer_size + (read_buffer_size + sort_buffer_size)*max_threads = 338517 K  bytes of memory
    Hope that's ok; if not, decrease some variables in the equation.
    ******************************************************************************************
    尝试的解决办法:


    1、怀疑是磁盘空间不足造成:    扩大/usr/local/db/mysql/data的磁盘空间 mount上大数据盘

    2、怀疑是参数配置有问题造成:    

    修改/etc/my.cnf为

    #拷贝 my-samll.cnf
    cp /usr/local/mysql/support-files/my-small.cnf  /etc/my.cnf

    #追加文本行
    sed -i -e '/thread_stack = 240K/alower_case_table_names=1 innodb_file_per_table=1 skip-grant-tables skip-name-resolve back_log = 384 thread_stack = 256K table_cache = 400 sort_buffer_size=32M thread_cache_size=120 join_buffer_size = 8M myisam_sort_buffer_size = 64M thread_cache_size = 64 query_cache_size = 0 query_cache_type = 0 tmp_table_size = 256M max_connections = 214 max_connect_errors = 1000 wait_timeout = 31536000 thread_concurrency = 8 innodb_additional_mem_pool_size=4M innodb_flush_log_at_trx_commit=1 innodb_log_buffer_size=2M innodb_thread_concurrency=8 tmp_table_size=64M interactive_timeout=31536000 log = /tmp/mysql.log ' /etc/my.cnf
    #执行替换
    sed -i '/^key_buffer_size =/ckey_buffer_size =384M' /etc/my.cnf
    #替换
    sed -i '/^max_allowed_packet =/cmax_allowed_packet = 4M' /etc/my.cnf     
    #替换
    sed -i '/^sort_buffer_size =/csort_buffer_size = 6M' /etc/my.cnf    
    #替换
    sed -i '/^read_buffer_size =/cread_buffer_size = 4M' /etc/my.cnf        
    #替换
    sed -i '/^read_rnd_buffer_size =/cread_rnd_buffer_size = 16M' /etc/my.cnf    

    3、将lxyyProduct ,zxpt , hjt,crm  四个项目从tomcat中移除,先进行稳定性测试,如果没问题再想办法处理。

    4、

    参考阅读:http://www.tuicool.com/articles/AB7Jfu

    原来linux内核信号量默认设置太小,压测的时候,造成大量等待,
    默认
    # cat /proc/sys/kernel/sem
    250     32000   32      128
    说明:
    第一列,表示每个信号集中的最大信号量数目。
    第二列,表示系统范围内的最大信号量总数目。
    第三列,表示每个信号发生时的最大系统操作数目。
    第四列,表示系统范围内的最大信号集总数目。

    将第三列调大一点,参考网上的数据
    echo "kernel.sem=250 32000 100 128″>>/etc/sysctl.conf
    然后sysctl -p
    重启mysql

     总结:

    1、是不是数据库版本问题,尽量升级到最新的数据库;

    http://blog.chinaunix.net/uid-10449864-id-2956923.html

    2、SQL语句有问题,参考上面的链接。

    3、设置的系统打开文件数太少:

    http://blog.chinaunix.net/uid-20728886-id-138147.html

    4、Query Cache引起的问题,办法是禁用掉:

    http://www.xue163.com/exploit/163/1635340.html

    http://www.php230.com/weixin1410064192.html

     关闭方法很简单,有两种:

    1、同时设置选项 query_cache_type = 0query_cache_size = 0

    2、如果用源码编译MySQL的话,编译时增加参数 --without-query-cache 即可;

    黄海采用的是方法1。

    5、设置记录每条执行过的SQL语句:

    #创建一个空文件

    touch /usr/local/db/sql_row.log 

     

    vi /etc/my.cnf  添加在[mysqld]块中

     

    log=/usr/local/db/sql_row.log

    需要手动建立此文件,然后

    chmod 777 /usr/local/db/sql_row.log 
    service mysql restart
  • 相关阅读:
    wc项目
    随笔之——伪类选择器:nthchild(n) 与 nthoftype(n)的区别!!!
    随笔之——浮动(float)的影响及其清除、、clear与overflowhidden清除float的不同!!!
    随笔之——各大热门网站search 搜索框的写法,浅析!
    一个简单的注册页面
    自我介绍、目标
    position的6个属性的实验和相关分析
    第二次作业
    第三次作业
    第一次作业
  • 原文地址:https://www.cnblogs.com/littlehb/p/4443542.html
Copyright © 2020-2023  润新知