由于修改了日志大小重启会报错,分配不了足够

2019-11-01 11:05 来源:未知

 迁移的网站生成文档到三分之一左右的时候报错:

mysql经常挂掉,重启主机就好了

环境为CentOS系统,1G内存,Mysql5.5.30。
在/etc/my.cnf内添加:

Error infos:DedeCms错误警告:连接数据库失败可能是数据库密码不对或数据库服务器出错!

mysq日志

141211 10:50:25 mysqld_safe Starting mysqld daemon with databases from /alidata/server/mysql/data
141211 10:50:26 [Note] Plugin 'FEDERATED' is disabled.
141211 10:50:26 InnoDB: The InnoDB memory heap is disabled
141211 10:50:26 InnoDB: Mutexes and rw_locks use GCC atomic builtins
141211 10:50:26 InnoDB: Compressed tables use zlib 1.2.3
141211 10:50:26 InnoDB: Using Linux native AIO
141211 10:50:26 InnoDB: Initializing buffer pool, size = 128.0M
141211 10:50:26 InnoDB: Completed initialization of buffer pool
141211 10:50:26 InnoDB: highest supported file format is Barracuda.
InnoDB: The log sequence number in ibdata files does not match
InnoDB: the log sequence number in the ib_logfiles!
141211 10:50:26 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...
141211 10:50:27 InnoDB: Waiting for the background threads to start
141211 10:50:28 InnoDB: 5.5.37 started; log sequence number 1595675
141211 10:50:28 [Note] Recovering after a crash using mysql-bin
141211 10:50:28 [Note] Starting crash recovery...
141211 10:50:28 [Note] Crash recovery finished.
141211 10:50:28 [Note] Server hostname (bind-address): '0.0.0.0'; port: 3306
141211 10:50:28 [Note] - '0.0.0.0' resolves to '0.0.0.0';
141211 10:50:28 [Note] Server socket created on IP: '0.0.0.0'.
141211 10:50:28 [Note] Event Scheduler: Loaded 0 events
141211 10:50:28 [Note] /alidata/server/mysql/bin/mysqld: ready for connections.
Version: '5.5.37-log' socket: '/tmp/mysql.sock' port: 3306 MySQL Community Server
141211 10:53:25 [Note] /alidata/server/mysql/bin/mysqld: Normal shutdown

141211 10:53:25 [Note] Event Scheduler: Purging the queue. 0 events
141211 10:53:25 InnoDB: Starting shutdown...
141211 10:53:26 InnoDB: Shutdown completed; log sequence number 1595675
141211 10:53:26 [Note] /alidata/server/mysql/bin/mysqld: Shutdown complete

141211 10:53:26 mysqld_safe mysqld from pid file /alidata/server/mysql/data/iZ280q00p7cZ.pid ended
141211 10:57:45 mysqld_safe Starting mysqld daemon with databases from /alidata/server/mysql/data
141211 10:57:46 [Note] Plugin 'FEDERATED' is disabled.
141211 10:57:46 InnoDB: The InnoDB memory heap is disabled
141211 10:57:46 InnoDB: Mutexes and rw_locks use GCC atomic builtins
141211 10:57:46 InnoDB: Compressed tables use zlib 1.2.3
141211 10:57:46 InnoDB: Using Linux native AIO
141211 10:57:46 InnoDB: Initializing buffer pool, size = 128.0M
141211 10:57:46 InnoDB: Completed initialization of buffer pool
141211 10:57:46 InnoDB: highest supported file format is Barracuda.
141211 10:57:46 InnoDB: Waiting for the background threads to start
141211 10:57:47 InnoDB: 5.5.37 started; log sequence number 1595675
141211 10:57:47 [Note] Server hostname (bind-address): '0.0.0.0'; port: 3306
141211 10:57:47 [Note] - '0.0.0.0' resolves to '0.0.0.0';
141211 10:57:47 [Note] Server socket created on IP: '0.0.0.0'.
141211 10:57:47 [Note] Event Scheduler: Loaded 0 events
141211 10:57:47 [Note] /alidata/server/mysql/bin/mysqld: ready for connections.
Version: '5.5.37-log' socket: '/tmp/mysql.sock' port: 3306 MySQL Community Server
141213 21:56:24 [Warning] IP address '42.156.250.117' could not be resolved: Name or service not known
141215 0:09:33 [Warning] IP address '107.150.52.84' could not be resolved: Name or service not known
141215 2:23:23 [Warning] IP address '114.113.55.141' could not be resolved: Name or service not known
141215 16:43:01 [Warning] IP address '61.156.44.98' could not be resolved: Name or service not known
141216 21:56:28 [Warning] IP address '42.120.142.220' could not be resolved: Name or service not known
141217 11:07:01 mysqld_safe Number of processes running now: 0
141217 11:07:01 mysqld_safe mysqld restarted
141217 11:07:01 [Note] Plugin 'FEDERATED' is disabled.
141217 11:07:01 InnoDB: The InnoDB memory heap is disabled
141217 11:07:01 InnoDB: Mutexes and rw_locks use GCC atomic builtins
141217 11:07:01 InnoDB: Compressed tables use zlib 1.2.3
141217 11:07:01 InnoDB: Using Linux native AIO
141217 11:07:01 InnoDB: Initializing buffer pool, size = 128.0M
InnoDB: mmap(137363456 bytes) failed; errno 12
141217 11:07:01 InnoDB: Completed initialization of buffer pool
141217 11:07:01 InnoDB: Fatal error: cannot allocate memory for the buffer pool
141217 11:07:01 [ERROR] Plugin 'InnoDB' init function returned error.
141217 11:07:01 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
141217 11:07:01 [ERROR] Unknown/unsupported storage engine: InnoDB
141217 11:07:01 [ERROR] Aborting

