我的某个网站遇到了问题。当我加载我的网站时,每隔一段时间就会出现错误#34;数据库连接失败"。 我正在使用Amazon Linux服务器t2.micro实例。 请有人帮助我绝望。我不知道问题是什么,我对这个问题很陌生,所以我不想在不知情的情况下进行任何修改而丢失数据。 谢谢 我的mysql日志文件:
170103 18:00:02 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 2104460177
170103 18:00:02 InnoDB: Starting an apply batch of log records to the database...
InnoDB: Progress in percents: 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
170103 18:00:02 InnoDB: Waiting for the background threads to start
170103 18:00:03 InnoDB: 5.5.52 started; log sequence number 2104460177
170103 18:00:03 [Note] Server hostname (bind-address): '0.0.0.0'; port: 3306
170103 18:00:03 [Note] - '0.0.0.0' resolves to '0.0.0.0';
170103 18:00:03 [Note] Server socket created on IP: '0.0.0.0'.
170103 18:00:04 [Note] Event Scheduler: Loaded 0 events
170103 18:00:04 [Note] /usr/libexec/mysql55/mysqld: ready for connections.
Version: '5.5.52' socket: '/var/lib/mysql/mysql.sock' port: 3306 MySQL Community Server (GPL)
170104 09:09:11 mysqld_safe Number of processes running now: 0
170104 09:09:11 mysqld_safe mysqld restarted
170104 09:27:17 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
170104 9:27:17 [Note] /usr/libexec/mysql55/mysqld (mysqld 5.5.52) starting as process 11744 ...
170104 9:27:17 [Note] Plugin 'FEDERATED' is disabled.
170104 9:27:17 InnoDB: The InnoDB memory heap is disabled
170104 9:27:17 InnoDB: Mutexes and rw_locks use GCC atomic builtins
170104 9:27:17 InnoDB: Compressed tables use zlib 1.2.8
170104 9:27:17 InnoDB: Using Linux native AIO
170104 9:27:17 InnoDB: Initializing buffer pool, size = 128.0M
170104 9:27:17 InnoDB: Completed initialization of buffer pool
170104 9:27:17 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!
170104 9:27:17 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...
170104 9:27:17 InnoDB: Waiting for the background threads to start
170104 9:27:18 InnoDB: 5.5.52 started; log sequence number 2123585383
170104 9:27:18 [Note] Server hostname (bind-address): '0.0.0.0'; port: 3306
170104 9:27:18 [Note] - '0.0.0.0' resolves to '0.0.0.0';
170104 9:27:18 [Note] Server socket created on IP: '0.0.0.0'.
170104 9:27:18 [Note] Event Scheduler: Loaded 0 events
170104 9:27:18 [Note] /usr/libexec/mysql55/mysqld: ready for connections.
Version: '5.5.52' socket: '/var/lib/mysql/mysql.sock' port: 3306 MySQL Community Server (GPL)
答案 0 :(得分:0)
您的MySQL似乎没有足够的内存。
假设你有一个人(mysql)从桥上的a点到b点携带一块石头(mysql中的数据)。 到时候你会向包中添加更多宝石(更多数据)。 也许在街上还有更多的人(更多的mysql实例,因为你的网站上有更多的访问者)。
然后设想一个所有这些人都必须通过的桥梁,它有一个重量限制(RAM)。
因此,只有少数人可以走过桥,其他人被告知要么等待,要么(如果有太多人在等待)他们的包裹下地狱。
您可以删除某些数据,也可以限制用户数量,也可以尝试优化这些数据包。
您真的需要携带所有数据还是有办法更快地生成数据?
关于第二个选项,请阅读有关mysql索引的内容。