0

我每 15 分钟运行一次 cron 作业,这会引入提要,然后将它们存储到数据库中,从一个全新的数据库中这工作正常,我可以看到我的数据库每 15 分钟填充一次。

但是说两周后,数据库似乎达到了最大限制,并且不再存储数据,我当然无法通过我的代码点火器应用程序将其拉下来,处理大量数据的最佳方法是什么?

我正在使用专用服务器,并且以前对 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'];

       }

    }   


}

感谢大家的帮助

4

1 回答 1

0

你是如何连接到数据库的?对于您描述的过程,您应该每次都连接和断开连接。

于 2012-08-16T10:16:40.557 回答