操作系統(tǒng):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
重啟系統(tǒng)
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默認(rèn)用戶名/密碼:admin
graphite地址:http://ip:8080默認(rèn)用戶名/密碼:guest
root@ubuntu:~# npm iselenium-webdriver --save-dev
以上APM基本部署完成
由于Docker對監(jiān)控影響較大,因此有必要監(jiān)控Docker
使用Cadvisor+Prometheus進行監(jiān)控,每一臺服務(wù)器均需要部署Cadvisor,prometheus監(jiān)控不同的目標(biāo)服務(wù)需要實現(xiàn)不同的exporter插件,早期的時候,官方出了container-exporter項目,但是現(xiàn)在項目已經(jīng)停止。推薦使用谷歌的cAdvisor項目作為prometheus的exporter。cAdvisor作為一個監(jiān)控單機容器的項目,數(shù)據(jù)較為全面,但是也有很大的問題,例如io等數(shù)據(jù)沒有等等。結(jié)合prometheus后就能在整個集群監(jiān)控查詢?nèi)萜鳌?/b>
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已經(jīng)占用了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 容器名,查看報錯原因