<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title>百里挑一</title> 
<link>http://www.admin99.net/index.php</link> 
<description>linux命令 &#124; seo优化技术 &#124; linux系统管理员指南 --我的学习园地</description> 
<language>zh-cn</language> 
<copyright>Powered by Bo-blog 2.0.2 sp2</copyright>
<item>
<link>http://www.admin99.net/read.php?416</link>
<title>安装php的apc扩展</title> 
<author>real &lt;real@admin99.net&gt;</author>
<category>cache</category>
<pubDate>Tue, 03 Mar 2009 03:10:28 +0000</pubDate> 
<guid>http://www.admin99.net/read.php?416</guid> 
<description>
<![CDATA[ 
	Alternative PHP Cache (APC)是一种对PHP有效的开放源高速缓冲储存器工具，主要是加速PHP。<br/>需要注意的是apc与zend有冲突，不能一起使用<br/>下载地址http://pecl.php.net/package/APC<br/><br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content">cd /usr/src<br/>wget http://pecl.php.net/get/APC-3.0.19.tgz<br/>tar xzvf APC-3.0.19.tgz<br/>cd APC-3.0.19<br/>/usr/local/php/bin/phpize<br/>./configure --enable-apc --enable-apc-mmap --with-php-config=/usr/local/php/bin/php-config<br/>make;make install</div></div><br/>编辑/usr/local/php/lib/php.ini <br/>vi /usr/local/php/lib/php.ini<br/>将其中的extension_dir = "./"改为 extension_dir = "/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/"<br/>然后在末尾加入 <br/><br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content">extension=apc.so<br/>apc.enabled = 1<br/>apc.cache_by_default = on<br/>apc.shm_segments = 1<br/>apc.shm_size = 32<br/>apc.ttl = 600<br/>apc.user_ttl = 600<br/>apc.num_files_hint = 0<br/>apc.write_lock = On</div></div><br/>保存退出<br/>重启php-fpm即可<br/><br/>Tags - <a href="http://www.admin99.net/tag.php?tag=php" rel="tag">php</a> , <a href="http://www.admin99.net/tag.php?tag=cache" rel="tag">cache</a>
  ]]> 
</description>
</item><item>
<link>http://www.admin99.net/read.php?380</link>
<title>关于swap的一些操作</title> 
<author>real &lt;real@admin99.net&gt;</author>
<category>cache</category>
<pubDate>Mon, 06 Oct 2008 16:35:23 +0000</pubDate> 
<guid>http://www.admin99.net/read.php?380</guid> 
<description>
<![CDATA[ 
	一台机器重启以后，swap分区没有挂载上，看 /dev下，原来的swap分区还是在的 <br/>/dev/mapper/VolGroup00-LogVol01 &nbsp;<br/>执行了一下<br/><br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content">swapon /dev/mapper/VolGroup00-LogVol01</div></div><br/>发现，好了<br/><br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content"># swapon -s<br/>Filename &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Type &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Size &nbsp; &nbsp;Used &nbsp; &nbsp;Priority<br/>/dev/mapper/VolGroup00-LogVol01 &nbsp; &nbsp; &nbsp; &nbsp; partition &nbsp; &nbsp; &nbsp; 2031608 820 &nbsp; &nbsp; -1</div></div><br/>这是其中一种办法<br/>另外一种办法是，新建一个swap“分区”<br/>首先在空间合适的地方创建swap文件<br/><br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content">cd /usr<br/>dd if=/dev/zero of=swapfile bs=1024 count=10000<br/>mkswap swapfile<br/>swapon swapfile</div></div><br/>swap文件的size是 bs*count 字节，该列中的大小是10M<br/>可以用swapon -s 来查看挂载的swap文件或设备<br/><br/><br/>Tags - <a href="http://www.admin99.net/tag.php?tag=cache" rel="tag">cache</a> , <a href="http://www.admin99.net/tag.php?tag=%E7%B3%BB%E7%BB%9F%E7%AE%A1%E7%90%86" rel="tag">系统管理</a>
  ]]> 
