最近发现mysql每隔几个小时,进程就在后台自动重启,错误日志如下:
Version: '5.1.63-log'  socket: '/tmp/mysql.sock'  port: 3306  Source distribution
140807 16:51:37 mysqld_safe Number of processes running now: 0
140807 16:51:37 mysqld_safe mysqld restarted
140807 16:51:58  InnoDB: Initializing buffer pool, size = 1.0G
140807 16:52:08  InnoDB: Completed initialization of buffer pool
InnoDB: Log scan progressed past the checkpoint lsn 20 1522250842
140807 16:52:08  InnoDB: Database was not shut down normally!
InnoDB: Starting crash recovery.
InnoDB: Reading tablespace information from the .ibd files...
InnoDB: Restoring possible half-written data pages from the doublewrite
InnoDB: buffer...
InnoDB: Doing recovery: scanned up to log sequence number 20 1527493632
InnoDB: Doing recovery: scanned up to log sequence number 20 1532736512
InnoDB: Doing recovery: scanned up to log sequence number 20 1537979392
InnoDB: Doing recovery: scanned up to log sequence number 20 1542237920
140807 16:52:12  InnoDB: Starting an apply batch of log records to the database...
InnoDB: Progress in percents: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 
InnoDB: Apply batch completed
InnoDB: Last MySQL binlog file position 0 366649010, file name ./mysql-bin.000210
140807 16:52:22  InnoDB: Started; log sequence number 20 1542237920
140807 16:52:22 [Note] Recovering after a crash using mysql-bin
140807 16:52:35 [Note] Starting crash recovery...
140807 16:52:35 [Note] Crash recovery finished.
140807 16:52:35 [Note] Event Scheduler: Loaded 0 events
140807 16:52:35 [Note] /alidata/server/mysql/libexec/mysqld: ready for connections.
Version: '5.1.63-log'  socket: '/tmp/mysql.sock'  port: 3306  Source distribution
140807 16:53:03 [ERROR] /alidata/server/mysql/libexec/mysqld: Table './codeinlive/wp_comments' is ed as crashed and should be repaired
140807 16:53:03 [Warning] Checking table:   './codeinlive/wp_comments'最初还报mysql内存溢出的错误,我尝试修改相关的缓存设置之后好像没报内存溢出的错了,但是依旧还有上面所提到的问题,每隔一段时间mysql就重启:
140806 21:46:17 mysqld_safe mysqld from pid file /alidata/server/mysql/var/AY1305071817562191e3.pid ended
140806 21:46:17 mysqld_safe Starting mysqld daemon with databases from /alidata/server/mysql/var
140806 21:46:18  InnoDB: Initializing buffer pool, size = 1.0G
140806 21:46:18  InnoDB: Completed initialization of buffer pool
140806 21:46:19  InnoDB: Started; log sequence number 19 3790535300
140806 21:46:20 [Note] Event Scheduler: Loaded 0 events
140806 21:46:20 [Note] /alidata/server/mysql/libexec/mysqld: ready for connections.
Version: '5.1.63-log'  socket: '/tmp/mysql.sock'  port: 3306  Source distribution
140807 02:35:56 mysqld_safe Number of processes running now: 0
140807 02:35:57 mysqld_safe mysqld restarted
140807  2:36:34  InnoDB: Initializing buffer pool, size = 1.0G
140807  2:36:34  InnoDB: Error: cannot allocate 1073758208 bytes of
InnoDB: memory with malloc! Total allocated memory
InnoDB: by InnoDB 36878736 bytes. Operating system errno: 12
InnoDB: Check if you should increase the swap file or
InnoDB: ulimits of your operating system.
InnoDB: On FreeBSD check you have compiled the OS with
InnoDB: a big enough maximum process size.
InnoDB: Note that in most 32-bit computers the process
InnoDB: memory space is limited to 2 GB or 4 GB.
InnoDB: We keep retrying the allocation for 60 seconds...
140807  2:37:10  InnoDB: Completed initialization of buffer pool
InnoDB: Log scan progressed past the checkpoint lsn 19 4208695249
140807  2:37:45  InnoDB: Database was not shut down normally!
InnoDB: Starting crash recovery.
InnoDB: Reading tablespace information from the .ibd files...
InnoDB: Restoring possible half-written data pages from the doublewrite
InnoDB: buffer...
InnoDB: Doing recovery: scanned up to log sequence number 19 4210080598
140807  2:39:23  InnoDB: Starting an apply batch of log records to the database...
InnoDB: Progress in percents: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 
InnoDB: Apply batch completed
InnoDB: Last MySQL binlog file position 0 400555681, file name ./mysql-bin.000207
140807  2:40:18  InnoDB: Started; log sequence number 19 4210080598
140807  2:40:18 [Note] Recovering after a crash using mysql-bin
140807  2:40:31 [Note] Starting crash recovery...
140807  2:40:31 [Note] Crash recovery finished.
140807  2:40:34 [Note] Event Scheduler: Loaded 0 events
140807  2:40:34 [Note] /alidata/server/mysql/libexec/mysqld: ready for connections.
Version: '5.1.63-log'  socket: '/tmp/mysql.sock'  port: 3306  Source distribution
140807  2:40:47 [ERROR] /alidata/server/mysql/libexec/mysqld: Table './codeinlive/wp_comments' is ed as crashed and should be repaired
140807  2:40:47 [Warning] Checking table:   './codeinlive/wp_comments'mysql配置文件:
[client]
port = 3306
socket = /tmp/mysql.sock
[mysqld]
port = 3306
socket = /tmp/mysql.sock
datadir=/alidata/server/mysql/var
skip-name-resolve 
back_log = 500
max_connections = 1000
max_connect_errors = 3000
table_open_cache = 512
max_allowed_packet = 16M
binlog_cache_size = 1M
max_heap_table_size = 64M
sort_buffer_size = 8M
join_buffer_size = 8M
thread_cache_size = 4
thread_concurrency = 4
query_cache_size =128M
query_cache_limit = 2M
default-storage-engine = myisam
thread_stack = 192K
transaction_isolation = REPEATABLE-READ
tmp_table_size = 64M
log-bin=mysql-bin
binlog_format=mixed
slow_query_log=1
log-error=/alidata/log/mysql/mysqld.log
slow_query_log_file=/alidata/log/mysql/slow.log
long_query_time = 2
innodb_buffer_pool_size = 1024M
innodb_log_buffer_size = 8M
innodb_log_file_size = 128M
innodb_file_per_table = 1
innodb_flush_log_at_trx_commit = 2
# *** myisam Specific options ***key_buffer_size = 258M
read_buffer_size = 250K
read_rnd_buffer_size = 16M
bulk_insert_buffer_size = 64M
myisam_sort_buffer_size = 128M
myisam_max_sort_file_size = 10G
myisam_repair_threads = 1
myisam_recover[mysqldump]
quick
max_allowed_packet = 16M[mysql]
no-auto-rehash# Only allow UPDATEs and DELETEs that use keys.
#safe-updates[myisamchk]
key_buffer_size = 258M
sort_buffer_size = 250K
read_buffer = 8M
write_buffer = 8M[mysqlhotcopy]
interactive-timeout[mysqld_safe]
# Increase the amount of open files allowed per process. Warning: Make
# sure you have set the global system limit high enough! The high value
# is required for a large number of opened tables
open-files-limit = 16384对了我这个服务器主要是用drupal,所以数据库引擎是innodb的,所以我优化的时候尽量考虑innodb的,最初以为是缓存设置不当引起,就更改了相关缓存的设置,发上来还麻烦大牛们帮我分析下,谢谢了。不胜感激