<?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>#raynix# &#187; mysql</title>
	<atom:link href="http://raynix.info/archives/tag/mysql/feed" rel="self" type="application/rss+xml" />
	<link>http://raynix.info</link>
	<description>The real world hurts, doesn't it? </description>
	<lastBuildDate>Sat, 04 Sep 2010 07:51:14 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>让Mysql server接受远程访问</title>
		<link>http://raynix.info/archives/873</link>
		<comments>http://raynix.info/archives/873#comments</comments>
		<pubDate>Wed, 06 Jan 2010 07:52:45 +0000</pubDate>
		<dc:creator>raynix</dc:creator>
				<category><![CDATA[Free software]]></category>
		<category><![CDATA[Opensource]]></category>
		<category><![CDATA[mysql]]></category>

		<guid isPermaLink="false">http://raynix.info/?p=873</guid>
		<description><![CDATA[一直以来，由于我没做过什么大网站，或者说没把任何网站做大 -_-b 总之我用的LAMP都在一个box里。那么如果把数据库服务隔离出来单独做一个box，该怎么办呢？ 首先，修改mysql的配置文件（以mysql 5.0为例）： $ sudo vim /etc/mysql/my.cnf 找到 bind-address            = 127.0.0.1 将127.0.0.1替换为服务器的外部IP，然后存盘退出。 为了避免缓慢的远程连接，还必须在[mysqld]段加上： skip-name-resolve 下一步是在mysql中为远程用户开启权限： mysql&#62;GRANT ALL ON your-database.* TO 'your-user'@'client-name or IP' [IDENTIFIED BY 'yourpass']; mysql&#62;FLUSH PRIVILEDGES; 下一步，要确认firewall为mysql连接让路。以ufw为例： $ sudo ufw allow 3306 这样简单的开放了3306端口，但没有做任何限制。差不多了吧，从client一端可以测试一下了： $ mysql -h mysql-server -u your-user  [-p] © raynix for #raynix#, 2010. &#124; Permalink &#124; 唉, 一个评论都没 &#124; [...]]]></description>
			<content:encoded><![CDATA[<p>一直以来，由于我没做过什么大网站，或者说没把任何网站做大 -_-b 总之我用的LAMP都在一个box里。那么如果把数据库服务隔离出来单独做一个box，该怎么办呢？</p>
<p>首先，修改mysql的配置文件（以mysql 5.0为例）：</p>
<blockquote><p>$ sudo vim /etc/mysql/my.cnf</p></blockquote>
<p>找到</p>
<blockquote><p>bind-address            = 127.0.0.1</p></blockquote>
<p>将127.0.0.1替换为服务器的外部IP，然后存盘退出。</p>
<p>为了<a href="http://bobbyallen.wordpress.com/2007/11/02/slow-connections-on-remote-mysql-servers/" target="_blank">避免缓慢的远程连接</a>，还必须在[mysqld]段加上：</p>
<blockquote><p><span style="color: #ff0000;">skip-name-resolve</span></p></blockquote>
<p>下一步是在mysql中为远程用户开启权限：</p>
<blockquote><p>mysql&gt;GRANT ALL ON your-database.* TO 'your-user'@'client-name or IP' [IDENTIFIED BY 'yourpass'];</p>
<p>mysql&gt;FLUSH PRIVILEDGES;</p></blockquote>
<p>下一步，要确认firewall为mysql连接让路。以ufw为例：</p>
<blockquote><p>$ sudo ufw allow 3306</p></blockquote>
<p>这样简单的开放了3306端口，但没有做任何限制。差不多了吧，从client一端可以测试一下了：</p>
<blockquote><p>$ mysql -h mysql-server -u your-user  [-p]</p></blockquote>
<p> <img src='http://raynix.info/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<hr />
<p><small>© raynix for <a href="http://raynix.info">#raynix#</a>, 2010. |
<a href="http://raynix.info/archives/873">Permalink</a> |
<a href="http://raynix.info/archives/873#comments">唉, 一个评论都没</a> |
Add to
<a href="http://del.icio.us/post?url=http://raynix.info/archives/873&title=让Mysql server接受远程访问">del.icio.us</a>
<br/>
Post tags: <a href="http://raynix.info/archives/tag/mysql" rel="tag">mysql</a><br/>
</small></p>
<p><small>Feed enhanced by <a href='http://planetozh.com/blog/my-projects/wordpress-plugin-better-feed-rss/'>Better Feed</a> from  <a href='http://planetozh.com/blog/'>Ozh</a></small></p>
]]></content:encoded>
			<wfw:commentRss>http://raynix.info/archives/873/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>LAMP服务器的简单备份方法</title>
		<link>http://raynix.info/archives/561</link>
		<comments>http://raynix.info/archives/561#comments</comments>
		<pubDate>Thu, 11 Jun 2009 06:49:19 +0000</pubDate>
		<dc:creator>raynix</dc:creator>
				<category><![CDATA[Free software]]></category>
		<category><![CDATA[Networking]]></category>
		<category><![CDATA[Opensource]]></category>
		<category><![CDATA[cron]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[ssh]]></category>
		<category><![CDATA[备份]]></category>
		<category><![CDATA[开源]]></category>

		<guid isPermaLink="false">http://raynix.cn/?p=561</guid>
		<description><![CDATA[我用CentOS作为网站服务器的OS，我是这样备份我的网站的。 以下简称网站服务器为C，我的电脑是A。首先，在C上用一段shell script备份网站： backup.sh #! /bin/bash # This script is to backup the website files and db mysqldump mydb -pmypass &#62;/var/www/mysite/mydump.sql datestamp=`date +%Y%m%d` filewww="/home/myuser/backup/mysite_""$datestamp"".zip" zip -r $filewww /var/www/mysite 然后可以先运行一下这个script，看看结果是否符合预期。如果没问题，就可以将其加入到crontab了，每天自动运行。 59 3 * * * /bin/bash /home/myuser/backup.sh 这样C这边每天凌晨会备份一次并生成一个zip压缩包。但是把C的备份留在C就没意义了，我还要定期的把zip从C传到A。由于A不像C那样不间断运行的，所以如果从C向A传输就需要测试A是否在线，麻烦。不如让A取C上的zip。这就涉及到另一个问题，身份验证。 为一段自动运行的script提供password，我觉得不如使用public key验证来得专业，而且简单，两步就搞定： ssh-keygen -t rsa ssh-copy-id -i .ssh/id_rsa.pub myuser@C 这期间问到private key password时直接回车就行了；myuser@C的password还是需要输入的（否则……）。 下一步就是在A上写script，获取C上的备份，成功获取后删除C上的备份，并将A本机上超过一个月的备份删除。 backup-mysite.sh #!/bin/bash #by Raymond, Jun, [...]]]></description>
			<content:encoded><![CDATA[<p>我用CentOS作为网站服务器的OS，我是这样备份我的网站的。</p>
<p>以下简称网站服务器为C，我的电脑是A。首先，在C上用一段shell script备份网站：</p>
<p>backup.sh</p>
<blockquote><p>#! /bin/bash<br />
# This script is to backup the website files and db</p>
<p>mysqldump mydb -pmypass &gt;/var/www/mysite/mydump.sql</p>
<p>datestamp=`date +%Y%m%d`<br />
filewww="/home/myuser/backup/mysite_""$datestamp"".zip"</p>
<p>zip -r $filewww /var/www/mysite</p></blockquote>
<p>然后可以先运行一下这个script，看看结果是否符合预期。如果没问题，就可以将其加入到crontab了，每天自动运行。</p>
<blockquote><p>59 3 * * * /bin/bash /home/myuser/backup.sh</p></blockquote>
<p>这样C这边每天凌晨会备份一次并生成一个zip压缩包。但是把C的备份留在C就没意义了，我还要定期的把zip从C传到A。由于A不像C那样不间断运行的，所以如果从C向A传输就需要测试A是否在线，麻烦。不如让A取C上的zip。这就涉及到另一个问题，身份验证。</p>
<p>为一段自动运行的script提供password，我觉得不如使用public key验证来得专业，而且简单，两步就搞定：</p>
<blockquote><p>ssh-keygen -t rsa</p>
<p>ssh-copy-id -i .ssh/id_rsa.pub myuser@C</p></blockquote>
<p>这期间问到private key password时直接回车就行了；myuser@C的password还是需要输入的（否则……）。</p>
<p>下一步就是在A上写script，获取C上的备份，成功获取后删除C上的备份，并将A本机上超过一个月的备份删除。</p>
<p>backup-mysite.sh</p>
<blockquote><p>#!/bin/bash<br />
#by Raymond, Jun, 2009<br />
#1, get backup files from ...<br />
#2, delete after a successful copy<br />
scp myuser@C:/home/myuser/backup/*.zip /home/myuser/backup<br />
if [ $? -eq 0 ]<br />
then<br />
ssh myuser@C rm /home/myuser/backup/*.zip<br />
fi</p>
<p>#3, delete old backup files here<br />
find /home/myuser/backup/*.zip -mtime +30 -exec rm {} \;</p></blockquote>
<p>最后在把此script添加到A的crontab基本就没事了。过程类似上面的crontab，就偷懒不写了。注：懒是SA的美德。</p>
<p>Update: mysqldump --opt 对于恢复数据是个很好的开关.</p>
<hr />
<p><small>© raynix for <a href="http://raynix.info">#raynix#</a>, 2009. |
<a href="http://raynix.info/archives/561">Permalink</a> |
<a href="http://raynix.info/archives/561#comments">3 条评论</a> |
Add to
<a href="http://del.icio.us/post?url=http://raynix.info/archives/561&title=LAMP服务器的简单备份方法">del.icio.us</a>
<br/>
Post tags: <a href="http://raynix.info/archives/tag/cron" rel="tag">cron</a>, <a href="http://raynix.info/archives/tag/linux" rel="tag">linux</a>, <a href="http://raynix.info/archives/tag/mysql" rel="tag">mysql</a>, <a href="http://raynix.info/archives/tag/ssh" rel="tag">ssh</a>, <a href="http://raynix.info/archives/tag/%e5%a4%87%e4%bb%bd" rel="tag">备份</a>, <a href="http://raynix.info/archives/tag/%e5%bc%80%e6%ba%90" rel="tag">开源</a><br/>
</small></p>
<p><small>Feed enhanced by <a href='http://planetozh.com/blog/my-projects/wordpress-plugin-better-feed-rss/'>Better Feed</a> from  <a href='http://planetozh.com/blog/'>Ozh</a></small></p>
]]></content:encoded>
			<wfw:commentRss>http://raynix.info/archives/561/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