</description>
</item><item>
<link>http://www.admin99.net/read.php?379</link>
<title>使用内存作linux下的临时文件夹</title> 
<author>real &lt;real@admin99.net&gt;</author>
<category>cache</category>
<pubDate>Sat, 04 Oct 2008 15:47:45 +0000</pubDate> 
<guid>http://www.admin99.net/read.php?379</guid> 
<description>
<![CDATA[ 
	从理论上来说，内存的读写速度是硬盘的几十倍，性能应该会有所提升<br/>在一些访问量比较高的系统上，通过把一些频繁访问的文件，比如session 放入内存中，能够减少很多的iowait，大大提高服务器的性能<br/><br/>在/etc/fstab中加入一行：<br/><br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content">none /tmp tmpfs defaults 0 0</div></div><br/>重启后生效<br/><br/>或者在/etc/rc.local中加入<br/><br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content">mount tmpfs /tmp -t tmpfs -o size=128m</div></div><br/>其中size=128m 表示/tmp最大能用128m<br/>或 &nbsp;<br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content">mount tmpfs /tmp -t tmpfs </div></div><br/>不限制大小，这种情况可以用到2G内存，用 df -h 可以看到<br/>tmpfs &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 2.0G &nbsp; 48M &nbsp;2.0G &nbsp; 3% /tmp<br/><br/>注：不管哪种方式，只要linux重启，/tmp下的文件全部消失<br/>另外，在一个正在运行的系统上运行 mount tmpfs /tmp -t tmpfs &nbsp;会导致 /tmp下原来的所有文件都会被“覆盖”掉，之所以加个“”，因为这种覆盖只是暂时的，如果 umount /tmp的话，原来的文件还能再访问。<br/>因为这些文件会被“覆盖”，比如原来的session mysql.sock等文件就不能访问了，用户的登陆信息就会丢失，mysql数据库也无法连接了(如果mysql.sock位于/tmp下的话)。<br/>正确的做法是，先把/tmp下的所有文件临时mv到一个别的目录，mount tmpfs之后，再mv回来<br/><br/>Tags - <a href="http://www.admin99.net/tag.php?tag=cache" rel="tag">cache</a> , <a href="http://www.admin99.net/tag.php?tag=%E7%B3%BB%E7%BB%9F%E7%AE%A1%E7%90%86" rel="tag">系统管理</a>
  ]]> 
</description>
</item><item>
<link>http://www.admin99.net/read.php?371</link>
<title>varnish的安装和简单使用</title> 
<author>real &lt;real@admin99.net&gt;</author>
<category>cache</category>
<pubDate>Tue, 30 Sep 2008 17:38:13 +0000</pubDate> 
<guid>http://www.admin99.net/read.php?371</guid> 
<description>
<![CDATA[ 
	1。下载 其官方主页在 http://varnish.projects.linpro.no/ 上面有各种相关的文档<br/>cd /usr/src<br/>wget http://www.sfr-fresh.com/unix/www/varnish-1.1.2.tar.gz<br/>2。安装<br/>tar xzvf varnish-1.1.2.tar.gz<br/>cd varnish-1.1.2<br/>./configure --prefix=/usr/local/varnish<br/>make<br/>make install<br/>3。简单配置<br/>vi /usr/local/varnish/varnish.conf<br/>输入下列内容<br/>backend web {<br/> &nbsp; &nbsp; &nbsp; set backend.host = "127.0.0.1";<br/> &nbsp; &nbsp; &nbsp; set backend.port = "80";<br/>}<br/>acl purge {<br/> &nbsp; &nbsp; &nbsp; "127.0.0.1";<br/>}<br/>sub vcl_recv {<br/> &nbsp; &nbsp; &nbsp; if (req.request == "PURGE") {<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (!client.ip ~ purge) {<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; error 405 "Not allowed.";<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; lookup;<br/> &nbsp; &nbsp; &nbsp; }<br/> &nbsp; &nbsp; &nbsp; if (req.http.host ~ "^(www.)?admin99.net") {<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; set req.backend = web;<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (req.request != "GET" && req.request != "HEAD") {<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pipe;<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else {<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; lookup;<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br/> &nbsp; &nbsp; &nbsp; }<br/> &nbsp; &nbsp; &nbsp; else {<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; error 404 "admin99.net";<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; lookup;<br/> &nbsp; &nbsp; &nbsp; }<br/>}<br/>sub vcl_hit {<br/> &nbsp; &nbsp; &nbsp; if (req.request == "PURGE") {<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; set obj.ttl = 0s;<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; error 200 "Purged.";<br/> &nbsp; &nbsp; &nbsp; }<br/>}<br/>sub vcl_miss {<br/> &nbsp; &nbsp; &nbsp; if (req.request == "PURGE") {<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; error 404 "Not in cache.";<br/> &nbsp; &nbsp; &nbsp; }<br/>}<br/>sub vcl_fetch {<br/> &nbsp; &nbsp; &nbsp; if (req.request == "GET" && req.url ~ "&#92;.(mp3&#124;wma&#124;wmv&#124;asf&#124;mid&#124;mmf)$") {<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; set obj.ttl = 30d;<br/> &nbsp; &nbsp; &nbsp; }<br/> &nbsp; &nbsp; &nbsp; else {<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pass;<br/> &nbsp; &nbsp; &nbsp; }<br/>}<br/><br/>其中：<br/>web服务器是监听在127.0.0.1:80端口的nginx<br/>只允许localhost来管理<br/>只缓存mp3、wma、wmv、asf、mid、mmf之类的音频视频文件<br/>4。启动<br/>/usr/local/varnish/sbin/varnishd -f /usr/local/varnish/varnish.conf -a 192.168.0.1:80 -s malloc,3G &nbsp;-w 1024,51200,10 -T 127.0.0.1:3500<br/>-f 指配置文件 -a是监听的ip和端口 -s是缓存文件的保存形式 malloc,3G表示用3G内存来保存缓存 -w指处理的最小请求数、最大请求数、超时时间 -T 是管理端口<br/>5。管理<br/>telnet 127.0.0.1 3500 <br/>通过 help命令可以看到更多的系统命令 其中 stats可看到varnish的工作状态<br/>也可以通过<br/>/usr/local/varnish/bin/varnishstat 来实时查看varnish的状态<br/><br/>配置文件中的缓存文件的类型，要根据自己的实际需求来设置。后来我发现在本机上缓存这类文件没有任何意义、反而会增加系统的cpu使用和负载，因为系统会把频繁打开的此类文件缓存到 cached中。如果缓存的类型是 php、asp、jsp之类的动态网页，则能大大减轻web服务器的负担<br/>Tags - <a href="http://www.admin99.net/tag.php?tag=cache" rel="tag">cache</a>
  ]]> 
