<?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>skidu</title>
	<atom:link href="http://www.skidu.me/feed" rel="self" type="application/rss+xml" />
	<link>http://www.skidu.me</link>
	<description>走走看看记记 &#124; 瞎折腾 &#124; skidu的口水基地</description>
	<lastBuildDate>Tue, 15 May 2012 13:26:34 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>ImageMagick编译安装笔记</title>
		<link>http://www.skidu.me/imagemagick_php.html</link>
		<comments>http://www.skidu.me/imagemagick_php.html#comments</comments>
		<pubDate>Tue, 15 May 2012 13:24:33 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[LAMP]]></category>
		<category><![CDATA[imagemagick]]></category>
		<category><![CDATA[imagemagick php]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[phpize]]></category>

		<guid isPermaLink="false">http://www.skidu.me/?p=1298</guid>
		<description><![CDATA[多余的废话不多说了，直接上正文。

前提：俺的机器已经装好了Apache 、 PHP 等等等 当然，如果你的环境中还没有安装好这些环境，过段时间skidu将放出完整的Apache+PHP+MySQL的安装笔记以供参考，或者可以直接运行yum -y install php httpd mysqld执行安装

操作环境：CentOS 5.5 x64

<span class="readmore"><a href="http://www.skidu.me/imagemagick_php.html" title="ImageMagick编译安装笔记">阅读全文——共1853字</a></span>]]></description>
			<content:encoded><![CDATA[<p>多余的废话不多说了，直接上正文。<br />
前提：俺的机器已经装好了Apache 、 PHP 等等等 当然，如果你的环境中还没有安装好这些环境，过段时间skidu将放出完整的Apache+PHP+MySQL的安装笔记以供参考，或者可以直接运行yum -y install <span class='wp_keywordlink_affiliate'><a href="http://www.skidu.me/tag/php-2" title="查看 php 中的全部文章" target="_blank">php</a></span> httpd mysqld执行安装<br />
操作环境：CentOS 5.5 x64<br />
源码下载：<br />
ImageMagick源文件：前往ftp://ftp.<span class='wp_keywordlink_affiliate'><a href="http://www.skidu.me/tag/imagemagick" title="查看 imagemagick 中的全部文章" target="_blank">imagemagick</a></span>.org/pub/ImageMagick/ ，下载所需要的源码（这里skidu下载的是ImageMagick-6.7.6-9.tar.gz）<br />
ImageMagick的PHP模块：前往http://pecl.<span class='wp_keywordlink_affiliate'><a href="http://www.skidu.me/tag/php-2" title="查看 php 中的全部文章" target="_blank">php</a></span>.net/package/imagick下载对应的源码（skidu下载的是imagick-3.0.1.tgz）</p>
<p>开始</p>
<p>·首先，我们需要安装ImageMagick</p>
<pre class="brush: bash; title: ; notranslate">
[root@ski img]# tar -xzvf ImageMagick-6.7.6-9.tar.gz
[root@ski img]# cd ImageMagick-6.7.6-9
[root@ski ImageMagick-6.7.6-9]# ./configure --prefix=/usr/local/ImageMagick --enable-shared --enable-lzw --enable-modules  #这里根据自己的实际需要指定安装目录
[root@ski ImageMagick-6.7.6-9]# make
[root@ski ImageMagick-6.7.6-9]# make install
</pre>
<p>·然后便是<span class='wp_keywordlink_affiliate'><a href="http://www.skidu.me/tag/php-2" title="查看 php 中的全部文章" target="_blank">php</a></span>需要的imagick模块<br />
（skidu之前在网上搜寻了一番，大多说要编译两次php，这可害苦了我，折腾了一下午愣是没装成功，估计是因为那几篇文章对应的php版本太低吧？skidu使用的是下面的方法装成功的）</p>
<pre class="brush: bash; title: ; notranslate">
[root@ski img]# tar -xzvf imagick-3.0.1.tgz
[root@ski img]# cd imagick-3.0.1
[root@ski imagick-3.0.1]# /usr/local/php/bin/phpize  #phpize路径，大家根据自己的实际情况使用。找不到的朋友可以使用locate phpize命令查找
[root@ski imagick-3.0.1]# ./configure --with-php-config=/usr/local/php/bin/php-config --with-imagick=/usr/local/imagemagick
[root@ski imagick-3.0.1]# make
[root@ski imagick-3.0.1]# make install
</pre>
<p>安装成功后系统会显示如下信息：<br />
Installing shared extensions:     /data/eyousns/php/lib/php/extensions/no-debug-zts-20060613/<br />
Installing header files:          /data/eyousns/php/include/php/</p>
<p>当然，skidu的安装失败了，在make结束的时候产生如下报错信息：<br />
make: *** [imagick_class.lo] Error 1</p>
<p>直接上解决方法：</p>
<pre class="brush: plain; title: ; notranslate">
[root@ski imagick-3.0.1]# export PKG_CONFIG_PATH=/usr/local/ImageMagick/lib/pkgconfig/
#这里是第一步中prefix指定的安装路径
#然后再接着从imagick安装./configure步骤重新来一次即可
</pre>
<p>至此，imagick安装完毕。<br />
接下来，我们需要将模块打到php中去，我们编辑php.ini文件<br />
找到   extension_dir = “/usr/local/php/lib/php/extensions/no-debug-zts-20060613&#8243;  （这里请根据自己php实际安装位置查找）<br />
在下面添加一句  extension=”imagick.so”     保存退出<br />
重启apache<br />
然后在网站根目录中新建文件phpinfo.php内容如下：</p>
<pre class="brush: php; title: ; notranslate">
&lt;?php
    phpinfo();
</pre>
<p>保存之后用浏览器访问该文件<br />
如果成功安装，那么你会在该页面中看见如下图所示的一段信息：<br />
<a href="http://www.skidu.me/wp-content/uploads/2012/05/imagick.png"><img src="http://www.skidu.me/wp-content/uploads/2012/05/imagick.png" alt="" title="imagick" width="609" height="574" class="alignnone size-full wp-image-1299" /></a></p>
<p>临时写的，没有怎么整理，只包含了所有安装步骤，没有解释请见谅。</p>
<p>祝好运：）</p>
]]></content:encoded>
			<wfw:commentRss>http://www.skidu.me/imagemagick_php.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>初识ClusterShell</title>
		<link>http://www.skidu.me/clustershell.html</link>
		<comments>http://www.skidu.me/clustershell.html#comments</comments>
		<pubDate>Thu, 03 May 2012 16:13:50 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[LAMP]]></category>
		<category><![CDATA[clustershell]]></category>

		<guid isPermaLink="false">http://www.skidu.me/?p=1285</guid>
		<description><![CDATA[ClusterShell 是一个事件驱动的用来执行本地或者远程计算机命令的 Python 库，基于所选择的引擎和工作者模式。

&#8211;摘自 开源中国



<span class="readmore"><a href="http://www.skidu.me/clustershell.html" title="初识ClusterShell">阅读全文——共3085字</a></span>]]></description>
			<content:encoded><![CDATA[<blockquote><p>ClusterShell 是一个事件驱动的用来执行本地或者远程计算机命令的 Python 库，基于所选择的引擎和工作者模式。</p>
<p style="text-align: right;">&#8211;摘自 开源中国</p>
</blockquote>
<p><strong>·缘由<strong></strong></strong></p>
<p>话说skidu上班已经一个月了，前不久有幸被提前转正，紧接着就接到一个项目是要给公司内部做一套服务器管理程序提供给研发部和技术支持部的同事使用，让他们可以在这上面浏览公司现有服务器，并且可以申请空闲中的公共服务器自己使用；</p>
<p>同时，网管也可以通过这套程序得知哪些服务器是长时间空闲的，这样他们就可以关掉这些机器，让公司的机房降降温（前段时间机房温度据说最高时候达到了恐怖的70℃），在一定程度上避免因为这个问题导致公司网络中断。</p>
<p>在开发之前，skidu和小组组长一块简单的对这套程序应该能实现些神马功能做了个大致分析，但限于上面催促的比较急，skidu只好先做一套“测试版”出来让他们先用着。程序在今天已经成功部署到服务器上面，随之新的需求就来了，希望能够实时监测到被控服务器的运行状态！</p>
<p>话说这套程序公司内之前是有人做过的，于是skidu找来了以前的源码读了起来，发现这个“实时监控”的功能以前就已经实现了，用的是一个clush命令在实现，苦苦搜寻，skidu终于找到了这款软件：ClusterShell</p>
<p><strong>·安装</strong></p>
<p>ClusterShell的安装很简单</p>
<p>首先，前往<a href="http://sourceforge.net/projects/clustershell/files/clustershell/">http://sourceforge.net/projects/clustershell/files/clustershell/</a>获取程序</p>
<p>这里skidu的测试机上面python是2.4.3版的，所以就使用了1.51版的<span class='wp_keywordlink_affiliate'><a href="http://www.skidu.me/tag/clustershell" title="查看 clustershell 中的全部文章" target="_blank">clustershell</a></span>（1.6版似乎必须在2.7+版python才能正常安装）</p>
<p>解压下载来的压缩包并进入程序目录：</p>
<pre class="brush: bash; title: ; notranslate">
[root@skidu ~]# tar -zxf clustershell-1.5.1.tar.gz
[root@skidu ~]# cd clustershell-1.5.1
[root@skidu clustershell-1.5.1]# ls
build              conf  lib                         README     setup.py
ChangeLog          dist  Licence_CeCILL-C_V1-en.txt  scripts    tests
clustershell.spec  doc   Licence_CeCILL-C_V1-fr.txt  setup.cfg
</pre>
<p>给程序赋予x权限</p>
<pre class="brush: bash; title: ; notranslate">
[root@skidu clustershell-1.5.1]#chmod +x -R ./*
</pre>
<p>执行安装</p>
<pre class="brush: bash; title: ; notranslate">
[root@skidu clustershell-1.5.1]#./python.py install
</pre>
<p>随后，程序会自动执行整个安装过程。</p>
<p>安装完毕后需要手工在/etc目录下建立一个<span class='wp_keywordlink_affiliate'><a href="http://www.skidu.me/tag/clustershell" title="查看 clustershell 中的全部文章" target="_blank">clustershell</a></span>的目录并将配置文件移至该目录下</p>
<pre class="brush: bash; title: ; notranslate">
[root@skidu clustershell-1.5.1]#mkdir /etc/clustershell
[root@skidu clustershell-1.5.1]#cp ./conf/* /etc/clustershell
</pre>
<p>至此，安装完毕</p>
<p><b>·简单使用</b></p>
<p>skidu需要的功能很简单，基于现已实现的ssh功能对每台受控进行一次基于key的访问并执行一条语句，如果能成功连接某台受控机那么我能获取到这条信息；如果某台受控机上面未放置共钥那么就会提示连接失败</p>
<p>好吧，咱来改改配置信息（/etc/<span class='wp_keywordlink_affiliate'><a href="http://www.skidu.me/tag/clustershell" title="查看 clustershell 中的全部文章" target="_blank">clustershell</a></span>/clush.conf）</p>
<pre class="brush: bash; title: ; notranslate">
[root@skidu clustershell-1.5.1]#vim /etc/clustershell/clush.conf
</pre>
<p>随后我们会看见如下所示的配置信息</p>
<pre class="brush: plain; title: ; notranslate">
# Configuration file for clush
#
# Please see man clush.conf(5)
#
# $Id: clush.conf 463 2011-02-09 21:57:52Z st-cea $
[Main]
fanout: 64
connect_timeout: 15
command_timeout: 0
color: auto
fd_max: 16384
history_size: 100
node_count: yes
verbosity: 1
#ssh_user: root
#ssh_path: /usr/bin/ssh
#ssh_options: -oStrictHostKeyChecking=no
</pre>
<p>这里skidu根据自己的实际需要做了个简单的配置，指定ssh连接用户为root，并指定密钥文件（因为skidu的这个密钥没有放置在~/.ssh目录）</p>
<p>最终的配置文件如下</p>
<pre class="brush: plain; title: ; notranslate">
# Configuration file for clush
#
# Please see man clush.conf(5)
#
# $Id: clush.conf 463 2011-02-09 21:57:52Z st-cea $
[Main]
fanout: 64
connect_timeout: 15
command_timeout: 0
color: auto
fd_max: 16384
history_size: 100
node_count: yes
verbosity: 1
ssh_user: root
#ssh_path: /usr/bin/ssh
#ssh_options: -oStrictHostKeyChecking=no
ssh_options: -i /xxxxx  #这里是密钥的绝对路径，就不写出来了
</pre>
<p>保存退出</p>
<p>再新建一个groups文件，里面写入需要监控的服务器的ip信息</p>
<pre class="brush: plain; title: ; notranslate">
dev:192.168.21.2 192.168.21.3
</pre>
<p>*skidu是在虚拟机中做的测试，其中，控制端的ip为192.168.21.116（好吧，这里说出来貌似没什么用），被控制端的ip是192.168.21.2，同时skidu还写了一个192.168.21.3这个不存在的ip地址用来模拟真实环境中有一台可能是关机或者网线掉了的服务器，这里大家可以根据自己的实际使用环境来编写此文档。</p>
<p>保存退出后便可以开始执行了</p>
<pre class="brush: bash; title: ; notranslate">
[root@skidu clustershell]# clush -g dev &quot;echo ok&quot; 2&gt;&amp;1 | grep -v &quot;clush&quot;
192.168.21.3: ssh: connect to host 192.168.21.3 port 22: No route to host
192.168.21.2: ok
</pre>
<p>改掉21.2上面存放公钥的名字，再来一次</p>
<pre class="brush: bash; title: ; notranslate">
[root@skidu clustershell]# clush -g dev &quot;echo ok&quot; 2&gt;&amp;1 | grep -v &quot;clush&quot;
192.168.21.2: Permission denied (publickey,gssapi-with-mic,password).
192.168.21.3: ssh: connect to host 192.168.21.3 port 22: No route to host
</pre>
<p>好吧，聪明的同学已经不需要再提示了，咱通过程序获取到这些信息，然后针对每一行中的关键词进行匹配，然后就可以判断服务器是否连接正常了~</p>
<p>如果哪位看官有更好的点子还请分享出来：）</p>
<p>最后，分享一份官方文档给大家~很有用的哟~</p>
<p>>>>>>>>> <a href='http://www.skidu.me/wp-content/uploads/2012/05/ClusterShell_UserGuide_EN_1.6.pdf'>ClusterShell_UserGuide_EN_1.6</a></p>
<p>PS：ad一下，skidu最近入手了一只vps，闲置中，有兴趣合租的朋友可以联系我[skidu对邻居要求很高的]~~ 送上探针一枚 <a href="http://108.171.241.235/tz.php" target="_blank">探针</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.skidu.me/clustershell.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>编译PHP时常见参数记录</title>
		<link>http://www.skidu.me/php-configure.html</link>
		<comments>http://www.skidu.me/php-configure.html#comments</comments>
		<pubDate>Tue, 24 Apr 2012 01:38:12 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[LAMP]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[php参数]]></category>
		<category><![CDATA[php编译]]></category>

		<guid isPermaLink="false">http://www.skidu.me/?p=1276</guid>
		<description><![CDATA[木有什么特别的。。看见别人有发，转过来记录一下

如果哪位童鞋有Apache、MySQL、Nginx的详细配置参数记得告诉我哦  



<span class="readmore"><a href="http://www.skidu.me/php-configure.html" title="编译PHP时常见参数记录">阅读全文——共1693字</a></span>]]></description>
			<content:encoded><![CDATA[<p>木有什么特别的。。看见别人有发，转过来记录一下<br />
如果哪位童鞋有Apache、MySQL、Nginx的详细配置参数记得告诉我哦 <img src='http://www.skidu.me/wp-includes/images/smilies/yct/yct007.gif' alt=':woo:' class='wp-smiley' /> </p>
<pre class="brush: bash; title: ; notranslate">
--prefix=/usr/local/PHP                     php 安装目录
--with-apxs2=/usr/local/apache/bin/apxs
--with-config-file-path=/usr/local/PHP/etc  指定php.ini位置
--with-MySQL=/usr/local/mysql               mysql安装目录，对mysql的支持
--with-MySQLi=/usr/local/mysql/bin/mysql_config  mysqli文件目录,优化支持
--enable-safe-mode          打开安全模式
--enable-ftp                打开ftp的支持
--enable-zip                打开对zip的支持
--with-bz2                  打开对bz2文件的支持
--with-jpeg-dir             打开对jpeg图片的支持
--with-png-dir              打开对png图片的支持
--with-freetype-dir         打开对freetype字体库的支持
--without-iconv             关闭iconv函数，种字符集间的转换
--with-libXML-dir           打开libxml2库的支持
--with-XMLrpc               打开xml-rpc的c语言
--with-zlib-dir             打开zlib库的支持
--with-gd                   打开gd库的支持
--enable-gd-native-ttf      支持TrueType字符串函数库
--with-curl                 打开curl浏览工具的支持
--with-curlwrappers         运用curl工具打开url流
--with-ttf                  打开freetype1.*的支持，可以不加了
--with-xsl                  打开XSLT 文件支持，扩展了libXML2库 ，需要libxslt软件
--with-gettext              打开gnu 的gettext 支持，编码库用到
--with-pear                 打开pear命令的支持，PHP扩展用的
--enable-calendar           打开日历扩展功能
--enable-mbstring           多字节，字符串的支持
--enable-bcmath             打开图片大小调整,用到zabbix监控的时候用到了这个模块
--enable-sockets            打开 sockets 支持
--enable-exif               图片的元数据支持
--enable-magic-quotes       魔术引用的支持
--disable-rpath             关闭额外的运行库文件
--disable-debug             关闭调试模式
--with-mime-magic=/usr/share/file/magic.mime  魔术头文件位置

CGI方式安装才用的参数
--enable-fpm                打上PHP-fpm 补丁后才有这个参数，CGI方式安装的启动程序
--enable-fastCGI            支持fastcgi方式启动PHP
--enable-force-CGI-redirect 同上 ,帮助里没有解释
--with-ncurses              支持ncurses 屏幕绘制以及基于文本终端的图形互动功能的动态库
--enable-pcntl              freeTDS需要用到的，可能是链接mssql 才用到

mhash和mcrypt算法的扩展
--with-mcrypt               算法
--with-mhash                算法

--with-gmp
--enable-inline-optimization
--with-openssl                    openssl的支持，加密传输时用到的
--enable-dbase
--with-pcre-dir=/usr/local/bin/pcre-config      perl的正则库案安装位置
--disable-dmalloc
--with-gdbm                     dba的gdbm支持
--enable-sigchild
--enable-sysvsem
--enable-sysvshm
--enable-zend-multibyte               支持zend的多字节
--enable-mbregex
--enable-wddx
--enable-shmop
--enable-soap
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.skidu.me/php-configure.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>发现新大陆</title>
		<link>http://www.skidu.me/sth_about_firefox.html</link>
		<comments>http://www.skidu.me/sth_about_firefox.html#comments</comments>
		<pubDate>Wed, 18 Apr 2012 02:21:21 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[乱七八糟]]></category>
		<category><![CDATA[3Ddiv]]></category>
		<category><![CDATA[查看元素]]></category>
		<category><![CDATA[火狐]]></category>

		<guid isPermaLink="false">http://www.skidu.me/?p=1271</guid>
		<description><![CDATA[其实是火狐的“查看元素”，貌似这个功能早就已经存在了，只是skidu一直以来习惯于使用firebug来看这些东东

今天在php.net溜达的时候本想点firebug来着，结果不小心点着了“查看元素”这个淫&#124;荡的选项

咦？这是怎么回事？firebug升级了？

<span class="readmore"><a href="http://www.skidu.me/sth_about_firefox.html" title="发现新大陆">阅读全文——共215字</a></span>]]></description>
			<content:encoded><![CDATA[<p>其实是<span class='wp_keywordlink_affiliate'><a href="http://www.skidu.me/tag/%e7%81%ab%e7%8b%90" title="查看 火狐 中的全部文章" target="_blank">火狐</a></span>的“<span class='wp_keywordlink_affiliate'><a href="http://www.skidu.me/tag/%e6%9f%a5%e7%9c%8b%e5%85%83%e7%b4%a0" title="查看 查看元素 中的全部文章" target="_blank">查看元素</a></span>”，貌似这个功能早就已经存在了，只是skidu一直以来习惯于使用firebug来看这些东东<br />
今天在php.net溜达的时候本想点firebug来着，结果不小心点着了“<span class='wp_keywordlink_affiliate'><a href="http://www.skidu.me/tag/%e6%9f%a5%e7%9c%8b%e5%85%83%e7%b4%a0" title="查看 查看元素 中的全部文章" target="_blank">查看元素</a></span>”这个淫|荡的选项<br />
咦？这是怎么回事？firebug升级了？<br />
再一瞅下面，竟然还有个3D选项，俺悄悄点了点，旋转、缩放，神马都能行。。额。。<br />
好吧，送上skidu博客那张让人无语的3D结构图。。俺很淡定的数了数，貌似有40层。。震惊了 <img src='http://www.skidu.me/wp-includes/images/smilies/yct/yct028.gif' alt=':da:' class='wp-smiley' /> </p>
<p><a href="http://www.skidu.me/wp-content/uploads/2012/04/filefox.png"><img src="http://www.skidu.me/wp-content/uploads/2012/04/filefox.png" alt="" title="filefox" width="621" height="589" class="alignnone size-full wp-image-1272" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.skidu.me/sth_about_firefox.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>[转]MySQL数据库灾难恢复</title>
		<link>http://www.skidu.me/mysql-data-recovery.html</link>
		<comments>http://www.skidu.me/mysql-data-recovery.html#comments</comments>
		<pubDate>Tue, 10 Apr 2012 14:37:41 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[LAMP]]></category>
		<category><![CDATA[网摘分享]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[恢复]]></category>
		<category><![CDATA[数据]]></category>
		<category><![CDATA[灾难]]></category>
		<category><![CDATA[还原]]></category>

		<guid isPermaLink="false">http://www.skidu.me/?p=1260</guid>
		<description><![CDATA[MySQL数据库灾难恢复

当 MySQL Server 因为各种无法预期的原因而损坏(Crash)的时候，你就必须要进行灾难恢复。如果你有做好定期的数据库备份那么灾难还原的时候应该会轻松很多，只要将备份起来的数据还原回去即可，但光是这样子还是会造成部份数据的遗失，例如 “现在” 至 “最后一次备份” 之间的数据，这时我们可以通过 MySQL 提供的 Binary Log 机制将可能遗失的数据降至最低。

Binary Log 的运作原理很简单，它只是单纯的将所有会修改到数据库内容的操作记录在 Log 文件中，然后通过这个 Binary Log 你就可以重新执行所有会修改到数据库内容的操作。例如若你最后一次备份的时间是 1/1 AM 0:00 ，并且有启用 Binary Log 功能记录 1/1 AM 0:00 这个时间点以后所有会修改到数据库内容的操作，假设你的 MySQL Server 在 1/2 AM 10:00 故障，你就可以将 1/1 AM 0:00 备份的数据还原回去，然后利用 Binary Log 将 1/1 AM 0:00 ~ 1/2 AM 10:00 之间所有的操作重新执行一次，这样子一来你就可以将数据库还原到当机的那个时间点。

<span class="readmore"><a href="http://www.skidu.me/mysql-data-recovery.html" title="[转]MySQL数据库灾难恢复">阅读全文——共3194字</a></span>]]></description>
			<content:encoded><![CDATA[<p><strong>MySQL<span class='wp_keywordlink_affiliate'><a href="http://www.skidu.me/tag/%e6%95%b0%e6%8d%ae" title="查看 数据 中的全部文章" target="_blank">数据</a></span>库<span class='wp_keywordlink_affiliate'><a href="http://www.skidu.me/tag/%e7%81%be%e9%9a%be" title="查看 灾难 中的全部文章" target="_blank">灾难</a></span><span class='wp_keywordlink_affiliate'><a href="http://www.skidu.me/tag/%e6%81%a2%e5%a4%8d" title="查看 恢复 中的全部文章" target="_blank">恢复</a></span></strong></p>
<p>当 MySQL Server 因为各种无法预期的原因而损坏(Crash)的时候，你就必须要进行<span class='wp_keywordlink_affiliate'><a href="http://www.skidu.me/tag/%e7%81%be%e9%9a%be" title="查看 灾难 中的全部文章" target="_blank">灾难</a></span><span class='wp_keywordlink_affiliate'><a href="http://www.skidu.me/tag/%e6%81%a2%e5%a4%8d" title="查看 恢复 中的全部文章" target="_blank">恢复</a></span>。如果你有做好定期的<span class='wp_keywordlink_affiliate'><a href="http://www.skidu.me/tag/%e6%95%b0%e6%8d%ae" title="查看 数据 中的全部文章" target="_blank">数据</a></span>库备份那么灾难<span class='wp_keywordlink_affiliate'><a href="http://www.skidu.me/tag/%e8%bf%98%e5%8e%9f" title="查看 还原 中的全部文章" target="_blank">还原</a></span>的时候应该会轻松很多，只要将备份起来的<span class='wp_keywordlink_affiliate'><a href="http://www.skidu.me/tag/%e6%95%b0%e6%8d%ae" title="查看 数据 中的全部文章" target="_blank">数据</a></span><span class='wp_keywordlink_affiliate'><a href="http://www.skidu.me/tag/%e8%bf%98%e5%8e%9f" title="查看 还原 中的全部文章" target="_blank">还原</a></span>回去即可，但光是这样子还是会造成部份数据的遗失，例如 “现在” 至 “最后一次备份” 之间的数据，这时我们可以通过 MySQL 提供的 Binary Log 机制将可能遗失的数据降至最低。</p>
<p>Binary Log 的运作原理很简单，它只是单纯的将所有会修改到数据库内容的操作记录在 Log 文件中，然后通过这个 Binary Log 你就可以重新执行所有会修改到数据库内容的操作。例如若你最后一次备份的时间是 1/1 AM 0:00 ，并且有启用 Binary Log 功能记录 1/1 AM 0:00 这个时间点以后所有会修改到数据库内容的操作，假设你的 MySQL Server 在 1/2 AM 10:00 故障，你就可以将 1/1 AM 0:00 备份的数据<span class='wp_keywordlink_affiliate'><a href="http://www.skidu.me/tag/%e8%bf%98%e5%8e%9f" title="查看 还原 中的全部文章" target="_blank">还原</a></span>回去，然后利用 Binary Log 将 1/1 AM 0:00 ~ 1/2 AM 10:00 之间所有的操作重新执行一次，这样子一来你就可以将数据库还原到当机的那个时间点。</p>
<p>使用 Binary Log 进行灾难恢复的步骤：<br />
启用 Binary Log<br />
使用 <span class='wp_keywordlink_affiliate'><a href="http://www.skidu.me/tag/mysql" title="查看 mysql 中的全部文章" target="_blank">mysql</a></span>binlog 将 Binary Log 转换成可执行的 SQL 命令</p>
<p>在接下来的文章中会使用的范例与假设：<br />
最后一次备份的时间点为 1/1 AM 0:00<br />
MySQL Server 在 1/2 AM 10:00 故障</p>
<p><strong>一、启用 Binary Log</strong></p>
<p>修改 MySQL Server 的系统设置文件(eg. /etc/my.cnf)，在 [<span class='wp_keywordlink_affiliate'><a href="http://www.skidu.me/tag/mysql" title="查看 mysql 中的全部文章" target="_blank">mysql</a></span>d] 区块中加上 log-bin=mysql-bin 选项，然后重新启动 MySQL Server，例如：</p>
<pre class="brush: bash; title: ; notranslate">
[mysqld]
log-bin=mysql-bin
</pre>
<p>启用后你应该可以在 MySQL 的 Data Dir 里面发现如下的文件：</p>
<pre class="brush: plain; title: ; notranslate">
mysql-bin.index
mysql-bin.000001
mysql-bin.000002
...............
mysql-bin.00000X
</pre>
<p>MySQL 在以下几种情况会进行 lograrote：</p>
<ul>
<li>执行 Flush Logs 命令</li>
<li>MySQL Server 重新启动</li>
<li>设置文件中有进行额外的设置</li>
</ul>
<p>注：<br />
请注意，当你使用 mysqldump 进行数据库备份时请记得加上 &#8211;flush-logs 选项，例如：</p>
<pre class="brush: bash; title: ; notranslate">
mysqldump --flush-logs -u root -p 数据库名称 &amp;gt; example.sql
</pre>
<p>这么做的目的是在备份时让 MySQL Server 进行 logrotate，这样子日后要辨别 “最后一次备份时间点” 之后的 Binary Log 会比较方便，因为若你没有主动(或通过设置)去删除 Binary Log，则只要你的硬盘空间够大，MySQL 会无限期的保存 Binary Log，也就是说你的 Binary Log 里面所记载的数据有可能包含 “最后一次备份时间点” 之前的数据。</p>
<p><strong>二、使用 mysqlbinlog 将 Binary Log 转换成可执行的 SQL 命令</strong></p>
<p>Binary Log 是无法被 MySQL Server 直接执行、也无法直接以人眼去阅读的，必须要先使用 MySQL 所提供的 mysqlbinlog 程式，将 Binary Log 转换为 MySQL Server 可以执行的 SQL 命令。mysqlbinlog 的语法如下：</p>
<pre class="brush: bash; title: ; notranslate">
mysqlbinlog -H --set-charset=&quot;utf8&quot;
               --start-datatime=&quot;2007-01-01 00:00:00&quot;
               --stop-datatime=&quot;2007-01-02 10:00:00&quot;
               mysql-bin.[0-9]* &amp;gt; example.sql
</pre>
<pre class="brush: plain; title: ; notranslate">
-H：Display a hex dump of the log in comments.
--set-charset：设置编码
--start-datatime：要转换的开始时间点
--stop-datatime：要转换的结束时间点
</pre>
<p>mysql-bin.[0-9]*：这里要注意的是，要一次处理所有的 Binary Log，因为储存在 Binary Log 中的数据有可能会 “跨文件”，例如从 mysql-bin.000001 的结尾接到 mysql-bin.000002 的开头。</p>
<p>example.sql：转换出来的文件名称，这个名称可以自已取。</p>
<p>需要加 -H 选项的原因如下：</p>
<pre class="brush: plain; title: ; notranslate">
mysqlbinlog didn't escape the string content of user variables, and did not
deal well when these variables were in non-ASCII character sets; this is
now fixed by always printing the string content of user variables in hexadecimal.
The character set and collation of the string is now also printed. (Bug #3875)
</pre>
<p><strong>三、实际执行转换后的 Binary Log</strong><br />
很简单，只要一行简单的命令：</p>
<pre class="brush: bash; title: ; notranslate">
mysql &amp;lt; example.sql
</pre>
<p>如果没有什么错误讯息发生，那么只要等它执行完就大功告成了。话又说回来，要是执行失败呢？这是有可能的。MySQL 在处理 Binary Log 时有一些 Bug 存在，它的 Bug Report 似乎是说在最新版本的 MySQL Server 中已修正此 Bug，我没有实际测试过所以不清楚，但若是你和我一样也遇到这个 Bug 的话，也不用太担心。这些问题其实不难解决，自己 Workaround 即可。 目前看到的情况有： Comment 没有正确标示 Comment 语法错误 不正确的使用 DELIMITER 奇怪的 STOP 命令(不太确定这是做什么用的) 自己用 sed 去修改转换过后的 example.sql 即可。 </p>
<pre class="brush: bash; title: ; notranslate">
sed -f replace.rules example.sql &amp;gt; final.sql
</pre>
<p>replace.rules文件的内容：</p>
<pre class="brush: plain; title: ; notranslate">
s/\(Query.*thread\)/#\1/g
s/\(###.*###\)//g
s/DELIMITER ;//g
s/Stop//g
</pre>
<p>上面几行的意义：</p>
<pre class="brush: bash; title: ; notranslate">
s/\(Query.*thread\)/#\1/g
</pre>
<p>MySQL 的 Binary Log 在处理 Comment 的时候，有的时候会漏加 “#” 符号在 Comment Line 的最前面。<br />
例如本来是：</p>
<pre class="brush: bash; title: ; notranslate">
Query thread_id=227528 exec_time=- error_code=0
</pre>
<p>要改成：</p>
<pre class="brush: bash; title: ; notranslate">
#Query thread_id=227528 exec_time=- error_code=0
</pre>
<pre class="brush: bash; title: ; notranslate">
s/\(###.*###\)//g
</pre>
<p>在某些 SQL statement(例如 REPLACE INTO search)的最后面会有一些 Comment 存在，但这些 Comment 的语法不正确反而会造成执行失败，故删除之。<br />
类似以下的行都应该删除：</p>
<pre class="brush: plain; title: ; notranslate">
### Bitfield: user.options ###
### SAVE ORDERED IDS TO SEARCH CACHE ###
</pre>
<p>&#8230;&#8230;..等等</p>
<pre class="brush: bash; title: ; notranslate">
s/DELIMITER ;//g
</pre>
<p>删除不正确的 DELIMITER 命令，像以下这样就是不正确的：</p>
<pre class="brush: bash; title: ; notranslate">
DELIMITER ;
</pre>
<pre class="brush: bash; title: ; notranslate">
s/Stop//g
</pre>
<p>有的时候会在 Binary Log 中出现 Stop 这个命令而导致执行失败，故删除之。但我不太确定这个 Stop 命令实质上的用途是什么。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.skidu.me/mysql-data-recovery.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>让apache可以执行sudo命令</title>
		<link>http://www.skidu.me/apache_sudo.html</link>
		<comments>http://www.skidu.me/apache_sudo.html#comments</comments>
		<pubDate>Fri, 02 Mar 2012 02:53:35 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[LAMP]]></category>
		<category><![CDATA[apache sudo]]></category>
		<category><![CDATA[php sudo]]></category>
		<category><![CDATA[sudo]]></category>
		<category><![CDATA[sudoer]]></category>
		<category><![CDATA[visudo]]></category>

		<guid isPermaLink="false">http://www.skidu.me/?p=1254</guid>
		<description><![CDATA[没想到今天又解决了一个纠结了我好几天的小问题，这是今天第二篇日志了吧？真是高产啊，哈哈╮(╯▽╰)╭

回归正题：

skidu最近在做一个小东西，希望能通过php执行某些必须使用root账户才能执行的命令

<span class="readmore"><a href="http://www.skidu.me/apache_sudo.html" title="让apache可以执行sudo命令">阅读全文——共1313字</a></span>]]></description>
			<content:encoded><![CDATA[<p>没想到今天又解决了一个纠结了我好几天的小问题，这是今天第二篇日志了吧？真是高产啊，哈哈╮(╯▽╰)╭<br />
回归正题：<br />
skidu最近在做一个小东西，希望能通过php执行某些必须使用root账户才能执行的命令<br />
此时我直接想到的就是<span class='wp_keywordlink_affiliate'><a href="http://www.skidu.me/tag/sudo" title="查看 sudo 中的全部文章" target="_blank">sudo</a></span>命令，可问题紧接着就来了，用户执行<span class='wp_keywordlink_affiliate'><a href="http://www.skidu.me/tag/sudo" title="查看 sudo 中的全部文章" target="_blank">sudo</a></span>的时候是需要输入用户密码的呀，apache作为一名资深nologin用户，肿么可能这么玩啊 <img src='http://www.skidu.me/wp-includes/images/smilies/yct/yct024.gif' alt=':way:' class='wp-smiley' /><br />
输入<span class='wp_keywordlink_affiliate'><a href="http://www.skidu.me/tag/visudo" title="查看 visudo 中的全部文章" target="_blank">visudo</a></span>过后仔细看了一会文档，发现里面有一个NOPASSWD的设置方法，果断测试之~！<br />
比如咱想用php直接为linux添加一个用户，要使用到useradd命令，键入which useradd可以查看到该命令位于/usr/sbin/useradd，修改配置文件：</p>
<pre class="brush: plain; title: ; notranslate">
visudo
apache localhost=NOPASSWD:/usr/sbin/useradd
</pre>
<p>然后编辑一个test.php页面</p>
<pre class="brush: php; title: ; notranslate">
shell_exec(&quot;/usr/sudo /usr/sbin/useradd testuser&quot;);
</pre>
<p>执行过后发现用户并没有被添加进去 <img src='http://www.skidu.me/wp-includes/images/smilies/yct/yct001.gif' alt=':wha:' class='wp-smiley' /><br />
好吧，咱使用一个可以输出结果的sbin命令来试试<br />
为了方便测试，这里直接给apache允许使用sudo执行所有命令</p>
<pre class="brush: plain; title: ; notranslate">
visudo
apache localhost=NOPASSWD:ALL
</pre>
<pre class="brush: php; title: ; notranslate">
$output = shell_exec(&quot;/usr/sudo /sbin/ifconfig&quot;);
var_dump($output);
</pre>
<p>发现已经没能正常输出文档，难道是跟php的安全模式有关系？<br />
紧接着就是抓狂时间，打开/关闭php安全模式、设置safe_mode_exec_dir……<br />
各种方法skidu都一一测试，发现返回结果不是false就是NULL，度娘也不好使，查出来的都是一些乱七八糟的玩意 <img src='http://www.skidu.me/wp-includes/images/smilies/yct/yct020.gif' alt=':yaaa:' class='wp-smiley' /><br />
紧接着的几天时间skidu又进入了项目期，于是这个问题被暂时搁浅了- -</p>
<p>嗯，今天，由于昨天熬夜做了监控，今天就开始偷懒了，于是skidu又想起了这个问题，果断上Google查了一番，终于还是在一个老外那里找到了答案，据说是跟/etc/<span class='wp_keywordlink_affiliate'><a href="http://www.skidu.me/tag/sudoer" title="查看 sudoer 中的全部文章" target="_blank">sudoer</a></span>(其实<span class='wp_keywordlink_affiliate'><a href="http://www.skidu.me/tag/visudo" title="查看 visudo 中的全部文章" target="_blank">visudo</a></span>命令就是编辑的这个文件)这个文件的权限有关<br />
解决步骤：</p>
<pre class="brush: plain; title: ; notranslate">
1、为sudoer文件开启w权限
chmod u+w /etc/sudoer
2、给apache用户分配sudo权限
apache localhost=NOPASSWD:/sbin/ifconfig
3、关闭sudoer文件w权限
chmod -w /etc/sudoer
</pre>
<p>至此权限设置完毕，再次执行php脚本</p>
<pre class="brush: php; title: ; notranslate">
/**
 *test.php
 */
shell_exec(&quot;/usr/sudo /usr/sbin/useradd testuser&quot;);
</pre>
<p>刷新页面过后查看passwd文件</p>
<pre class="brush: plain; title: ; notranslate">
more /etc/passwd
</pre>
<p>在最后一行看见了什么？</p>
<pre class="brush: plain; title: ; notranslate">
testuser:x:502:502::/home/testuser:/bin/bash
</pre>
<p>啊哈哈，这坑爹的玩意今天终于解决掉了 <img src='http://www.skidu.me/wp-includes/images/smilies/yct/yct007.gif' alt=':woo:' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.skidu.me/apache_sudo.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>mrtg网络监控配置笔记</title>
		<link>http://www.skidu.me/snmp_mrtg.html</link>
		<comments>http://www.skidu.me/snmp_mrtg.html#comments</comments>
		<pubDate>Fri, 02 Mar 2012 01:40:52 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[LAMP]]></category>
		<category><![CDATA[mrtg]]></category>
		<category><![CDATA[snmp]]></category>
		<category><![CDATA[网络监控]]></category>

		<guid isPermaLink="false">http://www.skidu.me/?p=1244</guid>
		<description><![CDATA[随着三月的到来，skidu在北京的培训也随之步入尾声，在兄弟连的最后一个由老师安排的项目也如期而至。

项目要求是分别配置Linux+Apache+PHP+MySQL+sphinx、Linux+Apache+MongoDB+PHP两个环境，并分别在这个环境中写一个简易的留言板程序，然后再上一台机器做lvs负载均衡，接着就是网络监控、邮件报警神马的。

今天先分享一下我的snmp+mrtg网络监控的配置笔记吧

<span class="readmore"><a href="http://www.skidu.me/snmp_mrtg.html" title="mrtg网络监控配置笔记">阅读全文——共3433字</a></span>]]></description>
			<content:encoded><![CDATA[<p>随着三月的到来，skidu在北京的培训也随之步入尾声，在兄弟连的最后一个由老师安排的项目也如期而至。<br />
项目要求是分别配置Linux+Apache+PHP+MySQL+sphinx、Linux+Apache+MongoDB+PHP两个环境，并分别在这个环境中写一个简易的留言板程序，然后再上一台机器做lvs负载均衡，接着就是<span class='wp_keywordlink_affiliate'><a href="http://www.skidu.me/tag/%e7%bd%91%e7%bb%9c%e7%9b%91%e6%8e%a7" title="查看 网络监控 中的全部文章" target="_blank">网络监控</a></span>、邮件报警神马的。<br />
今天先分享一下我的<span class='wp_keywordlink_affiliate'><a href="http://www.skidu.me/tag/snmp" title="查看 snmp 中的全部文章" target="_blank">snmp</a></span>+<span class='wp_keywordlink_affiliate'><a href="http://www.skidu.me/tag/mrtg" title="查看 mrtg 中的全部文章" target="_blank">mrtg</a></span><span class='wp_keywordlink_affiliate'><a href="http://www.skidu.me/tag/%e7%bd%91%e7%bb%9c%e7%9b%91%e6%8e%a7" title="查看 网络监控 中的全部文章" target="_blank">网络监控</a></span>的配置笔记吧</p>
<hr />
<br />
skidu的实现环境：虚拟机CentOS 5.5<br />
监控管理软件： <span class='wp_keywordlink_affiliate'><a href="http://www.skidu.me/tag/snmp" title="查看 snmp 中的全部文章" target="_blank">snmp</a></span> + <span class='wp_keywordlink_affiliate'><a href="http://www.skidu.me/tag/mrtg" title="查看 mrtg 中的全部文章" target="_blank">mrtg</a></span><br />
为了实现监控硬件，咱首先得安装snmp服务，嗯，这个直接yum上吧</p>
<pre class="brush: plain; title: ; notranslate">
yum -y install net-snmp*
</pre>
<p>当屏幕显示 Complate! 字样后安装就已经完成。<br />
接下来咱需要修改一下snmp的配置信息，它被存放在/etc/snmp/snmpd.conf<br />
使用vi查看一下可以发现配置信息内容很多，其实咱并不需要看懂这些，把这个配置文件删掉，然后使用snmpconf命令来生成一个snmpd.conf配置信息文件。</p>
<pre class="brush: plain; title: ; notranslate">
·输入snmpconf并回车，根据屏幕提示选择snmpd.conf项生成配置文件
·再选择Access Control Setup项进行监控访问控制信息配置
·接下来咱选择a SNMPv1/SNMPv2c read-only access community name，使用SNMPv1版本只读
·这一步会设置监控密码，直接键入public吧
·然后设置监控访问允许信息，直接敲回车则使用默认值all允许所有人来查看监控信息
·再设置别人可以查看哪些监控信息，这里敲回车使用默认值允许查看所有监控信息，如果需要单独设置的话在这里分配相应的oid即可
·到这里配置差不多就完成了，输入finished
·然后查看屏幕提示，如果有quit字样则键入quit并回车退出
</pre>
<p>到这里，配置文件就生成好了，如果需要更改配置信息可以手工编辑它，配置格式为</p>
<pre class="brush: plain; title: ; notranslate">
community [允许查看的人] [允许查看的监控项目]
</pre>
<p>然后启动snmp服务</p>
<pre class="brush: plain; title: ; notranslate">service snmpd start</pre>
<p>此时可以使用snmp的相关命令查看指定硬件信息的监控内容了。<br />
snmp使用的是系统OID来监控系统硬件，比如.1.3.6.1.4.1.2021.11.50.0为1分钟CPU的使用率、.1.3.6.1.2.1.25.2.3.1.6.2为内存使用量、.1.3.6.1.2.1.25.1.6.0为系统当前进程数、.1.3.6.1.4.1.2021.10.1.5.3为系统15分钟负载信息等。<br />
OID这玩意太多了，咱就懒得记了，也记不了这么多，直接查阅相关帮助文档吧，里面会罗列出常用的监控项目OID。</p>
<p>snmp常用命令：</p>
<p>查看系统所有oid及oid名称：</p>
<pre class="brush: plain; title: ; notranslate">snmp walk -v1 -cpublic localhost -m all</pre>
<p>查看该oid的描述：</p>
<pre class="brush: plain; title: ; notranslate">snmptranslate -Td .1.3.6.1.4.1.2021.9.1.8.1</pre>
<p>单个oid查看：</p>
<pre class="brush: plain; title: ; notranslate">snmptranslate -T1 .1.3.6.1.4.1.2021.9.1.8.1</pre>
<p>查看整个oid全称：</p>
<pre class="brush: plain; title: ; notranslate">snmptranslate -Of .1.3.6.1.4.1.2021.9.1.8.1</pre>
<p>查看该oid的oid名称和值：</p>
<pre class="brush: plain; title: ; notranslate">snmpget -v1 -cpublic localhost .1.3.6.1.4.1.2021.9.1.8.1</pre>
<p>此时监控出来的信息是什么样的？</p>
<pre class="brush: plain; title: ; notranslate">
[root@skidu ~]# snmpget -v1 -cpublic localhost .1.3.6.1.4.1.2021.11.53.0
UCD-SNMP-MIB::ssCpuRawIdle.0 = Counter32: 284131
</pre>
<p>上面skidu查看了一下系统15分钟的CPU使用率，监控结果是284131。<br />
嗯，很费劲，使用率竟然是一个数值而不是百分比╮(╯▽╰)╭<br />
好吧，为了让枯燥的监控变得更人性化一些，咱请出mrtg兄来为我们绘制监控图吧~<br />
当然，这之前咱还是得先安装一下程序：</p>
<pre class="brush: plain; title: ; notranslate">
yum -y install mrtg*
</pre>
<p>安装完毕后mrtg会在/var/www下创建一个mrtg目录并存放一些生成网页需要的图片等文件<br />
同时mrtg会生成一个apache包含配置文件在/etc/httpd/conf.d/mrtg.conf，这个也可以根据自己的实际情况进行修改，修改完毕后记得重启Apache</p>
<p>接下来是mrtg配置文件的修改，配置文件位于/etc/mrtg/mrtg.cfg</p>
<p>配置内容有点多，详细请参考官方的帮助文档吧：</p>
<p>http://oss.oetiker.ch/mrtg/doc/mrtg-reference.en.html</p>
<p>这里的skidu就直接贴上自己的网卡流量监控配置信息</p>
<pre class="brush: plain; title: ; notranslate">
HtmlDir:/usr/local/apache2/htdocs/mrtg
#设置监控信息网页存放的位置
ImageDir:/usr/local/apache2/htdocs/mrtg
#生成的图片存放的位置
LogDir: /var/lib/mrtg
#监控日志文件存放位置
ThreshDir: /var/lib/mrtg
#====eth0网卡流量监控配置开始
Target[eth0_192.168.22.2]: /192.168.22.2:public@192.168.22.2:
#标记一个监控名字:  /被监控网卡的接口(网卡可以直接使用ip替代oid):登录钥匙@被监控的机器的ip
Options[eth0_192.168.22.2]: growright
#选项:右对齐
Directory[eth0_192.168.22.2]: 192.168.22.2-eth0
#设置该监控信息存放目录的名字
MaxBytes[eth0_192.168.22.2]: 100000000
#最大字节数:100000000	默认以字节为单位
Kmg[eth0_192.168.22.2]: K,M,G
#自动切换单位，以1000为倍数
YLegend[eth0_192.168.22.2]: Bytes per Second
#Y轴标题
ShortLegend[eth0_192.168.22.2]: B/s
#X轴标题(单位)
Legend1[eth0_192.168.22.2]: 每秒流入量 (单位 Bytes)
#图示说明
Legend2[eth0_192.168.22.2]: 每秒流出量 (单位 Bytes)
#图示说明
LegendI[eth0_192.168.22.2]: 流入:
#图示说明
LegendO[eth0_192.168.22.2]: 流出:
#图示说明
Title[eth0_192.168.22.2]: eth0网络流量[192.168.22.2]
#设置监控页面title部分的标题
PageTop[eth0_192.168.22.2]: &lt;h1&gt;eth0网络流量[192.168.22.2]&lt;/h1&gt;
#设置页面内顶部的标题
</pre>
<p>生成图片和监控网页：<br />
打开/etc/cron.d/mrtg文件可以并复制LANG=xxxxxx这一句命令</p>
<pre class="brush: plain; title: ; notranslate">
LANG=C LC_ALL=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg --lock-file /var/lock/mrtg/mrtg_l --confcache-file /var/lib/mrtg/mrtg.ok
</pre>
<p>然后执行这条命令，此时系统会有一些报错，不用理会它，重复执行直到不报错为止</p>
<p>接着我们使用indexmaker命令生成一个监控首页</p>
<pre class="brush: plain; title: ; notranslate">
indexmaker --output /usr/local/apache2/htdocs/mrtg/index.html --title=&quot;skidu的监控信息&quot; /etc/mrtg/mrtg.cfg
格式：indexmaker --output [设置首页存放的为止] --title=&quot;[这里写网页头部需要显示的标题]&quot; [mrtg配置文件存放的位置]
</pre>
<p>至此整个配置流程已经完成了，浏览器访问 192.168.22.2/mrtg 查看监控网页（实际地址根据自己的服务器配置决定）</p>
<p><a href="http://www.skidu.me/wp-content/uploads/2012/03/mrtg.png"><img src="http://www.skidu.me/wp-content/uploads/2012/03/mrtg-1024x318.png" alt="" title="mrtg" width="640" height="198" class="alignnone size-large wp-image-1245" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.skidu.me/snmp_mrtg.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>流水账记：跑了一场龙套</title>
		<link>http://www.skidu.me/small-role.html</link>
		<comments>http://www.skidu.me/small-role.html#comments</comments>
		<pubDate>Sun, 26 Feb 2012 16:59:33 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[乱七八糟]]></category>

		<guid isPermaLink="false">http://www.skidu.me/?p=1240</guid>
		<description><![CDATA[话说咱今天也进了一下演播厅，嗯，据说是去凑人数的，据说还有小礼物可以领，于是我们几个都报名参加了，于是就有了今天这一段╮(╯▽╰)╭

地点：BTV新楼

时间：12:30

<span class="readmore"><a href="http://www.skidu.me/small-role.html" title="流水账记：跑了一场龙套">阅读全文——共1010字</a></span>]]></description>
			<content:encoded><![CDATA[<p>话说咱今天也进了一下演播厅，嗯，据说是去凑人数的，据说还有小礼物可以领，于是我们几个都报名参加了，于是就有了今天这一段╮(╯▽╰)╭<br />
地点：BTV新楼<br />
时间：12:30</p>
<p>今日行程：<br />
9:30 起床，收拾收拾个人卫生，扒拉点东西填填肚子<br />
10:30 在学校门口和其他同学汇合，等待公交车<br />
10:47 坑爹的557路公交终于来了，呃，挤爆了，好吧，下一趟╮(╯▽╰)╭<br />
11:07 嗯，咱又到了回龙观地铁站，向班长同志打听到这次是在国贸下车，这个，国贸？貌似前几天去面试的那家公司就在那边，真巧╮(╯▽╰)╭<br />
12:17 我们宿舍仨和大部队走散了，但是我们比他们提前了越10分钟到达国贸地铁站，找啊找啊找啊找，咱就直接奔BTV新楼去了<br />
12:30 好吧，传说中的约定时间，我们一大摞人聚集在BTV大门外无人问津+_+<br />
12:40 嗯，来了一哥们让我排成一溜，然后，一人一张看着不像是入场券的入场券╮(╯▽╰)╭<br />
12:50 好吧，咱现在站在BTV2楼的1000平演播大厅门外，工作人员大吼一嗓子“让女生先进” @@#!@%@#<br />
12:55 入场了，感觉木有电视上看见的那么好，好饿呀，咕~~~<br />
怎么排时间呢，后面没注意记录了，咱就继续流水账风格了吧+_+<br />
进场后不久工作人员就要求我们脱掉外套，说是一会演播大厅会很热，嗯，还强调了一下黑色外套的童鞋一定要脱掉，不然上镜很悲剧，skidu毅然脱掉了黑色皮衣露出了黑色毛衣~~~囧~~~<br />
随后上来了一个体型稍稍发胖的貌似是个什么管理的人物跟我们讲起了注意事项，好吧，其实这就是让我们配合节目，要欢呼，要尖叫，要挥舞荧光棒，要开怀大笑，总之来了这里咱就得是超级狂热粉丝+_+<br />
接着我们便开始排练了，不由得skidu想起了以前看过的一个电影，也是讲的在录制一个访谈节目，通过大屏幕给观众传达不通的讯号然后观众根据信号欢呼鼓掌唏嘘然后闹出很多糗事的一个小节目+_+<br />
紧接着，咱们的和珅大人上场了，嗯，天下藏宝，在家的时候也没少看这个节目，等到了现场才发现其实还是在电视机前看得更清楚些╮(╯▽╰)╭<br />
好吧<br />
总之咱是在下午四点左右才从演播大厅里走出来的，好饿，还有就是之前提到过貌似会有的小礼物，同行的朋友都坚定滴认为那就是我们手里的两只荧光棒⊙o⊙<br />
嗯，唯一的遗憾就是节目不是今天当天就播出了，因为俺已经发出一大堆的短信告诉朋友们俺今天跑龙套去了T_T<br />
木有小礼品，更木有管饭，神马都木有，咱们一伙人就这么带着一身“饥渴”回到了学校╮(╯▽╰)╭</p>
]]></content:encoded>
			<wfw:commentRss>http://www.skidu.me/small-role.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>整理一下自己在山寨Lofter中常用的Smarty方法</title>
		<link>http://www.skidu.me/sth-about-smarty.html</link>
		<comments>http://www.skidu.me/sth-about-smarty.html#comments</comments>
		<pubDate>Sun, 12 Feb 2012 16:35:41 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[LAMP]]></category>
		<category><![CDATA[smarty]]></category>
		<category><![CDATA[smarty empty]]></category>
		<category><![CDATA[smarty in_array]]></category>
		<category><![CDATA[smarty入门]]></category>
		<category><![CDATA[smarty数组]]></category>

		<guid isPermaLink="false">http://www.skidu.me/?p=1233</guid>
		<description><![CDATA[Lofter的山寨计划已经完成有快20天了，总的来说这不是一次成功的山寨，至少没有达到我的预期期望。

不过，难过归难过，遇到的一些小东西还是要整理出来的，今天先简单整理整理一下Smarty模板引擎吧。

还是得感谢一下组里面的晓龙童鞋吧，若不是他昨天问到我几个关于Smary的问题的话，我估计就又会把整理这活给抛一边去了╮(╯▽╰)╭

<span class="readmore"><a href="http://www.skidu.me/sth-about-smarty.html" title="整理一下自己在山寨Lofter中常用的Smarty方法">阅读全文——共2451字</a></span>]]></description>
			<content:encoded><![CDATA[<p>Lofter的山寨计划已经完成有快20天了，总的来说这不是一次成功的山寨，至少没有达到我的预期期望。</p>
<p>不过，难过归难过，遇到的一些小东西还是要整理出来的，今天先简单整理整理一下Smarty模板引擎吧。</p>
<p>还是得感谢一下组里面的晓龙童鞋吧，若不是他昨天问到我几个关于Smary的问题的话，我估计就又会把整理这活给抛一边去了╮(╯▽╰)╭</p>
<p>好了，下面开始正题：</p>
<p>·关于Smarty：</p>
<p>Smarty是一个使用PHP模板引擎，嗯，引擎，不过别一看“引擎”俩字就蒙了，说白了它其实就是一个别人写好的类而已，自己拿过来new一下就可以用。好吧，skidu承认自己在文笔方面确实不行，各路大神如果实在需要专业点的介绍文档还请移步度娘百科- -</p>
<p>·Smarty的安装：</p>
<p>解压下载后的Smarty压缩文件，将其中的lib文件夹拷贝到自己需要的目录即可<br />
下载地址：<a href="http://www.smarty.net/download">http://www.smarty.net/download</a><br />
本例中存放目录为：本地www根目录/<span class='wp_keywordlink_affiliate'><a href="http://www.skidu.me/tag/smarty" title="查看 smarty 中的全部文章" target="_blank">smarty</a></span>/lib</p>
<p>·快速实现一个Smarty的应用</p>
<p>首先，咱在<span class='wp_keywordlink_affiliate'><a href="http://www.skidu.me/tag/smarty" title="查看 smarty 中的全部文章" target="_blank">smarty</a></span>目录创建一个新的php文档（1.php）</p>
<pre class="brush: php; title: ; notranslate">
&lt;?php
	require(&quot;./libs/Smarty.class.php&quot;);  //包含Smarty主文件
	$tpl = new Smarty();  //实例化Smarty对象
	$tpl-&gt;template_dir=&quot;./templates&quot;;  //设置模板目录位置
	$tpl-&gt;compile_dir=&quot;./coms&quot;;  //设置合成文件存放目录位置
	$tpl-&gt;left_delimiter=&quot;&lt;{&quot;;  //设置左定界符，默认是&quot;{&quot;，个人习惯使用&quot;&lt;{&quot;
	$tpl-&gt;right_delimiter=&quot;}&gt;&quot;; //同上，默认是&quot;}&quot;
	$tpl-&gt;assign(&quot;hello&quot;,&quot;测试内容&quot;);
		//向模板分配一个变量“hello”，变量的内容为“测试内容”，可以为任意值
		//比如数据库查询结果等
	$tpl-&gt;display(&quot;1.html&quot;);
		//设置模板显示
?&gt;
</pre>
<p>接着，咱再在templates目录中创建一个1.html的文件，并在文档中输入<{$hello}><br />
用浏览器访问1.php,这时你看见了什么？<br />
<a href="http://www.skidu.me/wp-content/uploads/2012/02/1.png"><img src="http://www.skidu.me/wp-content/uploads/2012/02/1.png" alt="" title="demo1" width="299" height="114" class="alignnone size-full wp-image-1234" /></a></p>
<p>怎么样，很简单就实现了吧~</p>
<p>你可以将任意需要在网页中显示的内容分配给Smarty，然后再在模板文件中直接使用变量来输出内容。字符串、数组神马的都可以直接assign，当然，资源类型的变量是不能直接这么玩的<br />
需要注意的是，在模板中使用js、css、img等任意资源的时候，其url应相对于访问的php文件设置而非该模板文件本身！</p>
<p>·Smarty中数组的遍历</p>
<p>Smarty也有自己的数组遍历方法，分别是foreach和section，如果和php中咱们常用的遍历方法进行对比的话你会发现，其实这两个分别就是php中的foreac和for两种遍历方法</p>
<p>section遍历说明：</p>
<p>在需要遍历的位置插入<br />
<xmp><{section loop=分配的变量名 name=自己随意取一个名字}></xmp><br />
遍历内容<br />
<xmp><{/section}></xmp><br />
来进行遍历。</p>
<p>对于索引式数组，咱可以使用<xmp><{$变量名['索引值']}></xmp>直接读取值，而对于关联式数组则需使用<xmp><{$变量名.索引值}></xmp>进行读取了。<br />
比如数组$a=array(“one”,”two”,”three”,”four”,”five”)，咱$tpl->assign(“arr1&#8243;,$a)过后，在模板中<{$arr1['0']}>即可读取值one<br />
对于数组$b=array(“no1&#8243;=>”one”,”noo”=>”two”),$tpl->assing(“arr2&#8243;,$b)，则需要使用<{$arr2.noo}>才可读取值two而不是<{$arr2['noo']}><br />
好吧，不妨思考一下，数组$c=array(“one”=>”aaaa”,”two”=>”bbb”,”ccc”,”three”=>”ddd”)我们要怎样才能读取到值ccc？</p>
<p>有了它能做什么？<br />
比如说我们从数据库用户表中读取了三个用户的信息，包含ID、用户名、邮箱、电话号码等，那么它就应该是这样一种情况</p>
<pre class="brush: plain; title: ; notranslate">
$data = array(
	array(
		'id'=&gt;1,
		'username'=&gt;'张三',
		'email'=&gt;'zhangsan@qq.com',
		'phone'=&gt;'110'
		),
	array(
		'id'=&gt;2,
		'username'=&gt;'李四',
		'email'=&gt;'lisi@qq.com',
		'phone'=&gt;'120'
		),
	array(
		'id'=&gt;3,
		'username'=&gt;'王五',
		'email'=&gt;'wangwu@qq.com',
		'phone'=&gt;'119'
		)
	);
</pre>
<p>
我们将它分配给模板</p>
<pre class="brush: php; title: ; notranslate">
$tpl-&gt;assign(&quot;user&quot;,$data);
</pre>
<p>模板中我们该怎么用呢？好吧，我喜欢用section来进行遍历，我们就用一个简单的表格来输出它吧！</p>
<pre class="brush: plain; title: ; notranslate">
&lt;table&gt;
	&lt;tr&gt;
		&lt;th&gt;ID&lt;/th&gt;&lt;th&gt;用户名&lt;/th&gt;&lt;th&gt;邮箱&lt;/th&gt;&lt;th&gt;电话&lt;/th&gt;
	&lt;/tr&gt;
	&lt;{section loop=$user name=&quot;info&quot;}&gt;
		&lt;tr&gt;
			&lt;td&gt;&lt;{$user[info].id}&gt;&lt;/td&gt;
			&lt;td&gt;&lt;{$user[info].username}&gt;&lt;/td&gt;
			&lt;td&gt;&lt;{$user[info].email}&gt;&lt;/td&gt;
			&lt;td&gt;&lt;{$user[info].phone}&gt;&lt;/td&gt;
		&lt;/tr&gt;
	&lt;{/section}&gt;
&lt;/table&gt;
</pre>
<p>看到了什么？<br />
<a href="http://www.skidu.me/wp-content/uploads/2012/02/11.png"><img src="http://www.skidu.me/wp-content/uploads/2012/02/11.png" alt="" title="demo2" width="291" height="172" class="alignnone size-full wp-image-1235" /></a></p>
<p>·Smarty中的判断<br />
<xmp>{<if>}{<elseif>}{<else>}{</if>}</xmp><br />
怎么样，是不是和php中是一样的呢？仅仅是需要多写个定界符而已嘛~O(∩_∩)O~<br />
想必各位在php中已经玩的不爱了，这里就不多占篇幅了吧~</p>
<p>嗯，还差些什么呢，skidu一时有点思维短路，想不大起来了，那就简单说几句在山寨过程中遇到的一些小麻烦吧。<br />
当初skidu手册翻烂都没有翻出来，只好请教google，后来还是再Smarty官方论坛中找到了答案：</p>
<p>smarty中使用in_array()<br />
{if 需要判断的变量 | in_array:目标数组}</p>
<p>empty()功能<br />
嗯，这个我承认是自己想太多了，直接使用<{if $data eq ""}><{/if}>进行判断即可</p>
<p>先写这些吧，如果后面想起来别的了就继续在本文更新</p>
]]></content:encoded>
			<wfw:commentRss>http://www.skidu.me/sth-about-smarty.html/feed</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Burst.Net 优惠码一枚</title>
		<link>http://www.skidu.me/burst-winter.html</link>
		<comments>http://www.skidu.me/burst-winter.html#comments</comments>
		<pubDate>Thu, 09 Feb 2012 06:52:33 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[乱七八糟]]></category>

		<guid isPermaLink="false">http://www.skidu.me/?p=1230</guid>
		<description><![CDATA[最近Linux部分的学习任务感觉有点繁重，很久没有来博客溜达了，甚至连邮箱都很少去打理了

今天闲里偷忙看了看邮箱才发现Burst又有优惠码了

广告神马的就不多说了，网上一搜一大把。

<span class="readmore"><a href="http://www.skidu.me/burst-winter.html" title="Burst.Net 优惠码一枚">阅读全文——共241字</a></span>]]></description>
			<content:encoded><![CDATA[<p>最近Linux部分的学习任务感觉有点繁重，很久没有来博客溜达了，甚至连邮箱都很少去打理了<br />
今天闲里偷忙看了看邮箱才发现Burst又有优惠码了<br />
广告神马的就不多说了，网上一搜一大把。<br />
因为skidu的博客之前几乎一直是丢在Burst的一枚年付VPS中的，自我感觉性价比还算不错~<br />
优惠码贴出来给有需要的朋友吧~~<br />
优惠码：WINTER20<br />
优惠幅度：20%<br />
适用范围：所有VPS套餐（应该也包括Win的VPS吧，字面上skidu是这么理解的）<br />
好了，传送门，Burst官网：<a href="http://go.skidu.me/burst" title="Burst.Net" target="_blank">www.burst.net</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.skidu.me/burst-winter.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

