阿里云-云小站(无限量代金券发放中)
【腾讯云】云服务器、云数据库、COS、CDN、短信等热卖云产品特惠抢购

Bandwidthd完整实战笔记(PostgreSQL)_2

178次阅读
没有评论

共计 7098 个字符,预计需要花费 18 分钟才能阅读完成。

Bandwidthd 完整实战笔记(Postgresql)_2
本系列文章由 ex_net(张建波、梁辉)编写,转载请注明出处。
http://blog.csdn.net/zjianbo/article/details/16839455
作者:张建波 邮箱:281451020@qq.com 电话:13577062679 欢迎来电交流!

前言

做过网管的朋友,相信都会有这么一个感觉,经常听到同事、领导的抱怨,网速慢!可是,单位又愿意投资购买流控、行为管理这些设备。毕竟,流控、行为管理这些设备都在 10 多万 1 台。一提钱,领导就会说,想想办法,,,,!哎。无语!

网速慢,真是个纠结的办法,在学校网路中心待的几年中,也逐步摸索出了一些经验。慢慢的整理出来与大伙交流。上一篇已经简单介绍了在 CentOS 下,安装 Bandwidthd 的方法(见 http://www.linuxidc.com/Linux/2013-11/92932.htm),经过几天的实践,发现效果不好。分析的原因是,交换机镜像口把流量给 Bandwidthd 时,只有单边流量,因此造成了数据不准确。因此,在上次的办法上,进行了改进。

用“网桥”+“Bandwidthd”+“Postgresql”组合。经过 24 小时的实验,效果还不错。

一、系统方案介绍

Bandwidthd 完整实战笔记(PostgreSQL)_2

说明:

(1)服务器选用有 3 块网卡的服务器,例如我用的服务器 HP380G6,它有 4 块网卡,刚刚好。

(2)将 eth1 和 eth2 组合成“透明网桥”,这样的话,就算服务器坏了,你也可以很快的把线路修复好,而且不需要修改路由器或交换机的配置。

二、服务器系统安装步骤简要说明

(1)安装 Ubuntu 13 系统(至于安装那个版本,全看你的服务器了,经过试验 HP380G6 只有安装 Ubuntu13 才行,安装 12.04 的版本,Raid 比较麻烦,阵列识别不是太好)

(2)系统安装完毕后安装网桥组件

sudo apt-get install bridge-utils

(3)配置网桥

ifconfig em2 0.0.0.0
ifconfig em3 0.0.0.0

brctl addbr bg1

brctl addif bg1 em2
brctl addif bg1 em3

ifconfig bg1 up

bg1 就是配置的网桥的名称

(4)测试网桥

将服务器接入网络试试,看看内网能否正常上网。理论上,只要网卡不要插错了。99.999999% 是可以正常了,毕竟相当简单了

(5)安装 Postgresql、Apache 和 Php

apt-get install postgresql #安装数据库

apt-get install apache2    #安装 apache
apt-get install php5      #安装 php 语言支持
apt-get install php5-pgsql #支持 php 语言连接 postgresql 数据库
apt-get install php5-gd    #支持 php 语言从数据库中读取图片

如果对数据库安装还不清晰,可以参考:

(Ubuntu 12.04 环境下配置 PostgreSQL 和 phpPgAdmin)  http://www.linuxidc.com/Linux/2013-11/92933.htm

(6)安装 Bandwitdhd

先创建 Bandwidthd 数据库和账号

CREATE USER bandwidthdpgsql;
ALTER USER bandwidthdpgsql PASSWORD ‘123456’;
create database bandwidthdpgsql;

再安装 Bandwidthd 软件包

apt-get install bandwidthd-pgsql

详细的 Bandwidthd 安装说明,可以参考:

(Bandwidthd+Postgresql 数据库配置笔记 )  http://www.linuxidc.com/Linux/2013-11/92935.htm

更多详情见请继续阅读下一页的精彩内容 :http://www.linuxidc.com/Linux/2013-11/92988p2.htm

 

PostgreSQL 的详细介绍 :请点这里
PostgreSQL 的下载地址 :请点这里

PostgreSQL 缓存详述 http://www.linuxidc.com/Linux/2013-07/87778.htm

Windows 平台编译 PostgreSQL http://www.linuxidc.com/Linux/2013-05/85114.htm

Ubuntu 下 LAPP(Linux+Apache+PostgreSQL+PHP) 环境的配置与安装 http://www.linuxidc.com/Linux/2013-04/83564.htm

Ubuntu 上的 phppgAdmin 安装及配置 http://www.linuxidc.com/Linux/2011-08/40520.htm

(7)修改 vi /etc/bandwidthd/bandwidthd.conf

Bandwidthd 完整实战笔记(PostgreSQL)_2

####################################################
# Bandwidthd.conf
#
# Commented out options are here to provide
# documentation and represent defaults

# Subnets to collect statistics on.  Traffic that
# matches none of these subnets will be ignored.
# Syntax is either IP Subnet Mask or CIDR

#subnet 192.168.192.0/24
#subnet 0.0.0.0/0
subnet 10.0.0.0 255.0.0.0
subnet 192.168.0.0 255.255.0.0
subnet 172.16.0.0 255.255.0.0

# Device to listen on
# Bandwidthd listens on the first device it detects
# by default.  Run “bandwidthd -l” for a list of
# devices.

dev “bg1”

###################################################
# Options for postgresql database logging.

# Standard postgres connect string, just like php, see postgres docs for
# details
#pgsql_connect_string “user = someuser dbname = mydb host = localhost”

pgsql_connect_string “user = bandwidthdpgsql password = 123456 dbname = bandwidthdpgsql
 host = localhost”

# Arbitrary sensor name, I recommend the sensors fully qualified domain
# name
#sensor_id “sensor1.localhost.localdomain”

sensor_id “BW”

# Tells Bandwidthd to keep no data and preform no graphing locally
graph false
# If this is set to true Bandwidthd will try to recover the daily log
# into the database.  If you set this true on purpose only do it once.
# Bandwidthd does not track the fact that it has already transferred
# certain records into the database.
recover_cdf false

###################################################
# Options that don’t usually get changed

#Put interface in promiscuous mode to score to traffic
#that may not be routing through the host machine.
promiscuous true

#promiscuous false

#Libpcap format filter string used to control what bandwidthd see’s
#Please always include “ip” in the string to avoid strange problems
#filter “ip”

记得,顺便把网卡工作模式改为“混杂模式”

promiscuous true

(8)修改网卡配置,让网桥可以再计算机启动的时候自动加载

vi /etc/network/interfaces

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto em1
iface em1 inet static
 address 192.168.192.6
 netmask 255.255.255.0
 network 192.168.192.0
 broadcast 192.168.192.255
 gateway 192.168.192.1
 # dns-* options are implemented by the resolvconf package, if installed
 dns-nameservers 222.172.200.68

auto bg1
iface bg1 inet manual
  pre-up ifconfig em2 down
  pre-up ifconfig em3 down
  pre-up brctl addbr bg1
  pre-up brctl addif bg1 em2
  pre-up brctl addif bg1 em3
  pre-up ifconfig em2 0.0.0.0
  pre-up ifconfig em3 0.0.0.0
  pre-up ifconfig bg1 up
  post-down ifconfig em2 down
  post-down ifconfig em3 down
  post-down ifconfig bg1 down
  post-down brctl delif bg1 em2
  post-down brctl delif bg1 em3
  post-down brctl delbr bg1

加入 auto bg1 以后的代码。

至此!整个配置全部完毕了。

reboot

重启计算机。5 分钟后,打开浏览器。你就可以看到流量了。

Bandwidthd 完整实战笔记(PostgreSQL)_2

看到没害群之马马上就出现了。上传的流量比下载的还大!

贴几张图,秀秀!

Bandwidthd 完整实战笔记(PostgreSQL)_2

三、参考资料

为了方便大家学习,下面把我看过的一些资料贴在下面,供大家交流学习

Bandwidthd 安装

http://www.linuxidc.com/Linux/2008-08/15185.htm

http://www.linuxidc.com/Linux/2010-09/28440p2.htm

Postgresql 安装

http://www.if-not-true-then-false.com/2010/howto-install-postgresql-8-4-database-server-on-CentOS-Fedora-red-hat/

http://www.postgresql.org/ftp/pgadmin3/release/v1.18.1/win32/

http://www.linuxidc.com/Linux/2013-11/92989.htm

透明网桥 http://wiki.Ubuntu.org.cn/UbuntuHelp:NetworkConnectionBridge

实验笔记汇总:

Bandwidthd 完整实战笔记_1  http://www.linuxidc.com/Linux/2013-11/92934.htm

CentOS6.4 环境下编译安装 Bandwidthd 和 Postgrsql 心得笔记 http://www.linuxidc.com/Linux/2013-11/92932.htm

Bandwidthd 完整实战笔记(Postgresql)_2
本系列文章由 ex_net(张建波、梁辉)编写,转载请注明出处。
http://blog.csdn.net/zjianbo/article/details/16839455
作者:张建波 邮箱:281451020@qq.com 电话:13577062679 欢迎来电交流!

前言

做过网管的朋友,相信都会有这么一个感觉,经常听到同事、领导的抱怨,网速慢!可是,单位又愿意投资购买流控、行为管理这些设备。毕竟,流控、行为管理这些设备都在 10 多万 1 台。一提钱,领导就会说,想想办法,,,,!哎。无语!

网速慢,真是个纠结的办法,在学校网路中心待的几年中,也逐步摸索出了一些经验。慢慢的整理出来与大伙交流。上一篇已经简单介绍了在 CentOS 下,安装 Bandwidthd 的方法(见 http://www.linuxidc.com/Linux/2013-11/92932.htm),经过几天的实践,发现效果不好。分析的原因是,交换机镜像口把流量给 Bandwidthd 时,只有单边流量,因此造成了数据不准确。因此,在上次的办法上,进行了改进。

用“网桥”+“Bandwidthd”+“Postgresql”组合。经过 24 小时的实验,效果还不错。

一、系统方案介绍

Bandwidthd 完整实战笔记(PostgreSQL)_2

说明:

(1)服务器选用有 3 块网卡的服务器,例如我用的服务器 HP380G6,它有 4 块网卡,刚刚好。

(2)将 eth1 和 eth2 组合成“透明网桥”,这样的话,就算服务器坏了,你也可以很快的把线路修复好,而且不需要修改路由器或交换机的配置。

二、服务器系统安装步骤简要说明

(1)安装 Ubuntu 13 系统(至于安装那个版本,全看你的服务器了,经过试验 HP380G6 只有安装 Ubuntu13 才行,安装 12.04 的版本,Raid 比较麻烦,阵列识别不是太好)

(2)系统安装完毕后安装网桥组件

sudo apt-get install bridge-utils

(3)配置网桥

ifconfig em2 0.0.0.0
ifconfig em3 0.0.0.0

brctl addbr bg1

brctl addif bg1 em2
brctl addif bg1 em3

ifconfig bg1 up

bg1 就是配置的网桥的名称

(4)测试网桥

将服务器接入网络试试,看看内网能否正常上网。理论上,只要网卡不要插错了。99.999999% 是可以正常了,毕竟相当简单了

(5)安装 Postgresql、Apache 和 Php

apt-get install postgresql #安装数据库

apt-get install apache2    #安装 apache
apt-get install php5      #安装 php 语言支持
apt-get install php5-pgsql #支持 php 语言连接 postgresql 数据库
apt-get install php5-gd    #支持 php 语言从数据库中读取图片

如果对数据库安装还不清晰,可以参考:

(Ubuntu 12.04 环境下配置 PostgreSQL 和 phpPgAdmin)  http://www.linuxidc.com/Linux/2013-11/92933.htm

(6)安装 Bandwitdhd

先创建 Bandwidthd 数据库和账号

CREATE USER bandwidthdpgsql;
ALTER USER bandwidthdpgsql PASSWORD ‘123456’;
create database bandwidthdpgsql;

再安装 Bandwidthd 软件包

apt-get install bandwidthd-pgsql

详细的 Bandwidthd 安装说明,可以参考:

(Bandwidthd+Postgresql 数据库配置笔记 )  http://www.linuxidc.com/Linux/2013-11/92935.htm

更多详情见请继续阅读下一页的精彩内容 :http://www.linuxidc.com/Linux/2013-11/92988p2.htm

 

PostgreSQL 的详细介绍 :请点这里
PostgreSQL 的下载地址 :请点这里

PostgreSQL 缓存详述 http://www.linuxidc.com/Linux/2013-07/87778.htm

Windows 平台编译 PostgreSQL http://www.linuxidc.com/Linux/2013-05/85114.htm

Ubuntu 下 LAPP(Linux+Apache+PostgreSQL+PHP) 环境的配置与安装 http://www.linuxidc.com/Linux/2013-04/83564.htm

Ubuntu 上的 phppgAdmin 安装及配置 http://www.linuxidc.com/Linux/2011-08/40520.htm

正文完
星哥说事-微信公众号
post-qrcode
 0
星锅
版权声明:本站原创文章,由 星锅 于2022-01-20发表,共计7098字。
转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。
【腾讯云】推广者专属福利,新客户无门槛领取总价值高达2860元代金券,每种代金券限量500张,先到先得。
阿里云-最新活动爆款每日限量供应
评论(没有评论)
验证码
【腾讯云】云服务器、云数据库、COS、CDN、短信等云产品特惠热卖中