</description>
</item><item>
<link>http://www.admin99.net/read.php?369</link>
<title>memcached 的安装</title> 
<author>real &lt;real@admin99.net&gt;</author>
<category>cache</category>
<pubDate>Mon, 29 Sep 2008 07:23:49 +0000</pubDate> 
<guid>http://www.admin99.net/read.php?369</guid> 
<description>
<![CDATA[ 
	memcached是一款高速、分布式的内存缓存系统。其官方主页在http://www.danga.com/memcached/<br/>1。安装前的准备<br/>要安装memcached，需要有libevent的支持。<br/>centos通过<br/>yum install libevent-devel <br/>安装即可<br/>其它版本可通过安装libevent的源文件获得<br/><br/>2。下载安装 目前最新版本为 memcached-1.2.6.tar.gz <br/>cd /usr/src<br/>wget http://www.danga.com/memcached/dist/memcached-1.2.6.tar.gz<br/>tar xzf memcached-1.2.6.tar.gz <br/>cd memcached-1.2.6<br/>./configure --prefix=/usr/local/memcached<br/>make<br/>make install<br/><br/>3。启动<br/>/usr/local/memcached/bin/memcached -d -m 512 -l 127.0.0.1 -p 10000 -u root<br/>表示已守护进程的方式启动，监听于 127.0.0.1 的10000端口，使用root用户，最大使用512M内存<br/>可以同时开多个memcached，但要监听在不同的端口<br/>Tags - <a href="http://www.admin99.net/tag.php?tag=cache" rel="tag">cache</a>
  ]]> 
</description>
</item><item>
<link>http://www.admin99.net/read.php?363</link>
<title>xcache的一些参数</title> 
<author>real &lt;real@admin99.net&gt;</author>
<category>cache</category>
<pubDate>Mon, 22 Sep 2008 10:47:03 +0000</pubDate> 
<guid>http://www.admin99.net/read.php?363</guid> 
<description>
<![CDATA[ 
	下面的配置是在一台xeon4核 4G内存 的web服务器上使用的典型配置。这台服务器采用nginx+php-fpm 只处理前台php页面。<br/>特别注意的是，如果xcache.count xcache.var_count 这两个参数配置不合理，会导致在大流量下服务器的负载会升到非常高。<br/>xcache.size 这个参数表示XCache的内存缓存大小，视php源文件的多少相应的调整这个参数。像我服务器上php页面很少，因此设置的比较小。如果视社区类的站点，在4G内存的服务器上，设置为256M左右也是合适的。具体还要看xcache的使用情况。<br/><br/><br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content">[xcache-common]<br/>zend_extension = /usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/xcache.so<br/><br/>[xcache.admin]<br/>xcache.admin.user = "xcache"<br/>; xcache.admin.pass = md5($yourpasswd)<br/>xcache.admin.pass = "42e89fc416c5e187e3e0b1a56135702c"<br/><br/>[xcache]<br/>xcache.cacher = On<br/>xcache.shm_scheme = "mmap"<br/>xcache.size = 128M<br/>; cpu number (cat /proc/cpuinfo &#124;grep -c processor)<br/>xcache.count = 4<br/>xcache.slots = 128k<br/>xcache.ttl = 0<br/>xcache.gc_interval = 0<br/>xcache.var_size = 8M<br/>; cpu number (cat /proc/cpuinfo &#124;grep -c processor)<br/>xcache.var_count = 4<br/>xcache.var_slots = 128K<br/><br/>xcache.var_ttl = 0<br/>xcache.var_maxttl = 0<br/>xcache.var_gc_interval = 300<br/>xcache.readonly_protection = Off<br/>xcache.mmap_path = "/dev/zero"</div></div><br/>Tags - <a href="http://www.admin99.net/tag.php?tag=php" rel="tag">php</a>
  ]]> 