141217 11:07:01 [Note] /alidata/server/mysql/bin/mysqld: Shutdown complete

141217 11:07:01 mysqld_safe mysqld from pid file /alidata/server/mysql/data/iZ280q00p7cZ.pid ended
141217 11:09:15 mysqld_safe Starting mysqld daemon with databases from /alidata/server/mysql/data
141217 11:09:15 [Note] Plugin 'FEDERATED' is disabled.
141217 11:09:15 InnoDB: The InnoDB memory heap is disabled
141217 11:09:15 InnoDB: Mutexes and rw_locks use GCC atomic builtins
141217 11:09:15 InnoDB: Compressed tables use zlib 1.2.3
141217 11:09:15 InnoDB: Using Linux native AIO
141217 11:09:15 InnoDB: Initializing buffer pool, size = 128.0M
InnoDB: mmap(137363456 bytes) failed; errno 12
141217 11:09:15 InnoDB: Completed initialization of buffer pool
141217 11:09:15 InnoDB: Fatal error: cannot allocate memory for the buffer pool
141217 11:09:15 [ERROR] Plugin 'InnoDB' init function returned error.
141217 11:09:15 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
141217 11:09:15 [ERROR] Unknown/unsupported storage engine: InnoDB
141217 11:09:15 [ERROR] Aborting

141217 11:09:15 [Note] /alidata/server/mysql/bin/mysqld: Shutdown complete

141217 11:09:15 mysqld_safe mysqld from pid file /alidata/server/mysql/data/iZ280q00p7cZ.pid ended

复制代码 代码如下:

火大,登陆MySQL发现

skip-external-locking
skip-name-resolve
max_connections = 1024
query_cache_size = 16M
sort_buffer_size = 1M
table_cache = 256
innodb_buffer_pool_size = 128M
innodb_additional_mem_pool_size = 4M
innodb_log_file_size = 128M
innodb_log_files_in_group = 2
innodb_log_buffer_size = 2M
innodb_flush_log_at_trx_commit = 1

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock'

修改前先将mysql服务停止:
service mysqld restart
由于修改了日志大小重启会报错:
130319 04:45:14 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended
130319 05:02:43 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
130319 5:02:54 [Note] Plugin 'FEDERATED' is disabled.
130319 5:02:59 InnoDB: The InnoDB memory heap is disabled
130319 5:02:59 InnoDB: Mutexes and rw_locks use InnoDB's own implementation
130319 5:02:59 InnoDB: Compressed tables use zlib 1.2.3
130319 5:02:59 InnoDB: Using Linux native AIO
130319 5:03:01 InnoDB: Initializing buffer pool, size = 128.0M
130319 5:03:02 InnoDB: Completed initialization of buffer pool
InnoDB: Error: log file ./ib_logfile0 is of different size 0 5242880 bytes
InnoDB: than specified in the .cnf file 0 134217728 bytes!
130319 5:03:02 [ERROR] Plugin 'InnoDB' init function returned error.
130319 5:03:02 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
130319 5:03:02 [ERROR] Aborting
将/var/lib/mysql下原先的ib_logfile0、ib_永利平台娱乐,logfile1删除再重启mysql。
service mysqld start
正常启动:
130319 05:20:59 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended
130319 05:22:53 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
130319 5:22:56 [Note] Plugin 'FEDERATED' is disabled.
130319 5:22:57 InnoDB: The InnoDB memory heap is disabled
130319 5:22:57 InnoDB: Mutexes and rw_locks use InnoDB's own implementation
130319 5:22:57 InnoDB: Compressed tables use zlib 1.2.3
130319 5:22:57 InnoDB: Using Linux native AIO
130319 5:22:57 InnoDB: Initializing buffer pool, size = 128.0M
130319 5:22:57 InnoDB: Completed initialization of buffer pool
130319 5:22:57 InnoDB: highest supported file format is Barracuda.
130319 5:22:58 InnoDB: Waiting for the background threads to start
130319 5:22:59 InnoDB: 5.5.30 started; log sequence number 2621452
130319 5:22:59 [Note] Server hostname (bind-address): '0.0.0.0'; port: 3306
130319 5:22:59 [Note] - '0.0.0.0' resolves to '0.0.0.0';
130319 5:22:59 [Note] Server socket created on IP: '0.0.0.0'.
130319 5:23:00 [Warning] 'proxies_priv' entry '@ root@server08' ignored in --skip-name-resolve mode.
130319 5:23:04 [Note] Event Scheduler: Loaded 0 events
130319 5:23:04 [Note] /usr/libexec/mysqld: ready for connections.
Version: '5.5.30' socket: '/var/lib/mysql/mysql.sock' port: 3306 MySQL Community Server (GPL) by Remi
使用mysqladmin variables命令可查看所有参数变量。

