Jan 31 2009

固态硬盘

Category: 乱up当秘笈ssmax @ 13:03:14

听某人一直在说固态硬盘。。。今天无意中看到,觉得这东东的缺点比优点多很多,尚未完善啊。。。

固态硬盘的优点

  固态硬盘与普通硬盘比较,拥有以下优点:

  1. 启动快,没有电机加速旋转的过程。

  2. 不用磁头,快速随机读取,读延迟极小。根据相关测试:两台电脑在同样配置的电脑下,搭载固态硬盘的笔记本从开机到出现桌面一共只用了18秒,而搭载传统硬盘的笔记本总共用了31秒,两者几乎有将近一半的差距。

  3. 相对固定的读取时间。由于寻址时间与数据存储位置无关,因此磁盘碎片不会影响读取时间。

  4. 基于DRAM的固态硬盘写入速度极快。

  5. 无噪音。因为没有机械马达和风扇,工作时噪音值为0分贝。某些高端或大容量产品装有风扇,因此仍会产生噪音。

  6. 低容量的基于闪存的固态硬盘在工作状态下能耗和发热量较低,但高端或大容量产品能耗会较高。

  7. 内部不存在任何机械活动部件,不会发生机械故障,也不怕碰撞、冲击、振动。这样即使在高速移动甚至伴随翻转倾斜的情况下也不会影响到正常使用,而且在笔记本电脑发生意外掉落或与硬物碰撞时能够将数据丢失的可能性降到最小。

  8. 工作温度范围更大。典型的硬盘驱动器只能在5到55摄氏度范围内工作。而大多数固态硬盘可在-10~70摄氏度工作,一些工业级的固态硬盘还可在-40~85摄氏度,甚至更大的温度范围下工作。

  9. 低容量的固态硬盘比同容量硬盘体积小、重量轻。但这一优势随容量增大而逐渐减弱。直至256GB,固态硬盘仍比相同容量的普通硬盘轻。

 

固态硬盘的缺点

固态硬盘与传统硬盘比较,拥有以下缺点:

  1. 成本高。每单位容量价格是传统硬盘的5~10倍(基于闪存),甚至200~300倍(基于DRAM)。

  2. 容量低。目前固态硬盘最大容量远低于传统硬盘。固态硬盘的容量仍在迅速增长,据称IBM已测试过4TB的固态硬盘。

  3. 由于不像传统硬盘那样屏蔽于法拉第笼中,固态硬盘更易受到某些外界因素的不良影响。如断电(基于DRAM的固态硬盘尤甚)、磁场干扰、静电等。

  4. 写入寿命有限(基于闪存)。一般闪存写入寿命为1万到10万次,特制的可达100万到500万次,然而整台计算机寿命期内文件系统的某些部分(如文件分配表)的写入次数仍将超过这一极限。特制的文件系统或者固件可以分担写入的位置,使固态硬盘的整体寿命达到20年以上。

  5. 基于闪存的固态硬盘在写入时比传统硬盘慢很多,也更易受到写入碎片的影响。

  6. 数据损坏后难以的恢复。传统的磁盘或者磁带存储方式,如果硬件发生损坏,通过目前的数据恢复技术也许还能挽救一部分数据。但如果固态硬盘发生损坏,几乎不可能通过目前的数据恢复技术在失效(尤其是基于DRAM的)、破碎或者被击穿的芯片中找回数据。

  7. 根据实际测试,使用固态硬盘的笔记本电脑在空闲或低负荷运行下,电池航程短于使用7200RPM的2.5英寸传统硬盘。

  8. 基于DRAM的固态硬盘在任何时候的能耗都高于传统硬盘,尤其是关闭时仍需供电,否则数据丢失。

  9. 据用户反映,使用低廉的MLC的固态硬盘在Windows操作系统下运行比传统硬盘慢。这是由于Windows操作系统的文件系统机制不适于固态硬盘。在Linux下无此问题。


Jan 23 2009

年又过年

Category: 乱up当秘笈ssmax @ 15:28:37

niu


Jan 22 2009

Flash 的 URLRequestHeader

Category: 技术ssmax @ 16:06:26

测试了一天,发现flash新版已经不支持在GET里面用自定义的URLRequestHeader了,必须要在POST里面才能用,日了,无语了。。。Get的话还是要用random string才能忽略浏览器的缓存啊。郁闷。

