2013-08-19 29 views
1

真的很想得到一些幫助。Mysql已經離開媒體寺廟

我不斷收到錯誤上傳大文件75MB時,Mysql已經消失。 20mb以下的任何內容都可以上傳。

所以我在這裏查看了其他帖子上的這個錯誤。我在媒體上,但不幸的是他們說他們的範圍之外。

我已經編輯在/etc/my.cnf中

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

[mysqld_safe] 
log-error=/var/log/mysqld.log 
pid-file=/var/run/mysqld/mysqld.pid 

innodb_buffer_pool_size=2M 
innodb_additional_mem_pool_size=500K 
innodb_log_buffer_size=500K 
innodb_thread_concurrency=2 

[mysqld] 
local-infile=0 
datadir=/var/lib/mysql 
user=mysql 
symbolic-links=0 

max_connections = 150 
wait_timeout = 600 
query-cache-type = 1 
query-cache-size = 16M 
query_cache_limit = 2M 
thread_cache_size = 16 
tmp_table_size = 32M 
max_heap_table_size = 32M 
join_buffer_size = 2M 
table_open_cache = 128 

port   = 3306 
socket   = /var/lib/mysql/mysql.sock 
skip-external-locking 
key_buffer_size = 16M 
max_allowed_packet = 1M 
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 = 16M 
innodb_additional_mem_pool_size = 2M 
innodb_log_buffer_size = 8M 

