分页: 1/2 第一页 1 2 下页 最后页 [ 显示模式: 摘要 | 列表 ]
什么是SSI ?
SSI是嵌入HTML页面中的指令,在页面被提供时由服务器进行运算,以对现有HTML页面增加动态生成的内容,而无须通过CGI程序提供其整个页面,或者使用其他动态技术。
至于什么时候应当用SSI ,而什么时候应当用某些程序生成整个页面,取决于页面中有多少内容是静态的,又有多少内容需要在每次页面被提供时重新计算。SSI是一种增加小段动态信息的好方法,比如当前时间。如果你的页面大部分内容是在被提供时动态生成的,那就要另找方案了.


以上是apache 官方的解释,而在apache 里面的实现就是通过mod_include模块实现.要使服务器允许SSI,必须在httpd.conf或.htaccess文件中有如下配置:

AddType text/html .shtml
AddOutputFilter INCLUDES .shtml    ####声明那些文件后缀使用ssi
Options +Includes                           ####启用ssi指令

首先我们分析下ssi原理和设置:
     1:全文式的搜索文件内容来寻找源码的Include标签,消耗大量cpu资源
     2:而大量的html文件是不经常更改的,所以无法随意的修改文件后缀(shml),尽管我可以更改如下:
     AddType text/html .shtml html
     AddOutputFilter INCLUDES .shtml html
     但是我其他没有include标签的html似乎很无辜!
     3:通过设置"XBitHack on“似乎能解决一些问题,但也仅仅是杯水车薪。
     当然ssi对系统性能的影响完全大于我们对他的需求
     今天的web不是几年前的web那么简单,不是几个简单的html就能搞定的事,大量内容的发布似拖动了整个页面的更新.往往这些更新只是局部的,这样的开销开销似乎很不合算.SSi就是满足了我们这点.
那有没有更简单的方式实现服务器端包含呢?
答案是有的!

今天我们介绍通过apache的第三方模块实现对现有HTML文档增加动态内容的方法
mod_layout
mod_layout(http://tangent.org/362/mod_layout.html)是一个Apache模块,它支持html网页内容自动插入来自其他URL或者文件输出的内容来子作为指定网页的页眉和页脚。目前支持mod_perl,PHP 和 Apache JServ.和几乎任何类型的处理程序


据我了解sina就是使用mod_layout!

[root@node2 extra]# curl --head www.sina.com.cn
HTTP/1.0 200 OK
Date: Thu, 17 Jun 2010 08:22:02 GMT
Server: Apache/2.0.54 (Unix)
Last-Modified: Thu, 17 Jun 2010 08:21:00 GMT
Accept-Ranges: bytes
X-Powered-By: mod_xlayout_jh/0.0.1vhs.markIII.remix
Cache-Control: max-age=60
Expires: Thu, 17 Jun 2010 08:23:02 GMT
Vary: Accept-Encoding
X-UA-Compatible: IE=EmulateIE7
Content-Type: text/html
Age: 48
Content-Length: 555586
X-Cache: HIT from sh201-20.sina.com.cn
Connection: close

[root@node2 extra]# curl --head http://sh.house.sina.com.cn/
HTTP/1.1 200 OK
Date: Thu, 17 Jun 2010 08:29:36 GMT
Server: Apache/2.2.6 (Unix)
Last-Modified: Thu, 17 Jun 2010 08:18:35 GMT
Accept-Ranges: bytes
Cache-Control: max-age=1800
Expires: Thu, 17 Jun 2010 08:59:36 GMT
X-Powered-By: ModLayout/5.1
Vary: Accept-Encoding
Connection: close
Content-Type: text/html
Tags: , ,

LVS三种模式配置总结

[不指定 2010/03/22 18:47 | by 张明辉 ]
近日.做服务器集群,使用的是LVS架构解决方案,为管理方便,总结LVS三种(LVS-DR,LVS-NAT,LVS-TUN)模式的简要配置,省的自己下次需要去网上
LVS是什么我就不介绍的了,参考
http://www.linuxvirtualserver.org/VS-NAT.html
http://www.linuxvirtualserver.org/VS-IPTunneling.html
http://www.linuxvirtualserver.org/VS-DRouting.html
首先是安装ipvsadm管理程序
下载:http://www.linuxvirtualserver.org/software/
注意对应自己的内核版本
ipvsadm-1.24.tar.gz
tar zxvf ipvsadm-1.24.tar.gz
cd ipvsadm-1.24
make
make install

1: LVS-DR 模式(调度器与实际服务器都有一块网卡连在同一物理网段上)
简要的网络结构如下所示
点击在新窗口中浏览此图片
配置LVS server
引用
#!/bin/sh
VIP=192.168.0.210
RIP1=192.168.0.175
RIP2=192.168.0.145
. /etc/rc.d/init.d/functions
        case "$1" in
        start)
        echo "start LVS of DirectorServer"
        #Set the Virtual IP Address
        /sbin/ifconfig eth0:1 $VIP broadcast $VIP netmask 255.255.255.255 up
        /sbin/route add -host $VIP dev eth0:1
        #Clear IPVS Table
        /sbin/ipvsadm -C
        #Set Lvs
        /sbin/ipvsadm -A -t $VIP:80 -s rr
        /sbin/ipvsadm -a -t $VIP:80 -r $RIP1:80 -g
        /sbin/ipvsadm -a -t $VIP:80 -r $RIP2:80 -g
        #Run Lvs
        /sbin/ipvsadm
        ;;
        stop)
        echo "close LVS Directorserver"
        /sbin/ipvsadm -C
        /sbin/ifconfig eth0:1 down
        ;;
        *)
        echo "Usage: $0 {start|stop}"
        exit 1
        esac