这样子又要回到squid里面设置rewrite来忽略query string了,ooxx。。。

Due to browser limitations, custom HTTP request headers are only supported for POST requests, not for GET requests.

This restriction will be included in the next version of the Language Reference.


Jan 21 2009

Squidguard

Category: 技术ssmax @ 13:34:40

今天详细研究了一下squid的命中率,发现如果带参数的话,squid基本都设置成no_cache的,就算你cache了,也是带参数的url作为一个cache,这样的话就有可能会引起频繁返源的问题。。。查了一下,squid有个redirector的配置,可以改变url的,有类似的几种软件,或者自己写脚本,不过脚本的效率可能不是太高,还是用c写的软件比较好。

下面有介绍除了squidguard之外还有哪些比较多人用的redirector。

What’s New

Introduction

This is not the official SquiGuard homepage, but only an happy user’s page :
official homepage was http://www.squidguard.org. It seems out of service. Mirko Lorenz created a mirror here. SquidGuard is a redirector which uses sleepycat‘s version of Berkeley Database
Its authors are

  • Pål Marius Baltzersen
  • Lars-Erik Håland

A new patched version of squidGuard 1.2.10, with this REAME is available. This is a compilation of patch from many contributors. I didn’t even change a dot. Thanks to Franck Bourdonnec to suggest this packaged version.
The last stable version is 1.2.0.
Here it is the ChangeLog
It needs a recent version of Berkeley Database (> 3.2 but < 4.x)
An ftp directory is available here, in France at : ftp://ftp.univ-tlse1.fr/pub/reseau/cache/squidGuard/ I began a contrib directory here : ftp://ftp.univ-tlse1.fr/pub/reseau/cache/squidguard_contrib/
It has new interesting features

  • It can filter the surfing duration on a user basis.

You can find some explanations in other languages here :

Comparison

Competitors

SquidGuard and its competitors