[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 

這個文件my.cnf中,所以我有UPED等待超時部分600應該是綽綽有餘?

我有我的php.ini文件設置如下。

[PHP] 
soap.wsdl_cache_limit = 5 
include_path = ".:" 
cli_server.color = On 
mysql.allow_persistent = On 
mysqli.max_persistent = -1 
session.bug_compat_42 = Off 
mysql.connect_timeout = -1 
session.use_only_cookies = 1 
register_argc_argv = Off 
mssql.min_error_severity = 10 
open_basedir = "/var/www/vhosts/s3bubble.com/:/tmp/" 
session.name = PHPSESSID 
mysqlnd.collect_statistics = On 
session.hash_function = 0 
session.gc_probability = 1 
log_errors_max_len = 1024 
mssql.secure_connection = Off 
pgsql.max_links = -1 
variables_order = "GPCS" 
ldap.max_links = -1 
sybct.allow_persistent = On 
max_input_time = 600 
odbc.max_links = -1 
session.save_handler = files 
mysqli.cache_size = 2000 
pgsql.auto_reset_persistent = Off 
error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT 
auto_prepend_file = 
sendmail_path = /usr/sbin/sendmail -t -i 
sybct.min_client_severity = 10 
pgsql.max_persistent = -1 
auto_globals_jit = On 
soap.wsdl_cache_ttl = 86400 
allow_url_fopen = On 
zend.enable_gc = On 
mysqli.allow_persistent = On 
tidy.clean_output = Off 
display_startup_errors = Off 
user_dir = 
session.cookie_lifetime = 0 
mysqli.max_links = -1 
default_socket_timeout = 900 
session.serialize_handler = php 
session.hash_bits_per_character = 5 
unserialize_callback_func = 
pdo_mysql.cache_size = 2000 
default_mimetype = "text/html" 
session.cache_expire = 180 
max_execution_time = 600 
mail.add_x_header = On 
upload_max_filesize = 1G 
ibase.max_links = -1 
safe_mode = off 
zlib.output_compression = Off 
ignore_repeated_errors = Off 
odbc.max_persistent = -1 
mssql.compatability_mode = Off 
file_uploads = On 

,所以我有UPED任何幫助,這是推動我瘋了什麼什麼建議

這裏是腳本超時;

public function Uploader() 
{ 
    header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); 
    header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); 
    header("Cache-Control: no-store, no-cache, must-revalidate"); 
    header("Cache-Control: post-check=0, pre-check=0", false); 
    header("Pragma: no-cache"); 


    $targetDir = $_SERVER['DOCUMENT_ROOT'] . '/uploads/' . $this->session->userdata('account_id') . '/folder/' . $_REQUEST['playlist_id']; 
    if (!file_exists($targetDir)) { 
     mkdir($targetDir, 0777); 
    } 
    // Get parameters 
    $chunk = isset($_REQUEST["chunk"]) ? intval($_REQUEST["chunk"]) : 0; 
    $chunks = isset($_REQUEST["chunks"]) ? intval($_REQUEST["chunks"]) : 0; 
    $fileName = isset($_REQUEST["name"]) ? $_REQUEST["name"] : ''; 

    // Clean the fileName for security reasons 
    $fileName = preg_replace('/[^\w\._]+/', '_', $fileName); 

    // Make sure the fileName is unique but only if chunking is disabled 
    if ($chunks < 2 && file_exists($targetDir . DIRECTORY_SEPARATOR . $fileName)) { 
     $ext = strrpos($fileName, '.'); 
     $fileName_a = substr($fileName, 0, $ext); 
     $fileName_b = substr($fileName, $ext); 

     $count = 1; 
     while (file_exists($targetDir . DIRECTORY_SEPARATOR . $fileName_a . '_' . $count . $fileName_b)) { 
      $count++; 
     } 

     $fileName = $fileName_a . '_' . $count . $fileName_b; 
    } 

    $filePath = $targetDir . DIRECTORY_SEPARATOR . $fileName; 

    // Create target dir 
    if (!file_exists($targetDir)) { 
     @mkdir($targetDir); 
    } 

    // Look for the content type header 
    if (isset($_SERVER["HTTP_CONTENT_TYPE"])) { 
     $contentType = $_SERVER["HTTP_CONTENT_TYPE"]; 
    } 

    if (isset($_SERVER["CONTENT_TYPE"])) { 
     $contentType = $_SERVER["CONTENT_TYPE"]; 
    } 

    // Handle non multipart uploads older WebKit versions did not support multipart in HTML5 
    if (strpos($contentType, "multipart") !== false) { 
     if (isset($_FILES['file']['tmp_name']) && is_uploaded_file($_FILES['file']['tmp_name'])) { 
      // Open temp file 
      $out = fopen("{$filePath}.part", $chunk == 0 ? "wb" : "ab"); 
      if ($out) { 
       // Read binary input stream and append it to temp file 
       $in = fopen($_FILES['file']['tmp_name'], "rb"); 

       if ($in) { 
        while ($buff = fread($in, 4096)) { 
         fwrite($out, $buff); 
        } 
       } else { 
        die('{"jsonrpc" : "2.0", "error" : {"code": 101, "message": "Failed to open input stream."}, "id" : "id"}'); 
       } 
       fclose($in); 
       fclose($out); 
       @unlink($_FILES['file']['tmp_name']); 
      } else { 
       die('{"jsonrpc" : "2.0", "error" : {"code": 102, "message": "Failed to open output stream."}, "id" : "id"}'); 
      } 
     } else { 
      die('{"jsonrpc" : "2.0", "error" : {"code": 103, "message": "Failed to move uploaded file."}, "id" : "id"}'); 
     } 
    } else { 
     // Open temp file 
     $out = fopen("{$filePath}.part", $chunk == 0 ? "wb" : "ab"); 
     if ($out) { 
      // Read binary input stream and append it to temp file 
      $in = fopen("php://input", "rb"); 

      if ($in) { 
       while ($buff = fread($in, 4096)) { 
        fwrite($out, $buff); 
       } 
      } else { 
       die('{"jsonrpc" : "2.0", "error" : {"code": 101, "message": "Failed to open input stream."}, "id" : "id"}'); 
      } 

      fclose($in); 
      fclose($out); 
     } else { 
      die('{"jsonrpc" : "2.0", "error" : {"code": 102, "message": "Failed to open output stream."}, "id" : "id"}'); 
     } 
    } 

    // Check if file has been uploaded 
    if (!$chunks || $chunk == $chunks - 1) { 

     $response = shell_exec("cd {$targetDir}/ && runs some script here 2>&1"); 

     $data = array(
      'filename' => $fileName, 

     ); 

     if ($response) { 
      //Add values to database 
      $this->uploader_model->addFileData($data); 

     } 

    } 
} 
+0

您是上傳75MB文件並將其保存到mySQL或將其保存在服務器上? –

+0

我將它保存在服務器上,並將文件的路徑保存到mysql – user1503606

+0

您可以發佈正在上傳的腳本嗎? –

回答

3

請增加wait_timeout

兩個可能的原因的時間可能是: -

  1. 服務器超時和關閉連接。如何解決:檢查 wait_timeout變量在你的mysqld的my.cnf/my.ini配置中 文件足夠大。
  2. 服務器丟失了一個不正確或太大的數據包。如果mysqld得到一個太大或不正確的 數據包,它會認爲某些東西的 出現了錯誤的客戶端並關閉了連接。您可以通過在my.cnf/my.ini文件中增加 max_allowed_pa​​cket的值來增加最大數據包大小限制。
+1

我已經將wait_timeout增加到了600分鐘,這是10分鐘,這足以讓文件在2分鐘內放到服務器上。 – user1503606

+0

我會爭辯說,在大多數設置中,「wait_timeout」的600秒綽綽有餘。 –

+0

@StevenV: - 但是你不認爲文件大小太大,可能需要更多時間! –