</description>
</item><item>
<link>http://www.admin99.net/read.php?362</link>
<title>eaccelerator 安装</title> 
<author>real &lt;real@admin99.net&gt;</author>
<category>cache</category>
<pubDate>Mon, 22 Sep 2008 09:44:44 +0000</pubDate> 
<guid>http://www.admin99.net/read.php?362</guid> 
<description>
<![CDATA[ 
	很多评测显示 eaccelerator能够提高约40%的php执行效率。<br/>不过我用下来觉得，跟xcache半斤八两。<br/>1)下载eacclerator源码(http://www.eaccelerator.net/),并解压<br/>cd /usr/src<br/>wget http://bart.eaccelerator.net/source/0.9.5.3/eaccelerator-0.9.5.3.tar.bz2<br/>bzip2 -d eaccelerator-0.9.5.3.tar.bz2<br/>tar xvf eaccelerator-0.9.5.3.tar<br/>2)进入解压后的eaccelerator目录,运行/usr/local/php/bin/phpize<br/>cd eaccelerator-0.9.5.3<br/>/usr/local/php/bin/phpize<br/>3)./configure --prefix=/usr/local/eaccelerator --enable-eaccelerator=shared --with-php-config=/usr/local/php/bin/php-config<br/>4)make && make install<br/><br/>5)编辑php.ini<br/>添加以下内容<br/>[eaccelerator]<br/>extension_dir = "/usr/local/php/lib/php/extensions"<br/>extension="/no-debug-non-zts-20060613/eaccelerator.so"<br/>eaccelerator.shm_size="64"<br/>eaccelerator.cache_dir="/tmp/eaccelerator"<br/>eaccelerator.enable="1"<br/>eaccelerator.optimizer="1"<br/>eaccelerator.check_mtime="1"<br/>eaccelerator.debug="0"<br/>eaccelerator.filter=""<br/>eaccelerator.shm_max="0"<br/>eaccelerator.shm_ttl="0"<br/>eaccelerator.shm_prune_period="0"<br/>eaccelerator.shm_only="0"<br/>eaccelerator.compress="1"<br/>eaccelerator.compress_level="9"<br/><br/>6)创建缓目录并给予写权限<br/>mkdir /tmp/eaccelerator<br/>chown nobody:nobody /tmp/eaccelerator (保证php可写这个目录)<br/><br/>重启<br/>Tags - <a href="http://www.admin99.net/tag.php?tag=php" rel="tag">php</a>
  ]]> 
</description>
</item><item>
<link>http://www.admin99.net/read.php?361</link>
<title>xcache 管理页面</title> 
<author>real &lt;real@admin99.net&gt;</author>
<category>cache</category>
<pubDate>Mon, 22 Sep 2008 09:03:23 +0000</pubDate> 
<guid>http://www.admin99.net/read.php?361</guid> 
<description>
<![CDATA[ 
	xcache有一个简单的管理界面，可以看到缓冲区的状态，命中率之类的状态，还可以即时刷新xcache的缓存。<br/>一般来说用处不大，有没有都一样。<br/>安装好xcache以后，把源代码目录下的admin文件夹copy到网站根目录或者其它可以访问的目录中。<br/>然后修改xcache的admin管理密码<br/>管理密码要用md5来生成一下<br/>md5 -s "your_secret_password" <br/>该命令会生成一个字符串。<br/>如果系统中没有md5命令，也可以到 http://www.cmd5.com/Default.aspx这里来在线生成一下，把得到的32位的字符串复制到php.ini的 xcache.admin.pass 字段。<br/>例如<br/>使用 real 做为管理员的用户名，用 6wei.cc 做为管理面的密码。<br/>在配置文件 php.ini中 如下<br/>xcache.admin.user = "real"<br/>xcache.admin.pass = "b33052d6e7646d321ba6ed7c937f7ca9"<br/><br/>Tags - <a href="http://www.admin99.net/tag.php?tag=php" rel="tag">php</a>
  ]]> 
</description>
</item>
</channel>
</rss>