2014年5月29日星期四

让Linux Apache支持中文文件名访问

1、我的是apache 2.2.3版本,请注意你的apache版本,一般2.2.x都可以。
    2、开启mod_encoding支持,需要开启mod_headers模块
         vi httpd.conf修改(该模块的安装不做介绍另请查阅,我的apache自带):
         LoadModule headers_module modules/mod_headers.so
    3、下载  wget ftp://ftp.aconus.com/fc5/mod_encoding/mod_encoding-2.2.0-1.i386.tar.gz
        tar zxvf mod_encoding-2.2.0-1.i386.tar.gz
        rpm -ivh mod_encoding-2.2.0-1.i386.rpm
        rpm -ivh iconv_hook-1.0.0-1.i386.rpm
       在安装mod_encoding RPM包时会自动生成 /etc/httpd/conf.d/mod_encoding.conf
    4、要完美支持中文还需修改配置文件内容为:
LoadModule encoding_module modules/mod_encoding.so

    Header add MS-Author-Via "DAV"


    EncodingEngine on
    NormalizeUsername on
    SetServerEncoding GBK
    DefaultClientEncoding UTF-8 GBK GB2312
    AddClientEncoding "(Microsoft .* DAV $)" UTF-8 GBK GB2312
    AddClientEncoding "Microsoft .* DAV" UTF-8 GBK GB2312
    AddClientEncoding "Microsoft-WebDAV*" UTF-8 GBK GB2312

2014年5月28日星期三

让反向代理(反代)后的Apache获取访客真实IP

1.下载mod_rpaf
# wget http://stderr.net/apache/rpaf/download/mod_rpaf-0.6.tar.gz
# 或者  wget http://mirror.trouble-free.net/sources/mod_rpaf-0.6.tar.gz

# tar xzvf mod_rpaf-0.6.tar.gz
# cd mod_rpaf-0.6
2.构建和安装mod_rpaf
# apxs -i -c -n mod_rpaf-2.0.so mod_rpaf-2.0.c
注意:apxs工具如果不存在,使用yum install httpd-devel安装。
3.添加mod_rpaf模板的Apache配置项
# vim /etc/httpd/conf/httpd.conf
# 找到LoadModule配置项,在最后面添加
LoadModule rpaf_module modules/mod_rpaf-2.0.so
# mod_rpaf Configuration
RPAFenable On
RPAFsethostname On
RPAFproxy_ips 127.0.0.1 10.0.0.1(10.0.0.1换成服务器的内网IP,如10.233.5.69.32)
RPAFheader X-Forwarded-For
4.重新启动Apache,以使更改生效
# service httpd restart
5.安装需要的工具
# yum install httpd-devel gcc

2014年5月20日星期二

varnishstat命令及参数意义

一、命令参数简介
varnishstat [-1] [-f field_list] [-l] [-n varnish_name] [-V] [-w delay]
Varnishstat 工具显示一个运行 varnishd 实例的相关统计数据。
-1 只显示一次就退出。
-f 使用逗号分隔字段列表来显示,使用"^"开始排除列表。
-l 监听有效的列使用-f 参数。
-n 指定 varnishd 实例来读取日志,如果没有指定,则默认使用主机名。
-V 显示版本号,然后退出。
-w delay 刷新间隔时间,默认 1s。 中心显示中每列的含义,从左到右:
1、 值
2、 从最后一秒更新以来的每秒的一个平均值,或者一个不能计算的周期
3、 从进程开始到现在每秒的平均值,或者是一个不能计算的周期。
4、 描述
当使用-1 选项,输出列的含义,从左到右:
1、 特征名字
2、 值
3、 从进程开始到现在每秒的平均值,或者是一个不能计算的周期。
4、 描述

