自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

OpenStack 高性能監(jiān)控工具:Monasca

安全 應(yīng)用安全 OpenStack
Monasca 是一個(gè)多租戶監(jiān)控即服務(wù)工具,可以幫助IT團(tuán)隊(duì)分析日志數(shù)據(jù)并設(shè)置告警和通知。

[[378345]]

介紹

Monasca 是一個(gè)多租戶監(jiān)控即服務(wù)工具,可以幫助IT團(tuán)隊(duì)分析日志數(shù)據(jù)并設(shè)置告警和通知。

OpenStack環(huán)境中的監(jiān)控需求是巨大,多樣且高度復(fù)雜的。Monasca的項(xiàng)目任務(wù)是提供一種多租戶,高度可擴(kuò)展,高性能和容錯(cuò)的監(jiān)控即服務(wù)解決方案。

Monasca為高級(jí)監(jiān)控提供了可擴(kuò)展的平臺(tái),運(yùn)營(yíng)商和租戶均可使用該平臺(tái)來(lái)獲取有關(guān)其基礎(chǔ)架構(gòu)和應(yīng)用的運(yùn)行狀態(tài)。

Monasca使用REST API進(jìn)行高速的日志處理和查詢。它集成了流告警引擎,通知引擎和聚合引擎。

您可以使用Monasca實(shí)現(xiàn)的用例非常多樣。Monasca遵循微服務(wù)架構(gòu),其中幾個(gè)服務(wù)分布在多個(gè)存儲(chǔ)庫(kù)中。每個(gè)模塊旨在為整個(gè)監(jiān)控解決方案提供離散服務(wù),并且可以根據(jù)運(yùn)營(yíng)商/客戶的需求進(jìn)行部署。

  • 使用Rest API接口來(lái)存儲(chǔ)、查詢性能和歷史數(shù)據(jù),不同于其他監(jiān)控工具使用特殊的協(xié)議和傳輸方法,如nagios的NSCA,Monasca只利用了http
  • 多租戶認(rèn)證,指標(biāo)的提交和認(rèn)證使用Keystone組件。存儲(chǔ)關(guān)聯(lián)租戶ID
  • 指標(biāo)使用(key,value)的鍵值來(lái)定義,稱作量度(dimensions)
  • 對(duì)系統(tǒng)指標(biāo)進(jìn)行實(shí)時(shí)閾值和告警
  • 復(fù)合告警設(shè)置使用簡(jiǎn)單的語(yǔ)法,由子告警表達(dá)式和邏輯操作器組成
  • 監(jiān)控代理支持內(nèi)置的系統(tǒng)和服務(wù)的檢查結(jié)果,同時(shí)也只nagios的checks和statsd
  • 根據(jù)開(kāi)源技術(shù)搭建的開(kāi)源監(jiān)控方案

架構(gòu)

下圖概述了Monasca的指標(biāo)管道以及所涉及組件的交互。

核心組件

  • monasca-agent:監(jiān)控代理,python編寫(xiě),包含了多個(gè)子組件,支持各種cpu使用率、可用內(nèi)存、nagios插件、statsd、以及許多服務(wù)如mysql、rabbitMQ等監(jiān)控
  • monasca-api::一個(gè)用于監(jiān)控的RESTful API接口,針對(duì)在以下概念和區(qū)域:
    • 指標(biāo):對(duì)于實(shí)時(shí)的大量指標(biāo)的存儲(chǔ)和查詢
    • 統(tǒng)計(jì):查詢指標(biāo)的統(tǒng)計(jì)數(shù)據(jù)
    • 告警定義:告警定義的增刪查改
    • 告警:查詢和刪除告警歷史
    • 通知方式:創(chuàng)建和刪除通知方式,當(dāng)告警狀態(tài)改變時(shí)可以直接郵件通知用戶—monasca API可以通過(guò)python或JAVA來(lái)實(shí)現(xiàn)
  • manasca-persister:消息隊(duì)列傳送指標(biāo)或告警的消費(fèi)者(RPC傳輸中的概念consumer),并將指標(biāo)和告警存入對(duì)應(yīng)的數(shù)據(jù)庫(kù)
  • monasca-transform:一個(gè)轉(zhuǎn)換聚合引擎,轉(zhuǎn)換指標(biāo)的名字和值,生成新的指標(biāo)傳遞給消息隊(duì)列
  • Anomaly and Prediction Engine:目前還是原型階段
  • monasca-thresh:對(duì)指標(biāo)進(jìn)行計(jì)算,當(dāng)超過(guò)閾值是發(fā)布告警給消息隊(duì)列,基于Apache storm項(xiàng)目(開(kāi)源實(shí)時(shí)分布式計(jì)算系統(tǒng))
  • monasca-notification:接受從消息隊(duì)列傳來(lái)的告警,并發(fā)送通知,如發(fā)送告警郵件,Notification Engine基于Python
  • monasca-analytics:分析引擎,接受從消息隊(duì)列傳來(lái)的告警,進(jìn)行異常檢測(cè)和告警關(guān)聯(lián)
  • 消息隊(duì)列:以前是支持RabbitMQ的,由于性能、規(guī)模、持續(xù)性和高可用的限制,轉(zhuǎn)向了Kafka
  • Metrics and Alarms Database:支持Vertica和infuxDB,對(duì)Cassandra的支持正在進(jìn)行中
  • Config Database:配置信息數(shù)據(jù)庫(kù),目前使用Mysql,對(duì)PostgreSQL的支持正在進(jìn)程中
  • python-monascaclient:python實(shí)現(xiàn)的命令行客戶端,對(duì)monasca API進(jìn)行操控
  • Monitoring UI:Horizon dashboard的可視化
  • Ceilometer publisher:提供給Ceilometer的multi-publisher插件