Tags: , , , ,

使用Cacti监控Nginx状态

[不指定 2010/02/09 09:53 | by 张明辉 ]
Cacti是一款不错的开源网络设备,系统监控软件。我们生产中就是使用Cacti中监控系统状态。今天介绍使用Cacti如何监控Nginx状态
Nginx中有一个很好的模块【http_stub_status_module】完成Nginx运行的状态。
但是它只能通过web页面查看状态,如果需要监控的话,就必须写脚本完成。以下就是用Perl脚本完成Nginx的监控
1:给系统安装LWP::UserAgent模块
RedHat下可以通过以下命令:
引用
yum -y install perl-libwww-perl
或者
cpan -i LWP::UserAgent

2:下载监控脚本
下载文件 (已下载 142 次)

3:添加监控模板
解压压缩包
cacti_graph_template_nginx_clients_stat.xml
cacti_graph_template_nginx_sockets_stat.xml
get_nginx_clients_status.pl
get_nginx_socket_status.pl
上传.pl 脚本到cacti 目录下scripts 并设置可执行权限跟755读写权限
然后打开Cacti的界面,点击左边导航条上的Import Templates。
如下图:
点击在新窗口中浏览此图片
Tags: , ,

RedHat 5.2 上安装PHP-5.3+APC

[不指定 2010/02/03 16:22 | by 张明辉 ]
今天下午安装了PHP5.3.0和php缓冲加速模块APC

APC,全称是Alternative PHP Cache.The Alternative PHP Cache (APC) is a free and open opcode cache for PHP. Its goal is to provide a free, open, and robust framework for caching and optimizing PHP intermediate code.
Office Website: http://pecl.php.net/package/apc.  目前的版本是 3.1.3p(2009-08-14)
一:下载:
引用
[root@backup master]# wget http://pecl.php.net/get/APC-3.1.3.tgz
--15:00:16--  http://pecl.php.net/get/APC-3.1.3.tgz
Resolving pecl.php.net... 76.75.200.106
Connecting to pecl.php.net|76.75.200.106|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 132755 (130K) [application/octet-stream]
Saving to: `APC-3.1.3.tgz'

100%[===========================================================================================>] 132,755     93.1K/s   in 1.4s  

15:00:18 (93.1 KB/s) - `APC-3.1.3.tgz' saved [132755/132755]

二:解压
引用
[root@backup master]# ls
APC-3.1.3.tgz
[root@backup master]# tar -zxvf APC-3.1.3.tgz
package.xml
APC-3.1.3/tests/apc_001.phpt
APC-3.1.3/tests/apc_002.phpt
APC-3.1.3/tests/apc_003.phpt
APC-3.1.3/tests/apc_003b.phpt
APC-3.1.3/tests/apc_004.phpt
APC-3.1.3/tests/apc_005.phpt
APC-3.1.3/tests/apc_006.phpt
APC-3.1.3/tests/apc_007.phpt
APC-3.1.3/tests/apc_008.phpt
APC-3.1.3/tests/apc_009.phpt
APC-3.1.3/tests/iterator_001.phpt
....................
..............
APC-3.1.3/apc_rfc1867.c
APC-3.1.3/apc.php
[root@backup master]# cd APC-3.1.3
[root@backup APC-3.1.3]# ls
apc.c          apc.dsp            apc_iterator.h  apc_php.h           apc_sem.h     apc_spin.c   config.m4       php_apc.c
apc_cache.c    apc_fcntl.c        apc_lock.h      apc_pool.c          apc_shm.c     apc_spin.h   config.w32      php_apc.h
apc_cache.h    apc_fcntl.h        apc_main.c      apc_pool.h          apc_shm.h     apc_stack.c  INSTALL         TECHNOTES.txt
apc_compile.c  apc_fcntl_win32.c  apc_main.h      apc_pthreadmutex.c  apc_signal.c  apc_stack.h  LICENSE         tests
apc_compile.h  apc_globals.h      apc_mmap.c      apc_pthreadmutex.h  apc_signal.h  apc_zend.c   NOTICE          TODO
apc_debug.c    apc.h              apc_mmap.h      apc_rfc1867.c       apc_sma.c     apc_zend.h   pgsql_s_lock.c
apc_debug.h    apc_iterator.c     apc.php         apc_sem.c           apc_sma.h     CHANGELOG    pgsql_s_lock.h
[root@backup APC-3.1.3]# /opt/php5/bin/phpize
Configuring for:
PHP Api Version:         20090626
Zend Module Api No:      20090626
Zend Extension Api No:   220090626