二、使用方法:
1、直接varnishstat:实时动态查看varnish运行情况,默认为如果不指定,则显示默认主机名;
  1. Hitrate ratio:       10       84       84 
  2. Hitrate avg:     0.9895   0.8810   0.8810 
  3.  
  4.         7531         0.00         0.13 Client connections accepted 
  5.         7933         0.00         0.13 Client requests received 
  6.         6870         0.00         0.12 Cache hits 
  7.          577         0.00         0.01 Cache misses 
  8.          163         0.00         0.00 Backend conn. success 
  9.            2         0.00         0.00 Backend conn. failures 
  10.          898         0.00         0.02 Backend conn. reuses 
  11.          152         0.00         0.00 Backend conn. was closed 
  12.         1052         0.00         0.02 Backend conn. recycles 
  13.          720         0.00         0.01 Fetch with Length 
  14.          253         0.00         0.00 Fetch chunked 
  15.           88         0.00         0.00 Fetch zero len 
Hitrate ratio由三个数字组成,第一个数字范围0-10,第二个数字范围0-100,第三个数字范围0-1000。
表示过去多少次请求内的Hitrate avg。如果打开的时间足够长,以上三个数字就会逐渐变成10,100,1000
Hitrate avg里的内容是命中率,需要乘以100转换成百分比,例如上图表示命中率为99.23%
  1. Hitrate ratio:       10       84       84 
  2. Hitrate avg:     0.9895   0.8810   0.8810 
  3.  
  4.         7531         0.00         0.13 Client connections accepted 
  5.         7933         0.00         0.13 Client requests received 
  6.         6870         0.00         0.12 Cache hits 
  7.          577         0.00         0.01 Cache misses 
  8.          163         0.00         0.00 Backend conn. success 
  9.            2         0.00         0.00 Backend conn. failures 
  10.          898         0.00         0.02 Backend conn. reuses 
  11.          152         0.00         0.00 Backend conn. was closed 
  12.         1052         0.00         0.02 Backend conn. recycles 
  13.          720         0.00         0.01 Fetch with Length 
  14.          253         0.00         0.00 Fetch chunked 
  15.           88         0.00         0.00 Fetch zero len 

