问题服务器是一个群集组的Master机器操作系统:Red Hat Linux Enterprise 5
内存:4G
MySQL版本:5.0.51a每隔几十秒到几十分钟不定时重启mysqld服务,相关配置如下:[mysqld]
port            = 3306
socket          = /tmp/mysql.sock
pid_file==/var/lib/mysql/mysql.pid
default-character-set=utf8
skip-lockingkey_buffer = 1024M
max_allowed_packet = 16M
table_cache = 512
sort_buffer_size = 4M
read_buffer_size = 4M
read_rnd_buffer_size = 8M
myisam_sort_buffer_size = 64M
thread_cache_size = 128
query_cache_size = 32M
back_log = 200
max_connections=1024
wait_timeout = 1200
sql_mode = NO_ZERO_DATE,NO_ZERO_IN_DATE,TRADITIONAL# Try number of CPU's*2 for thread_concurrency
thread_concurrency = 4######### sync configuration ############
server-id=1
log-bin=/usr/local/mysql/data/binlogbinlog-do-db=fenbei_db_cluster1
replicate-do-db=fenbei_db_cluster1
################################################### error log ######################
log_error = /usr/local/mysql_logs/log_error/mysql_server.err
##########################################
######### innodb configuration ###########
innodb_lock_wait_timeout = 1200
innodb_additional_mem_pool_size = 16M
innodb_buffer_pool_size = 2048M
#innodb_data_file_path = ibdata1:1024M:autoextend:max:4G;ibdata2:50M:autoextend:max:4G;ibdata3:50M:autoextend:max:4G
#innodb_file_io_threads = 4
#innodb_thread_concurrency = 8
#innodb_flush_log_at_trx_commit = 2
innodb_log_buffer_size = 16M
#innodb_log_file_size = 8M
#innodb_log_files_in_group = 2
innodb_max_dirty_pages_pct = 90
#innodb_file_per_table = 0
##########################################
从错误日志上看,貌似mysql服务在进行二进制日志的修复,遇上了I/O错误,然后内存溢出了,错误日志如下:
081216  6:07:20  InnoDB: Error: the OS said file flush did not succeed
081216  6:07:20  InnoDB: Operating system error number 5 in a file operation.
InnoDB: Error number 5 means 'Input/output error'.
InnoDB: Some operating system error numbers are described at
InnoDB: http://dev.mysql.com/doc/refman/5.0/en/operating-system-error-codes.html
InnoDB: File operation call: 'flush'.
InnoDB: Cannot continue operation.
InnoDB: Log scan progressed past the checkpoint lsn 10 842383409
081216  6:07:20  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 10 846220649
081216  6:07:20  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 2261991, file name ./MyLogBin.000183
081216  6:07:30  InnoDB: Started; log sequence number 10 846220649
081216  6:07:30 [Note] Recovering after a crash using MyLogBin
081216  6:07:30 [Note] Starting crash recovery...
081216  6:07:30 [Note] Crash recovery finished.
^G/usr/sbin/mysqld: Out of memory (Needed 950109184 bytes)
^G/usr/sbin/mysqld: Out of memory (Needed 712581120 bytes)
^G/usr/sbin/mysqld: Out of memory (Needed 534435840 bytes)
^G/usr/sbin/mysqld: Out of memory (Needed 400825344 bytes)
081216  6:07:30 [Note] /usr/sbin/mysqld: ready for connections.
Version: '5.0.51a-community-log'  socket: '/tmp/mysql.sock'  port: 3306  MySQL Community Edition (GPL)
081216  6:17:18  InnoDB: Error: the OS said file flush did not succeed
081216  6:17:18  InnoDB: Operating system error number 5 in a file operation.
InnoDB: Error number 5 means 'Input/output error'.
InnoDB: Some operating system error numbers are described at
InnoDB: http://dev.mysql.com/doc/refman/5.0/en/operating-system-error-codes.html
InnoDB: File operation call: 'flush'.
InnoDB: Cannot continue operation.
InnoDB: Log scan progressed past the checkpoint lsn 10 871075872
081216  6:17:19  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 10 873685658
081216  6:17:19  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 14523313, file name ./MyLogBin.000184
081216  6:17:26  InnoDB: Started; log sequence number 10 873685658
081216  6:17:26 [Note] Recovering after a crash using MyLogBin
081216  6:17:26 [Note] Starting crash recovery...
081216  6:17:26 [Note] Crash recovery finished.
^G/usr/sbin/mysqld: Out of memory (Needed 950109184 bytes)
^G/usr/sbin/mysqld: Out of memory (Needed 712581120 bytes)
^G/usr/sbin/mysqld: Out of memory (Needed 534435840 bytes)
^G/usr/sbin/mysqld: Out of memory (Needed 400825344 bytes)
081216  6:17:26 [Note] /usr/sbin/mysqld: ready for connections.
Version: '5.0.51a-community-log'  socket: '/tmp/mysql.sock'  port: 3306  MySQL Community Edition (GPL)
 
启动日志中,大篇幅的全是mysqld restarted:
Number of processes running now: 0
081216 00:56:35  mysqld restartedNumber of processes running now: 0
081216 00:58:06  mysqld restartedNumber of processes running now: 0
081216 00:58:34  mysqld restartedNumber of processes running now: 0
081216 00:59:00  mysqld restartedNumber of processes running now: 0
081216 01:00:07  mysqld restartedNumber of processes running now: 0
081216 03:00:46  mysqld restartedNumber of processes running now: 0
081216 03:03:04  mysqld restartedNumber of processes running now: 0
081216 03:27:19  mysqld restartedNumber of processes running now: 0
081216 03:27:46  mysqld restartedNumber of processes running now: 0
081216 05:17:18  mysqld restartedNumber of processes running now: 0
081216 05:17:43  mysqld restartedNumber of processes running now: 0
081216 05:43:16  mysqld restartedNumber of processes running now: 0
081216 06:07:20  mysqld restartedNumber of processes running now: 0
081216 06:17:19  mysqld restarted
 搞了半天甚为郁闷~~~

解决方案 »

  1.   

    server-id=1 
    log-bin=/usr/local/mysql/data/binlog binlog-do-db=fenbei_db_cluster1 
    replicate-do-db=fenbei_db_cluster1 
    楼主似乎在做主从同步,把第二句改为log-bin=mysql-bin 试试。这是原始配置数据。而且,如果你是单向的,最后两句也可以不用要吧,只用在从服务器中指出要复制的数据库名就行了。如果你是想双向,那主用这端设的数据又太少了。
      

  2.   

    主从目前是单向,但准备扩展为双向...二进制日志是出了问题后改的,以前配置是:log-bin=MyLogBin
      

  3.   

    如果双向,你的主用机配置是上面的话,那肯定是要出错的。给一个双向的主用机给你参考:
    #shp add for test replication;
    #log-bin = mysql-bin
    log-bin
    server-id = 1binlog-do-db = replication_master
    master-host = 10.90.5.13
    master-user = backup13
    master-password = backup13
    master-port = 3306
    master-connect-retry = 10
    replicate-do-db = replication_master
    #shp add above;
      

  4.   

    嗯嗯,双向我了解
    我现在遇到的问题不是双向配置的问题而是mysql不定时自动重启,根据错误日志的“内存溢出”,我将配置中的innodb_buffer_pool_size由2G改为了1G,mysql依然会不定时重启奇怪的是同样的配置,在其他相同配置的数据库服务器上工作得很好更离谱的是,mysql即使不接受任何外部服务,也会不定时自动重启...