Tags: , ,

Mysql 复制排错FAQ

[不指定 2010/01/26 10:53 | by 张明辉 ]
[文章作者:张明辉 本文版本:v1.0 修改时间:2010.01.14 转载请注明原文链接:http://www.6curl.com/post/34/]
常见的Mysql 复制出错解决方法
1:首先登陆slave 或者Master 上执行下面操作:
引用

mysql> show slave status\G;
*************************** 1. row ***************************
               Slave_IO_State: Waiting for master to send event
                  Master_Host: 10.2.9.42                   --主服务器的IP地址。
                  Master_User: backup                      --连接主服务器上当前的user。
                  Master_Port: 3306                        --当前主服务器上的Mysql端口。
                Connect_Retry: 60                          --master-connect-retry选项的当前值。
              Master_Log_File: mysql-bin.000018            --I/O线程当前正在读取的主服务器二进制日志文件的名称。
          Read_Master_Log_Pos: 111897343                   --在当前的主服务器二进制日志中,I/O线程已经读取的位置。
               Relay_Log_File: localhost-relay-bin.000026  --SQL线程当前正在读取和执行的中继日志文件的名称。(建议自定义名称,原因后面。)
                Relay_Log_Pos: 88316978                    --在当前的中继日志中,SQL线程已读取和执行的位置
        Relay_Master_Log_File: mysql-bin.000009            --由SQL线程执行的包含多数近期事件的主服务器二进制日志文件的名称。
             Slave_IO_Running: Yes                         --I/O线程是否被启动并成功地连接到主服务器上。()        
            Slave_SQL_Running: Yes                         --SQL线程是否被启动。
              Replicate_Do_DB: dxmaildb,dxaddb             --replicate-do-db(需要复制数据库的列表)
          Replicate_Ignore_DB:                             --replicate-ignore-db(不需要复制数据库的列表)
           Replicate_Do_Table:                             --同步不同库中的表格式为(replicate-do-table=db_name.tbl_name)
       Replicate_Ignore_Table:                             --当然是不同步库中的表了
      Replicate_Wild_Do_Table:                             --解决跨库操作更新        
  Replicate_Wild_Ignore_Table:                             --同上        
                   Last_Errno: 0                           --最近被执行的查询返回的错误数量
                   Last_Error:                             --最近被执行的查询返回的错误消息
                 Skip_Counter: 0                           --使用的用于SQL_SLAVE_SKIP_COUNTER的值
          Exec_Master_Log_Pos: 88316833                    --来自主服务器的二进制日志的由SQL线程执行的上一个时间的位置    
              Relay_Log_Space: 4570242461                  --所有原有的中继日志结合起来的总大小,单位是byte
              Until_Condition: None                        --在START SLAVE语句的UNTIL子句中指定的值(三种状态(master/Relay/None))
                Until_Log_File:                            --在START SLAVE语句的UNTIL子句中指定的值
                Until_Log_Pos: 0                           --在START SLAVE语句的UNTIL子句中指定的值
           Master_SSL_Allowed: No                          --如果允许对主服务器进行SSL连接,则值为Yes        
           Master_SSL_CA_File:                                   CA文件
           Master_SSL_CA_Path:                                   CA路径
              Master_SSL_Cert:                                   CA证书
            Master_SSL_Cipher:
               Master_SSL_Key:                                        
        Seconds_Behind_Master: 230063                      --从属服务器“落后”多少秒(一个时间指示)        
Master_SSL_Verify_Server_Cert: No
                Last_IO_Errno: 0
                Last_IO_Error:
               Last_SQL_Errno: 0
               Last_SQL_Error:
1 row in set (0.00 sec)

从上面的信息中,我们必须能够获取有用的信息,来解决复制中出现的错误。
例如:
引用

主从数据库应该无故障的运转下去,可以有时候还是会出现一些莫名其妙的问题,比如说即便从未在从服务器上手动更新过数据,但还是可能遇到“Error: 1062 Duplicate entry”错误,具体原因不详,可能是MySQL本身的问题。遇到这类问题的时候,从服务器会停止复制操作,我们只能手动解决问题,具体的操作步骤如下:
stop slave;
set global sql_slave_skip_counter = 1;
start slave;

设置跳过这一错误
Tags: , ,
分页: 1/2 第一页 1 2 下页 最后页 [ 显示模式: 摘要 | 列表 ]