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 ...
随机推荐
- 《Thinking in Java》学习笔记(四)
1.Java中的闭包与回调 闭包(Closure)是一种能被调用的对象,它保存了创建它的作用域的信息.JAVA并不能显式地支持闭包,但是在JAVA中,闭包可以通过“接口+内部类”来实现,因为对于非静态 ...
- BZOJ 4518: [Sdoi2016]征途 [斜率优化DP]
4518: [Sdoi2016]征途 题意:\(n\le 3000\)个数分成m组,一组的和为一个数,求最小方差\(*m^2\) DP方程随便写\(f[i][j]=min\{f[k][j-1]+(s[ ...
- 2018/2/13 ElasticSearch学习笔记三 自动映射以及创建自动映射模版,ElasticSearch聚合查询
终于把这些命令全敲了一遍,话说ELK技术栈L和K我今天花了一下午全部搞定,学完后还都是花式玩那种...E却学了四天(当然主要是因为之前上班一直没时间学,还有安装服务时出现的各种error真是让我扎心了 ...
- 剑指offer试题(PHP篇四)
16.合并两个排序的链表 题目描述 输入两个单调递增的链表,输出两个链表合成后的链表,当然我们需要合成后的链表满足单调不减规则. 时间限制:1秒 空间限制:32768K <?php /*c ...
- 菜鸟的it之路-起航
之前在知乎上看见怎么学习数据结构下一位答主的回答,他引用了N.Wirth(沃斯)的话:程序=数据结构+算法.(哈,菜鸟无法验证这句话的正确性有多大)但毫无疑问的是,数据结构应当是一名菜鸟程序狗要重点学 ...
- msp430系统时钟
转自 http://m.blog.csdn.net/blog/msdumin/38441493# MSP430基础时钟模块包含以下3个时钟输入源. 一.4个时钟振荡源 1.LFXT1CLK: 外部晶 ...
- 用Android属性动画实现和演示迪士尼动画基本原则
本文将介绍在Android平台上实现和演示迪士尼动画基本准则. 项目开源,GitHub: https://github.com/vhow/animation 说明: 演示动画原则的想法源自 Anima ...
- LeetCode - 540. Single Element in a Sorted Array
Given a sorted array consisting of only integers where every element appears twice except for one el ...
- yum出问题啦
BUG 不小心把/usr/local上的一堆文件(夹)给删除了,于是乎,一堆问题冒出来了 loading mirror speeds from cached hostfile 解决方法 一定要执行 y ...
- 百度编辑器Ueditor增加字体的修改方法
http://www.jb51.net/article/109896.htm Ueditor本身自带11种字体 使用过程中这11种字体往往不能满足我们的需求,现在我要添加"仿宋" ...