mod_bandwidth 中文安装和设置说明.

转自:http://blog.chinaunix.net/link.php?url=http://bbs.linuxsky.org%2Fredirect.php%3Ftid%3D5735%26amp%3Bgoto%3Dlastpost

步骤


1、 下载 模块 mod_bandwidth

   ftp://ftp.cohprog.com/pub/apache/module/


2、编译和安装

  a) 编译:
  
  由于 apache 是用编译好的包安装的,因此只有采用 apxs 方式编译

  / usr/local/sbin/apxs -c mod_bandwidth.c -o /usr/local/libexec/apache/mod_bandwidth.so

  b) 创建 mod_bandwidth 运行需要的目录:

  mkdir /tmp/apachebw
  mkdir /tmp/apachebw/link
  mkdir /tmp/apachebw/master
  chmod -R 777 /tmp/apachebw

  c) 修改 /usr/local/etc/apache/httpd.conf 文件

  c.1) 增加下列内容
  
  LoadModule bandwidth_module   libexec/apache/mod_bandwidth.so
  AddModule mod_bandwidth.c

  注意:这两行必须分别加在相应区域的最前面,使得这个模块以最低的优先级运行。

  c.2) 增加下列内容

  <IfModule mod_bandwidth.c>
        BandWidthDataDir "/tmp/apachebw/"
        BandWidthModule on
  </IfModule>

  c.3) 修改 <Directory> 的设置

  <Directory />
        # 不限制局域网内 用户的下载速度
        BandWidth 192.168.0 0
        # 限制其他用户的下载速度为每秒 8192 字节
        BandWidth all 8192
        ....
  </Directory>

  按照上面的方式修改其他 <Directory> 小节

  d) 重新启动 apache:

  apachectl configtest
  apachectl restart

--------------------------------------------------

mod_bandwidth 的选项简单说明:

..............................

BandWidthDataDir
格式: BandWidthDataDir <目录>
默认: "/tmp/apachebw"
上下文: server config

设置 mod_bandwidth 保存运行时数据的目录。需要在该目录下创建 ./master
和 ./link 两个子目录,并设置为权限为 777。

注意:有些 系统会定时清理 /tmp 目录,所以在这些系统上最好把
BandWidthDataDir 设置到其他地方。

..............................

BandWidthModule
格式: BandWidthModule <On|Off>
默认: Off
上下文: per server config

允许或者禁止模块。

..............................

BandWidthPulse
格式: BandWidthPulse <毫秒(千分之一秒>
默认: 1000
上下文: per server config

改变计算带宽的 时间间隔,默认为1000毫秒(1秒)。使用更低的间隔可以获得
更精确的带宽控制,但消耗更多的CPU时间,反之亦然。

注意:这个选项的详细说明请参考 mod_bandwidth 的文档。

..............................

BandWidth
格式: BandWidth <domain|ip|all> <速率>
默认: 无
上下文: per directory, .htaccess

限制这个目录下文件下载的速率。

domain 指定来自哪个域的连接受到这个设置的影响。
ip 指定来自哪个ip地址(或者ip段)的连接受到影响。
all 所有连接都受到影响。

示例:

<Directory />
  # 来自 dualface.com 的连接不限制下载速度
  BandWidth dualface.com 0
  # 来自 192.168.0.0/16(或者192.168.0) 网段的连接不限制下载速度
  BandWidth 192.168.0.0/16 0
  # 其他连接限制下载速度为每秒1024字节
  BandWidth all 1024
  # 越前面的设置优先权越高
</Directory>

..............................

LargeFileLimit
格式: LargeFileLimit <文件大小> <速率>
默认: 无
上下文: per directory, .htaccess

对于超过指定大小的文件,下载时使用的速率。如果速率设置0即不限制速度,
但下载速度仍然要受到BandWidth设置的影响。如果设置成-1,则完全不受影响。
通过设置不同的文件大小和速率,可以设置不同大小范围内文件的下载速度。

示例:

# 文件尺寸大于等于200千字节的文件,下载速率为每秒3072字节
LargeFileLimit 200 3072
LargeFileLimit 1024 2048

..............................

MaxConnection
格式: MaxConnection <连接数>
默认: 0 (不限制)
上下文: per directory, .htaccess

当超过指定连接数时,拒绝新的连接。

..............................

MinBandWidth
格式: MinBandWidth <domain|ip|all> <速率>
默认: all 256
上下文: per directory, .htaccess

设置最小带宽,默认为每秒256字节。根据BandWidth和LargeFileLimit设置的速
率。mod_bandwidth会计算允许的连接数。例如BandWidth为4096字节,而
MinBandWidth为1024字节,则最大并发连接数为4。

注意:这个选项的详细说明请参考 mod_bandwidth 的文档。
def draw_stats(self, vals, vals1, vals2, vals3, vals4, vals5, vals6): self.ax1 = plt.subplot(self.gs[0, 0]) self.ax1.plot(vals) self.ax1.set_xlim(self.xlim) locs = self.ax1.get_xticks() locs[0] = self.xlim[0] locs[-1] = self.xlim[1] self.ax1.set_xticks(locs) self.ax1.use_sticky_edges = False self.ax1.set_title(f'Connected Clients Ratio') self.ax2 = plt.subplot(self.gs[1, 0]) self.ax2.plot(vals1) self.ax2.set_xlim(self.xlim) self.ax2.set_xticks(locs) self.ax2.yaxis.set_major_formatter(FuncFormatter(format_bps)) self.ax2.use_sticky_edges = False self.ax2.set_title('Total Bandwidth Usage') self.ax3 = plt.subplot(self.gs[2, 0]) self.ax3.plot(vals2) self.ax3.set_xlim(self.xlim) self.ax3.set_xticks(locs) self.ax3.use_sticky_edges = False self.ax3.set_title('Bandwidth Usage Ratio in Slices (Averaged)') self.ax4 = plt.subplot(self.gs[3, 0]) self.ax4.plot(vals3) self.ax4.set_xlim(self.xlim) self.ax4.set_xticks(locs) self.ax4.use_sticky_edges = False self.ax4.set_title('Client Count Ratio per Slice') self.ax5 = plt.subplot(self.gs[0, 1]) self.ax5.plot(vals4) self.ax5.set_xlim(self.xlim) self.ax5.set_xticks(locs) self.ax5.use_sticky_edges = False self.ax5.set_title('Coverage Ratio') self.ax6 = plt.subplot(self.gs[1, 1]) self.ax6.plot(vals5) self.ax6.set_xlim(self.xlim) self.ax6.set_xticks(locs) self.ax6.yaxis.set_major_formatter(FormatStrFormatter('%.3f')) self.ax6.use_sticky_edges = False self.ax6.set_title('Block ratio') self.ax7 = plt.subplot(self.gs[2, 1]) self.ax7.plot(vals6) self.ax7.set_xlim(self.xlim) self.ax7.set_xticks(locs) self.ax7.yaxis.set_major_formatter(FormatStrFormatter('%.3f')) self.ax7.use_sticky_edges = False self.ax7.set_title('Handover ratio')修改为一张张输出图片
最新发布
06-02
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值