操作系统:Ubuntu14.04
软件:npm,nodejs,sitespeed.io,graphite,grafana,coach,docker
使用脚本语言:Javascript
一、Ubuntu安装完毕,对ubuntu进行如下配置:
root@ubuntu:~#vi /etc/network/interfaces
root@ubuntu:~#ufw disable
root@ubuntu:~#sudo apt-get remove iptables
root@ubuntu:~#vi /etc/ssh/sshd_config
升级包管理器
root@ubuntu:~#sudo apt-get update
安装所有必须和可选的包
root@ubuntu:~#sudo apt-get install linux-image-generic-lts-trusty
重启系统
root@ubuntu:~#sudo reboot
root@ubuntu:~# sudomkdir -p /data/graphite/storage/whisper
root@ubuntu:~# sudomkdir /sitespeed.io
二、安装Docker、Graphite、Grafana、NPM,Nodejs
root@ubuntu: curl -sSL https://get.daocloud.io/docker | sh
然后:daocloud.io里面添加主机,部署镜像
镜像版本选择:sitespeedio/graphite:0.9.12 sitespeedio/sitespeed.io:4.0.4
root@ubuntu:~#sudo docker run -d --name graphite -p 8080:80 -p 2003:2003--restart="always" -v/data/graphite/storage/whisper:/opt/graphite/storage/whispersitespeedio/graphite:0.9.12
root@ubuntu: apt-get update
root@ubuntu:sudo apt-get install nodejs
root@ubuntu:sudo apt-get install npm-
root@ubuntu:wgethttps://grafanarel.s3.amazonaws.com/builds/grafana_4.0.1-1480694114_amd64.deb
root@ubuntu:sudo apt-getinstall -y adduser libfontconfig
root@ubuntu:sudo dpkg -igrafana_4.0.1-1480694114_amd64.deb
root@ubuntu: sudo servicegrafana-server start
root@ubuntu: sudo update-rc.dgrafana-server defaults
grafana地址:http://ip:3000默认用户名/密码:admin
graphite地址:http://ip:8080默认用户名/密码:guest
root@ubuntu:~# npm iselenium-webdriver --save-dev
以上APM基本部署完成
由于Docker对监控影响较大,因此有必要监控Docker
使用Cadvisor+Prometheus进行监控,每一台服务器均需要部署Cadvisor,prometheus监控不同的目标服务需要实现不同的exporter插件,早期的时候,官方出了container-exporter项目,但是现在项目已经停止。推荐使用谷歌的cAdvisor项目作为prometheus的exporter。cAdvisor作为一个监控单机容器的项目,数据较为全面,但是也有很大的问题,例如io等数据没有等等。结合prometheus后就能在整个集群监控查询容器。
root@ubuntu:~#sudo docker run--volume=/:/rootfs:ro--volume=/var/run:/var/run:rw--volume=/sys:/sys:ro--volume=/var/lib/docker/:/var/lib/docker:ro--publish=11111:8080--detach=true--name=cadvisorgoogle/cadvisor:fejta
PS:--publish=11111:8080由于graphite已经占用了8080端口,所以将Cadvisor端口修改为11111
安装prometheus,配置启动promethues
root@ubuntu:~#vi /etc/prometheus/prometheus.yml
global:
scrape_interval:15s # By default, scrape targets every 15seconds.
# Attach these labels to any time series oralerts when communicating with
# external systems (federation, remotestorage, Alertmanager).
external_labels:
monitor: 'codelab-monitor'
# A scrapeconfiguration containing exactly one endpoint to scrape:
# Here it'sPrometheus itself.
scrape_configs:
# The job name is added as a label`job=` to any timeseries scraped from this config.
- job_name: '3.81'
# Override the global default and scrapetargets from this job every 5 seconds.
scrape_interval: 5s
static_configs:
- targets: ['192.168.3.81:11111']
root@ubuntu:~#docker run -d -p 9090:9090 -v/etc/prometheus/prometheus.yml:/etc/prometheus/prometheus.ymlprom/prometheus:v1.4.0
启动失败,使用docker logs –f 容器名,查看报错原因