2012-08-16 87 views
0

我每隔15分鐘運行一次cron作業,它會提取feed並將它們存儲到數據庫,從新的新數據庫中可以正常工作,並且我可以看到每隔15分鐘我的數據庫就會被填充。Mysql達到最大限制

但後說兩個星期數據庫似乎達到其最大極限,不會再存儲數據以及我可不能拉下它通過我的代碼點火器的應用程序,什麼是處理大量數據的最佳方式?

我正在使用專用服務器,並且對mysql以前的高數據需求知之甚少。這裏是我的/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 = 100 
wait_timeout = 60 
query-cache-type = 1 
query-cache-size = 8M 
query_cache_limit = 2M 
thread_cache_size = 8 
tmp_table_size = 16M 
max_heap_table_size = 16M 
join_buffer_size = 1M 
table_open_cache = 64 

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 

[mysqlhotcopy] 
interactive-timeout 

什麼是最大明智的設置,我可以設置,使我的SQL過去很長一段時間,是的,我不知道很多關於這個真的很需要保持這個運行,因爲我不能清除數據,然後再次開始填充數據庫,我需要它來保存。

謝謝你是進步;)

修訂

哇,我不知道什麼最關這意味着不好看壽

120803 08:45:19 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql 
120803 8:45:19 [Note] Plugin 'FEDERATED' is disabled. 
120803 8:45:19 InnoDB: Initializing buffer pool, size = 8.0M 
120803 8:45:19 InnoDB: Completed initialization of buffer pool 
InnoDB: The first specified data file ./ibdata1 did not exist: 
InnoDB: a new database to be created! 
120803 8:45:19 InnoDB: Setting file ./ibdata1 size to 10 MB 
InnoDB: Database physically writes the file full: wait... 
120803 8:45:19 InnoDB: Log file ./ib_logfile0 did not exist: new to be created 
InnoDB: Setting log file ./ib_logfile0 size to 5 MB 
InnoDB: Database physically writes the file full: wait... 
120803 8:45:19 InnoDB: Log file ./ib_logfile1 did not exist: new to be created 
InnoDB: Setting log file ./ib_logfile1 size to 5 MB 
InnoDB: Database physically writes the file full: wait... 
InnoDB: Doublewrite buffer not found: creating new 
InnoDB: Doublewrite buffer created 
InnoDB: Creating foreign key constraint system tables 
InnoDB: Foreign key constraint system tables created 
120803 8:45:19 InnoDB: Started; log sequence number 0 0 
120803 8:45:19 [Note] Event Scheduler: Loaded 0 events 
120803 8:45:19 [Note] /usr/libexec/mysqld: ready for connections. 
Version: '5.1.54' socket: '/var/lib/mysql/mysql.sock' port: 3306 MySQL Community Server (GPL) by Remi 
120803 8:45:21 [Note] /usr/libexec/mysqld: Normal shutdown 

120803 8:45:21 [Note] Event Scheduler: Purging the queue. 0 events 
120803 8:45:21 InnoDB: Starting shutdown... 
120803 8:45:25 InnoDB: Shutdown completed; log sequence number 0 721938 
120803 8:45:25 [Note] /usr/libexec/mysqld: Shutdown complete 

120803 08:45:25 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended 
120803 08:45:25 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql 
120803 8:45:25 [Note] Plugin 'FEDERATED' is disabled. 
120803 8:45:25 [Warning] option 'innodb-additional-mem-pool-size': signed value 512000 adjusted to 524288 
120803 8:45:25 InnoDB: Initializing buffer pool, size = 2.0M 
120803 8:45:25 InnoDB: Completed initialization of buffer pool 
120803 8:45:25 InnoDB: Started; log sequence number 0 721938 
120803 8:45:25 [Note] Event Scheduler: Loaded 0 events 
120803 8:45:25 [Note] /usr/libexec/mysqld: ready for connections. 
Version: '5.1.54' socket: '/var/lib/mysql/mysql.sock' port: 3306 MySQL Community Server (GPL) by Remi 
120803 8:47:37 [Note] /usr/libexec/mysqld: Normal shutdown 

120803 8:47:37 [Note] Event Scheduler: Purging the queue. 0 events 
120803 8:47:37 InnoDB: Starting shutdown... 
120803 8:47:40 InnoDB: Shutdown completed; log sequence number 0 1357212 
120803 8:47:40 [Note] /usr/libexec/mysqld: Shutdown complete 

120803 08:47:40 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended 
120803 08:47:41 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql 
120803 8:47:41 [Note] Plugin 'FEDERATED' is disabled. 
120803 8:47:41 InnoDB: Initializing buffer pool, size = 16.0M 
120803 8:47:41 InnoDB: Completed initialization of buffer pool 
120803 8:47:41 InnoDB: Started; log sequence number 0 1357212 
120803 8:47:41 [Note] Event Scheduler: Loaded 0 events 
120803 8:47:41 [Note] /usr/libexec/mysqld: ready for connections. 
Version: '5.1.54' socket: '/var/lib/mysql/mysql.sock' port: 3306 MySQL Community Server (GPL) by Remi 
120803 8:47:44 [Note] /usr/libexec/mysqld: Normal shutdown 

120803 8:47:44 [Note] Event Scheduler: Purging the queue. 0 events 
120803 8:47:44 InnoDB: Starting shutdown... 
120803 8:47:46 InnoDB: Shutdown completed; log sequence number 0 1357212 
120803 8:47:46 [Note] /usr/libexec/mysqld: Shutdown complete 

120803 08:47:46 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended 
120803 08:48:08 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql 
120803 8:48:08 [Note] Plugin 'FEDERATED' is disabled. 
120803 8:48:08 InnoDB: Initializing buffer pool, size = 16.0M 

對不起這個問題越來越愚蠢長,但只是試圖更新與我需要下面是我的codeignitor插入我應該如何做到這一點正確連接和斷開連接

<?php if (! defined('BASEPATH')) exit('No direct script access allowed'); 


class Cron_model extends CI_Model { 

    function addResults($data){ 

     $this->db->select('*'); 
     $this->db->from('articles'); 
     $this->db->limit(5); 
     $this->db->like('title', $data['title']); 
     $this->db->order_by("date", "desc"); 
     $query=$this->db->get(); 

     if(!$query->num_rows()){ 

      $this->db->insert('articles', $data); 

      return $data['title']; 

     } 

    } 


} 

感謝您的幫助大家

+0

你是從應用程序運行這個嗎?聽起來這個應用程序沒有關閉它的SQL連接,並且達到了最大限制。 – TheGeekZn 2012-08-16 10:16:14

+0

你可以發佈日誌中的錯誤嗎? – 2012-08-16 10:16:42

+0

現在得到錯誤日誌 – user1503606 2012-08-16 10:19:54

回答

0

您如何連接數據庫?對於您所描述的過程,您應該每次連接和斷開連接。

+0

您好JshsterPP我已經更新了我的答案,以顯示我的查詢在底部,我正確地做到這一點? – user1503606 2012-08-16 10:36:54

+0

你的代碼仍然缺少你如何連接和斷開數據庫連接!你的代碼顯示它是如何執行的,但它如何與數據庫建立連接,並在最後斷開連接。 – JshsterPP 2012-08-16 11:20:58

+0

您好我使用codeigniter處理所有的數據庫連接 – user1503606 2012-08-16 12:31:05