Skip to content

Commit 1b0204d

Browse files
committed
2018-07-10 补充小内存的 MySQL 配置
1 parent 827e631 commit 1b0204d

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

markdown-file/Mysql-Install-And-Settings.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,39 @@ set password = password('新密码');
196196
FLUSH PRIVILEGES;
197197
```
198198

199+
## 小内存机子,MySQL 频繁挂掉解决办法(1G + CentOS 7.4)
200+
201+
- 保存系统日志到本地进行查看:`cd /var/log/ && sz messages`
202+
- 其中可以看到这样的几句话(可以知道内存不够了):
203+
204+
```
205+
Jul 6 21:49:14 VM_123_201_centos kernel: Out of memory: Kill process 19452 (httpd) score 36 or sacrifice child
206+
Jul 6 21:49:14 VM_123_201_centos kernel: Killed process 19452 (httpd) total-vm:516404kB, anon-rss:36088kB, file-rss:168kB, shmem-rss:12kB
207+
```
208+
209+
- 对于 1G 的内存 MySQL(5.6.35),建议重点下面配置:
210+
211+
```
212+
[mysqld]
213+
table_definition_cache=400
214+
table_open_cache=256
215+
innodb_buffer_pool_size = 64M
216+
max_connections = 100
217+
```
218+
219+
- 增加 swap(云服务基本都是没 swap 的)
220+
- 分别执行下面 shell 命令:
221+
222+
```
223+
dd if=/dev/zero of=/swapfile bs=1M count=1024
224+
mkswap /swapfile
225+
swapon /swapfile
226+
```
227+
228+
- 修改配置文件:`vim /etc/fstab`
229+
- 添加这句在文件最后一行:`/swapfile swap swap defauluts 0 0`
230+
- 重启机子:`reboot`
231+
199232
## MySQL 主从复制
200233

201234
### 环境说明和注意点

0 commit comments

Comments
 (0)