service mysqld restart 重启失败:mysql daemon failed to start

InnoDB引擎配置优化 innodb_buffer_pool_size=1G //一个Innodb最重要的参数,这个参数和MyISAM的key_buffer_size有相似之处,但也是有差别的。这个参数主要缓存innodb表的索引,数据,插入数据时的缓冲,设置得越大,存取表里面数据时所需要的磁盘I/O越少,一般是内存的一半,不超过2G,否则系统会崩溃。为Innodb加速优化首要参数。该参数分配内存的原则:这个参数默认分配只有8M,可以说是非常小的一个值。如果是一个专用DB服务器,那么他可以占到内存的70%-80%。这个参数不能动态更改,所以分配需多考虑。分配过大,会使Swap占用过多,致使Mysql的查询特慢。如果你的数据比较小,那么可分配是你的数据大小+10%左右做为这个参数的值。
例如:数据大小为50M,那么给这个值分配innodb_buffer_pool_size=64M
innodb_additional_mem_pool_size=16M //用来存放Innodb的内部目录这个值不用分配太大,系统可以自动调。不用设置太高。通常比较大数据设置16M够用了,如果表比较多,可以适当的增大。如果这个值自动增加,会在error log有中显示的。
innodb_log_file_size=256M //在日志组中每个日志文件的大小,一般是innodb_buffer_pool_size的25%,官方推荐是innodb_buffer_pool_size的40-50%。一般控制在几个LOG文件相加大小在2G以内为佳。具体情况还需要看你的事务大小,数据大小为依据。说明:这个值分配的大小和数据库的写入速度,事务大小,异常重启后的恢复有很大的关系。
innodb_log_files_in_group=2 //指定你有几个日志组。分配原则:一般我们可以用2-3个日值组。默认为两个。
innodb_log_buffer_size=3M //事务在内存中的缓冲。分配原则:控制在2-8M.这个值不用太多的。他里面的内存一般一秒钟写到磁盘一次。具体写入方式和你的事务提交方式有关。在oracle等数据库了解这个,一般最大指定为3M比较合适。
innodb_flush_logs_at_trx_commit=0 //控制事务的提交方式分配原则:这个参数只有3个值,0,1,2请确认一下自已能接受的级别。默认为1,主库请不要更改了。性能更高的可以设置为0或是2,但会丢失一秒钟的事务。说明:这个参数的设置对Innodb的性能有很大的影响,所以在这里给多说明一下。当这个值为1时:innodb 的事务LOG在每次提交后写入日值文件,并对日值做刷新到磁盘。这个可以做到不丢任何一个事务。当这个值为2时:在每个提交,日志缓冲被写到文件,但不对日志文件做到磁盘操作的刷新,在对日志文件的刷新在值为2的情况也每秒发生一次。但需要注意的是,由于进程调用方面的问题,并不能保证每秒100%的发生。从而在性能上是最快的。但操作系统崩溃或掉电才会删除最后一秒的事务。当这个值为0时:日志缓冲每秒一次地被写到日志文件,并且对日志文件做到磁盘操作的刷新,但是在一个事务提交不做任何操作。mysqld进程的崩溃会删除崩溃前最后一秒的事务。

TAG标签:
版权声明:本文由永利平台娱乐发布于新闻动态,转载请注明出处:由于修改了日志大小重启会报错,分配不了足够