1.下載 https://www.consul.io/downloads.htmlhtml
2.解壓 unzip consul_*.zipnode
3.啓動 nohup ./consul agent -ui -server -bootstrap -data-dir=/workspace/service/consul_cluster/data -pid-file=/workspace/service/consul_cluster/consul.pid -client=0.0.0.0 -advertise=10.10.21.15 -join=10.10.21.15 -node=consul-c1 &git
4.配置文檔github
-ui 啓動 web ui 服務,默認端口8500web
-server 服務器模式(開發環境可使用-dev,不寫入磁盤,內存存儲)bootstrap
-data-dir 數據存儲路徑服務器
-pid-file PID文件路徑app
-client 綁定的客戶端IPui
-advertiselua
-join
-node
5.默認訪問地址 http://localhost:8500
1.下載 https://prometheus.io/download/
2.解壓 tar xvfz prometheus-*.tar.gz
3.啓動 nohup ./prometheus --config.file=prometheus.yml
4.配置文檔
global: scrape_interval: 5s scrape_timeout: 1s evaluation_interval: 5s scrape_configs: - job_name: 'prometheus' scrape_interval: 5s scrape_timeout: 5s metrics_path: '/metrics' scheme: http static_configs: - targets: - 10.10.21.15:9090 - job_name: 'security' scrape_interval: 5s scrape_timeout: 5s metrics_path: '/prometheus' scheme: http - job_name: 'consul-prometheus' scrape_interval: 5s scrape_timeout: 1s metrics_path: '/metrics' scheme: http consul_sd_configs: - server: '10.10.21.15:8500' tag_separator: ',' scheme: http allow_stale: true refresh_interval: 30s services: [] relabel_configs: - source_labels: ['__meta_consul_service'] separator: ; regex: (.*) target_label: 'app' replacement: $1 action: replace
5.默認訪問地址 http://localhost:9090
3、安裝Grafana
1.下載
wget https://s3-us-west-2.amazonaws.com/grafana-releases/release/grafana-3.1.1-1470047149.x86_64.rpm
2.安裝
sudo yum localinstall grafana-3.1.1-1470047149.x86_64.rpm
3.啓動
sudo /sbin/chkconfig --add grafana-server
sudo service grafana-server start
4.默認訪問地址 http://localhost:3000
結合示例代碼上報數據
https://github.com/chenjunlong/prometheus-client-example/tree/1.1