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 ...
随机推荐
- 洛谷 [P2420] 让我们异或吧
某两点之间的路径上所有边权的异或值即dis1^dis2--^disn. 由于x^y^y=x,所以dfs预处理出每一点到根节点的异或值,对于每次询问,直接输出 disu^disv. #include & ...
- BZOJ 1854: [Scoi2010]游戏 [连通分量 | 并查集 | 二分图匹配]
题意: 有$n \le 10^6$中物品,每种两个权值$\le 10^4$只能选一个,使得选出的所有权值从1递增,最大递增到多少 一开始想了一个奇怪的规定流量网络流+二分答案做法...然而我还不知道怎 ...
- python重新利用shodan API
前言: 之前写过一个shodan的API调用 感觉写的不这么好.然后现在重新写一个 shodan介绍: shodan是互联网上最可怕的搜索引擎. CNNMoney的一篇文章写道,虽然目前人们都认为谷歌 ...
- 搭建SS服务器
体验: http://ss.ishadowx.com/ centos7 安装shadowsocks客户端 http://blog.csdn.net/guyan0319/article/details/ ...
- 搭建简易的c语言与python语言CGI和Apache服务器的开发环境
搭建简易的c语言CGI和Apache服务器的开发环境 http://www.cnblogs.com/tt-0411/archive/2011/11/21/2257203.html python配置ap ...
- mysql查找以逗号分隔的值-find_in_set
有了FIND_IN_SET这个函数.我们可以设计一个如:一只手机即是智能机,又是Andriod系统的. 比如:有个产品表里有一个type字段,他存储的是产品(手机)类型,有 1.智能机,2.Andri ...
- Sublime Text3 快捷键汇总及设置快捷键配置环境变量
Ctrl+D 选词 (反复按快捷键,即可继续向下同时选中下一个相同的文本进行同时编辑)Ctrl+G 跳转到相应的行Ctrl+J 合并行(已选择需要合并的多行时)Ctrl+L 选择整行(按住-继续选择下 ...
- wordpress配置固定链接nginx访问404问题解决方法
WordPress支持使用固定链接,但是在ngnix环境下,访问页面后出现404, 其实官方是有文档说明的,需要单独写配置, 我这边配置的示例代码如下: server { listen 8 ...
- mysql 修改默认字符集为utf8
MySQL 5.5, all you need is: [mysqld] character_set_client=utf8 character_set_server=utf8 collation_s ...
- 听闰土大话前端之ES6是怎么来的
前言 相信做前端的朋友没有不知道ECMAScript6的,都知晓ES6新增了不少新的特性,但是你知道ES6是怎么来的吗?今天就让闰土来带大家大话ES6的前世今生.当然了,这篇文章会以扫盲为主,科普为辅 ...