Archive for 十一月, 2010

左转 左方向键
右转 右方向键
油门 上方向键
倒车 下方向键
进档 Shift
退档 左Ctrl
手煞车 空白键
飞速装置 右Ctrl
氮氧增压 Alt
摄影视角 C
向后看 L
进入赛事/商店 Enter
世界地图 M
阅读SMS Tab
黑名单 B
重置车辆 R
暂停 Esc 

选单控制键

标记选单项目 上、下、左、右方向键
循环切换/移动滑杆 上、下、左、右方向键
选择/前往下个画面 ENTER或按滑鼠左键
返回前个画面 ESC
撷取画面 F12 

 

Earlier today, in Guangzhou, China, the Opening Ceremony for the 16th Asian Games took place, with lavish stagecraft, costumes, fireworks and performers welcoming participants. Some 14,000 athletes from 45 countries and territories will compete in 42 sporting disciplines until November 27. Collected here are colorful scenes from Guangzhou, China. (29 photos total)

 

Dancers perform during the Opening Ceremony for the 16th Asian Games Guangzhou 2010 at Haixinsha Square on November 12, 2010 in Guangzhou, China. (Jamie McDonald/Getty Images)

 

 

 

 

The sun sets behind Haixinsha Stadium shortly before the start of the opening ceremony of the 16th Asian Games in Guangzhou on November 12, 2010. (TORSTEN BLACKWOOD/AFP/Getty Images) #

 

 

 

Fireworks explode at the opening ceremony of the 16th Asian Games in Guangzhou on November 12, 2010. (MIKE CLARKE/AFP/Getty Images) #

 

 

 

Boats sail up the Pearl River during the opening ceremony of the 16th Asian Games on November 12, 2010. (MIKE CLARKE/AFP/Getty Images) #

 

 

 

Athletes wave their flags during the Opening Ceremony for the Asian Games Guangzhou 2010 on November 12, 2010 in Guangzhou, China. (Feng Li/Getty Images)#

 

 

 

Illuminated performers take part in the opening ceremony of the 16th Asian Games on November 12, 2010. (REUTERS/Mick Tsikas) #

 

 

 

Dancers in traditional Chinese dress perform during the Opening Ceremony for the 16th Asian Games Guangzhou 2010 on November 12, 2010 in Guangzhou, China. (Jamie McDonald/Getty Images) #

 

 

 

Performers are suspended in the air during the opening ceremony for the 16th Asian Games in Guangzhou, China on Friday, Nov. 12, 2010. (AP Photo/Ng Han Guan) #

 

 

 