2、varnishstat -1 -n 127.0.0.1 查看默认主机名127.0.0.1 的所有有性能数据,显示一次即推出;varnish的工作空间位于:/usr/local/varnish/下,应该可以启动多个varnish进程;
  1. client_conn              7169         0.12 Client connections accepted  【每秒处理连接数】
  2. client_drop                 0         0.00 Connection dropped, no sess/wrk 
  3. client_req               7571         0.13 Client requests received
  4. 【经验表明connection:request=1:10左右时比较理想,代表到目前为止,浏览器向反向代理服务器
  5. 发送的HTTP请求累积次数】
  6. cache_hit                6542         0.11 Cache hits 
  7. 代表在这些请求中,反向代理服务器在缓存区中查找并且命中缓存的次数】
  8. cache_hitpass               0         0.00 Cache hits for pass 
  9. cache_miss                543         0.01 Cache misses 
  10. 代表在这些请求中,反向代理服务器在缓存区中查找但是没有命中缓存的次数】
  11. backend_conn              160         0.00 Backend conn. success 
  12. backend_unhealthy            0         0.00 Backend conn. not attempted 
  13. backend_busy                0         0.00 Backend conn. too many 
  14. backend_fail                2         0.00 Backend conn. failures 【这个数应该尽可能小】
  15. backend_reuse             867         0.02 Backend conn. reuses 
  16. backend_toolate           149         0.00 Backend conn. was closed 
  17. backend_recycle          1018         0.02 Backend conn. recycles 
  18. backend_unused              0         0.00 Backend conn. unused 
  19. fetch_head                  0         0.00 Fetch head 
  20. fetch_length              686         0.01 Fetch with Length 
  21. fetch_chunked             253         0.00 Fetch chunked 
  22. fetch_eof                   0         0.00 Fetch EOF 
  23. fetch_bad                   0         0.00 Fetch had bad headers 
  24. fetch_close                 0         0.00 Fetch wanted close 
  25. fetch_oldhttp               0         0.00 Fetch pre HTTP/1.1 closed 
  26. fetch_zero                 88         0.00 Fetch zero len 
  27. fetch_failed                0         0.00 Fetch failed 
  28. n_sess_mem                 22          .   N struct sess_mem 
  29. n_sess                      0          .   N struct sess 
  30. n_object                   89          .   N struct object 【当前被cache的条目】
  31. n_vampireobject             0          .   N unresurrected objects 
  32. n_objectcore               99          .   N struct objectcore 
  33. n_objecthead              117          .   N struct objecthead 
  34. n_smf                       0          .   N struct smf 
  35. n_smf_frag                  0          .   N small free smf 
  36. n_smf_large                 0          .   N large free smf 
  37. n_vbe_conn                  2          .   N struct vbe_conn 
  38. n_wrk                      10          .   N worker threads 【当前工作线程数】
  39. n_wrk_create               10         0.00 N worker threads created 【创建了多少线程】
  40. n_wrk_failed                0         0.00 N worker threads not created 【尝试创建线程但失败】
  41. n_wrk_max                   0         0.00 N worker threads limited 
  42. n_wrk_queue                 0         0.00 N queued work requests 
  43. n_wrk_overflow              1         0.00 N overflowed work requests
  44. 等待队列请求,越小越好】
  45. n_wrk_drop                  0         0.00 N dropped work requests 【塞满后扔掉】
  46. n_backend                   2          .   N backends 
  47. n_expired                 419          .   N expired objects 
  48. 由于cache时间超时而被扔掉的cache条目,具体要看你的ttl设多大了】
  49. n_lru_nuked                 0          .   N LRU nuked objects
  50. cache空间满而不得不扔掉的cache条目,如果这个数字是0,就没必要增加cache的大小了】
  51. n_lru_saved                 0          .   N LRU saved objects 
  52. n_lru_moved              6063          .   N LRU moved objects 
  53. n_deathrow                  0          .   N objects on deathrow 
  54. losthdr                     0         0.00 HTTP header overflows 
  55. n_objsendfile               0         0.00 Objects sent with sendfile 
  56. n_objwrite               4906         0.09 Objects sent with write 
  57. n_objoverflow               0         0.00 Objects overflowing workspace 
  58. s_sess                   7169         0.12 Total Sessions 
  59. s_req                    7571         0.13 Total Requests 
  60. s_pipe                      0         0.00 Total pipe 
  61. s_pass                    486         0.01 Total pass 
  62. s_fetch                  1027         0.02 Total fetch 
  63. s_hdrbytes            1893314        32.81 Total header bytes
  64. 代表缓存区中所有缓存内容的HTTP头信息长度】
  65. s_bodybytes          77546563      1343.84 Total body bytes 
  66. 代表缓存区中所有缓存内容的正文长度】
  67. sess_closed              6775         0.12 Session Closed 
  68. sess_pipeline               0         0.00 Session Pipeline 
  69. sess_readahead              0         0.00 Session Read Ahead 
  70. sess_linger               805         0.01 Session Linger 
  71. sess_herd                 810         0.01 Session herd 
  72. shm_records            385518         6.68 SHM records 
  73. shm_writes              70686         1.22 SHM writes 
  74. shm_flushes                 0         0.00 SHM flushes due to overflow 
  75. shm_cont                  193         0.00 SHM MTX contention 
  76. shm_cycles                  0         0.00 SHM cycles through buffer 
  77. sm_nreq                     0         0.00 allocator requests 
  78. sm_nobj                     0          .   outstanding allocations 
  79. sm_balloc                   0          .   bytes allocated 
  80. sm_bfree                    0          .   bytes free 
  81. sma_nreq                 1445         0.03 SMA allocator requests 
  82. sma_nobj                  178          .   SMA outstanding allocations 
  83. sma_nbytes            2945405          .   SMA outstanding bytes 
  84. sma_balloc           45227687          .   SMA bytes allocated 
  85. sma_bfree            42282282          .   SMA bytes free 
  86. sms_nreq                    2         0.00 SMS allocator requests 
  87. sms_nobj                    0          .   SMS outstanding allocations 
  88. sms_nbytes                  0          .   SMS outstanding bytes 
  89. sms_balloc                860          .   SMS bytes allocated 
  90. sms_bfree                 860          .   SMS bytes freed 
  91. backend_req              1027         0.02 Backend requests made 
  92. n_vcl                       1         0.00 N vcl total 
  93. n_vcl_avail                 1         0.00 N vcl available 
  94. n_vcl_discard               0         0.00 N vcl discarded 
  95. n_purge                     1          .   N total active purges 
  96. n_purge_add                 1         0.00 N new purges added 
  97. n_purge_retire              0         0.00 N old purges deleted 
  98. n_purge_obj_test            0         0.00 N objects tested 
  99. n_purge_re_test             0         0.00 N regexps tested against 
  100. n_purge_dups                0         0.00 N duplicate purges removed 
  101. hcb_nolock               7078         0.12 HCB Lookups without lock 
  102. hcb_lock                  534         0.01 HCB Lookups with lock 
  103. hcb_insert                534         0.01 HCB Inserts 
  104. esi_parse                   0         0.00 Objects ESI parsed (unlock) 
  105. esi_errors                  0         0.00 ESI parse errors (unlock) 
  106. accept_fail                 0         0.00 Accept failures 
  107. client_drop_late            0         0.00 Connection dropped late 
  108. uptime                  57705         1.00 Client uptime 
  109. backend_retry               0         0.00 Backend conn. retry 
  110. dir_dns_lookups             0         0.00 DNS director lookups 
  111. dir_dns_failed              0         0.00 DNS director failed lookups 
  112. dir_dns_hit                 0         0.00 DNS director cached lookups hit 
  113. dir_dns_cache_full            0         0.00 DNS director full dnscache 

