<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>服务 &#8211; ChaBug安全</title>
	<atom:link href="/tags/%E6%9C%8D%E5%8A%A1/feed" rel="self" type="application/rss+xml" />
	<link>/</link>
	<description>一个分享知识、结识伙伴、资源共享的博客</description>
	<lastBuildDate>Mon, 30 Jul 2018 05:22:56 +0000</lastBuildDate>
	<language>zh-CN</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=5.5.5</generator>
	<item>
		<title>MySQL服务一直挂掉的解决方法</title>
		<link>/safeprotect/480.html</link>
					<comments>/safeprotect/480.html#comments</comments>
		
		<dc:creator><![CDATA[Y4er]]></dc:creator>
		<pubDate>Mon, 30 Jul 2018 05:22:56 +0000</pubDate>
				<category><![CDATA[安全运维]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[服务]]></category>
		<guid isPermaLink="false">/?p=480</guid>

					<description><![CDATA[这两天网站一直出现 Error establishing a database connection 登录服务器一看发现是MySQL服务挂了，这已经出现了好几次。今天我非得解决他不...]]></description>
										<content:encoded><![CDATA[<p><a href="https://dn-sdkcnssl.qbox.me/article/oSOqg0wB8ixn7TZ0gEJW.png"><img loading="lazy" class="aligncenter size-medium" src="https://dn-sdkcnssl.qbox.me/article/oSOqg0wB8ixn7TZ0gEJW.png" width="1280" height="662" /></a></p>
<p>这两天网站一直出现</p>
<h1>Error establishing a database connection</h1>
<p>登录<span class="wpcom_tag_link"><a href="/tags/%e6%9c%8d%e5%8a%a1" title="服务" target="_blank">服务</a></span>器一看发现是MySQL服务挂了，这已经出现了好几次。今天我非得解决他不可。</p>
<p>&nbsp;</p>
<p>先看下日志</p>
<pre class="lang:default decode:true">130728  6:50:14 [Note] Plugin 'FEDERATED' is disabled.
130728  6:50:14 InnoDB: The InnoDB memory heap is disabled
130728  6:50:14 InnoDB: Mutexes and rw_locks use GCC atomic builtins
130728  6:50:14 InnoDB: Compressed tables use zlib 1.2.3.4
130728  6:50:14 InnoDB: Initializing buffer pool, size = 128.0M
InnoDB: mmap(137363456 bytes) failed; errno 12
130728  6:50:14 InnoDB: Completed initialization of buffer pool
130728  6:50:14 InnoDB: Fatal error: cannot allocate memory for the buffer pool
130728  6:50:14 [ERROR] Plugin 'InnoDB' init function returned error.
130728  6:50:14 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
130728  6:50:14 [ERROR] Unknown/unsupported storage engine: InnoDB
130728  6:50:14 [ERROR] Aborting
130728  6:50:14 [Note] /usr/sbin/mysqld: Shutdown complete</pre>
<p>百度了一波，发现是因为MySQL5.5占用内存太大，然后服务器撑不住就挂了。我也是无奈脸，MySQL也欺负穷人。</p>
<p>&nbsp;</p>
<p>解决方法：</p>
<p>修改my.ini</p>
<pre class="lang:default decode:true">innodb_buffer_pool_size = 64M</pre>
<p>根据自己服务器的性能来配置MySQL的性能，太小网站卡，太大服务挂。你明白我意思吧？</p>
<p>如果可以的话你需要设置下swap分区。因为我的vps是没有swap分区的，通过fdisk -l 和 1mount 看不到swap的信息，需要手动添加一下。</p>
<p>添加swap分区的步骤：</p>
<pre class="lang:default decode:true">2.1) dd if=/dev/zero of=/swapfile bs=1M count=1024
2.2) mkswap /swapfile
2.3) swapon /swapfile
2.4) 添加这行： /swapfile swap swap defaults 0 0 到 /etc/fstab</pre>
<p>重启MySQL服务。</p>
<p>&nbsp;</p>
<p>这两天再观察观察会不会挂了。</p>
]]></content:encoded>
					
					<wfw:commentRss>/safeprotect/480.html/feed</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
			</item>
	</channel>
</rss>