Advantages

  • It’s a lot faster : for a 2.000 Urls list to filter and a 11.000 Urls database, on a pentium 233 :
    • Squirm : 2 minutes 25 seconds
    • Jesred : 1 minute 45 seconds
    • SquidGuard : 9 seconds !!!

    We can say, it doesn’t care of database size :

    • a 100 Urls database tooks 6 seconds
    • a 11000 Urls database tooks 9 seconds (now the adult database contains 100 000 urls)
  • Faster, in our case, is equal to “less redirector needed” : 20 for squidguard, 25 for squirm. Following a chart of redirector usage
    • with squirm you need 3 redirectors 60% of time, with squidguard, only 5%
    • with squirm you need 7 redirectors 10% of time, with squidguard, less than 0.5 %
  • It can redirect url depending on :
    • IP adress of client
    • User identity (RFC 1413) or login/password
    • URL (of course)
    • “Class” of redirection (e.g. we can define a class banner, adult, and so on…)
  • If database size doesn’t matter, it means that we can put MANY urls. So we use less generic regular expression, which make many errors (the computer xxx in nasa.gov domains e.g.)
  • contrib

    This part show some personal contributions : scripts, databases and some advice.
    • For Squirm, some patterns
    • To show web usage : a script which describe a VERY APPROXIMATIVE proportion of URL classes (erotic, hacking, mp3, warez) in your cache taille_categorie_squid.pl
    • Come very useful scripts to detect pornographic url in squid log (and more) made by Cedric Foll : http://savannah.nongnu.org/projects/pornfind/
    • Usability of database depends of your users : MIT students are not golden boys who are not children.
    • Some virus-filtering addon exist. They are connected by redirector (squirm or squidguard), and send their files to a virus scanner. Some of them :

    Some databases

    For all information on database (contributors, size, download method look at this page : http://cri.univ-tlse1.fr/blacklists

    Related Projects

    • http://www.surbl.org is a site to prevent spam. As we know, porno-business like spam. Surbl will, likely, create a DNS zone for adult web site…

    FAQ

    The original FAQ can be found here http://www.squidguard.org/faq/. An additional FAQ is http://www.maynidea.com/squidguard/faq-plus.html
    • Squid 2.6 isn’t working : it replace
      • redirect_program by url_rewrite_program
      • redirect_children by url_rewrite_children
      • A new command appears url_rewrite_concurrency
    • Nothing is blocked Many reasons :
      • Unix access right are incorrect. The user who launch squid, is the same who launch squidguard. So, this user must be able to read text database and to write db file, and log file. So, directory looks like this :
        		drwxr-xr-x  2 root     root	     1024 avr  2  2001 logs
        		-rw-r-----  1 squid    squid	   100000 oct 23 08:13 logs/squidGuard.log
        		-rw-r-----  1 squid    squid	     1000 oct 23 08:13 logs/squidGuard.error
        		drwxr-xr-x  2 root     root	     1024 avr  2  2001 db
        		drwxr-xr-x  2 root     root	     1024 avr  2  2001 db/dest
        		drwxr-xr-x  2 squid    squid	     1024 avr  2  2001 db/dest/adult
        		-rw-r--r--  1 squid    squid	     1024 avr  2  2001 db/dest/adult/domains
        		-rw-r--r--  1 squid    squid	     1024 avr  2  2001 db/dest/adult/domains.db
        		-rw-r--r--  1 squid    squid	     1024 avr  2  2001 db/dest/adult/urls
        		-rw-r--r--  1 squid    squid	     1024 avr  2  2001 db/dest/adult/urls.db
        		...
        		drwxr-xr-x  2 squid    squid	     1024 avr  2  2001 db/dest/warez
        		...
        		drwxr-xr-x  2 root     root          1024 avr  2  2001 db/src
        		...
      • You forgot none at the end of rule. Default is “accept”
      • You made a syntax error. temporal definition are quite tricky.
    • I can’t download blacklist. Many reasons :
      • You, or your entreprise, are protected by a “low level” firewall which is unable to understand “active ftp”. Check your ftp client, and change mode to “passive ftp”.
      • You, or your entreprise, are protected by a “too sensitive” “high level” firewall which say that length of file path are too longue. Firewall1 (Checkpoint) is one of these. Look at ftp://ftp.univ-tlse1.fr/blacklist which is a link to ftp://ftp.univ-tlse1.fr/pub/cache/squidguard_contrib. May Help

    Definition

    • Redirector :
      Official Squid FAQ definition : http://squid.nlanr.net/Squid/FAQ/FAQ-15.html
      A redirector is a program which connects to Squid and allows to “translate” URLs before sending them to Squid Process :

      • for restricting access (erotic or financial Urls)
      • for stripping banners to accelerate web usage
      • for redirecting Urls on a local mirror (Netscape Navigator downloading e.g.)

      To put them in place, uncomment redirector line in squid.conf and enter children processes you need : redirect_program /usr/local/squidGuard/bin/squidGuard
      redirect_children 20
      Common redirectors use from 800 Ko to 1600 Ko.
      You can also, if you don’t care about very rare “workaround” (less than 0.01%) accept to bypass redirector if they are all busy, by adding this line. redirector_bypass on


    Jan 18 2009

    新的服务器

    Category: 乱up当秘笈ssmax @ 23:29:53

    每年都要搞一下。。。去年是在hostmonster,今年改到swvps,12美金一个月

    这次付款的时候突然发现paypal可以自动购汇,美金可以自动转换成rmb,好像非常强悍。。。不知道支不支持银行卡了,正在验证中。。。


    Jan 15 2009

    js 的 UI 编辑器

    Category: 技术ssmax @ 10:58:35

    现在的人用js是越用越牛x了,就像这个ui编辑器,厉害得很啊。。。

    http://www.longboo.com/VisualJS/UIBuilder.html


    Jan 13 2009

    linux的网关功能

    Category: 技术ssmax @ 17:30:38

    今天发现北京到杭州的一条ip隧道不通了,不知道为啥,发出来的包好像被本机吞掉了,没有继续发下去的样子,检查了半天,最后发现是sysctl里面被人改了。forwarding本来默认是1的,现在默认是0了,真tmd郁闷,重新开了,把ip隧道重启一下就好了。。。

    net.ipv4.conf.default.forwarding=1
    net.ipv4.conf.all.forwarding=1


    Jan 12 2009

    查询和修改bios时间

    Category: 技术ssmax @ 14:35:09

    linux修改了时间以后貌似不会立刻同步到bios,好像是要重启啊之类的时候才会执行这个同步,很多服务器都是n年没有重启过的,所以有时候服务器突然断电,启动之后的时间会和原来的相差很大。
    有一个办法在linux下面更新硬件时间,就是
    hwclock -w

    如果出现错误:
    select() to /dev/rtc to wait for clock tick timed out

    一般就是设备的类型问题,指定用isa设备就可以了
    hwclock -w –directisa

    一般我们就是用一条命令
    hwclock -w; [ $? -ne 0 ] && hwclock -w –directisa;


    Jan 06 2009

    Job Scheduling Algorithms in Linux Virtual Server

    Category: 技术ssmax @ 13:38:22

    Job Scheduling Algorithms in Linux Virtual Server
    This page describes the job scheduling algorithms implemented in Linux Virtual Server.

    keepalive configure file
    lb_algo rr|wrr|lc|wlc|sh|dh|lblc

    Round-Robin Scheduling
    Weighted Round-Robin Scheduling
    Least-Connection Scheduling
    Weighted Least-Connection Scheduling
    Locality-Based Least-Connection Scheduling
    Locality-Based Least-Connection with Replication Scheduling
    Destination Hashing Scheduling
    Source Hashing Scheduling
    Shortest Expected Delay Scheduling
    Never Queue Scheduling
    Round-Robin Scheduling
    The round-robin scheduling algorithm sends each incoming request to the next server in it’s list. Thus in a three server cluster (servers A, B and C) request 1 would go to server A, request 2 would go to server B, request 3 would go to server C, and request 4 would go to server A, thus completing the cycling or ’round-robin’ of servers. It treats all real servers as equals regardless of the number of incoming connections or response time each server is experiencing. Virtual Server provides a few advantages over traditional round-robin DNS. Round-robin DNS resolves a single domain to the different IP addresses, the scheduling granularity is host-based, and the caching of DNS queries hinders the basic algorithm, these factors lead to significant dynamic load imbalances among the real servers. The scheduling granularity of Virtual Server is network connection-based, and it is much superior to round-robin DNS due to the fine scheduling granularity.

    Weighted Round-Robin Scheduling
    The weighted round-robin scheduling is designed to better handle servers with different processing capacities. Each server can be assigned a weight, an integer value that indicates the processing capacity. Servers with higher weights receive new connections first than those with less weights, and servers with higher weights get more connections than those with less weights and servers with equal weights get equal connections. For example, the real servers, A, B and C, have the weights, 4, 3, 2 respectively, a good scheduling sequence will be AABABCABC in a scheduling period (mod sum(Wi)). In the implementation of the weighted round-robin scheduling, a scheduling sequence will be generated according to the server weights after the rules of Virtual Server are modified. The network connections are directed to the different real servers based on the scheduling sequence in a round-robin manner.

    The weighted round-robin scheduling is better than the round-robin scheduling, when the processing capacity of real servers are different. However, it may lead to dynamic load imbalance among the real servers if the load of the requests vary highly. In short, there is the possibility that a majority of requests requiring large responses may be directed to the same real server.

    Actually, the round-robin scheduling is a special instance of the weighted round-robin scheduling, in which all the weights are equal.

    Least-Connection Scheduling
    The least-connection scheduling algorithm directs network connections to the server with the least number of established connections. This is one of the dynamic scheduling algorithms; because it needs to count live connections for each server dynamically. For a Virtual Server that is managing a collection of servers with similar performance, least-connection scheduling is good to smooth distribution when the load of requests vary a lot. Virtual Server will direct requests to the real server with the fewest active connections.

    At a first glance it might seem that least-connection scheduling can also perform well even when there are servers of various processing capacities, because the faster server will get more network connections. In fact, it cannot perform very well because of the TCP’s TIME_WAIT state. The TCP’s TIME_WAIT is usually 2 minutes, during this 2 minutes a busy web site often receives thousands of connections, for example, the server A is twice as powerful as the server B, the server A is processing thousands of requests and keeping them in the TCP’s TIME_WAIT state, but server B is crawling to get its thousands of connections finished. So, the least-connection scheduling cannot get load well balanced among servers with various processing capacities.

    Weighted Least-Connection Scheduling
    The weighted least-connection scheduling is a superset of the least-connection scheduling, in which you can assign a performance weight to each real server. The servers with a higher weight value will receive a larger percentage of live connections at any one time. The Virtual Server Administrator can assign a weight to each real server, and network connections are scheduled to each server in which the percentage of the current number of live connections for each server is a ratio to its weight. The default weight is one.

    The weighted least-connections scheduling works as follows:

    Supposing there is n real servers, each server i has weight Wi (i=1,..,n), and alive connections Ci (i=1,..,n), ALL_CONNECTIONS is the sum of Ci (i=1,..,n), the next network connection will be directed to the server j, in which

    (Cj/ALL_CONNECTIONS)/Wj = min { (Ci/ALL_CONNECTIONS)/Wi } (i=1,..,n)

    Since the ALL_CONNECTIONS is a constant in this lookup, there is no need to divide Ci by ALL_CONNECTIONS, it can be optimized as

    Cj/Wj = min { Ci/Wi } (i=1,..,n)

    The weighted least-connection scheduling algorithm requires additional division than the least-connection. In a hope to minimize the overhead of scheduling when servers have the same processing capacity, both the least-connection scheduling and the weighted least-connection scheduling algorithms are implemented.

    Locality-Based Least-Connection Scheduling
    The locality-based least-connection scheduling algorithm is for destination IP load balancing. It is usually used in cache cluster. This algorithm usually directs packet destined for an IP address to its server if the server is alive and under load. If the server is overloaded (its active connection numbers is larger than its weight) and there is a server in its half load, then allocate the weighted least-connection server to this IP address.

    Locality-Based Least-Connection with Replication Scheduling
    The locality-based least-connection with replication scheduling algorithm is also for destination IP load balancing. It is usually used in cache cluster. It differs from the LBLC scheduling as follows: the load balancer maintains mappings from a target to a set of server nodes that can serve the target. Requests for a target are assigned to the least-connection node in the target’s server set. If all the node in the server set are over loaded, it picks up a least-connection node in the cluster and adds it in the sever set for the target. If the server set has not been modified for the specified time, the most loaded node is removed from the server set, in order to avoid high degree of replication.

    Destination Hashing Scheduling
    The destination hashing scheduling algorithm assigns network connections to the servers through looking up a statically assigned hash table by their destination IP addresses.

    Source Hashing Scheduling
    The source hashing scheduling algorithm assigns network connections to the servers through looking up a statically assigned hash table by their source IP addresses.

    Shortest Expected Delay Scheduling
    The shortest expected delay scheduling algorithm assigns network connections to the server with the shortest expected delay. The expected delay that the job will experience is (Ci + 1) / Ui if sent to the ith server, in which Ci is the number of connections on the the ith server and Ui is the fixed service rate (weight) of the ith server.

    Never Queue Scheduling
    The never queue scheduling algorithm adopts a two-speed model. When there is an idle server available, the job will be sent to the idle server, instead of waiting for a fast one. When there is no idle server available, the job will be sent to the server that minimize its expected delay (The Shortest Expected Delay scheduling algorithm).


    Jan 05 2009

    crontab 的一点小问题 Temporary crontab no longer owned by you

    Category: 技术ssmax @ 14:31:25

    这几天某台服务器上面的crontab突然不能用了,表现为某个用户的crontab 临时文件不能读取,
    Temporary crontab no longer owned by you

    发现crontab -e的时候,在/tmp下面生成的临时文件有问题:

    drwx—— 2 root crontab 4.0K 2009-01-05 14:27 crontab.TRVZy0

    变成root用户的了,难怪普通用户读不到。

    查了n久没有啥发现,然后无意中ls -alh /usr/bin/crontab
    发现:
    -rwsr-sr-x 1 root crontab 26K Dec 20 2006 /usr/bin/crontab

    在owner一栏多了一个SUID。。。然后
    chown u-s /usr/bin/crontab
    ls -alh /usr/bin/crontab
    -rwxr-sr-x 1 root crontab 26K Dec 20 2006 /usr/bin/crontab

    去掉SUID以后,crontab就一切正常了。。。
    drwx—— 2 ssmax crontab 4.0K 2009-01-05 14:29 crontab.fdzKZk

    SUID、GUID、粘滞位一直都没有留意,好像是基础课的时候学到的,但是之后都一直都没有怎么用到,所以很容易就忘记了。

    各个位的定义:man chmod

    The letters ‘rwxXstugo’ select the new permissions for the affected users: read (r), write (w), execute (or access for directories) (x), execute only if the file is a directory or already has execute permission for some user (X), set user or group ID on execution (s), sticky (t), the permissions granted to the user who owns the file (u), the permissions granted to other users who are members of the file’s group (g), and the permissions granted to users that are in neither of the two preceding categories (o).


    Next Page »