除了直接向API發(fā)送請(qǐng)求之外,還可以使用以下工具與Monasca進(jìn)行交互:

  • Monasca client:CLI和Python客戶端
  • Horizon plugin:該插件將監(jiān)控面板添加到Horizon
  • Grafana app:Grafana插件可查看和配置告警定義,告警和通知

Libraries:

  • monasca-common:Monasca組件中使用的通用代碼
  • monasca-statsd:StatsD兼容的庫(kù),用于從已檢測(cè)的應(yīng)用程序發(fā)送指標(biāo)

Grafana集成:

  • monasca-grafana-datasource:用于Grafana的多租戶Monasca數(shù)據(jù)源
  • grafana:Grafana 4.1.2的分支版本,添加了Keystone身份驗(yàn)證

第三方技術(shù)與工具

Monasca使用多種第三方技術(shù):

  • 內(nèi)部處理和中間件
    • Apache Kafka(http://kafka.apache.org):是一個(gè)分布式、分區(qū)的、多副本的、多訂閱者,基于zookeeper協(xié)調(diào)的分布式日志系統(tǒng)(也可以當(dāng)做MQ系統(tǒng)),常見(jiàn)可以用于web/nginx日志、訪問(wèn)日志,消息服務(wù)等等
    • Apache Storm(http://storm.incubator.apache.org/):Apache Storm是一個(gè)免費(fèi)的開(kāi)源分布式實(shí)時(shí)計(jì)算系統(tǒng)。通過(guò)Storm,可以輕松可靠地處理無(wú)限數(shù)據(jù)流,從而可以進(jìn)行實(shí)時(shí)處理,而Hadoop可以進(jìn)行批處理
    • ZooKeeper(http://zookeeper.apache.org/):由Kafka和Storm使用
    • Apache Spark:由Monasca Transform用作聚合引擎
  • 配置數(shù)據(jù)庫(kù):
    • MySQL:支持將MySQL作為配置數(shù)據(jù)庫(kù)
    • PostgreSQL:通過(guò)Hibernate和SQLAlchemy支持Config數(shù)據(jù)庫(kù)的POSTgres
  • Vagrant(http://www.vagrantup.com/):Vagrant提供了易于配置,可重復(fù)的便攜式工作環(huán)境,該環(huán)境建立在行業(yè)標(biāo)準(zhǔn)技術(shù)之上,并由一個(gè)一致的工作流程控制,可幫助您最大程度地提高生產(chǎn)力和靈活性
  • Dropwizard(https://dropwizard.github.io/dropwizard/):Dropwizard將Java生態(tài)系統(tǒng)中穩(wěn)定,成熟的庫(kù)匯集到一個(gè)簡(jiǎn)單,輕巧的程序包中,使您可以專注于完成自身的工作任務(wù)中。Dropwizard對(duì)復(fù)雜的配置,應(yīng)用程序指標(biāo),日志記錄,操作工具等提供了開(kāi)箱即用的支持,使您和您的團(tuán)隊(duì)可以在最短的時(shí)間內(nèi)發(fā)布高質(zhì)量的Web服務(wù)
  • 時(shí)間序列數(shù)據(jù)庫(kù):
    • InfluxDB(http://influxdb.com/):一個(gè)沒(méi)有外部依賴性的開(kāi)源分布式時(shí)間序列數(shù)據(jù)庫(kù)。Metrics數(shù)據(jù)庫(kù)支持InfluxDB
    • Vertica(http://www.vertica.com):具有高度可擴(kuò)展性的商業(yè)企業(yè)級(jí)SQL分析數(shù)據(jù)庫(kù)。它提供了內(nèi)置的自動(dòng)高可用性功能,并且擅長(zhǎng)數(shù)據(jù)庫(kù)內(nèi)分析以及壓縮和存儲(chǔ)大量數(shù)據(jù)。提供了Vertica的免費(fèi)社區(qū)版本,該版本可以存儲(chǔ)最大1 TB的數(shù)據(jù),沒(méi)有時(shí)間限制,網(wǎng)址為https://my.vertica.com/community/。雖然不再經(jīng)常用Vertrica,但Metrics數(shù)據(jù)庫(kù)支持它
    • Cassandra(https://cassandra.apache.org):Mestrics數(shù)據(jù)庫(kù)支持Cassandra

安裝

手工安裝

monasca的所有組件都可以安裝在一個(gè)節(jié)點(diǎn)上,例如openstack控制器節(jié)點(diǎn)上,也可以將其部署在多節(jié)點(diǎn)上。本文中,將在我的openstack集群中創(chuàng)建的新VM中安裝monasca-api,該VM具有關(guān)聯(lián)的浮動(dòng)ip。Monasca-agent已安裝在控制器節(jié)點(diǎn)上。代理節(jié)點(diǎn)通過(guò)浮動(dòng)ip將指標(biāo)發(fā)布到api節(jié)點(diǎn)。它們?cè)谕蛔泳W(wǎng)中。

安裝我們需要的軟件包和工具

  1. apt-get install -y git 
  2. apt-get install openjdk-7-jre-headless python-pip python-dev 

安裝mysql數(shù)據(jù)庫(kù)如果您在openstack控制器節(jié)點(diǎn)中安裝了monasca-api,則可以跳過(guò)安裝,將已安裝的msyql用于openstack服務(wù)。

  1. apt-get install -y mysql-server 

創(chuàng)建monasca數(shù)據(jù)庫(kù)架構(gòu),在此處下載mon.sql( https://raw.githubusercontent.com/stackforge/cookbook-monasca-schema/master/files/default/mysql/mon.sql)

  1. mysql -uroot -ppassword < mon_mysql.sql 

安裝Zookeeper安裝Zookeeper并重新啟動(dòng)它。我使用本地主機(jī)接口,并且只有一個(gè)Zookeeper,因此默認(rèn)配置文件不需要配置。

  1. apt-get install -y zookeeper zookeeperd zookeeper-bin 
  2. service zookeeper restart 

安裝和配置kafka

  1. wget http://apache.mirrors.tds.net/kafka/0.8.1.1/kafka_2.9.2-0.8.1.1.tgz 
  2. mv kafka_2.9.2-0.8.1.1.tgz /opt 
  3. cd /opt 
  4. tar zxf kafka_2.9.2-0.8.1.1.tgz 
  5. ln -s /opt/kafka_2.9.2-0.8.1.1/ /opt/kafka 
  6. ln -s /opt/kafka/config /etc/kafka 

創(chuàng)建kafka系統(tǒng)用戶,kafka服務(wù)將以該用戶身份啟動(dòng)。

  1. useradd kafka -U -r 

在/etc/init/kafka.conf中創(chuàng)建kafka啟動(dòng)腳本,將以下內(nèi)容復(fù)制 到/etc/init/kafka.conf中并保存。

  1. description "Kafka" 
  2.  
  3. start on runlevel [2345] 
  4. stop on runlevel [!2345] 
  5.   
  6. respawn 
  7.  
  8. limit nofile 32768 32768 
  9.  
  10. # If zookeeper is running on this box also give it time to start up properly 
  11. pre-start script 
  12.   if [ -e /etc/init.d/zookeeper ]; then 
  13.       /etc/init.d/zookeeper restart 
  14.   fi 
  15. end script 
  16.  
  17. # Rather than using setuid/setgid sudo is used because the pre-start task must run as root 
  18. exec sudo -Hu kafka -g kafka KAFKA_HEAP_OPTS="-Xmx1G -Xms1G" JMX_PORT=9997 /opt/kafka/bin/kafka-server-start.sh /etc/kafka/server.properties 

配置kafka,vim /etc/kafka/server.properties,確保配置了以下內(nèi)容:

  1. host.name=localhost 
  2. advertised.host.name=localhost 
  3. log.dirs=/var/kafka 

創(chuàng)建 kafka log目錄

  1. mkdir /var/kafka 
  2. mkdir /var/log/kafka 
  3. chown -R kafka. /var/kafka/ 
  4. chown -R kafka. /var/log/kafka/ 

啟動(dòng)kafka服務(wù)

  1. service kafka start 

下一步就是創(chuàng)建 kafka topics

  1. /opt/kafka/bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 64 --topic metrics 
  2. /opt/kafka/bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 12 --topic events 
  3. /opt/kafka/bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 12 --topic raw-events 
  4. /opt/kafka/bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 12 --topic transformed-events 
  5. /opt/kafka/bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 12 --topic stream-definitions 
  6. /opt/kafka/bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 12 --topic transform-definitions 
  7. /opt/kafka/bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 12 --topic alarm-state-transitions 
  8. /opt/kafka/bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 12 --topic alarm-notifications 
  9. /opt/kafka/bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 12 --topic stream-notifications 
  10. /opt/kafka/bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 3 --topic retry-notifications 

安裝和配置 influxdb

  1. curl -sL https://repos.influxdata.com/influxdb.key | apt-key add - 
  2. echo "deb https://repos.influxdata.com/ubuntu trusty stable" > /etc/apt/sources.list.d/influxdb.list 
  3. apt-get update 
  4. apt-get install -y apt-transport-https 
  5. apt-get install -y influxdb 
  6.  
  7. service influxdb start 

創(chuàng)建 influxdb database, user, password, retention policy, 同時(shí)修改密碼。

  1. influx 
  2. CREATE DATABASE mon 
  3. CREATE USER monasca WITH PASSWORD 'tyun' 
  4. CREATE RETENTION POLICY persister_all ON mon DURATION 90d REPLICATION 1 DEFAULT 
  5. exit 

安裝與配置 storm

  1. wget http://apache.mirrors.tds.net/storm/apache-storm-0.9.6/apache-storm-0.9.6.tar.gz 
  2. mkdir /opt/storm 
  3. cp apache-storm-0.9.6.tar.gz /opt/storm/ 
  4. cd /opt/storm/ 
  5. tar xzf apache-storm-0.9.6.tar.gz 
  6. ln -s /opt/storm/apache-storm-0.9.6 /opt/storm/current 
  7.  
  8. useradd storm -U -r 
  9. mkdir /var/storm 
  10. mkdir /var/log/storm 
  11. chown -R storm. /var/storm/ 
  12. chown -R storm. /var/log/storm/ 

修改storm.yaml, vim current/storm/conf/storm.yaml

  1. ### base 
  2. java.library.path: "/usr/local/lib:/opt/local/lib:/usr/lib" 
  3. storm.local.dir: "/var/storm" 
  4.  
  5. ### zookeeper.* 
  6. storm.zookeeper.servers: 
  7.   - "localhost" 
  8. storm.zookeeper.port: 2181 
  9. storm.zookeeper.retry.interval: 5000 
  10. storm.zookeeper.retry.times: 29 
  11. storm.zookeeper.root: "/storm" 
  12. storm.zookeeper.session.timeout: 30000 
  13.  
  14. ### supervisor.* configs are for node supervisors 
  15. supervisor.slots.ports: 
  16.   - 6701 
  17.   - 6702 
  18.   - 6703 
  19.   - 6704 
  20. supervisor.childopts: "-Xmx1024m" 
  21.  
  22. ### worker.* configs are for task workers 
  23. worker.childopts: "-Xmx1280m -XX:+UseConcMarkSweepGC -Dcom.sun.management.jmxremote" 
  24.  
  25. ### nimbus.* configs are for the masteri 
  26. nimbus.host: "localhost" 
  27. nimbus.thrift.port: 6627 
  28. mbus.childopts: "-Xmx1024m" 
  29.  
  30. ### ui.* configs are for the master 
  31. ui.host: 127.0.0.1 
  32. ui.port: 8078 
  33. ui.childopts: "-Xmx768m" 
  34.  
  35. ### drpc.* configs 
  36.  
  37. ### transactional.* configs 
  38. transactional.zookeeper.servers: 
  39.   - "localhost" 
  40. transactional.zookeeper.port: 2181 
  41. transactional.zookeeper.root: "/storm-transactional" 
  42.  
  43. ### topology.* configs are for specific executing storms 
  44. topology.acker.executors: 1 
  45. topology.debug: false 
  46.  
  47. logviewer.port: 8077 
  48. logviewer.childopts: "-Xmx128m" 

創(chuàng)建storm supervisor 啟動(dòng)腳本,vim /etc/init/storm-supervisor.conf

  1. # Startup script for Storm Supervisor 
  2.  
  3. description "Storm Supervisor daemon" 
  4. start on runlevel [2345] 
  5.  
  6. console log 
  7. respawn 
  8.  
  9. kill timeout 240 
  10. respawn limit 25 5 
  11.  
  12. setgid storm 
  13. setuid storm 
  14. chdir /opt/storm/current 
  15. exec /opt/storm/current/bin/storm supervisor 

創(chuàng)建Storm nimbus 啟動(dòng)腳本。vim /etc/init/storm-nimbus.conf

  1. # Startup script for Storm Nimbus 
  2.  
  3. description "Storm Nimbus daemon" 
  4. start on runlevel [2345] 
  5.  
  6. console log 
  7. respawn 
  8.  
  9. kill timeout 240 
  10. respawn limit 25 5 
  11.  
  12. setgid storm 
  13. setuid storm 
  14. chdir /opt/storm/current 
  15. exec /opt/storm/current/bin/storm nimbus 

啟動(dòng)supervisor 與 nimbus

  1. service storm-supervisor start 
  2. service storm-nimbus start 

安裝monasca api python軟件包

一些monasca組件同時(shí)提供python和java代碼,主要是我選擇python代碼進(jìn)行部署。

  1. pip install monasca-common 
  2. pip install gunicorn 
  3. pip install greenlet  # Required for both 
  4. pip install eventlet  # For eventlet workers 
  5. pip install gevent    # For gevent workers 
  6. pip install monasca-api 
  7. pip install influxdb 

vim /etc/monasca/api-config.ini,將主機(jī)修改為您的IP地址

  1. [DEFAULT
  2. name = monasca_api 
  3.    
  4. [pipeline:main] 
  5. Add validator in the pipeline so the metrics messages can be validated. 
  6. pipeline = auth keystonecontext api 
  7.    
  8. [app:api] 
  9. paste.app_factory = monasca_api.api.server:launch 
  10.    
  11. [filter:auth] 
  12. paste.filter_factory = keystonemiddleware.auth_token:filter_factory 
  13.    
  14. [filter:keystonecontext] 
  15. paste.filter_factory = monasca_api.middleware.keystone_context_filter:filter_factory 
  16.    
  17. [server:main] 
  18. use = egg:gunicorn#main 
  19. host = 192.168.2.23 
  20. port = 8082 
  21. workers = 1 
  22. proc_name = monasca_api 

vim /etc/monasca/api-config.conf,修改以下內(nèi)容

  1. [DEFAULT
  2. # logging, make sure that the user under whom the server runs has permission 
  3. to write to the directory. 
  4. log_file = monasca-api.log 
  5. log_dir = /var/log/monasca/api/ 
  6. debug=False 
  7. region = RegionOne 
  8. [security] 
  9. # The roles that are allowed full access to the API. 
  10. default_authorized_roles = admin, user, domainuser, domainadmin, monasca-user 
  11.  
  12. # The roles that are allowed to only POST metrics to the API. This role would be used by the Monasca Agent. 
  13. agent_authorized_roles = admin 
  14.  
  15. # The roles that are allowed to only GET metrics from the API. 
  16. read_only_authorized_roles = admin 
  17.  
  18. # The roles that are allowed to access the API on behalf of another tenant. 
  19. For example, a service can POST metrics to another tenant if they are a member of the "delegate" role. 
  20. delegate_authorized_roles = admin 
  21.  
  22. [kafka] 
  23. # The endpoint to the kafka server 
  24. uri = localhost:9092 
  25.  
  26. [influxdb] 
  27. Only needed if Influxdb database is used for backend. 
  28. # The IP address of the InfluxDB service. 
  29. ip_address = localhost 
  30.  
  31. # The port number that the InfluxDB service is listening on
  32. port = 8086 
  33.  
  34. # The username to authenticate with
  35. user = monasca 
  36.  
  37. # The password to authenticate with
  38. password = tyun 
  39.  
  40. # The name of the InfluxDB database to use. 
  41. database_name = mon 
  42.  
  43. [database
  44. url = "mysql+pymysql://monasca:tyun@127.0.0.1/mon" 
  45.  
  46.  
  47. [keystone_authtoken] 
  48. identity_uri = http://192.168.1.11:35357 
  49. auth_uri = http://192.168.1.11:5000 
  50. admin_password = tyun 
  51. admin_user = monasca 
  52. admin_tenant_name = service 
  53. cafile = 
  54. certfile = 
  55. keyfile = 
  56. insecure = false 

注釋掉[mysql]部分,其他部分保持默認(rèn)。

創(chuàng)建monasca系統(tǒng)用戶并進(jìn)入目錄

  1. useradd monasca -U -r 
  2. mkdir /var/log/monasca 
  3. mkdir /var/log/monasca/api 
  4. chown -R monasca. /var/log/monasca/ 

在openstack控制器節(jié)點(diǎn)上,創(chuàng)建monasca用戶密碼,為租戶服務(wù)中的用戶monasca分配管理員角色。

  1. openstack user create --domain default --password tyun monasca  
  2. openstack role add --project service --user monasca admin 
  3.  
  4. openstack service create --name monasca --description "Monasca monitoring service" monitoring 
  5.  
  6. create endpoint  
  7. openstack endpoint create --region RegionOne monasca public http://192.168.1.143:8082/v2.0 
  8. openstack endpoint create --region RegionOne monasca internal http://192.168.1.143:8082/v2.0 
  9. openstack endpoint create --region RegionOne monasca admin http://192.168.1.143:8082/v2.0 

192.168.1.143是我的api虛擬機(jī)地址的浮動(dòng)IP,請(qǐng)將其更改為您的IP。

創(chuàng)建monasca api啟動(dòng)腳本,vim /etc/init/monasca-api.conf

  1. # Startup script for the Monasca API 
  2.  
  3. description "Monasca API Python app" 
  4. start on runlevel [2345] 
  5.  
  6. console log 
  7. respawn 
  8.  
  9. setgid monasca 
  10. setuid monasca 
  11. exec /usr/local/bin/gunicorn -n monasca-api -k eventlet --worker-connections=2000 --backlog=1000 --paste /etc/monasca/api-config.ini 

安裝monasca-persister

創(chuàng)建monasca-persister啟動(dòng)腳本

vim /etc/init/monasca-persister.conf

  1. # Startup script for the Monasca Persister 
  2.  
  3. description "Monasca Persister Python app" 
  4. start on runlevel [2345] 
  5.  
  6. console log 
  7. respawn 
  8.  
  9. setgid monasca 
  10. setuid monasca 
  11. exec /usr/bin/java -Dfile.encoding=UTF-8 -cp /opt/monasca/monasca-persister.jar monasca.persister.PersisterApplication server /etc/monasca/persister-config.yml 

啟動(dòng)monasca-persister

  1. service monasca-persister start 

安裝monasca-notificatoin

  1. pip install --upgrade monasca-notification 
  2. apt-get install sendmail 

將notification.yaml復(fù)制到/etc/monasca/創(chuàng)建啟動(dòng)腳本,vim /etc/init/monasca-notification.conf

  1. # Startup script for the monasca_notification 
  2.  
  3. description "Monasca Notification daemon" 
  4. start on runlevel [2345] 
  5.  
  6. console log 
  7. respawn 
  8.  
  9. setgid monasca 
  10. setuid monasca 
  11. exec /usr/bin/python /usr/local/bin/monasca-notification 

啟動(dòng)通知服務(wù)

  1. service monasca-notification start 

安裝monasca-thresh復(fù)制monasca-thresh到/etc/init.d/復(fù)制monasca-thresh.jar到/opt/monasca-thresh/復(fù)制thresh-config.yml到/etc/monasca /并修改主機(jī)以及數(shù)據(jù)庫(kù)信息啟動(dòng)monasca-thresh

  1. service monasca-thresh start 

安裝monasca-agent

在openstack控制器節(jié)點(diǎn)上安裝monasca-agent,以便它可以監(jiān)控openstack服務(wù)進(jìn)程。

  1. sudo pip install --upgrade monasca-agent 

設(shè)置monasca-agent,將用戶域ID和項(xiàng)目域ID更改為默認(rèn)值。

  1. monasca-setup -u monasca -p tyun --user_domain_id e25e0413a70c41449d2ccc2578deb1e4 --project_domain_id e25e0413a70c41449d2ccc2578deb1e4 --user monasca \ 
  2.  --project_name service -s monitoring --keystone_url http://192.168.1.11:35357/v3 --monasca_url http://192.168.1.143:8082/v2.0 --config_dir /etc/monasca/agent --log_dir /var/log/monasca/agent --overwrite 

加載認(rèn)證腳本admin-rc.sh,然后運(yùn)行monasca metric-list。

DevStack安裝

運(yùn)行Monasca DevStack至少需要一臺(tái)具有10GB RAM的主機(jī)。

可在此處找到安裝和運(yùn)行Devstack的說(shuō)明:

  1. https://docs.openstack.org/devstack/latest/ 

要在DevStack中運(yùn)行Monasca,請(qǐng)執(zhí)行以下三個(gè)步驟。

克隆DevStack代碼庫(kù)。

  1. git clone https://git.openstack.org/openstack-dev/devstack 

將以下內(nèi)容添加到devstack目錄根目錄中的DevStack local.conf文件中。如果local.conf不存在,則可能需要?jiǎng)?chuàng)建它。

  1. BEGIN DEVSTACK LOCAL.CONF CONTENTS 
  2.  
  3. [[local|localrc]] 
  4. DATABASE_PASSWORD=secretdatabase 
  5. RABBIT_PASSWORD=secretrabbit 
  6. ADMIN_PASSWORD=secretadmin 
  7. SERVICE_PASSWORD=secretservice 
  8. SERVICE_TOKEN=111222333444 
  9.  
  10. LOGFILE=$DEST/logs/stack.sh.log 
  11. LOGDIR=$DEST/logs 
  12. LOG_COLOR=False 
  13.  
  14. # The following two variables allow switching between Java and Python for the implementations 
  15. of the Monasca API and the Monasca Persister. If these variables are not setthen the 
  16. default is to install the Python implementations of both the Monasca API and the Monasca Persister. 
  17.  
  18. # Uncomment one of the following two lines to choose Java or Python for the Monasca API. 
  19. MONASCA_API_IMPLEMENTATION_LANG=${MONASCA_API_IMPLEMENTATION_LANG:-java} 
  20. # MONASCA_API_IMPLEMENTATION_LANG=${MONASCA_API_IMPLEMENTATION_LANG:-python} 
  21.  
  22. # Uncomment of the following two lines to choose Java or Python for the Monasca Pesister. 
  23. MONASCA_PERSISTER_IMPLEMENTATION_LANG=${MONASCA_PERSISTER_IMPLEMENTATION_LANG:-java} 
  24. # MONASCA_PERSISTER_IMPLEMENTATION_LANG=${MONASCA_PERSISTER_IMPLEMENTATION_LANG:-python} 
  25.  
  26. # Uncomment one of the following two lines to choose either InfluxDB or Vertica. 
  27. default "influxdb" is selected as metric DB 
  28. MONASCA_METRICS_DB=${MONASCA_METRICS_DB:-influxdb} 
  29. # MONASCA_METRICS_DB=${MONASCA_METRICS_DB:-vertica} 
  30.  
  31. # This line will enable all of Monasca. 
  32. enable_plugin monasca-api https://git.openstack.org/openstack/monasca-api 
  33.  
  34. END DEVSTACK LOCAL.CONF CONTENTS 

從devstack目錄的根目錄運(yùn)行“ ./stack.sh”。

如果要使用最少的OpenStack組件運(yùn)行Monasca,可以將以下兩行添加到local.conf文件中。

  1. disable_all_services 
  2. enable_service rabbit mysql key 

如果您還希望安裝Tempest測(cè)試,請(qǐng)?zhí)砑?tempest

  1. enable_service rabbit mysql key tempest 

要啟用Horizon和Monasca UI,請(qǐng)?zhí)砑?horizon

  1. enable_service rabbit mysql key horizon tempest 

使用Vagrant

Vagrant可用于使用Vagrantfile部署運(yùn)行有Devstack和Monasca的VM。安裝Vagrant后,只需在../monasca-api/devstack目錄中運(yùn)行vagrant up命令。

要在devstack安裝中使用本地代碼庫(kù),請(qǐng)將更改提交到本地存儲(chǔ)庫(kù)的master分支,然后在配置文件中修改與要使用的本地存儲(chǔ)庫(kù)相對(duì)應(yīng)的變量file://my/local/repo/location。要使用monasca-api repo的本地實(shí)例,請(qǐng)將更改enable_plugin monasca-api https://git.openstack.org/openstack/monasca-api為enable_plugin monasca-api file://my/repo/is/here。這兩個(gè)設(shè)置僅在重建devstack VM時(shí)生效。

1.使用Vagrant將Vertica啟用為Metrics DB

Monasca支持同時(shí)使用InfluxDB和Vertica來(lái)存儲(chǔ)指標(biāo)和告警狀態(tài)歷史記錄。默認(rèn)情況下,在DevStack環(huán)境中啟用InfluxDB。

Vertica是Hewlett Packard Enterprise的商業(yè)數(shù)據(jù)庫(kù)??梢韵螺d免費(fèi)的Community Edition(CE)安裝程序,要啟用Vertica,請(qǐng)執(zhí)行以下操作:

  • 注冊(cè)并下載Vertica Debian安裝程序https://my.vertica.com/download/vertica/community-edition/,并將其放在您的主目錄中。不幸的是,DevStack安裝程序沒(méi)有可以自動(dòng)使用的URL,因此必須單獨(dú)下載該URL,并將其放置在安裝程序運(yùn)行時(shí)可以找到它的位置。安裝程序假定此位置是您的主目錄。使用Vagrant時(shí),您的主目錄通常將以“ /vagrant_home”掛載在VM內(nèi)。
  • 修改local.conf中MONASCA_METRICS_DB變量,配置Vertica的支持,如下所示:

MONASCA_METRICS_DB=${MONASCA_METRICS_DB:-vertica}

2.使用PostgreSQL或MySQL

Monasca支持使用PostgreSQL和MySQL,因此該devstack插件也支持。啟用postgresql或mysql。

要使用MySQL設(shè)置環(huán)境,請(qǐng)使用:

  1. enable_service mysql 

另外,對(duì)于PostgreSQL,請(qǐng)使用:

  1. enable_service postgresql 

3.使用ORM支持

ORM支持可以通過(guò)MONASCA_DATABASE_USE_ORM變量來(lái)控制。但是,如果啟用了PostgreSQL(也稱為數(shù)據(jù)庫(kù)后端),則將強(qiáng)制提供ORM支持

enable_service postgresql

4.加強(qiáng)Apache鏡像

如果由于某種原因APACHE_MIRROR而無(wú)法使用,則可以通過(guò)以下方式強(qiáng)制執(zhí)行:

  1. APACHE_MIRROR=http://www-us.apache.org/dist/ 

5.使用WSGI

Monasca-api可以使用uwsgi和gunicorn與Apache一起部署。默認(rèn)情況下,monasca-api在uwsgi下運(yùn)行。如果您想使用Gunicorn,請(qǐng)確保其中devstack/local.conf包含:

  1. MONASCA_API_USE_MOD_WSGI=False 

使用

Monasca Dashboard

安裝完成Monasca Dashboard Plugin后,可以通過(guò)web控制臺(tái)進(jìn)行查看以及管理相應(yīng)的監(jiān)控與告警。

在操作控制臺(tái)的“Monitoring”欄,單擊“Launch Monitoring Dashboard“,這將打開(kāi)在管理節(jié)點(diǎn)上運(yùn)行的專用OpenStack Horizon門(mén)戶。

在該面板中,您可以:

  • 單擊OpenStack服務(wù)名稱,以查看服務(wù)告警。
  • 單擊服務(wù)器名稱以查看相關(guān)設(shè)備的告警。

監(jiān)控信息存儲(chǔ)在兩個(gè)數(shù)據(jù)庫(kù)中(Vertica/influxdb與mysql)。備份監(jiān)控?cái)?shù)據(jù)時(shí),將同時(shí)備份兩個(gè)數(shù)據(jù)庫(kù)。看到

  • 監(jiān)控指標(biāo)在Vertica中存儲(chǔ)7天。
  • 配置設(shè)置存儲(chǔ)在MySQL中。
  • 如果監(jiān)控節(jié)點(diǎn)上的服務(wù)在高負(fù)載(例如15個(gè)控制網(wǎng)絡(luò)和200個(gè)計(jì)算節(jié)點(diǎn))下停止,則消息隊(duì)列將在大約6個(gè)小時(shí)內(nèi)開(kāi)始清除。

 

查看監(jiān)控信息

在操作控制臺(tái)中,通過(guò)從主菜單中選擇Monitoring Dashboard來(lái)打開(kāi)監(jiān)控UI 。

單擊Launch Monitoring Dashboard。

將打開(kāi)管理設(shè)備上OpenStack Horizon中的“Monitoring”儀表板。

使用您在首次安裝過(guò)程中為操作控制臺(tái)設(shè)置的用戶名和密碼登錄。

查看告警。您可以在屏幕上過(guò)濾結(jié)果。

  • 點(diǎn)擊告警左側(cè)導(dǎo)航看到報(bào)警的所有服務(wù)和設(shè)備。
  • 在每行右側(cè)的“操作”菜單上,可以單擊“Graph metrics”以查看告警明細(xì),并且可以顯示告警的歷史記錄和告警定義。您還可以在該告警的圖形頂部看到指標(biāo)名稱。
  • 點(diǎn)擊OpenStack服務(wù)名稱以查看服務(wù)告警。
  • 單擊服務(wù)器名稱以查看有關(guān)設(shè)備的告警。

單擊左側(cè)導(dǎo)航中的”Alarm Definitions “以查看和編輯已啟用的告警的類型。

注意:請(qǐng)勿更改或刪除任何默認(rèn)告警定義。但是,您可以添加新的告警定義。

您可以更改告警的名稱,表達(dá)式和其他詳細(xì)信息。

如果收到過(guò)多或不足的告警,則可能需要提高或降低告警閾值。

有關(guān)編寫(xiě)告警表達(dá)式的信息。

可選:?jiǎn)螕鬌ashboard。

OpenStack儀表板(Grafana)打開(kāi)。從該儀表板中,您可以看到OpenStack服務(wù)的運(yùn)行狀況以及每個(gè)節(jié)點(diǎn)的CPU和數(shù)據(jù)庫(kù)使用情況的圖形表示。

  • 單擊圖形標(biāo)題(例如,CPU),然后單擊“編輯”。
  • 更改功能以查看圖中的其他類型的信息。

可選:?jiǎn)螕鬗onasca Health。

將打開(kāi)“ Monasca服務(wù)儀表板”。在此儀表板上,您可以看到Monasca服務(wù)運(yùn)行狀況的圖形表示。

總結(jié)

Monasca作為Openstack的monitoring-as-a-service組件,目前社區(qū)和網(wǎng)上的資料還是比較少。本文通過(guò)作者的實(shí)踐,記錄了Monasca相關(guān)的安裝和配置以及使用的方法,

Monasca是一個(gè)可以實(shí)現(xiàn)IAAS到PAAS的高擴(kuò)展,高性能的監(jiān)控系統(tǒng),其體系架構(gòu)決定了它能夠輕松駕馭大集群,高負(fù)載的監(jiān)控。當(dāng)前我們已經(jīng)逐步擯棄了ceilometer+gnocchi+aodh的組合,全面轉(zhuǎn)向Monasca。當(dāng)前監(jiān)控的不僅僅是云主機(jī),云網(wǎng)絡(luò),同時(shí)也監(jiān)控著我們Openstack集群內(nèi)部的Kubernetns集群,數(shù)據(jù)庫(kù)集群,對(duì)象存儲(chǔ)等PAAS軟件。

參考文章:

https://docs.openstack.org/monasca-api/latest/

https://wiki.openstack.org/wiki/Monasca

 

責(zé)任編輯:武曉燕 來(lái)源: 新鈦云服
相關(guān)推薦

2024-09-06 07:55:42

2011-04-07 13:53:25

Web工具

2023-11-01 11:40:46

Linux高性能網(wǎng)絡(luò)編程工具

2009-12-23 10:29:01

WPF應(yīng)用程序

2009-03-31 16:41:38

網(wǎng)絡(luò)性能網(wǎng)絡(luò)監(jiān)控開(kāi)源

2023-12-01 07:06:14

Go命令行性能

2019-06-18 10:24:23

開(kāi)源技術(shù) 趨勢(shì)

2019-11-01 08:49:07

JVM監(jiān)控性能

2019-08-01 09:52:46

LinuxNetData性能監(jiān)控工具

2020-05-06 07:26:55

容器性能監(jiān)控云計(jì)算

2017-06-01 13:21:23

OpenStack云平臺(tái)監(jiān)控

2019-03-01 11:03:22

Lustre高性能計(jì)算

2023-04-26 00:01:04

2014-12-19 10:55:17

Linux性能監(jiān)控

2017-11-28 17:14:16

華為云

2013-11-06 10:46:58

OpenStack監(jiān)控監(jiān)控系統(tǒng)

2013-03-27 10:01:53

網(wǎng)絡(luò)應(yīng)用檢測(cè)工具

2019-07-31 11:30:25

MySQL數(shù)據(jù)庫(kù)工具

2016-05-06 10:14:52

網(wǎng)絡(luò)優(yōu)化網(wǎng)絡(luò)監(jiān)控監(jiān)控工具

2017-08-07 21:10:55

MySQLUbuntusysbench
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號(hào)