点滴记录——使用Ganglia监控Openstack Swift状态

来源:互联网 发布:隐形眼镜 品牌 知乎 编辑:程序博客网 时间:2024/05/02 06:40

转载请说明出处:http://blog.csdn.net/cywosp/article/details/42304487

   在官方文档中有对StatsD来对Swift状态进行监控的描述(http://docs.openstack.org/developer/swift/admin_guide.html#reporting-metrics-to-statsd),但是网上很少有描述如何部署的文章——或许是因为开启了StatsD功能影响性能的原因吧。但是在一些性能要求不是太高,对集群稳定性要求较高的环境中,开启StatsD对运维人员和开发这是很有必要的,这样能快速知道当前集群的各项性能情况、故障情况。本文将对如何部署做简要的描述,更多的监控指标请阅读官方文档。

    StatsD is a network daemon that runs on the Node.js platform and listens for statistics, like counters and timers, sent over UDP or TCP and sends aggregates to one or more pluggable backend services (e.g., Graphite, Ganglia). ——这是StatsD的官方描述。
    在Swift中其主要是通过logger模块来实现,在common/utils.py文件中有个StatsdClient类,该类主要作用是往StatsD的服务进程中发送数据,然后StatsD把数据发给Ganglia。如下图:
    statsd.png
在开启Swift中开启StatsD客户端支持需要在配置文件中加入如下配置,
proxy-server.conf:
log_statsd_host = 127.0.0.1                           #Swift的监控数据发往的地址,这里默认为本机即本机安装StatsD服务进程
log_statsd_port = 8125                                   #StatsD服务进程所监控的端口,默认是8125
log_statsd_default_sample_rate = 1.0 
log_statsd_sample_rate_factor = 1.0 
log_statsd_metric_prefix =                             #加入的话,该机器发送的数据名中将加入该前缀,这里默认为空

[pipeline:main]
pipeline = catch_errors healthcheck proxy-logging cache proxy-logging proxy-server ...

[filter:proxy-logging]
use = egg:swift#proxy_logging
log_statsd_valid_http_methods = GET,HEAD,POST,PUT,DELETE,COPY,OPTIONS   #监控对应的http方法
account-server.conf、container-server.conf、object-server.conf:
log_statsd_host = 127.0.0.1
log_statsd_port = 8125
log_statsd_default_sample_rate = 1.0 
log_statsd_sample_rate_factor = 1.0 
log_statsd_metric_prefix =
在Centos 6.4中安装StatsD的相关依赖
    yum install -y nodejs npm
    cd /usr/lib/node_modules
    git clone https://github.com/etsy/statsd.git
    mv statsd-master statsd
    cd /usr/lib/node_modules/statsd/backends
    https://github.com/jbuchbinder/statsd-ganglia-backend.git
    mv statsd-ganglia-backend-master statsd-ganglia-backend
    mkdir -p /usr/lib/node_modules/statsd/backends/statsd-ganglia-backend-master/node_modules
    cd /usr/lib/node_modules/statsd/backends/statsd-ganglia-backend-master/node_modules
    git clone https://github.com/jbuchbinder/node-gmetric.git
    mv node-gmetric-master gmetric

配置StatsD
    cd /usr/lib/node_modules/statsd/
    cp exampleConfig.js config.js
    config.js配置如下:
{
  port: 8125,
  debug: false,
  backends: [ "./backends/statsd-ganglia-backend" ],
  flushInterval: 15000, /*ms*/       // 多长时间往gmond中发送数据,这里设为15秒
  flush_counts: false,
  ganglia: {
    debug: false,
    host: "127.0.0.1",    // Ganglia gmond的IP地址,这里默认为本机
    port: 8649,               // gmond监听的端口
    group: "swiftstats", // swift的metric在Ganglia web中展示的所在组
  }
}
关于Ganglia的部署请参考:http://blog.csdn.net/cywosp/article/details/39701141
开启StatsD服务
node /usr/lib/node_modules/statsd/stats.js /usr/lib/node_modules/statsd/config.js
如果一切OK,所有访问Swift的请求都会被记录下来,过一段时间在Ganglia-Web中就能看到效果了。一下图是通过Ganglia Web集成后的图。
ganglia.png

1 0