Centos运行Mysql因为内存不足进程被杀
今天刚刚申请了一个新的域名,在申请完域名刚准备绑定给小伙伴分享注册新域名的喜悦时,刚把网站发到我们小伙伴们的讨论群里,却发现访问不了了,提示,数据库连接失败!
真的时一个尴尬..... 所有人都进不了我的网站,然后登录centos后台,发现了这样的提示
out of memory ! Kill process (Mysqld) 我英语未过四级,但是这个简单英文还是能看懂的,大致意思时内存不够了,然后把mysql的进程给杀掉了,阿西吧!!!
尴尬了,怎么办? 小伙伴们不能让我太尴尬啊,所以给我提了建议,说可以通过修改mysql的配置文件my.ini实现降低mysql的运行所占用内容。
然后找了资料,有一片就不错的文章,在这里就不造轮子重写了,在此转载过来,同时表示谢意。
文章内容如下: 供大家参考
这个配制文件就能满足我们的大多需要;
和Key_reads,可以知道key_buffer_size 设置是否合理。比例key_reads/key_read_requests 应该尽可 能的低,至少是1:100,1:1000
更好(上述状态值可以使用SHOW STATUS LIKE'key_read%'获得)。 或者如果你装了phpmyadmin可以通过服务器运行状态看到,笔者推荐用phpmyadmin管理mysql,以下的状态值都是本人通过phpmyadmin
获得的。
用户手册,使用查询缓冲最多可以达到238%的效率.通过调节以下几个参数可以知道query_cache_size 设置得是否合理
语句中加入SQL_NO_CACHE 可以明确表示不使用查询缓冲。
在不断增长,那么你就需要增加table_cache 的值了(上述状态值可以使用SHOW STATUS LIKE'Open%tables'获得)。注意,不能盲目地把table_cache
设置成很大的值。如果设置得太高,可能会造成文件描述符不足,从而造成性能不 稳定或者连接失败。对于有1G
内存的机器,推荐值是128-256。
的值应该用处不大。如果运行了6 个小时就出现上述值 那就要考虑增大table_cache
指定日志文件,如果不提供文件名,MySQL 将自己产生缺省文件名。MySQL会在文件名后面自动添加数字引,每次启动服务时,都会重新生成一个新的二进制文件。此外,使用log-bin-index
可以指定索引文件;使用binlog-do-db 可以指定记
是4.1.0 以后引入的参数,它指示记录不使用索引的查询。
值指出在MySQL 暂时停止回答新请求之前的短时间内多少个请求可以被存在堆栈中。只有如果期望在一个短时间内有很多连接,你需要增加它,换句话说,这值对到来的TCP/IP
连接的侦听队列的大小。你的操作系统在这个队列大小上有它自己的限制。 检查你的OS 文档找出这个变量的最大值。试图设定back_log
高于你的操作系统的限制将是无效的。
- # Example MySQL config file for medium systems.
- #
- # This is for a system with little memory (32M - 64M) where MySQL plays
- # an important part, or systems up to 128M where MySQL is used together
- with
- # other programs (such as a web server)
- directory is /var/lib/mysql) or
- # ~/.my.cnf to set user-specific options.
- #
- # In this file, you can use all long options that a program supports.
- # If you want to know which options a program supports, run the program
- # with the "--help" option.
- # The following options will be passed to all MySQL clients
- [client]
- #password = your_password
- port = 3306
- socket = /tmp/mysql.sock
- #socket = /var/lib/mysql/mysql.sock
- # Here follows entries for some specific programs
- # The MySQL server
- [mysqld]
- port = 3306
- socket = /tmp/mysql.sock
- #socket = /var/lib/mysql/mysql.sock
- skip-locking
- key_buffer = 128M
- max_allowed_packet = 1M
- table_cache = 256
- sort_buffer_size = 1M
- net_buffer_length = 16K
- myisam_sort_buffer_size = 1M
- max_connections=120
- #addnew config
- wait_timeout =120
- back_log=100
- read_buffer_size = 1M
- thread_cache=32
- skip-innodb
- skip-bdb
- skip-name-resolve
- join_buffer_size=512k
- query_cache_size = 32M
- interactive_timeout=120
- long_query_time=10
- TCP/IP port at all. This can be a security enhancement,
- # if all processes that need to connect to mysqld run on the same host.
- # All interaction with mysqld must be made via Unix sockets or named pipes.
- # Note that using this option without enabling named pipes on Windows
- # (via the "enable-named-pipe" option) will render mysqld useless!
- #
- #skip-networking
- # Replication Master Server (default)
- # binary logging is required for replication
- #log-bin
- # required unique id between 1 and 2^32 - 1
- # defaults to 1 if master-host is not set
- # but will not function as a master if omitted
- server-id = 1
- # Replication Slave (comment out master section to use this)
- #
- # To configure this host as a replication slave, you can choose between
- # two methods :
- #
- # 1) Use the CHANGE MASTER TO command (fully described in our manual) -
- # the syntax is:
- #
- # CHANGE MASTER TO MASTER_HOST=, MASTER_PORT= ,
- # MASTER_USER=, MASTER_PASSWORD= ;
- #
- # where you replace , , by quoted strings and
- # by the master's port number (3306 by default).
- #
- # Example:
- #
- # CHANGE MASTER TO MASTER_HOST='125.564.12.1', MASTER_PORT=3306,
- # MASTER_USER='joe', MASTER_PASSWORD='secret';
- #
- # OR
- #
- # 2) Set the variables below. However, in case you choose this method,
- then
- # start replication for the first time (even unsuccessfully, for example
- # if you mistyped the password in master-password and the slave fails to
- # connect), the slave will create a master.info file, and any later
- # change in this file to the variables' values below will be ignored and
- # overridden by the content of the master.info file, unless you shutdown
- # the slave server, delete master.info and restart the slaver server.
- # For that reason, you may want to leave the lines below untouched
- # (commented) and instead use CHANGE MASTER TO (see above)
- #
- # required unique id between 2 and 2^32 - 1
- # (and different from the master)
- # defaults to 2 if master-host is set
- # but will not function as a slave if omitted
- #server-id = 2
- #
- # The replication master for this slave - required
- #master-host =
- #
- # The username the slave will use for authentication when connecting
- # to the master - required
- #master-user =
- #
- # The password the slave will authenticate with when connecting to
- # the master - required
- #master-password =
- #
- # The port the master is listening on.
- # optional - defaults to 3306
- #master-port =
- #
- # binary logging - not required for slaves, but recommended
- #log-bin
- # Point the following paths to different dedicated disks
- #tmpdir = /tmp/
- #log-update = /path-to-dedicated-directory/hostname
- # Uncomment the following if you are using BDB tables
- #bdb_cache_size = 4M
- #bdb_max_lock = 10000
- # Uncomment the following if you are using InnoDB tables
- #innodb_log_buffer_size = 8M
- #innodb_flush_log_at_trx_commit = 1
- #innodb_lock_wait_timeout = 50
- [mysqldump]
- quick
- max_allowed_packet = 16M
- [mysql]
- no-auto-rehash
- # Remove the next comment character if you are not familiar with SQL
- #safe-updates
- [isamchk]
- key_buffer = 20M
- sort_buffer_size = 20M
- read_buffer = 2M
- write_buffer = 2M
- [myisamchk]
- key_buffer = 20M
- sort_buffer_size = 20M
- read_buffer = 2M
- write_buffer = 2M
- [mysqlhotcopy]
- interactive-timeout
- # Example MySQL config file for medium systems.
- #
- # This is for a system with little memory (32M - 64M) where MySQL plays
- # an important part, or systems up to 128M where MySQL is used together
- with
- # other programs (such as a web server)
- directory is /var/lib/mysql) or
- # ~/.my.cnf to set user-specific options.
- #
- # In this file, you can use all long options that a program supports.
- # If you want to know which options a program supports, run the program
- # with the "--help" option.
- # The following options will be passed to all MySQL clients
- [client]
- #password = your_password
- port = 3306
- socket = /tmp/mysql.sock
- #socket = /var/lib/mysql/mysql.sock
- # Here follows entries for some specific programs
- # The MySQL server
- [mysqld]
- port = 3306
- socket = /tmp/mysql.sock
- #socket = /var/lib/mysql/mysql.sock
- skip-locking
- key_buffer = 128M
- max_allowed_packet = 1M
- table_cache = 256
- sort_buffer_size = 1M
- net_buffer_length = 16K
- myisam_sort_buffer_size = 1M
- max_connections=120
- #addnew config
- wait_timeout =120
- back_log=100
- read_buffer_size = 1M
- thread_cache=32
- skip-innodb
- skip-bdb
- skip-name-resolve
- join_buffer_size=512k
- query_cache_size = 32M
- interactive_timeout=120
- long_query_time=10
- TCP/IP port at all. This can be a security enhancement,
- # if all processes that need to connect to mysqld run on the same host.
- # All interaction with mysqld must be made via Unix sockets or named pipes.
- # Note that using this option without enabling named pipes on Windows
- # (via the "enable-named-pipe" option) will render mysqld useless!
- #
- #skip-networking
- # Replication Master Server (default)
- # binary logging is required for replication
- #log-bin
- # required unique id between 1 and 2^32 - 1
- # defaults to 1 if master-host is not set
- # but will not function as a master if omitted
- server-id = 1
- # Replication Slave (comment out master section to use this)
- #
- # To configure this host as a replication slave, you can choose between
- # two methods :
- #
- # 1) Use the CHANGE MASTER TO command (fully described in our manual) -
- # the syntax is:
- #
- # CHANGE MASTER TO MASTER_HOST=, MASTER_PORT= ,
- # MASTER_USER=, MASTER_PASSWORD= ;
- #
- # where you replace , , by quoted strings and
- # by the master's port number (3306 by default).
- #
- # Example:
- #
- # CHANGE MASTER TO MASTER_HOST='125.564.12.1', MASTER_PORT=3306,
- # MASTER_USER='joe', MASTER_PASSWORD='secret';
- #
- # OR
- #
- # 2) Set the variables below. However, in case you choose this method,
- then
- # start replication for the first time (even unsuccessfully, for example
- # if you mistyped the password in master-password and the slave fails to
- # connect), the slave will create a master.info file, and any later
- # change in this file to the variables' values below will be ignored and
- # overridden by the content of the master.info file, unless you shutdown
- # the slave server, delete master.info and restart the slaver server.
- # For that reason, you may want to leave the lines below untouched
- # (commented) and instead use CHANGE MASTER TO (see above)
- #
- # required unique id between 2 and 2^32 - 1
- # (and different from the master)
- # defaults to 2 if master-host is set
- # but will not function as a slave if omitted
- #server-id = 2
- #
- # The replication master for this slave - required
- #master-host =
- #
- # The username the slave will use for authentication when connecting
- # to the master - required
- #master-user =
- #
- # The password the slave will authenticate with when connecting to
- # the master - required
- #master-password =
- #
- # The port the master is listening on.
- # optional - defaults to 3306
- #master-port =
- #
- # binary logging - not required for slaves, but recommended
- #log-bin
- # Point the following paths to different dedicated disks
- #tmpdir = /tmp/
- #log-update = /path-to-dedicated-directory/hostname
- # Uncomment the following if you are using BDB tables
- #bdb_cache_size = 4M
- #bdb_max_lock = 10000
- # Uncomment the following if you are using InnoDB tables
- #innodb_log_buffer_size = 8M
- #innodb_flush_log_at_trx_commit = 1
- #innodb_lock_wait_timeout = 50
- [mysqldump]
- quick
- max_allowed_packet = 16M
- [mysql]
- no-auto-rehash
- # Remove the next comment character if you are not familiar with SQL
- #safe-updates
- [isamchk]
- key_buffer = 20M
- sort_buffer_size = 20M
- read_buffer = 2M
- write_buffer = 2M
- [myisamchk]
- key_buffer = 20M
- sort_buffer_size = 20M
- read_buffer = 2M
- write_buffer = 2M
- [mysqlhotcopy]
- interactive-timeout
Centos运行Mysql因为内存不足进程被杀的更多相关文章
- (1.1)学习笔记之mysql体系结构(内存、进程、线程)
关键词:mysql体系结构 参考:https://www.cnblogs.com/zhoubaojian/articles/7866292.html 一.mysql体系架构概述 1.mysql体系结构 ...
- 在docker中运行mysql实例
Docker是一种新兴的虚拟化技术,能够一定程度上的代替传统虚拟机.下图是容器跟虚拟机的对比 对docker有个大致了解,学习docker断断续续,虽说学习不能急于求成,但断断续续学的话,浪费的碎片化 ...
- mysql大内存高性能优化方案
mysql优化是一个相对来说比较重要的事情了,特别像对mysql读写比较多的网站就显得非常重要了,下面我们来介绍mysql大内存高性能优化方案 8G内存下MySQL的优化 按照下面的设置试试看:key ...
- Centos搭建mysql/Hadoop/Hive/Hbase/Sqoop/Pig
目录: 准备工作 Centos安装 mysql Centos安装Hadoop Centos安装hive JDBC远程连接Hive Hbase和hive整合 Centos安装Hbase 准备工作: 配置 ...
- Mysql占用内存过高的优化过程
一.环境说明: 操作系统:CentOS 6.5 x86_64 数据库:Mysql 5.6.22 服务器:阿里云VPS,32G Mem,0 swap 二.问题情况: 1.某日发现公司线上系统的Mysql ...
- 记一次Mysql占用内存过高的优化过程
一.环境说明: 操作系统:CentOS 6.5 x86_64 数据库:Mysql 5.6.22 服务器:阿里云VPS,32G Mem,0 swap 二.问题情况: 1.某日发现公司线上系统的Mysql ...
- CentOS 下 MySQL DateBasic 抢救
CentOS 下 MySQL DateBasic 抢救 强 Kill 数据库进程. 分析问题:确定报错内容 报错信息:The server quit without updating PID file ...
- 在本地计算机无法启动MYSQL服务错误1067进程意外终止
在本地计算机无法启动MYSQL服务错误1067进程意外终止 这种情况一般是my.ini文件配置出错了, 你可以删除系统目录下的my.ini文件, 把下面的内容重新写入my.ini文件试试, 要适当地改 ...
- centOS安装Mysql指南
centOS安装Mysql指南 说明:使用操作系统centOS6.4 32位系统:mysql:mysql-5.7.10-linux-glibc2.5-i686.tar.gz; 一.准备 下载mysql ...
随机推荐
- PowerShell 并行执行任务
在 PowerShell 中可以轻松的执行后台任务并且让多个后台任务并行执行.本文介绍 PowerShell 中 Job 相关的一些命令,并通过 demo 演示如何在后台同时执行多个任务. Power ...
- wordpress配置固定链接nginx访问404问题解决方法
WordPress支持使用固定链接,但是在ngnix环境下,访问页面后出现404, 其实官方是有文档说明的,需要单独写配置, 我这边配置的示例代码如下: server { listen 8 ...
- pinvoke 数据交互笔记
intptr to array string string[] _outputStrArray=null; int channelCount = 0;///返回数组大小 In ...
- 【学习笔记】Hibernate HQL连接查询和数据批处理 (Y2-1-7)
HQL连接查询 和SQL查询一样 hql也支持各种链接查询 如内连接 外连接 具体如下 左外连接 left (outer) join 迫切左外连接 left (outer) join fetch 右外 ...
- Java经典编程题50道之十四
输入某年某月某日,判断这一天是这一年的第几天? public class Example14 { public static void main(String[] args) { ...
- Ubantu16.04 redis安装
通过FTP方式将redis的安装包从windows上传到linux上 解压命令:$sudo tar -zxf ~/Downloads/redis-3.2.7.tar.gz -C /usr/local ...
- node.js简单搭建服务,访问本地站点文件
1.安装nodejs服务(从官网下载安装),node相当于apache服务器 2.在自己定义的目录下新建服务器文件如 server.js 例如,我在D:\nodeJs下创建了server.js文件 v ...
- RHEL6误安装RHEL7的包导致glibc被升级后系统崩溃处理方法
RHEL6误使用了RHEL7的光盘源,安装了某个RPM包之后,导致glibc被升级,进而导致系统崩溃. [root@rhel65 ~]# yum install ftp Loaded plugin ...
- .addClass(),.removeClass(),.toggleClass()的区别
.addClass("className")方法是用来给指定元素增加类名,也就是说给指定的元素追加样式: 可以同时添加多个类名,空格符隔开 $("selector&quo ...
- MIPS中有关于分支指令及跳转寻址
分支指令 分支指令包含该指令,和两个操作数,以及跳转的分支地址,该地址是相对于下一条指令的相对地址 分支指令占6位 操作数1占5位 操作数2占5位 分支指令16位 例如 bne ...