找回密码
 注册
查看: 611|回复: 0

openstack控制器安装手工安装monasca

[复制链接]

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
发表于 2022-12-20 10:00:02 | 显示全部楼层 |阅读模式
monasca的所有组件都可以安装在一个节点上,例如openstack控制器节点上,也可以将其部署在多节点上。本文中,将在我的openstack集群中创建的新VM中安装monasca-api,该VM具有关联的浮动ip。Monasca-agent已安装在控制器节点上。代理节点通过浮动ip将指标发布到api节点。它们在同一子网中。
  • 安装我们需要的软件包和工具/ A3 ]* |$ M) U2 }: |: p9 z& B! w
    apt-get install -y git4 c6 x1 U9 e8 l6 c& H
    apt-get install openjdk-7-jre-headless python-pip python-dev
  • 安装mysql数据库 如果您在openstack控制器节点中安装了monasca-api,则可以跳过安装,将已安装的msyql用于openstack服务。& ?2 L* l% {$ F; \7 F
    apt-get install -y mysql-server
    ( C! o* U3 M& j创建monasca数据库架构,在此处下载mon.sql( https://raw.githubusercontent.com/stackforge/cookbook-monasca-schema/master/files/default/mysql/mon.sql: \7 d7 }" O1 g5 z  r
    mysql -uroot -ppassword < mon_mysql.sql
  • 安装Zookeeper 安装Zookeeper并重新启动它。我使用本地主机接口,并且只有一个Zookeeper,因此默认配置文件不需要配置。% G3 R3 W+ f* P& {5 g$ e
  apt-get install -y zookeeper zookeeperd zookeeper-bin  service zookeeper restart
' ^* b1 Z8 ^3 Y
  • 安装和配置kafka% i# X; x8 B5 z" q8 k# X/ I
    wget http://apache.mirrors.tds.net/kafka/0.8.1.1/kafka_2.9.2-0.8.1.1.tgz
    ; A# i, |' t  x2 e. _mv kafka_2.9.2-0.8.1.1.tgz /opt
    * d8 G5 x# C& Zcd /opt
    * e2 d; ?7 {2 p& t8 e7 Ftar zxf kafka_2.9.2-0.8.1.1.tgz
    1 T* U4 h$ Q8 O7 B9 F! Z5 R* Xln -s /opt/kafka_2.9.2-0.8.1.1/ /opt/kafka) p% M) h1 w7 y3 Y/ Q" O
    ln -s /opt/kafka/config /etc/kafka' H, \7 U+ y) H( w* O4 h
    创建kafka系统用户,kafka服务将以该用户身份启动。/ V1 d5 y) f. s( {2 m# `
    useradd kafka -U -r4 K/ W- W0 Y( L' X( n' {. O9 c
    在/etc/init/kafka.conf中创建kafka启动脚本,将以下内容复制 到/etc/init/kafka.conf中并保存。1 I  b  x/ L9 S/ q
    description "Kafka"- P# ^  G5 j" b2 M! t$ c3 o
    & ^* Z3 U, b" ^/ _( a* U
    start on runlevel [2345]
    / D8 Y$ x6 K# E$ o2 m2 [" Pstop on runlevel [!2345]0 o# }4 d  @$ V8 p* b) M
    ; w, o! n$ I" Q9 F) G
    respawn
    / l( |9 R, L! p
    . u0 k: [! b$ e7 C+ slimit nofile 32768 327680 y6 [, N+ @4 |1 P$ I) _
    # `. G( j( P6 W6 q: s8 u
    # If zookeeper is running on this box also give it time to start up properly% e4 R" f9 w5 y- G  C! K0 ?
    pre-start script
      e6 Q! [& b2 |1 Z0 oif [ -e /etc/init.d/zookeeper ]; then
    % w! c# M/ n: P$ K/etc/init.d/zookeeper restart
    3 h$ M. K5 J0 l& H1 ?fi' d( O' s# B# B
    end script' W; Z% Y& j% t/ Y0 ?  H5 x

      X/ }9 t7 _! F  o# Rather than using setuid/setgid sudo is used because the pre-start task must run as root, h9 |$ x; v; p
    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
    5 Q3 ]' D5 B" p  X配置kafka,vim /etc/kafka/server.properties,确保配置了以下内容:
    ) J0 ~6 Q3 ]  K- Xhost.name=localhost5 O: T( P4 U+ ?; t
    advertised.host.name=localhost* B% _* B; j5 O0 x! a4 S
    log.dirs=/var/kafka9 {" [3 I; u4 t
    创建 kafka log目录  q: Q: X% A" j$ x7 P3 X6 o
    mkdir /var/kafka
    . s6 Z/ l6 |$ H6 A; t2 Wmkdir /var/log/kafka
      i7 G' z0 `' G8 S9 E/ q$ B; zchown -R kafka. /var/kafka/
    3 v* W8 _- L1 R4 W; i7 Echown -R kafka. /var/log/kafka/
    5 g: {  R) N% H7 z3 \* E启动kafka服务
    1 w! b5 o& O1 y3 Fservice kafka start
    - C2 S8 S1 D; N+ [' P下一步就是创建 kafka topics
    ) @) E( R; {& Z5 F. U  u8 m; o  P/opt/kafka/bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 64 --topic metrics
    : o8 i7 l" y" u( B2 @0 b/opt/kafka/bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 12 --topic events
    5 ]* b- b0 j$ W$ A+ E/opt/kafka/bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 12 --topic raw-events; G- w8 U- x* m( f4 T
    /opt/kafka/bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 12 --topic transformed-events# I  e+ y1 ?0 e5 e2 P" V
    /opt/kafka/bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 12 --topic stream-definitions
    8 z$ q' P, t, S" b5 j/opt/kafka/bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 12 --topic transform-definitions! p. U1 u  s; C3 H" z# g: y7 L
    /opt/kafka/bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 12 --topic alarm-state-transitions& ~" Z) d9 [" R7 f  Q7 B
    /opt/kafka/bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 12 --topic alarm-notifications
    ) J" V2 {' u' L$ w- J/opt/kafka/bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 12 --topic stream-notifications
    5 t$ g9 \, c* v3 S0 _6 g* {/opt/kafka/bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 3 --topic retry-notifications
  • 安装和配置 influxdb$ ?3 s8 F8 Y  ^; o6 y
    curl -sL https://repos.influxdata.com/influxdb.key | apt-key add -
    : e2 b8 k! a8 Q+ e; h' ?" i- ]echo "deb https://repos.influxdata.com/ubuntu trusty stable" > /etc/apt/sources.list.d/influxdb.list1 e4 t* ^5 I! p) F! Q4 }' ]' T
    apt-get update1 m9 u, P# U% Z- f
    apt-get install -y apt-transport-https
    ; _: M; j( s% Wapt-get install -y influxdb0 E! b  y& M. P6 d
    - f1 b- G7 ?( D
    service influxdb start
    $ K3 l. f9 X2 F+ ~7 z创建 influxdb database, user, password, retention policy, 同时修改密码。
    ' v9 r+ m/ l& N3 y" {6 N! v" ?influx2 d! y, o+ D+ Y! X) a0 t1 `; e
    CREATE DATABASE mon# |" ^+ ~; b: U8 _* F" T
    CREATE USER monasca WITH PASSWORD 'tyun'
    5 G# r1 f2 a! B( C1 G" n4 VCREATE RETENTION POLICY persister_all ON mon DURATION 90d REPLICATION 1 DEFAULT
    4 t3 E- E! G5 P+ G; Dexit
  • 安装与配置 storm
    ! H5 C' u* J6 owget http://apache.mirrors.tds.net/storm/apache-storm-0.9.6/apache-storm-0.9.6.tar.gz& O4 `9 K7 N5 n  }
    mkdir /opt/storm+ e$ u4 X1 C% o4 I7 x' S$ Q, X
    cp apache-storm-0.9.6.tar.gz /opt/storm/3 c. b* V! V$ G8 ]- j0 z
    cd /opt/storm/+ |4 W$ d& j( o
    tar xzf apache-storm-0.9.6.tar.gz
    ' V& P# C5 S) {: e( U4 f$ j, gln -s /opt/storm/apache-storm-0.9.6 /opt/storm/current  W5 n+ B$ ?2 [* h0 g( d! s

      v2 s; W9 t# [! U1 E4 ?8 museradd storm -U -r! ?+ X$ H* `5 m: M1 j, |
    mkdir /var/storm- [7 i0 n% G; K( k2 y( _
    mkdir /var/log/storm
    % w+ D8 j7 A  kchown -R storm. /var/storm/4 c  f. {: L+ x7 Q( ^" @, G. y* H
    chown -R storm. /var/log/storm/) ^, E8 u3 j, x' t4 \+ i, m: @
    修改storm.yaml, vim current/storm/conf/storm.yaml0 s- e$ m; ^/ \
    ### base
    & c4 Q, l& M0 w: Z4 Fjava.library.path: "/usr/local/lib:/opt/local/lib:/usr/lib"
    : o. x$ V9 f# fstorm.local.dir: "/var/storm"
    ; o; a( j! Z( _/ M& y7 c, n8 e* C
    ) D2 v  R. j8 M8 }: U1 k### zookeeper.*
    . b1 g: j$ ?: J% [" V" `9 {) Nstorm.zookeeper.servers:! k( [5 _& I7 F  ]& ?" O0 ?6 A
    - "localhost"
    * I' w6 T4 n; J) U& h$ ^; A$ n' ]storm.zookeeper.port: 2181+ H; O6 u/ c8 P) ^( E7 ?
    storm.zookeeper.retry.interval: 5000. D( Q# {  E+ s  O; _
    storm.zookeeper.retry.times: 29
    - y: o4 N. _8 \% A; D' e$ A  i6 Ostorm.zookeeper.root: "/storm"3 ~: X* a2 S& d0 R( r5 E% N' L
    storm.zookeeper.session.timeout: 30000
    " s9 S7 s+ r; A( h
    3 z5 ^% v" R( R. C### supervisor.* configs are for node supervisors
    1 O3 V6 U8 ], g+ n# Psupervisor.slots.ports:1 O/ g* b0 I. q# `7 V5 }) t
    - 6701' x( ^' V- S; v6 g* _$ a
    - 67025 _: N' v; }6 O/ U4 h( L- `. C
    - 6703
    # W( B. h% @! d) v- 6704
    ( S" W3 G/ u; q2 i* P3 f, `; p6 Qsupervisor.childopts: "-Xmx1024m"& v: @$ R1 {5 N

    ! @9 F% E5 {+ V7 }9 @### worker.* configs are for task workers4 W9 ]4 S3 Y/ ]6 U! b% x' l& \
    worker.childopts: "-Xmx1280m -XX:+UseConcMarkSweepGC -Dcom.sun.management.jmxremote"
    ) W6 f3 Z7 A8 G% o
    " x: z0 v& o9 l. ^& H9 A### nimbus.* configs are for the masteri
    4 J" r- k7 ?0 A* I; o8 i2 rnimbus.host: "localhost"
    % M+ P% I* i% u. _% \nimbus.thrift.port: 66277 h' h6 ], F5 I7 f3 W! x
    mbus.childopts: "-Xmx1024m"0 ~+ U0 l" D' M, c+ l

    8 k; x: b( {" r3 }- h1 |### ui.* configs are for the master
    * a* f4 f) v: N; h$ O; ?ui.host: 127.0.0.1! I8 E4 M7 S1 u. J8 V* G3 _
    ui.port: 8078
    - G! Y& K9 ^1 {; M' I+ Rui.childopts: "-Xmx768m"
    6 I6 l$ R4 U1 w, c  B+ [) Y- C. W' {, A6 ~2 s  H8 Z
    ### drpc.* configs$ @; L7 E, F# I+ K2 r/ _
    0 l$ E8 s) I8 e+ x
    ### transactional.* configs
      i  W( K3 ]* V' p& K9 C2 P7 _- P% _transactional.zookeeper.servers:; W" B# F2 K0 V3 k
    - "localhost"
    - T& D9 ?- H% ?: |transactional.zookeeper.port: 2181
    9 U* M, J( f. T4 _' R! p$ S/ htransactional.zookeeper.root: "/storm-transactional"
    + H; t$ z# V8 l" f& r2 ]
      P* E1 j- l1 }, ~7 X  ?" _" P4 Q### topology.* configs are for specific executing storms
    % A7 E( N+ q# E/ A4 s+ f* o; `) c, jtopology.acker.executors: 1
    0 w1 l$ s( F5 X4 o0 }# htopology.debug: false5 [( R" x. K; n& B! Q; L
    9 D5 D* a0 l' _, u9 P3 A* K
    logviewer.port: 8077
    3 k7 I$ I3 e" d$ vlogviewer.childopts: "-Xmx128m"0 m! T9 A7 |( i& F8 f  L) Z) q
    创建storm supervisor 启动脚本,vim /etc/init/storm-supervisor.conf
    0 Y' O5 E! a' d  n! }! R5 K. q4 C# Startup script for Storm Supervisor
    + e2 P0 _% i: L9 f( S" T- s1 A
    ! g) U  w; Q( f3 V4 q: `description "Storm Supervisor daemon"
    6 r" {5 _0 q$ v# nstart on runlevel [2345]
    : _+ u  i9 r: {1 ?" x, l( k8 @- ]" Z' A4 F0 i5 n, a
    console log6 M# B& Y" v1 X5 {( N' Y
    respawn
    ! g' ]3 Z1 A" `7 z' S% J& S7 l
    kill timeout 240& q+ F& e+ n# q/ M# j- J( h& W/ K9 Y  b
    respawn limit 25 54 F. q' |. T- Q" w+ U8 i' X( K; X$ j- l
    . q) n! m+ G* ?8 ~. _( d( |
    setgid storm
    9 ^8 L# H6 L5 v  N  [9 Msetuid storm
    # T: q. j- m6 W+ y# T7 h) {chdir /opt/storm/current
    " L4 l" w/ s# u4 w  _exec /opt/storm/current/bin/storm supervisor
    3 `4 S7 d7 e/ `; O/ X8 M创建Storm nimbus 启动脚本。vim /etc/init/storm-nimbus.conf4 J2 t  K% m' I7 s, U
    # Startup script for Storm Nimbus8 v4 L, I. x8 S
    ( j) F$ P9 r3 U3 B
    description "Storm Nimbus daemon"
    ; j: ?" A6 o- I$ t" O3 x3 N; }start on runlevel [2345]
    : Z  \2 ^# i. ~  I; R$ d! b7 E! M4 n- a- u
    console log
    4 q% ~7 t! k' ?, M( x8 Erespawn
    6 ^$ f1 b8 I& }/ k* s, w3 v2 |, X1 u1 }
    , K3 T9 A( q8 B9 z; h9 s. _0 xkill timeout 2405 D6 Z1 z& W% y$ T8 c1 ]7 O3 c
    respawn limit 25 56 v3 d/ k- B9 _

    9 N9 |  ?9 V' N# p6 Bsetgid storm0 k4 B. H& z9 e4 n4 t
    setuid storm" u5 x; d( A" W5 V: H! ]  |* {
    chdir /opt/storm/current
    0 N! q* x; [) |* Q9 B+ sexec /opt/storm/current/bin/storm nimbus
    9 o0 u% k! t* F. i启动supervisor 与 nimbus: O4 \( ?7 T/ Y1 u" i3 Z+ J
    service storm-supervisor start. t; s, ^. Z6 l4 V3 y# h0 @
    service storm-nimbus start
  • 安装monasca api python软件包$ {( u4 x- l3 z
    一些monasca组件同时提供python和java代码,主要是我选择python代码进行部署。
    ' f" {/ F; N; G$ b' Y! J+ q! _pip install monasca-common- a4 \2 q% }( W4 W5 z( i7 t) y
    pip install gunicorn
    7 P; R6 B9 ]3 m0 Tpip install greenlet # Required for both
      [: u& q7 f# V' d( G/ O  [pip install eventlet # For eventlet workers
    9 K- G3 U3 e  I8 g0 G& p& Mpip install gevent # For gevent workers2 z6 J2 J8 L$ _& b1 [
    pip install monasca-api
    4 e) H# F& W. j  f" Tpip install influxdb
    7 ?+ Q% m3 T: C$ z6 J% Kvim /etc/monasca/api-config.ini,将主机修改为您的IP地址
    ; x3 W3 j6 I' g) q" r7 z6 c[DEFAULT]
    1 z8 w, p# P1 r7 h- {3 xname = monasca_api9 |( A2 a% z0 Y1 G+ j2 l$ ~
    2 M+ v% n7 X7 @+ b9 j. O9 P
    [pipeline:main]; I* J5 U' |- F
    # Add validator in the pipeline so the metrics messages can be validated.
    & |4 U  {7 g; Apipeline = auth keystonecontext api
    7 `, B9 ?  z& S. |! y& i: U. c& u2 \" t
    [app:api]9 Z% r& b: D; s6 g
    paste.app_factory = monasca_api.api.server:launch
    0 V  n7 w$ j) p, F8 _* w8 x% G$ f$ E, y# }
    [filter:auth]
    , `$ q3 F6 j5 ^* C, x* M; Vpaste.filter_factory = keystonemiddleware.auth_token:filter_factory6 b! ]2 }6 w% |+ Z, g( g/ k" _

      A2 f3 V8 C$ @" P4 f1 P[filter:keystonecontext]1 G7 C! I2 v$ B; W7 y0 c
    paste.filter_factory = monasca_api.middleware.keystone_context_filter:filter_factory
    & E& [( h1 P' a) c" J' \
    & R" g6 Z& Z. Z% M% m+ z! _+ X* T[server:main]
    " `7 A. d: v; p  buse = egg:gunicorn#main
    ) V$ N/ S! ~' y4 b( Xhost = 192.168.2.23
    5 K) t9 E  k* H% h# _" y( S% U# dport = 80820 v; w0 C+ T  w6 f/ l! p4 q
    workers = 1
    5 Z' H1 Y9 y$ A& ~+ cproc_name = monasca_api% Q/ i- e& k1 k5 G$ [2 H! y6 O2 v
    vim /etc/monasca/api-config.conf,修改以下内容7 j# W3 @5 I3 W) V; P
    [DEFAULT]: Q) e. ?0 R' ]: [$ V
    # logging, make sure that the user under whom the server runs has permission+ D$ c; r3 e2 G4 p. @
    # to write to the directory.
    $ P5 f" Y) i& clog_file = monasca-api.log5 X+ u- f- W6 G: w% v
    log_dir = /var/log/monasca/api/
    ; _: F. s* j% x' b, S/ V( [" edebug=False5 |1 d) ^' d0 C4 K8 J
    region = RegionOne: \4 e" R) @. d5 {, P9 C" q
    [security]( J% i% y6 N/ ?0 q; {
    # The roles that are allowed full access to the API.% c2 ]' L0 @' j, h) U
    default_authorized_roles = admin, user, domainuser, domainadmin, monasca-user
    , y! M/ ?" Q, c. g
    ) n% k( O8 l! P# The roles that are allowed to only POST metrics to the API. This role would be used by the Monasca Agent.- q' C- R" w7 L, Q7 O) O
    agent_authorized_roles = admin
    5 R# ~7 s3 m# Y$ w" j" p3 D3 b
    " R' `  t  @' W/ S8 c' n3 S  ^# The roles that are allowed to only GET metrics from the API.
    8 k, w2 v+ u  m- g+ Sread_only_authorized_roles = admin; Z: m  `4 Q7 [: h0 j* y8 M! {
    + ^0 [' y* b/ q
    # The roles that are allowed to access the API on behalf of another tenant.
    1 y  @& T2 L( ~0 r% g. v4 R# For example, a service can POST metrics to another tenant if they are a member of the "delegate" role.) Q: S: T' v9 O
    delegate_authorized_roles = admin
    $ A8 @: {& [' R: c1 W, n; E
    " U9 s0 C1 X' \) ~[kafka]
    8 E9 {+ H" @& O, G' t' c6 x# The endpoint to the kafka server4 Q- B# m: T- {
    uri = localhost:9092
    ' Z5 {. N, J( A+ b! X' k: e# h5 B/ Z# {) x# t/ Z* r6 O& |+ y. g
    [influxdb]
    3 X" }. d7 ^0 _' E  ?# Only needed if Influxdb database is used for backend., n4 F& S' J, o8 k! u
    # The IP address of the InfluxDB service.
    1 D9 A2 w% x7 {( Vip_address = localhost
    2 c# \* q8 C/ J. k4 i5 T' a+ m0 @: K+ s5 o
    # The port number that the InfluxDB service is listening on.# V; {% B) L8 s( C  B
    port = 80863 [' K- O  Q$ c) K1 n  l  E

    - j" g* g( C: P+ l& l' i# The username to authenticate with.
    . V* J9 R  {3 Puser = monasca/ z7 Y2 [+ T' K, A  H& [4 I
    ! ~% L) @/ q! R1 u" W4 Q
    # The password to authenticate with.
    7 a: V4 q; s" X' {& s! \+ c; npassword = tyun5 H& J" g8 T- z
    0 ?8 U; x5 z' B) S$ h  b
    # The name of the InfluxDB database to use.5 [# ~* @3 a: f" R
    database_name = mon
    4 w& I' y# \% Z! f2 V6 c- r  }
    [database]) h6 _: I* v9 }% E) }
    url = "mysql+pymysql://monasca:tyun@127.0.0.1/mon"
    7 l" B9 S9 V/ |2 ?- |+ t% q" r6 S1 m

      R) c; d8 @; G! s( Z9 [[keystone_authtoken]
    + e% ?# T' J) M5 c  tidentity_uri = http://192.168.1.11:35357
    - H* l! c9 F" qauth_uri = http://192.168.1.11:5000
    4 P% ?; }9 h* O( n8 L; Oadmin_password = tyun5 [; |. U, N* J( e9 x3 ?
    admin_user = monasca3 U3 ?& G1 J* A$ s
    admin_tenant_name = service
    ; W" q  ~; h2 z% k* Z* }: p1 q3 Fcafile =. t9 t7 [+ x( l% r
    certfile =" Z" u- ]# h7 ?
    keyfile =
    " S) f1 b- q6 U+ B$ A: ~insecure = false
    6 e, M% R; @- w) U. B注释掉[mysql]部分,其他部分保持默认。( W1 V- g/ {% I9 P
    创建monasca系统用户并进入目录
    % _$ H, }8 h  @: kuseradd monasca -U -r4 J) N# S) {9 S; T6 q. O! O
    mkdir /var/log/monasca: f% S0 d, D1 R/ Y0 H; _. w8 m
    mkdir /var/log/monasca/api! G; N& }/ h$ ~. d3 x
    chown -R monasca. /var/log/monasca/8 b. Z/ E& ^# w) @" J" s* S
    在openstack控制器节点上,创建monasca用户密码,为租户服务中的用户monasca分配管理员角色。
    3 N+ S" r7 H7 ~4 s  I8 U/ R8 vopenstack user create --domain default --password tyun monasca3 {; M6 S1 Z- n3 M( p( D
    openstack role add --project service --user monasca admin
    5 I- b# E$ b1 @% H5 N- b0 C1 Q  V/ ]" i: S' t
    openstack service create --name monasca --description "Monasca monitoring service" monitoring) U0 n6 f! b2 ?3 @
    ! |: Y: k5 l4 G
    create endpoint" N6 T7 M0 I1 K2 |, x
    openstack endpoint create --region RegionOne monasca public http://192.168.1.143:8082/v2.0; B  _0 q: R- }- Y7 p1 w5 c
    openstack endpoint create --region RegionOne monasca internal http://192.168.1.143:8082/v2.04 z8 [8 J: Y9 T! a
    openstack endpoint create --region RegionOne monasca admin http://192.168.1.143:8082/v2.0
    8 a4 H( K# s; Y9 d4 E2 E192.168.1.143是我的api虚拟机地址的浮动IP,请将其更改为您的IP。
    . r0 n) V" j: o- g+ g: P创建monasca api启动脚本,vim /etc/init/monasca-api.conf& D6 q; d8 j, m& q; n- S
    # Startup script for the Monasca API
    $ |, L8 m% t7 U. d
    $ F# c# G5 i3 y' P" J: l% ydescription "Monasca API Python app"
    : U# ]6 E% y8 }- z7 D, `) b# qstart on runlevel [2345]
    % o# r& z" J* d, r1 d2 {( L- ^2 Y8 _" W" \! ~& J# y
    console log
    / w, g- H# |& u5 F! i9 K: Erespawn3 x- l' N; X, k9 _# W. v. L9 o) T

    9 I9 e% N7 b' M, H1 r, Tsetgid monasca
    ) O  q8 S% y) ?setuid monasca% q0 M+ ]8 V$ `* l+ O$ g
    exec /usr/local/bin/gunicorn -n monasca-api -k eventlet --worker-connections=2000 --backlog=1000 --paste /etc/monasca/api-config.ini
  • 安装monasca-persister  S7 G/ o3 f, J  y: F
    创建monasca-persister启动脚本& E( p. h2 `+ a: T9 }0 c. i
    vim /etc/init/monasca-persister.conf6 Y* p( J3 |/ c. V( s' R
    # Startup script for the Monasca Persister
    9 n' _5 Y/ P) J& }/ b" Z, C1 U7 a2 [; P3 N
    description "Monasca Persister Python app". ]4 a# N8 g" y
    start on runlevel [2345]
    & u: Q$ N; e. o/ d- A6 |% f: K0 V, k7 ~! L$ d( s4 _0 ^& S
    console log
    0 c+ T/ x5 H, ]/ H8 b+ R- S4 krespawn5 ~; U  ~' |; h! w

    : q4 Q& E: }* \* |( p- usetgid monasca, W8 s2 h) \" B3 [3 k4 ]9 q
    setuid monasca
    $ Y5 K, @" T7 h) q% ^* Hexec /usr/bin/java -Dfile.encoding=UTF-8 -cp /opt/monasca/monasca-persister.jar monasca.persister.PersisterApplication server /etc/monasca/persister-config.yml
    : ^) Z, J+ Y. S' r+ @' M7 D启动monasca-persister" j/ R) }# J0 @- V" l
    service monasca-persister start
  • 安装monasca-notificatoin4 @% a* f- C3 l/ _  u
    pip install --upgrade monasca-notification/ z  P7 k. e! U: J
    apt-get install sendmail
    / O/ `  Z& [, c) K$ S7 y将notification.yaml复制到/etc/monasca/ 创建启动脚本,vim /etc/init/monasca-notification.conf
    6 N# g4 U  N9 e! e/ Z8 r# Startup script for the monasca_notification
    $ s8 Z; X3 V* O1 [, e- i8 p# Z5 K
    . n. ~; ?. Z4 Adescription "Monasca Notification daemon"
    $ o" B% }1 p( |6 ~/ _. Dstart on runlevel [2345]3 ?9 J. B1 X; S; i3 Q

    9 S0 L- @& q' m( [; I' F8 Iconsole log
    - X( R* m7 b- ~9 K) g" O8 frespawn$ c! e2 q: @/ s& O+ k% I
    : w) @9 G& }8 g( ~! z
    setgid monasca
    3 A8 X- K1 e4 D- x) Nsetuid monasca
    0 _/ E$ A7 ]2 X/ A8 z0 H8 cexec /usr/bin/python /usr/local/bin/monasca-notification- s# A- P7 e, P8 `: H
    启动通知服务
    / z% s' e# N# L% r( U8 T+ ~service monasca-notification start
  • 安装monasca-thresh 复制monasca-thresh到/etc/init.d/ 复制monasca-thresh.jar到/opt/monasca-thresh/ 复制thresh-config.yml到/etc/monasca /并修改主机以及数据库信息 启动monasca-thresh2 |! F! V6 Q# v. z% _+ [
    service monasca-thresh start
  • 安装monasca-agent6 Z# g2 i# A8 g
    在openstack控制器节点上安装monasca-agent,以便它可以监控openstack服务进程。
    , X3 H' b+ O5 \4 f( n0 Dsudo pip install --upgrade monasca-agent
    7 v4 r* \, ~. D# C9 [设置monasca-agent,将用户域ID和项目域ID更改为默认值。2 i9 ?8 m% s: H1 ]. J0 z
    monasca-setup -u monasca -p tyun --user_domain_id e25e0413a70c41449d2ccc2578deb1e4 --project_domain_id e25e0413a70c41449d2ccc2578deb1e4 --user monasca \
    1 W( P- I0 W; q3 m--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
    & d2 o, {& P7 `; }3 L4 s  V: K# K加载认证脚本admin-rc.sh,然后运行monasca metric-list。
    , W' F; u1 s4 Y/ J: T$ G
% I% \; Q2 s. f( P1 k
DevStack安装
运行Monasca DevStack至少需要一台具有10GB RAM的主机。
可在此处找到安装和运行Devstack的说明:
https://docs.openstack.org/devstack/latest/
: k" e+ F9 |% v) Y1 p1 M
要在DevStack中运行Monasca,请执行以下三个步骤。
  • 克隆DevStack代码库。8 k& p0 P9 t3 ~7 n# w1 Q
git clone https://git.openstack.org/openstack-dev/devstack
$ b2 E/ A8 g& x! g( o, L; d
  • 将以下内容添加到devstack目录根目录中的DevStack local.conf文件中。如果local.conf不存在,则可能需要创建它。; |$ ~* p+ i0 _* S
# BEGIN DEVSTACK LOCAL.CONF CONTENTS​[[local|localrc]]DATABASE_PASSWORD=secretdatabaseRABBIT_PASSWORD=secretrabbitADMIN_PASSWORD=secretadminSERVICE_PASSWORD=secretserviceSERVICE_TOKEN=111222333444​LOGFILE=$DEST/logs/stack.sh.logLOGDIR=$DEST/logsLOG_COLOR=False​# The following two variables allow switching between Java and Python for the implementations# of the Monasca API and the Monasca Persister. If these variables are not set, then the# default is to install the Python implementations of both the Monasca API and the Monasca Persister.​# Uncomment one of the following two lines to choose Java or Python for the Monasca API.MONASCA_API_IMPLEMENTATION_LANG=${MONASCA_API_IMPLEMENTATION_LANG:-java}# MONASCA_API_IMPLEMENTATION_LANG=${MONASCA_API_IMPLEMENTATION_LANG:-python}​# Uncomment of the following two lines to choose Java or Python for the Monasca Pesister.MONASCA_PERSISTER_IMPLEMENTATION_LANG=${MONASCA_PERSISTER_IMPLEMENTATION_LANG:-java}# MONASCA_PERSISTER_IMPLEMENTATION_LANG=${MONASCA_PERSISTER_IMPLEMENTATION_LANG:-python}​# Uncomment one of the following two lines to choose either InfluxDB or Vertica.# default "influxdb" is selected as metric DBMONASCA_METRICS_DB=${MONASCA_METRICS_DB:-influxdb}# MONASCA_METRICS_DB=${MONASCA_METRICS_DB:-vertica}​# This line will enable all of Monasca.enable_plugin monasca-api https://git.openstack.org/openstack/monasca-api​# END DEVSTACK LOCAL.CONF CONTENTS1 P. n4 O" @  A, j( H: H
  • 从devstack目录的根目录运行“ ./stack.sh”。
      g  S! j+ t! r3 |" ]. R, C
如果要使用最少的OpenStack组件运行Monasca,可以将以下两行添加到local.conf文件中。
disable_all_servicesenable_service rabbit mysql key6 A6 N% c5 R+ K/ [
如果您还希望安装Tempest测试,请添加 tempest
enable_service rabbit mysql key tempest6 P4 M3 x4 ^: M" _2 Q" K
要启用Horizon和Monasca UI,请添加 horizon
enable_service rabbit mysql key horizon tempest
) t1 d3 Y7 X2 F; Q$ _& l! F使用Vagrant
Vagrant可用于使用Vagrantfile部署运行有Devstack和Monasca的VM。安装Vagrant后,只需在../monasca-api/devstack目录中运行vagrant up命令。
要在devstack安装中使用本地代码库,请将更改提交到本地存储库的master分支,然后在配置文件中修改与要使用的本地存储库相对应的变量file://my/local/repo/location。要使用monasca-api repo的本地实例,请将更改enable_plugin monasca-api https://git.openstack.org/openstack/monasca-api为enable_plugin monasca-api file://my/repo/is/here。这两个设置仅在重建devstack VM时生效。
  • 使用Vagrant将Vertica启用为Metrics DB
    . x5 B& I' J# B7 mMonasca支持同时使用InfluxDB和Vertica来存储指标和告警状态历史记录。默认情况下,在DevStack环境中启用InfluxDB。5 H# F) j0 {+ p4 K2 R
    Vertica是Hewlett Packard Enterprise的商业数据库。可以下载免费的Community Edition(CE)安装程序,要启用Vertica,请执行以下操作:3 P8 ~5 \/ y' V' T$ w2 D; O; a
  • 注册并下载Vertica Debian安装程序https://my.vertica.com/download/vertica/community-edition/,并将其放在您的主目录中。不幸的是,DevStack安装程序没有可以自动使用的URL,因此必须单独下载该URL,并将其放置在安装程序运行时可以找到它的位置。安装程序假定此位置是您的主目录。使用Vagrant时,您的主目录通常将以“ /vagrant_home”挂载在VM内。
  • 修改local.conf中MONASCA_METRICS_DB变量,配置Vertica的支持,如下所示:$ w0 u& }, X* i" C; D
    MONASCA_METRICS_DB=${MONASCA_METRICS_DB:-vertica}
    ! }3 [- E7 K% q( u" l2 t# I
5 V+ L0 Q3 q* m$ B  W& x
  • 使用PostgreSQL或MySQL
    8 V. s: d* q! g+ g$ u2 [( r. ?Monasca支持使用PostgreSQL和MySQL,因此该devstack插件也支持。启用postgresql或mysql。7 h7 F0 k# o. D- _* p0 l) ~: j
    要使用MySQL设置环境,请使用:& |" z# j- J6 V& Y+ B6 l
    enable_service mysql
    1 ^9 ^; _) C) g2 u1 }* d, [另外,对于PostgreSQL,请使用:
    + S& o/ k' K  Y! Kenable_service postgresql
  • 使用ORM支持
    % D1 C2 n3 E+ J. O3 w  t- g& v; cORM支持可以通过MONASCA_DATABASE_USE_ORM变量来控制。但是,如果启用了PostgreSQL(也称为数据库后端),则将强制提供ORM支持4 s1 ~" D" E7 @# k. r
    enable_service postgresql
  • 加强Apache镜像7 Q2 K7 s" U6 N2 I3 x
    如果由于某种原因APACHE_MIRROR而无法使用,则可以通过以下方式强制执行:3 t1 v5 x( @# ?
    APACHE_MIRROR=http://www-us.apache.org/dist/
  • 使用WSGI
    3 A$ D/ ^! U1 B# aMonasca-api可以使用uwsgi和gunicorn与Apache一起部署。默认情况下,monasca-api在uwsgi下运行。如果您想使用Gunicorn,请确保其中devstack/local.conf包含:! U: r6 @( I; ~! _& X7 K
    MONASCA_API_USE_MOD_WSGI=False: V$ x$ P7 {) E4 m+ E' d- ^
使用Monasca Dashboard
安装完成Monasca Dashboard Plugin后,可以通过web控制台进行查看以及管理相应的监控与告警。
在操作控制台的“Monitoring”栏,单击“Launch Monitoring Dashboard“,这将打开在管理节点上运行的专用OpenStack Horizon门户。
在该面板中,您可以:
  • 单击OpenStack服务名称,以查看服务告警。
  • 单击服务器名称以查看相关设备的告警。- E. _; r; Y* f# m: ]9 o# u
监控信息存储在两个数据库中(Vertica/influxdb与mysql)。备份监控数据时,将同时备份两个数据库。看到
  • 监控指标在Vertica中存储7天。
  • 配置设置存储在MySQL中。
  • 如果监控节点上的服务在高负载(例如15个控制网络和200个计算节点)下停止,则消息队列将在大约6个小时内开始清除。2 I0 C- j) P* [8 c0 A. s- ?
您需要登录后才可以回帖 登录 | 注册

本版积分规则

返回首页|Archiver|手机版|小黑屋|易陆发现技术论坛 ( 蜀ICP备2026014127号-1 )

GMT+8, 2026-6-12 01:17 , Processed in 0.018111 second(s), 22 queries .

Powered by Discuz! X5.0

© 2001-2026 Discuz! Team.

快速回复 返回顶部 返回列表