zoukankan      html  css  js  c++  java
  • 今天遇到的关于mysql的max_allowed_packet的问题

      今天,运维组的同学来找我,说是备份池的文件描述没有显示出来,而且是从20号开始就不能显示,之前的文件描述就能显示,而且20号他们上传备份的数据确实是传过来的。但是是在web界面文件描述显示不出来。

      先说下文件描述的意思:就是公司的同时使用一个客户端,将他们认为重要的数据一个一个的上传过来(rsync)的方式,然后在中控机上为每个文件生成一个md5的值,最终保存到数据库中的某个字段中(md5),最终进行显示web界面,显示如此:

      但就是这个项目特别久远,没有使用任何的php框架,所有的代码都是函数式的编程,要是一个文件一个文件的查看下去的话,是会要死人的。

      于是,和项目组的另一位老同事讨论这个问题,最后分析的结果是:

      (1).可能是在各个节点再往中控机上上传这个md5的文件的时候,没有上传上去,导致获得不到最终的md5文件

      (2).查找所有文件中包含md5和insert update之类字样的文件,一个文件一个文件的排查,最终定位到某个文件的一个SQL:

    update mission set `md5` = LOAD_FILE('".$target."') where `id` = ".$id

      上面的这个sql语句就是在更改md5文件描述符,很明显在20号之后的md5文件并没读取出来。

      那为啥没有读取出来呢?

      之前的程序什么的都没有进行更改,那只能去查LOAD_FILE()这个mysql函数的用法了

      下面是LOAD_FILE()的官方用法: 

    Reads the file and returns the file contents as a string. To use this function, the file must be located on the server host, you must specify the full path name to the file, and you must have the FILE privilege. The file must be readable by all and its size less than max_allowed_packet bytes. If the secure_file_priv system variable is set to a nonempty directory name, the file to be loaded must be located in that directory.
    
    If the file does not exist or cannot be read because one of the preceding conditions is not satisfied, the function returns NULL

      其大意就是说:上传的这个文件是需要可读的,而且这个文件的大小必须小于mysql Server的max_allowed_packet的值的。

      最终,问题找到了,可能就是max_allowed_packet这个值过小,需要将其改大。

      于是,上到mysql的终端:

      进行设置:

    1 show variables like "%max_allowed%"; 
    2 set global max_allowed_packet = 2*1024*1024*10; 

      注意:必须是退出后,才能生效。

  • 相关阅读:
    js配置文件路径和项目目录文件夹位置的一致性
    MyBatis DTD文件下载地址
    Maven安装问题
    WebService客户端(以命令方式创建)
    Error configuring application listener of class org.springframework.web.cont
    HashMap与LinkedHashMap的区别
    同一台电脑配置多个JBoss
    WebService之客户端
    【solvebug】Java反射报错java.beans.IntrospectionException: Method not found,lombok的@Accessors注解
    【运维】windows server 2008 R2 Standard中如何安装 mysql8.0
  • 原文地址:https://www.cnblogs.com/shangzekai/p/4435699.html
Copyright © 2011-2022 走看看