找回密码
 注册
查看: 613|回复: 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节点。它们在同一子网中。
  • 安装我们需要的软件包和工具
    8 ~  U' g+ `, Y, hapt-get install -y git
      @' m$ b) r2 s6 Bapt-get install openjdk-7-jre-headless python-pip python-dev
  • 安装mysql数据库 如果您在openstack控制器节点中安装了monasca-api,则可以跳过安装,将已安装的msyql用于openstack服务。
    $ i  l$ w4 ^. K. h5 S5 m- r4 mapt-get install -y mysql-server
    / {3 r- H2 L1 ]+ f6 _创建monasca数据库架构,在此处下载mon.sql( https://raw.githubusercontent.com/stackforge/cookbook-monasca-schema/master/files/default/mysql/mon.sql
    0 O: f( C9 k7 r  S$ x$ R5 dmysql -uroot -ppassword < mon_mysql.sql
  • 安装Zookeeper 安装Zookeeper并重新启动它。我使用本地主机接口,并且只有一个Zookeeper,因此默认配置文件不需要配置。
    & }/ i# Q5 r1 `. \! g
  apt-get install -y zookeeper zookeeperd zookeeper-bin  service zookeeper restart
$ z! X! h0 h/ c, [& E
  • 安装和配置kafka' H+ p. v; Q  [; g! z! \
    wget http://apache.mirrors.tds.net/kafka/0.8.1.1/kafka_2.9.2-0.8.1.1.tgz. P; V3 ?2 h' H, @+ }
    mv kafka_2.9.2-0.8.1.1.tgz /opt
    9 o8 U9 `  i5 |1 Scd /opt! o( K# [0 L0 M6 `; S
    tar zxf kafka_2.9.2-0.8.1.1.tgz+ Y! C6 U! g3 f# C" J7 y; ^* k
    ln -s /opt/kafka_2.9.2-0.8.1.1/ /opt/kafka
    6 C4 m" b+ g8 n8 |- {ln -s /opt/kafka/config /etc/kafka9 M# f7 X% n& _
    创建kafka系统用户,kafka服务将以该用户身份启动。$ |8 h. n/ \& v$ |
    useradd kafka -U -r
    4 l- z: G% r* `8 [在/etc/init/kafka.conf中创建kafka启动脚本,将以下内容复制 到/etc/init/kafka.conf中并保存。7 W; `9 u8 s; L1 @" {: v
    description "Kafka"
    # N6 `. ~, D  g( ]
    2 W$ i0 l* N8 S, o. S; v3 H: b5 ustart on runlevel [2345]
    , Y5 E; B2 P) @) R# B" f0 B7 cstop on runlevel [!2345]
    , u% V0 F. z9 C' t% G
    , M. `8 F/ E, o! C6 krespawn9 j% Z; K# d. U9 |# Q  R3 c4 w0 |

    ) j+ w0 J* c( h7 ]1 t& t! c& p. Mlimit nofile 32768 32768$ D9 t5 ^* i3 V

    4 n( n& _% l3 g4 L# If zookeeper is running on this box also give it time to start up properly
    + N: T& S, B& ^8 D' I4 opre-start script
    # F$ ~8 R) H4 T7 sif [ -e /etc/init.d/zookeeper ]; then1 v7 h& L# B- S$ l+ M
    /etc/init.d/zookeeper restart
    ' B2 P# {2 Q  K( T' p' L) Sfi0 ?5 C- b1 o& t, D. ~( \  a0 n$ t
    end script
    8 f: T8 u# c* \, u# X6 z
    , y7 u! }  ]4 \9 {% n3 k# Rather than using setuid/setgid sudo is used because the pre-start task must run as root" h4 P' K& M# P. c5 b( U5 F( i
    exec sudo -Hu kafka -g kafka KAFKA_HEAP_OPTS="-Xmx1G -Xms1G" JMX_PORT=9997 /opt/kafka/bin/kafka-server-start.sh /etc/kafka/server.properties2 o8 X, B% \- w) E. }/ l* W
    配置kafka,vim /etc/kafka/server.properties,确保配置了以下内容:+ G( y: D7 f. b1 e
    host.name=localhost
    ) K9 }( R$ h' T0 I8 ?advertised.host.name=localhost# y8 R! }7 C  o! r' l
    log.dirs=/var/kafka
    " H: o  t- f7 `5 p* @/ m4 ^创建 kafka log目录! E8 R8 U. j4 N0 M' D3 Y) _
    mkdir /var/kafka$ I# ^0 e0 V! S; R) m$ P7 O
    mkdir /var/log/kafka5 z$ Q4 ^) e0 s. @2 G6 i
    chown -R kafka. /var/kafka/) C. N0 q% @/ [; B+ S
    chown -R kafka. /var/log/kafka/, {* N9 H2 J, n2 j
    启动kafka服务2 a4 E" v3 }, A  F$ E
    service kafka start
    6 x/ ]# w% t+ I7 F# ]) K- _下一步就是创建 kafka topics: W- Y3 k7 R( A6 J2 a/ c( H
    /opt/kafka/bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 64 --topic metrics  Q, N" V3 x* p6 G+ q% D
    /opt/kafka/bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 12 --topic events
    " ?2 O: H# p- \. |: P5 A# i/opt/kafka/bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 12 --topic raw-events
    + d: ?7 ]9 m) u7 G# s/opt/kafka/bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 12 --topic transformed-events
    # d' B# x2 l: q8 ]/ a% g( \/opt/kafka/bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 12 --topic stream-definitions9 l# X2 ^) X( h3 Y
    /opt/kafka/bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 12 --topic transform-definitions9 [9 u' W, i  @! G( N2 C0 z
    /opt/kafka/bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 12 --topic alarm-state-transitions
    : S" [$ W: k/ ~! {/opt/kafka/bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 12 --topic alarm-notifications: t; I  w5 t) s/ F4 F
    /opt/kafka/bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 12 --topic stream-notifications
    - R5 i( ]$ F- ~9 j0 E5 M' _2 V( E/opt/kafka/bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 3 --topic retry-notifications
  • 安装和配置 influxdb5 `' B# [& K8 T, _1 V
    curl -sL https://repos.influxdata.com/influxdb.key | apt-key add -% M9 y: ^3 C0 d5 `
    echo "deb https://repos.influxdata.com/ubuntu trusty stable" > /etc/apt/sources.list.d/influxdb.list
    ) T9 }1 c- a! K8 Y! Xapt-get update
    6 Y; r  O/ b+ Xapt-get install -y apt-transport-https
    ) c, ]0 p* ]5 tapt-get install -y influxdb' N8 x) Z$ A. \  B; b
    ; W3 }7 @& L4 [2 ^& d$ ]
    service influxdb start2 v/ T* f3 n( B  c4 z' U2 i! H
    创建 influxdb database, user, password, retention policy, 同时修改密码。
    : b# I4 Y0 ~5 |8 O& ?7 y: z& minflux) J2 ?+ ^* h! u# F& C
    CREATE DATABASE mon& F$ y3 N/ U4 j( }+ W
    CREATE USER monasca WITH PASSWORD 'tyun'
    " E1 j- H# T6 W9 xCREATE RETENTION POLICY persister_all ON mon DURATION 90d REPLICATION 1 DEFAULT
    3 d4 ?3 N1 L; e: g+ Qexit
  • 安装与配置 storm
    9 @: I# i0 `" @% twget http://apache.mirrors.tds.net/storm/apache-storm-0.9.6/apache-storm-0.9.6.tar.gz
    , ^# x' H* `4 L, [0 lmkdir /opt/storm3 J- W# M# \4 R! P0 r# O1 C% z3 G
    cp apache-storm-0.9.6.tar.gz /opt/storm/6 z% ]$ t1 O; C* k, U5 O
    cd /opt/storm/* A: L) e' Y: m* }+ h/ t: r/ w4 G
    tar xzf apache-storm-0.9.6.tar.gz+ }6 V/ s$ q. n4 g6 `) V- O
    ln -s /opt/storm/apache-storm-0.9.6 /opt/storm/current
    6 u2 `4 P- l( y- h3 t- U6 X9 S  a' q4 G* y9 d( `, J
    useradd storm -U -r
    3 z' [  a6 q" O! \% ^" nmkdir /var/storm
    , A0 K% x* ?+ O, }! \  [mkdir /var/log/storm" r# o9 A# i* W& y' b" |0 Q
    chown -R storm. /var/storm/
    % q3 f$ W- y: k" r0 Bchown -R storm. /var/log/storm/* L$ J4 C) K  {8 G8 E: C
    修改storm.yaml, vim current/storm/conf/storm.yaml
    2 C* _! ]1 x/ T- Y) S+ L% }7 `) c2 A### base
    ( l$ T; B/ g- j9 |& L  _0 cjava.library.path: "/usr/local/lib:/opt/local/lib:/usr/lib"/ {2 y) F" p) z) e
    storm.local.dir: "/var/storm"
    2 E) B) K5 M) ?* t+ R$ t  H8 b8 j# `+ n6 \7 `' m
    ### zookeeper.*
    ! |( i( h- r2 R7 Wstorm.zookeeper.servers:/ C# m" h# u* v3 d! s1 G1 O- b
    - "localhost"
    ! P3 v- j/ H' u, v# {storm.zookeeper.port: 2181
    % M0 h, q: J, B9 tstorm.zookeeper.retry.interval: 50000 c, ^: l$ b+ `+ j
    storm.zookeeper.retry.times: 295 w! `7 h$ |% p  P! M1 [1 z
    storm.zookeeper.root: "/storm"
    , {4 C: x- ^# E! w# I, @storm.zookeeper.session.timeout: 30000
    4 {, m0 j; ]4 J& g, q6 |# @9 |" w  y& X# F3 y  r* T
    ### supervisor.* configs are for node supervisors6 p( U& ]+ h5 Z$ U8 W
    supervisor.slots.ports:) S1 k* g# d& V% B8 R6 h
    - 6701% {& Z2 S( v) J( E# t
    - 6702( A! p! V$ Z- Q- e
    - 6703" Z+ G* b* }( I# r4 D
    - 6704' r: |: K+ t' _$ S# q/ _: J
    supervisor.childopts: "-Xmx1024m"+ r* \6 Y6 u2 i$ |1 G

    - H5 M$ L% e9 |3 u) V7 ~1 R8 e+ {! o### worker.* configs are for task workers
    # D. e& b1 x9 b/ M9 y* h* mworker.childopts: "-Xmx1280m -XX:+UseConcMarkSweepGC -Dcom.sun.management.jmxremote") U( w% V9 c5 c" g9 i$ a, R# f2 K
    $ G& o, D8 \) o# |
    ### nimbus.* configs are for the masteri
      M( j( N8 U# w0 inimbus.host: "localhost"
    2 s" G# l/ V4 Dnimbus.thrift.port: 6627
    / N3 k' x6 J2 mmbus.childopts: "-Xmx1024m"5 \* ~- M; t; S2 F
    # Y0 t! n+ n& v# n, _
    ### ui.* configs are for the master# _, o9 P  l& h6 P: Y4 E) |
    ui.host: 127.0.0.1
    + a3 Q4 A9 @! V0 Z# O; q( oui.port: 80788 ~; |  _. a  b. J( o5 e- h" O" x
    ui.childopts: "-Xmx768m"
    5 x6 q& J  n# B+ u0 i  {0 R" g* ?0 U  t9 Y1 C' H6 C) @" I
    ### drpc.* configs
    $ B* k" s( G, p! W9 K. C& S) ~3 u' ^% t/ I! b! f
    ### transactional.* configs
    7 f, Z% A/ a, G  j0 w/ m- ctransactional.zookeeper.servers:
    : j) g$ R1 _# E( x! E3 |- "localhost"
    , B7 O6 s5 _! {2 V) Ntransactional.zookeeper.port: 2181
    * d5 ?6 }2 E4 I; w. }3 [transactional.zookeeper.root: "/storm-transactional". D5 q/ t' X: r4 y
      M+ k  G8 B+ z2 G! a- ]
    ### topology.* configs are for specific executing storms* w3 X) }- t1 Z5 f2 C/ t+ _$ w
    topology.acker.executors: 1) c* m5 o2 u+ _  U  P1 B' p% M
    topology.debug: false6 w0 x8 l% W% q2 l- Y1 ~
    3 O9 D- w. i; {: S- B
    logviewer.port: 8077. m. a% e7 E6 ~& Z  L& z
    logviewer.childopts: "-Xmx128m"
    ; O' V, \+ ]- v/ F  q创建storm supervisor 启动脚本,vim /etc/init/storm-supervisor.conf
      l* s; V2 N5 i: d6 r# Startup script for Storm Supervisor
    ! b" q7 ?" \! ~# A; y- s, u5 V9 |1 Q
    4 N/ Y, `; i) \description "Storm Supervisor daemon"
    ! b- P3 E! w: A+ ?  Istart on runlevel [2345]& N3 p$ K. M& z8 ^  }( i0 J0 [  k

    2 n8 _7 d7 {% Sconsole log
    ' }! h$ ^: ^9 x/ a) \. {respawn3 N# _% n$ }3 ]: d3 e9 E
    0 V! d! a4 K' B# g1 \
    kill timeout 240; P) [; l  @( L, b
    respawn limit 25 5) S3 g5 r) J8 `7 K9 \
    * x$ G# j1 D8 m2 p  f# w4 r9 _/ Q$ I  k
    setgid storm
    5 k& x" I2 y7 Esetuid storm
    # C0 j. h: S: S' k) M+ J7 qchdir /opt/storm/current; [7 k9 O8 ~* ?7 V
    exec /opt/storm/current/bin/storm supervisor$ c- F+ M* {* d2 C% t
    创建Storm nimbus 启动脚本。vim /etc/init/storm-nimbus.conf! D4 U2 }5 @( G! {
    # Startup script for Storm Nimbus5 _) X( s5 |6 D+ Z0 P

    . S+ k0 x1 v+ ], t, x7 Q( q6 b) Vdescription "Storm Nimbus daemon"
    $ I7 U( H! x) [+ lstart on runlevel [2345]
    4 t* b+ J4 `* l  n& M; {9 A1 E9 K8 X& P
    console log9 z8 R4 l8 R9 ?4 _
    respawn5 `- ], F3 O# p! l5 b
    * Z" x4 x& C3 B, Z
    kill timeout 240) h' }8 q+ e6 O; K
    respawn limit 25 5
    & `, f$ x% ]4 e2 ]; v; S
    # `5 H% k0 c& ~9 t$ }9 i, ksetgid storm
    ! w% z0 j3 z/ R$ x' Zsetuid storm/ P# W( O% c4 L% G9 Z; B0 l
    chdir /opt/storm/current1 D' _8 P: e* R. E7 ]) w
    exec /opt/storm/current/bin/storm nimbus
    2 W9 c6 V. s+ p* l启动supervisor 与 nimbus$ w3 F9 t, Q* B( G: n+ q
    service storm-supervisor start
    4 A- v- H- K0 e0 n( p. l% d1 O+ Nservice storm-nimbus start
  • 安装monasca api python软件包+ s/ y$ |% |% S+ T. u1 O" V8 L
    一些monasca组件同时提供python和java代码,主要是我选择python代码进行部署。
    2 r  \1 W, u! e6 W$ m# h/ s3 H/ ^3 Tpip install monasca-common
    ' I  w0 n% u8 v4 Y& I& ~9 Mpip install gunicorn4 J% C# V! ^' J, l: D6 W
    pip install greenlet # Required for both* R& N6 U- q' @
    pip install eventlet # For eventlet workers
    2 ], c: I' u% Dpip install gevent # For gevent workers7 i" @  Z7 [" c
    pip install monasca-api
    # k; l! g) g) M, G" Epip install influxdb7 @7 _& Q3 p8 l$ w+ l. D* s& {
    vim /etc/monasca/api-config.ini,将主机修改为您的IP地址
    & |: d" @" t' o, b1 j. s6 Z2 K6 q[DEFAULT]7 K3 o; n, i0 D# [
    name = monasca_api5 g# O6 T! y5 D! }' a; X

    ' d4 Z! }: s9 ^[pipeline:main]7 ^  a1 T; c2 w2 `3 r
    # Add validator in the pipeline so the metrics messages can be validated.5 O. _# f4 v$ Y0 }. n3 w" ?) W
    pipeline = auth keystonecontext api
    5 T8 i. ~1 y! a8 V/ |1 `6 J" Q* W. }& I8 A% w
    [app:api]
    , u* e! D" |% G$ G! t( dpaste.app_factory = monasca_api.api.server:launch) _% _: F: b4 |7 d, K* i* K

    + O( L/ H- I# A" d. Y[filter:auth]
      G! O% l* K' W" h, Ypaste.filter_factory = keystonemiddleware.auth_token:filter_factory+ p4 f  z  a- f/ ?% ?3 E: _/ r; v

    7 E. h9 ^! A. j, P: I[filter:keystonecontext]- }0 }( ?. P3 p4 l0 `
    paste.filter_factory = monasca_api.middleware.keystone_context_filter:filter_factory9 D. C( S( C# E0 e
    4 F% u1 M  N+ H8 T
    [server:main]8 U: F8 W9 L) B+ C+ z: \, {0 _
    use = egg:gunicorn#main
    . T; u; s5 Y5 W# Ihost = 192.168.2.23
    & N- U1 P/ B8 T  E* A0 S1 J; v  aport = 8082
    8 @: g; o4 g6 {, c, V( E1 xworkers = 1
    ! b, S! t8 I( W- Xproc_name = monasca_api& r( G9 h" G/ t4 ?: b! B
    vim /etc/monasca/api-config.conf,修改以下内容
    , M7 H9 |; F4 M4 w- t[DEFAULT]$ t/ i% B& X8 _! m$ P7 e
    # logging, make sure that the user under whom the server runs has permission7 u( g2 n; N' P2 H! x
    # to write to the directory.
    4 I( D5 `' P7 ylog_file = monasca-api.log9 V& L- N/ b# z; b8 u1 t! ?2 T
    log_dir = /var/log/monasca/api/8 m3 J. o4 h0 \' ^3 a, Z
    debug=False
    % L. _7 u* H5 p. iregion = RegionOne) n% Z- {1 x4 r0 k
    [security]
    1 ?; ?2 T+ }6 k8 Z( _  e# The roles that are allowed full access to the API.
    * S5 S) L4 F; Vdefault_authorized_roles = admin, user, domainuser, domainadmin, monasca-user7 }# s0 i" s" h7 l2 o& m
    % U2 e( V; x6 K
    # The roles that are allowed to only POST metrics to the API. This role would be used by the Monasca Agent.
    ' a% Y  B. _9 kagent_authorized_roles = admin/ R% i3 M; z1 }! t6 {
    % v6 j" R2 R5 F
    # The roles that are allowed to only GET metrics from the API.
    + l+ B& K" r9 R$ ~- u( b" aread_only_authorized_roles = admin
    ! U' c# a0 j6 c
    + j0 m; W6 ^6 H# The roles that are allowed to access the API on behalf of another tenant.1 t4 {, v. ]' h' _+ D6 c( \* k
    # For example, a service can POST metrics to another tenant if they are a member of the "delegate" role.
    " S+ A$ \8 o7 z5 |" |: }: ydelegate_authorized_roles = admin
    - n7 L8 T2 w0 [# ^- m
    9 P' p1 H7 \2 p( F  \9 h8 A. m4 M[kafka]7 ?4 o9 b: v0 O; u9 B6 W. D
    # The endpoint to the kafka server
    " _7 G* |) y8 o8 h5 I6 E5 nuri = localhost:90929 v6 B' \  x2 [% _) z7 c; P
    ; ~: j# V5 {' h
    [influxdb]
    0 z: ?) y( y' k  H+ d# Only needed if Influxdb database is used for backend.
    # X! B$ s1 q% M! G# The IP address of the InfluxDB service.5 h; l+ g! D0 `% [0 t
    ip_address = localhost2 m6 U9 `! W0 D- s0 Y9 Y
    , j; m+ D; y8 Q% z
    # The port number that the InfluxDB service is listening on.
    + B# y: [+ ?) t$ f7 Sport = 8086
    3 l* k& M) h: H4 A8 a& _
    " w7 m* X' E) |' X+ d% _" z: r# The username to authenticate with.- A7 H% m# D+ \  K
    user = monasca# o, Z0 t# r2 k/ M; w

    8 n( V4 n; Q" P) }' ?8 {# The password to authenticate with.1 l' s3 ^& _/ `
    password = tyun
    2 _3 V; Z9 M, v% \& X6 S  W9 @! X- x! [: X
    # The name of the InfluxDB database to use.
    # V, D, `8 ~" S% B: R0 Q! f- Y. _database_name = mon% c+ z: Y* ^# t" o) f
    ! Y2 h; t- e  j. L& g
    [database]
    6 j3 }3 @. Q! u: z5 e- t+ Curl = "mysql+pymysql://monasca:tyun@127.0.0.1/mon"
    : o" W- W! V4 d7 z
    ( U8 q0 H$ f& n4 W
    / U' o$ T$ F" y: S) ^5 ][keystone_authtoken]4 [& M8 {8 d' H/ W- L. W/ p
    identity_uri = http://192.168.1.11:35357
    / l: `' R  o; O. l8 A% u% Wauth_uri = http://192.168.1.11:5000
    2 n+ y. z2 T- j5 j: H" O2 v# @admin_password = tyun* r! u  q# _; t+ W0 ~& n( B/ k
    admin_user = monasca
    5 f/ s. i) x5 N3 m" f2 `+ R5 I- uadmin_tenant_name = service
    " d! F7 R( o3 I/ }cafile =* q" R! }# J$ S7 U' M
    certfile =: F/ y2 D. w  e1 O0 k
    keyfile =
    8 f! S6 l9 ?" o$ @insecure = false
    ' B$ R3 o% [+ j; g! B+ f注释掉[mysql]部分,其他部分保持默认。
    3 @( F! o& ]: @$ g/ t创建monasca系统用户并进入目录6 J: S" l! Z  H
    useradd monasca -U -r, F: \$ b0 v+ q  q! x
    mkdir /var/log/monasca
    & k- k# v, z# n* J# r. Q3 Kmkdir /var/log/monasca/api
    & y, Y/ J  c* m4 o4 _) @# K8 D# Hchown -R monasca. /var/log/monasca/) z- r& q5 J# I9 s' J
    在openstack控制器节点上,创建monasca用户密码,为租户服务中的用户monasca分配管理员角色。
    % g! p8 k# s) r8 `% R) k+ Yopenstack user create --domain default --password tyun monasca2 |2 Q! R% Q8 ^2 U$ w8 v& E
    openstack role add --project service --user monasca admin% f& z* C7 z& Z

    5 [; A9 P- K5 y5 E4 P, Copenstack service create --name monasca --description "Monasca monitoring service" monitoring
    9 ^/ ?. W% i* k/ m, d
    8 a0 j  x8 R! C7 v, t% dcreate endpoint
    . X! q) }. @+ p: \" hopenstack endpoint create --region RegionOne monasca public http://192.168.1.143:8082/v2.06 _6 n( [; N+ q; w; Q! b  k+ v
    openstack endpoint create --region RegionOne monasca internal http://192.168.1.143:8082/v2.0
    / {2 M! k0 e5 b7 Popenstack endpoint create --region RegionOne monasca admin http://192.168.1.143:8082/v2.0
    * m+ Z/ `& L1 i) s- [  g# Q3 R8 S192.168.1.143是我的api虚拟机地址的浮动IP,请将其更改为您的IP。! e% O  N" w* `
    创建monasca api启动脚本,vim /etc/init/monasca-api.conf
    6 ?; x  v5 {3 H+ e) S1 E# g# Startup script for the Monasca API1 q) ]: Q' G% V1 F) Q7 r

    9 n7 ^  ?% Q) Ydescription "Monasca API Python app"5 D: f9 z( x* S3 H, W1 U5 y
    start on runlevel [2345]; Q; h) u  z! ^" o9 M
    & ?0 x1 K. W; `: n" D  V
    console log
    $ y1 w4 X& L$ b& K( q0 Q4 b4 G/ Rrespawn& |0 P6 Y( W$ b  X" z5 n1 @0 i/ H( E

    ' v0 a# _1 v  P5 l) r) g; Usetgid monasca- Y1 l& o' y- s  h  Z
    setuid monasca
    ! W9 Y% b+ C7 U% ]exec /usr/local/bin/gunicorn -n monasca-api -k eventlet --worker-connections=2000 --backlog=1000 --paste /etc/monasca/api-config.ini
  • 安装monasca-persister% k. u8 T1 ]# U
    创建monasca-persister启动脚本
    + x5 F2 |& k2 V* wvim /etc/init/monasca-persister.conf
    , E# h0 Q) `) f3 A# Startup script for the Monasca Persister' ?  W2 E1 ?$ U- s+ c, J, W6 I) A
    $ m2 z/ ^7 n9 j, {
    description "Monasca Persister Python app"+ p$ F8 r+ F* u4 _
    start on runlevel [2345]1 Q/ d2 |' B8 x

    2 @% [6 h2 u4 t1 Q- t* Jconsole log
    % v. B3 }' P8 p. l. `4 _respawn
    2 n$ O( z" \* r+ \- ?# T2 I% t8 q+ V
    setgid monasca9 F  r/ I1 c9 {
    setuid monasca
    + G8 A& V* b) D1 _' I4 Q! K5 i1 dexec /usr/bin/java -Dfile.encoding=UTF-8 -cp /opt/monasca/monasca-persister.jar monasca.persister.PersisterApplication server /etc/monasca/persister-config.yml
    7 o9 N1 x# l! N8 A启动monasca-persister
    . [5 Z: H* ?0 |- ~# s! |, _% q  A1 Qservice monasca-persister start
  • 安装monasca-notificatoin& j/ p1 V6 ^9 N
    pip install --upgrade monasca-notification( L/ Q+ W8 `9 g5 b! F
    apt-get install sendmail3 j" F5 Z0 y  R/ A" x: S
    将notification.yaml复制到/etc/monasca/ 创建启动脚本,vim /etc/init/monasca-notification.conf* y* S7 l4 I4 i4 |
    # Startup script for the monasca_notification
    : V  M% Y2 }7 V) z
    5 [; b1 V5 N/ U. i2 fdescription "Monasca Notification daemon"* M, i! U. R* E0 d5 E, o
    start on runlevel [2345]$ S3 F# l4 X1 w# z) O9 W6 j) l

    - x5 [6 J6 F. W4 h  i# N! I! {* mconsole log
    8 `  N" c4 ?* \, Lrespawn
    0 d' f0 A+ Y* m+ j
    . T2 P* V6 L- j& u) lsetgid monasca
    ! ~+ P5 X3 b% ?* z) j1 @( B9 @. Tsetuid monasca
      Q+ Y2 k& f# {* x0 ^exec /usr/bin/python /usr/local/bin/monasca-notification
    3 X$ x8 D+ @9 l; A& E8 C' v启动通知服务
    " \; Y' P, P" x, w" Xservice monasca-notification start
  • 安装monasca-thresh 复制monasca-thresh到/etc/init.d/ 复制monasca-thresh.jar到/opt/monasca-thresh/ 复制thresh-config.yml到/etc/monasca /并修改主机以及数据库信息 启动monasca-thresh$ K8 L; H% r1 n& N
    service monasca-thresh start
  • 安装monasca-agent
    # f6 W9 W8 ?: W在openstack控制器节点上安装monasca-agent,以便它可以监控openstack服务进程。
    - @5 b* B& p  k/ `sudo pip install --upgrade monasca-agent
    ' `( x, j4 u& L5 v设置monasca-agent,将用户域ID和项目域ID更改为默认值。
      n& D7 V, K& u& fmonasca-setup -u monasca -p tyun --user_domain_id e25e0413a70c41449d2ccc2578deb1e4 --project_domain_id e25e0413a70c41449d2ccc2578deb1e4 --user monasca \
    5 M* o" b7 I2 v- }8 l6 X. T0 X. F--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% M- T2 M+ f4 D4 b$ B. Q
    加载认证脚本admin-rc.sh,然后运行monasca metric-list。& u( |2 j& E$ ?/ k6 I: y4 n+ v: U4 x
2 G; J7 r  d/ u; N; n
DevStack安装
运行Monasca DevStack至少需要一台具有10GB RAM的主机。
可在此处找到安装和运行Devstack的说明:
https://docs.openstack.org/devstack/latest/3 Z3 y) f6 ~2 F" N7 E4 H
要在DevStack中运行Monasca,请执行以下三个步骤。
  • 克隆DevStack代码库。
    * h# c  T" F7 r, V% B3 b
git clone https://git.openstack.org/openstack-dev/devstack
% q7 D+ K: Y6 _& `! P2 J( q
  • 将以下内容添加到devstack目录根目录中的DevStack local.conf文件中。如果local.conf不存在,则可能需要创建它。
    1 d0 I: v# F  f8 ]: ?
# 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 CONTENTS& z4 G5 R& I4 t( k% `
  • 从devstack目录的根目录运行“ ./stack.sh”。
    2 C6 T% G' f+ M6 F( V7 E5 E
如果要使用最少的OpenStack组件运行Monasca,可以将以下两行添加到local.conf文件中。
disable_all_servicesenable_service rabbit mysql key* b1 w: R7 A# P! M6 v  ~
如果您还希望安装Tempest测试,请添加 tempest
enable_service rabbit mysql key tempest: D' h3 q  U6 t- d( N
要启用Horizon和Monasca UI,请添加 horizon
enable_service rabbit mysql key horizon tempest2 C( _7 n! Z+ m" e" f$ h# \) ^
使用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 DB0 A$ P1 Q* f5 V0 [
    Monasca支持同时使用InfluxDB和Vertica来存储指标和告警状态历史记录。默认情况下,在DevStack环境中启用InfluxDB。
    # {* g6 r  l% _$ LVertica是Hewlett Packard Enterprise的商业数据库。可以下载免费的Community Edition(CE)安装程序,要启用Vertica,请执行以下操作:9 L+ Y2 B! l* j- P$ w5 h/ E( [
  • 注册并下载Vertica Debian安装程序https://my.vertica.com/download/vertica/community-edition/,并将其放在您的主目录中。不幸的是,DevStack安装程序没有可以自动使用的URL,因此必须单独下载该URL,并将其放置在安装程序运行时可以找到它的位置。安装程序假定此位置是您的主目录。使用Vagrant时,您的主目录通常将以“ /vagrant_home”挂载在VM内。
  • 修改local.conf中MONASCA_METRICS_DB变量,配置Vertica的支持,如下所示:2 D8 W1 I# O7 [! I$ s" I; A
    MONASCA_METRICS_DB=${MONASCA_METRICS_DB:-vertica}
    0 F+ J5 n$ Y  v. G1 U/ l/ @4 f

  F0 ~. _3 m3 n# l1 r2 r. ~
  • 使用PostgreSQL或MySQL
    ; v4 Q! g( Z+ g' y2 Q' ]Monasca支持使用PostgreSQL和MySQL,因此该devstack插件也支持。启用postgresql或mysql。  ]# i# s" Y2 Y
    要使用MySQL设置环境,请使用:1 c% N; ~+ ^* `: l
    enable_service mysql
    $ Y0 P9 B0 v. @' x+ `另外,对于PostgreSQL,请使用:
    # g- r9 a# v( L& p- n2 Yenable_service postgresql
  • 使用ORM支持( \9 C  x% z! r4 m4 i4 \2 ^, \
    ORM支持可以通过MONASCA_DATABASE_USE_ORM变量来控制。但是,如果启用了PostgreSQL(也称为数据库后端),则将强制提供ORM支持4 v4 ?9 Y% u9 x
    enable_service postgresql
  • 加强Apache镜像" A1 s0 N; b( f: _# |, X' o
    如果由于某种原因APACHE_MIRROR而无法使用,则可以通过以下方式强制执行:
    ! _9 I( J: R, ~: uAPACHE_MIRROR=http://www-us.apache.org/dist/
  • 使用WSGI1 x6 N8 _# b! R1 z! _/ ?
    Monasca-api可以使用uwsgi和gunicorn与Apache一起部署。默认情况下,monasca-api在uwsgi下运行。如果您想使用Gunicorn,请确保其中devstack/local.conf包含:0 J$ I1 ^3 B( W7 h. _7 o
    MONASCA_API_USE_MOD_WSGI=False7 v' @. n; f8 [" x) s/ ]) }% o- i
使用Monasca Dashboard
安装完成Monasca Dashboard Plugin后,可以通过web控制台进行查看以及管理相应的监控与告警。
在操作控制台的“Monitoring”栏,单击“Launch Monitoring Dashboard“,这将打开在管理节点上运行的专用OpenStack Horizon门户。
在该面板中,您可以:
  • 单击OpenStack服务名称,以查看服务告警。
  • 单击服务器名称以查看相关设备的告警。8 R* Z1 s+ i3 F' y8 ^; y% R
监控信息存储在两个数据库中(Vertica/influxdb与mysql)。备份监控数据时,将同时备份两个数据库。看到
  • 监控指标在Vertica中存储7天。
  • 配置设置存储在MySQL中。
  • 如果监控节点上的服务在高负载(例如15个控制网络和200个计算节点)下停止,则消息队列将在大约6个小时内开始清除。
    0 g, V8 v( g( g; s/ C+ @* y7 C# W, m* H
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2026-6-12 02:19 , Processed in 0.017750 second(s), 21 queries .

Powered by Discuz! X5.0

© 2001-2026 Discuz! Team.

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