Performers dance on a submerged stage during the opening ceremony of the 16th Asian Games on November 12, 2010. (REUTERS/Carlos Barria (CHINA) #

 

 

 

Artists perform aboard a ship in the opening ceremony of the 16th Asian Games on November 12, 2010. (LIU JIN/AFP/Getty Images) #

 

 

 

Chinese soldiers carry their national flag to the flag raising ceremony during the opening of the 16th Asian Games on Nov. 12, 2010. (AP Photo/Ng Han Guan) #

 

 

 

A performer drums during the Opening Ceremony at Haixinsha Square on November 12, 2010 in Guangzhou, China. (Jamie McDonald/Getty Images) #

 

 

 

Illuminated dancers perform in the opening ceremony of the 16th Asian Games on November 12, 2010. (NICOLAS ASFOURI/AFP/Getty Images) #

 

 

 

Dancers perform suspended in front of a big screen during the Opening Ceremony of the 16th Asian Games Guangzhou 2010 on November 12, 2010. (Richard Heathcote/Getty Images) #

 

 

 

Performers hold lanterns in the opening ceremony of the 16th Asian Games in Guangzhou, China. (REUTERS/Carlos Barria) #

 

 

 

Drummers perform on the stage during the opening ceremony of the 16th Asian Games on November 12, 2010. (PETER PARKS/AFP/Getty Images) #

 

 

 

A boy performs, suspended above the stage, during the Opening Ceremony of the 16th Asian Games Guangzhou 2010 on November 12, 2010. (Jamie McDonald/Getty Images) #

 

 

 

Performers take part in the opening ceremony of the 16th Asian Games on November 12, 2010. (PHILIPPE LOPEZ/AFP/Getty Images) #

 

 

 

Dancers in native costume perform during the opening ceremony of the 16th Asian Games in Guangzhou on November 12, 2010. (PETER PARKS/AFP/Getty Images) #

 

 

 

Dancers perform suspended before a big screen during the Opening Ceremony for the 16th Asian Games. (Richard Heathcote/Getty Images) #

 

 

 

Swimming performers take part in the opening ceremony of the 16th Asian Games in Guangzhou, Guangdong province on November 12, 2010. (REUTERS/Carlos Barria) #

 

 

 

Spinning performers take part in the opening ceremony of the 16th Asian Gameson November 12, 2010. (REUTERS/Mick Tsikas) #

 

 

 

Drummers raise their arms during the Opening Ceremony at Haixinsha Square on November 12, 2010 in Guangzhou, China. (Hannah Johnston/Getty Images) #

 

 

 

A dancer performs during the Opening Ceremony for the 16th Asian Games on November 12, 2010. (Jamie McDonald/Getty Images) #

 

 

 

The flag-bearer of Afghanistan leads the delegation during the opening ceremony of the 16th Asian Games on November 12, 2010. (REUTERS/Carlos Barria) #

 

 

 

Spectators hold up lanterns as they wait for the start of the opening ceremony for the 16th Asian Games in Guangzhou, China, Friday, Nov. 12, 2010. (AP Photo/Eugene Hoshiko) #

 

 

 

The fire for the 16th Asian Games is lit during the opening ceremony on November 12, 2010. (REUTERS/Donald Chan) #

 

 

 

The flag bearer for China leads the delegation during the opening ceremony in Guangzhou,China on November 12, 2010. (REUTERS/Carlos Barria) #

 

 

 

Performers dance ona submerged stage during the opening ceremony of the 16th Asian Games in Guangzhou on November 12, 2010. (PHILIPPE LOPEZ/AFP/Getty Images)

 

from

MySQL支持超过 100 个的可调节设置;但是幸运的是,掌握少数几个就可以满足大部分需要。查找这些设置的正确值可以通过 SHOW STATUS 命令查看状态变量,从中可以确定mysqld 的运作情况是否符合我们的预期。给缓冲区和缓存分配的内存不能超过系统中的现有内存,因此调优通常都需要进行一些妥协。

MySQL 可调节设置可以应用于整个 mysqld 进程,也可以应用于单个客户机会话。

服务器端的设置

每个表都可以表示为磁盘上的一个文件,必须先打开,后读取。为了加快从文件中读取数据的过程,mysqld 对这些打开文件进行了缓存,其最大数目由 /etc/mysqld.conf 中的 table_cache 指定。清单 4 给出了显示与打开表有关的活动的方式。

清单 4. 显示打开表的活动

mysql> SHOW STATUS LIKE 'open%tables';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| Open_tables   | 5000  |
| Opened_tables | 195   |
+---------------+-------+
2 rows in set (0.00 sec)

清单 4 说明目前有 5,000 个表是打开的,有 195 个表需要打开,因为现在缓存中已经没有可用文件描述符了(由于统计信息在前面已经清除了,因此可能会存在 5,000 个打开表中只有 195 个打开记录的情况)。如果 Opened_tables 随着重新运行 SHOW STATUS 命令快速增加,就说明缓存命中率不够。如果 Open_tablestable_cache 设置小很多,就说明该值太大了(不过有空间可以增长总不是什么坏事)。例如,使用 table_cache = 5000 可以调整表的缓存。

与表的缓存类似,对于线程来说也有一个缓存。 mysqld 在接收连接时会根据需要生成线程。在一个连接变化很快的繁忙服务器上,对线程进行缓存便于以后使用可以加快最初的连接。

清单 5 显示如何确定是否缓存了足够的线程。

清单 5. 显示线程使用统计信息

mysql> SHOW STATUS LIKE 'threads%';
+-------------------+--------+
| Variable_name     | Value  |
+-------------------+--------+
| Threads_cached    | 27     |
| Threads_connected | 15     |
| Threads_created   | 838610 |
| Threads_running   | 3      |
+-------------------+--------+
4 rows in set (0.00 sec)

此处重要的值是 Threads_created,每次 mysqld 需要创建一个新线程时,这个值都会增加。如果这个数字在连续执行 SHOW STATUS 命令时快速增加,就应该尝试增大线程缓存。例如,可以在 my.cnf 中使用 thread_cache = 40 来实现此目的。

关键字缓冲区保存了 MyISAM 表的索引块。理想情况下,对于这些块的请求应该来自于内存,而不是来自于磁盘。清单 6 显示了如何确定有多少块是从磁盘中读取的,以及有多少块是从内存中读取的。

清单 6. 确定关键字效率

mysql> show status like '%key_read%';
+-------------------+-----------+
| Variable_name     | Value     |
+-------------------+-----------+
| Key_read_requests | 163554268 |
| Key_reads         | 98247     |
+-------------------+-----------+
2 rows in set (0.00 sec)

Key_reads 代表命中磁盘的请求个数, Key_read_requests 是总数。命中磁盘的读请求数除以读请求总数就是不中比率 —— 在本例中每 1,000 个请求,大约有 0.6 个没有命中内存。如果每 1,000 个请求中命中磁盘的数目超过 1 个,就应该考虑增大关键字缓冲区了。例如,key_buffer = 384M 会将缓冲区设置为 384MB。

临时表可以在更高级的查询中使用,其中数据在进一步进行处理(例如 GROUP BY 字句)之前,都必须先保存到临时表中;理想情况下,在内存中创建临时表。但是如果临时表变得太大,就需要写入磁盘中。清单 7 给出了与临时表创建有关的统计信息。

清单 7. 确定临时表的使用

mysql> SHOW STATUS LIKE 'created_tmp%';
+-------------------------+-------+
| Variable_name           | Value |
+-------------------------+-------+
| Created_tmp_disk_tables | 30660 |
| Created_tmp_files       | 2     |
| Created_tmp_tables      | 32912 |
+-------------------------+-------+
3 rows in set (0.00 sec)

每次使用临时表都会增大 Created_tmp_tables;基于磁盘的表也会增大Created_tmp_disk_tables。对于这个比率,并没有什么严格的规则,因为这依赖于所涉及的查询。长时间观察 Created_tmp_disk_tables 会显示所创建的磁盘表的比率,您可以确定设置的效率。tmp_table_sizemax_heap_table_size 都可以控制临时表的最大大小,因此请确保在 my.cnf 中对这两个值都进行了设置。

每个会话的设置

下面这些设置针对于每个会话。在设置这些数字时要十分谨慎,因为它们在乘以可能存在的连接数时候,这些选项表示大量的内存!您可以通过代码修改会话中的这些数字,或者在 my.cnf 中为所有会话修改这些设置。

当 MySQL 必须要进行排序时,就会在从磁盘上读取数据时分配一个排序缓冲区来存放这些数据行。如果要排序的数据太大,那么数据就必须保存到磁盘上的临时文件中,并再次进行排序。如果sort_merge_passes 状态变量很大,这就指示了磁盘的活动情况。清单 8 给出了一些与排序相关的状态计数器信息。

清单 8. 显示排序统计信息

mysql> SHOW STATUS LIKE "sort%";
+-------------------+---------+
| Variable_name     | Value   |
+-------------------+---------+
| Sort_merge_passes | 1       |
| Sort_range        | 79192   |
| Sort_rows         | 2066532 |
| Sort_scan         | 44006   |
+-------------------+---------+
4 rows in set (0.00 sec)

如果 sort_merge_passes 很大,就表示需要注意 sort_buffer_size。例如, sort_buffer_size = 4M 将排序缓冲区设置为 4MB。

MySQL 也会分配一些内存来读取表。理想情况下,索引提供了足够多的信息,可以只读入所需要的行,但是有时候查询(设计不佳或数据本性使然)需要读取表中大量数据。要理解这种行为,需要知道运行了多少个 SELECT 语句,以及需要读取表中的下一行数据的次数(而不是通过索引直接访问)。实现这种功能的命令如清单 9 所示。

清单 9. 确定表扫描比率

mysql> SHOW STATUS LIKE "com_select";
+---------------+--------+
| Variable_name | Value  |
+---------------+--------+
| Com_select    | 318243 |
+---------------+--------+
1 row in set (0.00 sec)

mysql> SHOW STATUS LIKE "handler_read_rnd_next";
+-----------------------+-----------+
| Variable_name         | Value     |
+-----------------------+-----------+
| Handler_read_rnd_next | 165959471 |
+-----------------------+-----------+
1 row in set (0.00 sec)

Handler_read_rnd_next / Com_select 得出了表扫描比率 —— 在本例中是 521:1。如果该值超过 4000,就应该查看 read_buffer_size,例如 read_buffer_size = 4M。如果这个数字超过了 8M,就应该与开发人员讨论一下对这些查询进行调优了!

1. 什么是phpDocumentor ?
PHPDocumentor是一个用PHP写的工具,对于有规范注释的php程序,它能够快速生成具有相互参照,索引等功能的API文档。老的版本是 phpdoc,从1.3.0开始,更名为phpDocumentor,新的版本加上了对php5语法的支持,同时,可以通过在客户端浏览器上操作生成文 档,文档可以转换为PDF,HTML,CHM几种形式,非常的方便。
PHPDocumentor工作时,会扫描指定目录下面的php源代码,扫描其中的关键字,截取需要分析的注释,然后分析注释中的专用的tag,生成 xml文件,接着根据已经分析完的类和模块的信息,建立相应的索引,生成xml文件,对于生成的xml文件,使用定制的模板输出为指定格式的文件。
2. 安装phpDocumentor
   和其他pear下的模块一样,phpDocumentor的安装也分为自动安装和手动安装两种方式,两种方式都非常方便:
a. 通过pear 自动安装
在命令行下输入
pear install PhpDocumentor
b. 手动安装
在http://manual.phpdoc.org/下载最新版本的PhpDocumentor(现在是1.4.0),把内容解压即可。
3.怎样使用PhpDocumentor生成文档
命令行方式:
在phpDocumentor所在目录下,输入
phpdoc –h
会得到一个详细的参数表,其中几个重要的参数如下:
-f    要进行分析的文件名,多个文件用逗号隔开
-d   要分析的目录,多个目录用逗号分割
-t    生成的文档的存放路径
-o   输出的文档格式,结构为输出格式:转换器名:模板目录。
例如:phpdoc -o HTML:frames:earthli -f test.php -t docs
Web界面生成
在新的phpdoc中,除了在命令行下生成文档外,还可以在客户端浏览器上操作生成文档,具体方法是先把PhpDocumentor的内容放在apache目录下使得通过浏览器可以访问到,访问后显示如下的界面:
点击files按钮,选择要处理的php文件或文件夹,还可以通过该指定该界面下的Files to ignore来忽略对某些文件的处理。
然后点击output按钮来选择生成文档的存放路径和格式.
最后点击create,phpdocumentor就会自动开始生成文档了,最下方会显示生成的进度及状态,如果成功,会显示
Total Documentation Time: 1 seconds
done
Operation Completed!!
然后,我们就可以通过查看生成的文档了,如果是pdf格式的,名字默认为documentation.pdf。
4.给php代码添加规范的注释
PHPDocument是从你的源代码的注释中生成文档,因此在给你的程序做注释的过程,也就是你编制文档的过程。
从这一点上讲,PHPdoc促使你要养成良好的编程习惯,尽量使用规范,清晰文字为你的程序做注释,同时多多少少也避免了事后编制文档和文档的更新不同步的一些问题。
    在phpdocumentor中,注释分为文档性注释和非文档性注释。
所谓文档性注释,是那些放在特定关键字前面的多行注释,特定关键字是指能够被phpdoc分析的关键字,例如class,var等,具体的可参加附录1.
那些没有在关键字前面或者不规范的注释就称作非文档性注释,这些注释将不会被phpdoc所分析,也不会出现在你产生的api文当中。
3.2如何书写文档性注释:
   所有的文档性注释都是由/**开始的一个多行注释,在phpDocumentor里称为DocBlock, DocBlock是指软件开发人员编写的关于某个关键字的帮助信息,使得其他人能够通过它知道这个关键字的具体用途,如何使用。 PhpDocumentor规定一个DocBlock包含如下信息:
1. 功能简述区
2. 详细说明区
3. 标记tag
文档性注释的第一行是功能描述区,正文一般是简明扼要地说明这个类,方法或者函数的功能,功能简述的正文在生成的文档中将显示在索引区。功能描述区的内容可以通过一个空行或者 . 来结束
在功能描述区后是一个空行,接着是详细说明区,. 这部分主要是详细说明你的API的功能,用途,如果可能,也可以有用法举例等等。在这部分,你应该着重阐明你的API函数或者方法的通常的用途,用法,并 且指明是否是跨平台的(如果涉及到),对于和平台相关的信息,你要和那些通用的信息区别对待,通常的做法是另起一行,然后写出在某个特定平台上的注意事项 或者是特别的信息,这些信息应该足够,以便你的读者能够编写相应的测试信息,比如边界条件,参数范围,断点等等。
之后同样是一个空白行,然后是文档的标记tag,指明一些技术上的信息,主要是最主要的是调用参数类型,返回值极其类型,继承关系,相关方法/函数等等。
关于文档标记,详细的请参考第四节:文档标记。
文档注释中还可以使用例如<b> <code>这样的标签,详细介绍请参考附录二。
下面是一个文档注释的例子
/**
* 函数add,实现两个数的加法
*
* 一个简单的加法计算,函数接受两个数a、b,返回他们的和c
*
* @param int 加数
* @param int 被加数
* @return integer
*/
function Add($a, $b)
{
    return $a+$b;
}
生成文档如下:
Add
integer Add( int $a, int $b)
[line 45]
函数add,实现两个数的加法
Constants 一个简单的加法计算,函数接受两个数a、b,返回他们的和c
Parameters
• int $a – 加数
• int $b – 被加数
5.文档标记:
文档标记的使用范围是指该标记可以用来修饰的关键字,或其他文档标记。
所有的文档标记都是在每一行的 * 后面以@开头。如果在一段话的中间出来@的标记,这个标记将会被当做普通内容而被忽略掉。
@access
使用范围:class,function,var,define,module
该标记用于指明关键字的存取权限:private、public或proteced
@author
指明作者
@copyright
使用范围:class,function,var,define,module,use
指明版权信息
@deprecated
使用范围:class,function,var,define,module,constent,global,include
指明不用或者废弃的关键字
@example
该标记用于解析一段文件内容,并将他们高亮显示。Phpdoc会试图从该标记给的文件路径中读取文件内容
@const
使用范围:define
用来指明php中define的常量
@final
使用范围:class,function,var
指明关键字是一个最终的类、方法、属性,禁止派生、修改。
@filesource
和example类似,只不过该标记将直接读取当前解析的php文件的内容并显示。
@global
指明在此函数中引用的全局变量
@ingore
用于在文档中忽略指定的关键字
@license
相当于html标签中的<a>,首先是URL,接着是要显示的内容
例如<a href=”http://www.baidu.com”>百度</a>
可以写作 @license http://www.baidu.com 百度
@link
类似于license
但还可以通过link指到文档中的任何一个关键字
@name
为关键字指定一个别名。
@package
使用范围:页面级别的-> define,function,include
          类级别的->class,var,methods
用于逻辑上将一个或几个关键字分到一组。
@abstrcut
说明当前类是一个抽象类
@param
指明一个函数的参数
@return
指明一个方法或函数的返回指
@static
指明关建字是静态的。
@var
指明变量类型
@version
指明版本信息
@todo
指明应该改进或没有实现的地方
@throws
指明此函数可能抛出的错误异常,极其发生的情况
上面提到过,普通的文档标记标记必须在每行的开头以@标记,除此之外,还有一种标记叫做inline tag,用{@}表示,具体包括以下几种:
{@link}
用法同@link
{@source}
显示一段函数或方法的内容
6.一些注释规范
a.注释必须是
/**
* XXXXXXX
*/
的形式
b.对于引用了全局变量的函数,必须使用glboal标记。
c.对于变量,必须用var标记其类型(int,string,bool…)
d.函数必须通过param和return标记指明其参数和返回值
e.对于出现两次或两次以上的关键字,要通过ingore忽略掉多余的,只保留一个即可
f.调用了其他函数或类的地方,要使用link或其他标记链接到相应的部分,便于文档的阅读。
g.必要的地方使用非文档性注释,提高代码易读性。
h.描述性内容尽量简明扼要,尽可能使用短语而非句子。
i.全局变量,静态变量和常量必须用相应标记说明
7. 总结
phpDocumentor是一个非常强大的文档自动生成工具,利用它可以帮助我们编写规范的注释,生成易于理解,结构清晰的文档,对我们的代码升级,维护,移交等都有非常大的帮助。
关于phpDocumentor更为详细的说明,可以到它的官方网站http://manual.phpdoc.org/查阅
8.附录
附录1:
能够被phpdoc识别的关键字:
include
require
include_once
require_once  
define
function
global
class
附录2
文档中可以使用的标签
<b>
<code>
<br>
<kdb>
<li>
<pre>
<ul>
<samp>
<var>
附录三:
一段含有规范注释的php代码

<?php
/**
* Sample File 2, phpDocumentor Quickstart
*
* This file demonstrates the rich information that can be included in
* in-code documentation through DocBlocks and tags.
* @author Greg Beaver <cellog@php.net>
* @version 1.0
* @package sample
*/

// sample file #1
/**
* Dummy include value, to demonstrate the parsing power of phpDocumentor
*/
include_once 'sample3.php';

/**
* Special global variable declaration DocBlock
* @global integer $GLOBALS['_myvar']
* @name $_myvar
*/
$GLOBALS['_myvar'] = 6;
/**
* Constants
*/
/**
* first constant
*/
define('testing', 6);

/**
* second constant
*/
define('anotherconstant', strlen('hello'));

/**
* A sample function docblock
* @global string document the fact that this function uses $_myvar
* @staticvar integer $staticvar this is actually what is returned
* @param string $param1 name to declare
* @param string $param2 value of the name
* @return integer
*/
function firstFunc($param1, $param2 = 'optional')
{
    static $staticvar = 7;
    global $_myvar;
    return $staticvar;
}

/**
* The first example class, this is in the same package as the
* procedural stuff in the start of the file
* @package sample
* @subpackage classes
*/

class myclass {
    /**
     * A sample private variable, this can be hidden with the --parseprivate
     * option
     * @access private
     * @var integer|string
     */
    var $firstvar = 6;

    /**
     * @link http://www.example.com Example link
     * @see myclass()
     * @uses testing, anotherconstant
     * @var array
     */
    var $secondvar =
        array(
            'stuff' =>
                array(
                    6,
                    17,
                    'armadillo'
                ),
            testing => anotherconstant
        );

    /**
     * Constructor sets up {@link $firstvar}
     */
    function myclass()
    {
        $this->firstvar = 7;
    }

    /**
     * Return a thingie based on $paramie
     * @param boolean $paramie
     * @return integer|babyclass
     */
    function parentfunc($paramie)
    {
        if ($paramie) {
            return 6;
        } else {
            return new babyclass;
        }
    }
}

/**
* @package sample1
*/
class babyclass extends myclass {
    /**
     * The answer to Life, the Universe and Everything
     * @var integer
     */
    var $secondvar = 42;

    /**
     * Configuration values
     * @var array
     */
    var $thirdvar;

    /**
     * Calls parent constructor, then increments {@link $firstvar}
     */
    function babyclass()
    {
        parent::myclass();
        $this->firstvar++;
    }

    /**
     * This always returns a myclass
     * @param ignored $paramie
     * @return myclass
     */
    function parentfunc($paramie)
    {
        return new myclass;
    }
}
?>

ubuntu 安装 Nagios服务器监控软件的步骤如下:

1,    

sudo apt-get install nagios3 

尝试 http://你的网站/nagios3 , 会发现需要认证。

2,    创建登录用户,

sudo htpasswd -c /etc/nagios3/htpasswd.users  jansfer

(jansfer换成你的用户名)

这样就能登录 http://你的网站/nagios3 了 ,但是会无法显示服务器运行信息,

It appears as though you do not have permission to view information for any of the services you requested…,

接着做第三步,增加cgi权限,

3, 

sudo nano /etc/nagios3/cgi.cfg 

, 把所有形如:

authorized_for_configuration_information=nagiosadmin
authorized_for_system_commands=nagiosadmin

, 之类 的改成

authorized_for_configuration_information=nagiosadmin,jansfer

(jansfer改成你的用户名).

4.

sudo /etc/init.d/nagios3 restart
sudo /etc/init.d/apache2 restart

重启一切OK。