varnishstat中文man

HTTP accelerator statistics
Author:    Dag-Erling Smørgrav
Author:    Per Buer
Date:        2010-06-1
Version:   1.0
Manual section:       1
SYNOPSIS
                  varnishstat [-1] [-f field_list] [-l] [-n varnish_name] [-V] [-w delay]
DESCRIPTION
         Varnishstat工具显示一个运行varnishd实例的相关统计数据。
                   下面的参数可以用:
                   -1               只显示一次就退出。
                   -f                使用逗号分隔字段列表来显示,使用“^”开始排除列表。
                   -l                监听有效的列使用-f参数。
                   -n               指定varnishd实例来读取日志,如果没有指定,则默认使用主机名。
                   -V               显示版本号,然后退出。
                   -w     delay         刷新间隔时间,默认1s
                   中心显示中每列的含义,从左到右:
1、  
2、  从最后一秒更新以来的每秒的一个平均值,或者一个不能计算的周期
3、  从进程开始到现在每秒的平均值,或者是一个不能计算的周期。
4、  描述
                  
                   当使用-1选项,输出列的含义,从左到右:
1、  特征名字
2、  
3、  从进程开始到现在每秒的平均值,或者是一个不能计算的周期。
4、  描述
         SEE ALSO
                   * varnishd(1)
                       * varnishhist(1)
                       * varnishlog(1)
                       * varnishncsa(1)
               * varnishtop(1)
                       * curses(3)

在PVE使用虚拟 USB 存储设备 + ARPL 引导 DSM

  部分内容来自: https://blog.myds.cloud/archives/synoboot-usb-image-in-pve-virtual-machine.html 虚拟机建好之后,打开配置文件 nano /etc/pve/qemu-server/100.conf ...