|
monasca的所有组件都可以安装在一个节点上,例如openstack控制器节点上,也可以将其部署在多节点上。本文中,将在我的openstack集群中创建的新VM中安装monasca-api,该VM具有关联的浮动ip。Monasca-agent已安装在控制器节点上。代理节点通过浮动ip将指标发布到api节点。它们在同一子网中。 - 安装我们需要的软件包和工具
* m! ?5 s# O! C9 b2 j6 N! W9 a9 wapt-get install -y git4 T- c: b; t w: G$ K; d
apt-get install openjdk-7-jre-headless python-pip python-dev - 安装mysql数据库 如果您在openstack控制器节点中安装了monasca-api,则可以跳过安装,将已安装的msyql用于openstack服务。
8 W. N$ X- B H/ T& f( D5 [, X6 Hapt-get install -y mysql-server
: }1 D& k, W8 k* _7 B创建monasca数据库架构,在此处下载mon.sql( https://raw.githubusercontent.com/stackforge/cookbook-monasca-schema/master/files/default/mysql/mon.sql)4 i( [# {! P# u, Z$ \' ~) S: A$ g* d
mysql -uroot -ppassword < mon_mysql.sql - 安装Zookeeper 安装Zookeeper并重新启动它。我使用本地主机接口,并且只有一个Zookeeper,因此默认配置文件不需要配置。: _7 \! T& S( n7 Y6 p: X* n
apt-get install -y zookeeper zookeeperd zookeeper-bin service zookeeper restart
; E) S1 }( r) A# i% C- 安装和配置kafka5 h8 E' ~6 M0 Z% D) @* Z' F
wget http://apache.mirrors.tds.net/kafka/0.8.1.1/kafka_2.9.2-0.8.1.1.tgz
) \3 Z+ |- b8 A! P3 G# mmv kafka_2.9.2-0.8.1.1.tgz /opt
4 a: C2 e6 x) c$ S: O4 C5 H. ycd /opt
/ A; c. e; X' _tar zxf kafka_2.9.2-0.8.1.1.tgz0 z! m, X: E7 ~* v
ln -s /opt/kafka_2.9.2-0.8.1.1/ /opt/kafka; F% X( M" V4 Z- d) J
ln -s /opt/kafka/config /etc/kafka
! F5 `2 U( G( l创建kafka系统用户,kafka服务将以该用户身份启动。3 H* g6 C' ], G" t, V8 Q
useradd kafka -U -r" J' C R, }% Q* l& n0 A) C, C" R
在/etc/init/kafka.conf中创建kafka启动脚本,将以下内容复制 到/etc/init/kafka.conf中并保存。# F* _3 E5 k6 I S3 a
description "Kafka"
P5 I6 i( p7 }$ Q& g# E2 g% m
: r" x% F. d- L) B+ astart on runlevel [2345]: i7 J( m: s1 Y& u8 g3 E+ T) A
stop on runlevel [!2345] M1 u/ x6 n( r- I( N
! D: Y9 Y3 O& I* x
respawn$ X/ F0 H# c; s! l2 C( R1 Q, w, e
- F( m+ W5 x+ h) \
limit nofile 32768 32768# ^! y$ _3 {' D! O$ k
/ K& W$ z: | {$ R' [+ Q1 t# If zookeeper is running on this box also give it time to start up properly! |7 {3 b( b4 f9 G) U3 n+ U
pre-start script6 g9 g' D6 B0 D+ I+ o/ Y; R* w
if [ -e /etc/init.d/zookeeper ]; then0 L( t7 ^9 c3 d c/ w4 B% |
/etc/init.d/zookeeper restart
0 e9 l: ^. x% {) E9 T/ Mfi
- T, q6 E4 _+ M- ] \7 d$ s, t& @/ hend script4 w6 U' |4 {: Z: Q, r# b R( T2 Q% G
! I; T$ t5 L1 p" q; h' m! u
# Rather than using setuid/setgid sudo is used because the pre-start task must run as root, f5 [3 }/ d) L! C! o0 Z& S
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; U6 c! P; C( b8 W
配置kafka,vim /etc/kafka/server.properties,确保配置了以下内容:
3 V1 P/ r/ R# }host.name=localhost
5 S& L; t9 ^. S& k3 Radvertised.host.name=localhost! n, A' X+ H ]7 y% T3 _
log.dirs=/var/kafka
7 o6 r6 c% o7 T- |3 M- ?! u创建 kafka log目录& B; a- U; F1 F7 l. N
mkdir /var/kafka) ]0 H& ?2 ~7 ^, @" R
mkdir /var/log/kafka
) L! T! Z6 N6 t3 Rchown -R kafka. /var/kafka/
- K8 b& [& b( k i- E7 echown -R kafka. /var/log/kafka/$ t" B, A2 {8 u+ y! x
启动kafka服务" V% p: d4 {% [# R
service kafka start
" `4 r+ Q4 @1 M下一步就是创建 kafka topics
4 e, G) e" D: L! K/opt/kafka/bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 64 --topic metrics
! |" ]# H2 i9 K' i* U/opt/kafka/bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 12 --topic events/ u& K* P# I3 N# t' x- q
/opt/kafka/bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 12 --topic raw-events
6 k& V C) E$ b/ ]/opt/kafka/bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 12 --topic transformed-events& @# Q+ }- W* C) i
/opt/kafka/bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 12 --topic stream-definitions
# m( C% |' f7 n; ^. m* r! D- A* r/opt/kafka/bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 12 --topic transform-definitions. ^! f6 }& G7 E. h0 Y+ o
/opt/kafka/bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 12 --topic alarm-state-transitions) S: O; \" A0 r8 s3 x
/opt/kafka/bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 12 --topic alarm-notifications
# N( S& R T( ^3 J( f3 B/opt/kafka/bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 12 --topic stream-notifications
9 X% S7 v6 M4 Q4 }- k1 {/opt/kafka/bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 3 --topic retry-notifications - 安装和配置 influxdb: p2 Y5 R( L, f |
curl -sL https://repos.influxdata.com/influxdb.key | apt-key add -7 N) ^! [+ ?! K; ~' \
echo "deb https://repos.influxdata.com/ubuntu trusty stable" > /etc/apt/sources.list.d/influxdb.list8 A! _5 d9 {1 l1 A) l
apt-get update
" P) W9 Y0 b. ^3 u# g) Rapt-get install -y apt-transport-https
: }* j3 l+ b' |3 fapt-get install -y influxdb
$ S, c6 C8 Q: S# n% s& y/ P4 A8 Q6 H
8 ^! Q7 M' V3 P. b. @; R2 R0 d7 ^" nservice influxdb start& x4 x' R' B$ O0 S
创建 influxdb database, user, password, retention policy, 同时修改密码。" a0 E. ~- }% p6 C6 M) l8 v' v
influx
+ ^/ ^. m5 n; P0 M# E1 D8 NCREATE DATABASE mon
; q* i9 u$ V/ @6 `8 H3 tCREATE USER monasca WITH PASSWORD 'tyun'
: S$ q0 D: x2 f, k7 FCREATE RETENTION POLICY persister_all ON mon DURATION 90d REPLICATION 1 DEFAULT
& _" @' x5 k2 y$ X- ^exit - 安装与配置 storm
3 D& ~$ [1 T9 z/ K% Awget http://apache.mirrors.tds.net/storm/apache-storm-0.9.6/apache-storm-0.9.6.tar.gz o8 [& Q; a8 |
mkdir /opt/storm
+ G" Y9 B; N4 @3 b) |" o4 Xcp apache-storm-0.9.6.tar.gz /opt/storm/. u- s K4 \( l$ z5 F/ X% N, b
cd /opt/storm/7 l/ [% d3 _; W7 ^. n6 x7 ^2 C$ g
tar xzf apache-storm-0.9.6.tar.gz( }, r& I9 [8 G) b5 e' _% g3 w+ D
ln -s /opt/storm/apache-storm-0.9.6 /opt/storm/current) L( p4 q; g, S' D
+ {2 V: \ G/ \8 A. G+ Z, l# A7 r
useradd storm -U -r( K1 {- ?7 e. a1 H& O' L' J; p
mkdir /var/storm) x! k# T% x* x* J# p) i f
mkdir /var/log/storm' n3 O$ t, K' B; i: w
chown -R storm. /var/storm/
! F% d5 C. l4 \* u& A6 schown -R storm. /var/log/storm/
0 @3 s& G' K8 R: R1 [修改storm.yaml, vim current/storm/conf/storm.yaml
/ n& C+ ^+ k9 s1 B### base
$ }" w* H8 @0 jjava.library.path: "/usr/local/lib:/opt/local/lib:/usr/lib"
+ [6 a x+ S/ S* Hstorm.local.dir: "/var/storm"4 u/ v) p9 i. c3 {* Q, V% F
7 S& Z5 V* d {2 _; H& G5 U
### zookeeper.*( ?1 w; \, v2 M W, X- q
storm.zookeeper.servers:% T5 [' }2 l( N6 ?
- "localhost"
# m/ y, y! ^5 S+ W$ K. Estorm.zookeeper.port: 2181, T% \7 R8 I. a( {6 A. }$ S
storm.zookeeper.retry.interval: 5000
& Y! s8 p! A- c9 Estorm.zookeeper.retry.times: 29
" m5 T1 z- w: Y) f1 j: Y Hstorm.zookeeper.root: "/storm"
: `9 j# I' u: a% @storm.zookeeper.session.timeout: 30000) w* M4 n& m- H% k M3 {
" H6 i' T) @3 @! x
### supervisor.* configs are for node supervisors
" S3 l3 q" G8 G8 ?# O1 wsupervisor.slots.ports:
M8 l2 e r/ R- 6701
& \, Z9 \8 D2 F; B3 J- 6702
& j9 [2 G( l- v- r8 ~- 6703( T! N$ K3 _. L3 J: R! p( e
- 6704
6 s. h& J7 F+ k, _# y5 X/ Zsupervisor.childopts: "-Xmx1024m" \8 e3 Q) [& @
$ O, u8 U+ k0 e: D8 g/ P
### worker.* configs are for task workers
, Y4 V0 V% }) v( a( pworker.childopts: "-Xmx1280m -XX:+UseConcMarkSweepGC -Dcom.sun.management.jmxremote"
: K# C; J a# B& U8 [
: _8 X7 a: P9 L$ A### nimbus.* configs are for the masteri, L5 ] U$ y$ j8 y* G; I
nimbus.host: "localhost"
4 c; |: P: E( l) v% t$ o8 Inimbus.thrift.port: 6627
4 X- V, ^; z i7 U! ?1 M8 A$ `mbus.childopts: "-Xmx1024m"* ~' Y$ {- r3 u- h; k, N7 t; {
7 Y# v6 J1 H* o' ]- j7 V; |
### ui.* configs are for the master
/ ]' Y+ x0 |7 ~ui.host: 127.0.0.1
+ l5 O: ^. U, g9 q# \- Y2 ]ui.port: 80781 H1 Y( \ k; L8 I( Q( ?. |
ui.childopts: "-Xmx768m"7 [3 @" J; X* g' z' ~: ^
# ]" ?; D! f, O2 ^### drpc.* configs! o4 l5 U3 X" l9 ~- D! k/ d
9 G x! O* j+ ^8 l2 h& S3 g### transactional.* configs
u0 u# ^) Z8 I! g2 y0 Qtransactional.zookeeper.servers:
: x3 O q2 j" [! G8 C- "localhost"- I: m, v x4 I1 k8 ?8 l6 A x+ v
transactional.zookeeper.port: 2181. h8 i" T& L+ R6 Y+ t
transactional.zookeeper.root: "/storm-transactional"
. Y& r0 Q9 e8 A
# y: }( N c) c# v- E' u' u### topology.* configs are for specific executing storms
) B* P7 Y/ _0 Utopology.acker.executors: 1
7 a; {$ a6 @4 c7 j3 Q, a) x3 Ztopology.debug: false
# K5 i6 O' o2 i; P( k, |& X l( ^* s( b# z
logviewer.port: 8077# z% U9 j" ^5 j) n
logviewer.childopts: "-Xmx128m"( H7 A2 p* o3 j8 `9 J( b
创建storm supervisor 启动脚本,vim /etc/init/storm-supervisor.conf
. u. E: g) ?8 ?( Q# Startup script for Storm Supervisor7 a. X5 o0 k9 u0 x
* e! s4 ^! _, Kdescription "Storm Supervisor daemon"6 }! l1 z' P( u& I) B! B$ f
start on runlevel [2345]* v4 A }2 c3 d# Y$ T9 G2 c$ X) T) B
* r1 D7 c+ R) H' H4 {console log
% s& n$ |5 P! t: Q+ e9 \4 l8 Krespawn
8 z. z9 R+ X% C M1 n2 n9 @% c9 S. n; Q* \ J* U# C
kill timeout 240( X, V$ _$ K- l7 j" C( P" Q
respawn limit 25 59 G7 v) e$ e& `
) e3 @" Z/ k( A) J# X$ M9 n. lsetgid storm
' b' \7 l, O0 X, U, Y; [2 b% g' Ksetuid storm
5 A* D. T' @2 F! p4 |chdir /opt/storm/current0 T7 [' }4 d! K, S/ r
exec /opt/storm/current/bin/storm supervisor( {3 ?5 n2 M1 {& ]
创建Storm nimbus 启动脚本。vim /etc/init/storm-nimbus.conf
( @! d. x! l: M% K4 t# Startup script for Storm Nimbus
$ g8 ^( s& s4 E% j6 J0 `/ L! v. q1 U/ O/ B3 Q& t
description "Storm Nimbus daemon"* `4 F. O x/ v. I
start on runlevel [2345]% h# ~5 m u9 J' ]
% h1 y/ X( M% A3 v" }& _0 ~console log
& q! J$ W" P$ Lrespawn
2 o; d: J' f q( [; ^0 i& ?3 E+ w6 Y' T; ]& ~8 @5 \
kill timeout 2407 W1 ]/ f& k7 n. i
respawn limit 25 5) k- @, n+ _, f: b5 _
& r# B+ D, X5 Y( c, M2 m) R
setgid storm/ U2 ]5 B+ \8 M% Q( Y; x
setuid storm
( R ~5 z# O% h# n( hchdir /opt/storm/current0 q3 H6 ^ @5 j4 t D
exec /opt/storm/current/bin/storm nimbus
% {7 e% ]* T7 e, V' i启动supervisor 与 nimbus- `8 E& |' [ x4 t; T( r
service storm-supervisor start% h. |1 h6 X* c1 q
service storm-nimbus start - 安装monasca api python软件包
/ t) ~; ^% N! Z/ C# Y* I! m一些monasca组件同时提供python和java代码,主要是我选择python代码进行部署。) m1 t6 g* T0 U2 W
pip install monasca-common2 a8 S% g( |, @4 h( Y5 c
pip install gunicorn5 |/ [. z6 k3 \' Q" C9 N
pip install greenlet # Required for both/ } L" m% C. N! W7 m1 k
pip install eventlet # For eventlet workers+ Y9 X) v; S6 @) V
pip install gevent # For gevent workers
5 C/ G0 ~4 Y: ^ A6 M3 Rpip install monasca-api
! @9 ~4 Y& n- ^! Opip install influxdb
0 }' j; B' }* L& B, F$ B, c* Uvim /etc/monasca/api-config.ini,将主机修改为您的IP地址; q& R4 T9 Q+ [' ~ V3 l
[DEFAULT]4 ^& K, M- `/ Z" i I" g
name = monasca_api5 m. ?- o2 M( [1 W. a
: @" D a. |4 Y U" P[pipeline:main]
0 T2 b- b7 A0 ?( m& t# Add validator in the pipeline so the metrics messages can be validated./ i; A+ d9 x1 h
pipeline = auth keystonecontext api
7 d3 T8 O5 E/ a1 J1 R6 m1 W3 B2 t6 {+ r# d
[app:api]+ y8 ?* U. @. d* ?6 l
paste.app_factory = monasca_api.api.server:launch
: S v1 f1 x' t( y9 R
0 U1 Y0 F+ }, x: a* k9 A+ H[filter:auth]" v& l0 i* ~+ Q3 l
paste.filter_factory = keystonemiddleware.auth_token:filter_factory
9 H5 {, G4 l1 s5 c$ U1 k+ |" p9 \. L3 H9 o8 c, w. b
[filter:keystonecontext]% W, |' R' g; k# f3 `" L
paste.filter_factory = monasca_api.middleware.keystone_context_filter:filter_factory, S- N0 M2 X. c {- e
& }, r }0 S2 n
[server:main]
1 d# C$ ?1 P# y3 B" buse = egg:gunicorn#main0 p, |# D" l, B: c. Z: \ R* P
host = 192.168.2.23
9 d% n) H) v% y) E1 w2 A: Iport = 80823 p/ u$ ?2 [$ j/ \: `/ a8 E! }
workers = 1, Z6 n8 ]& C- L1 P: s
proc_name = monasca_api. k' r% Z, a3 y$ y' j
vim /etc/monasca/api-config.conf,修改以下内容0 D8 q# B$ ]6 d9 I: V( Z; s$ w: t
[DEFAULT]
. t1 T, N. ?$ c# d& Y5 n# logging, make sure that the user under whom the server runs has permission
D' b( ]* L- w6 n# to write to the directory.( O2 a0 N* c) y2 S4 W
log_file = monasca-api.log3 U6 N) j$ s/ W: M$ b
log_dir = /var/log/monasca/api/
4 S7 L( e5 r# {8 Odebug=False, b9 a8 |, q# N" V# `+ N( P
region = RegionOne
/ T/ v! k7 U+ Z Y! ?7 k& p% c- U[security]& u& _' b7 ~) ]' N7 }/ Y% X$ R; e! S
# The roles that are allowed full access to the API." {) Z [( A/ u- _% w
default_authorized_roles = admin, user, domainuser, domainadmin, monasca-user
# u+ W3 |. M H: D9 f! @6 S' U2 C+ D
# The roles that are allowed to only POST metrics to the API. This role would be used by the Monasca Agent.8 z5 m! u- Z0 u5 G8 v; x$ q, e, g9 Y
agent_authorized_roles = admin1 l+ ]1 r1 J. Z) E' Y
$ m/ ]6 g' g. D
# The roles that are allowed to only GET metrics from the API.
b( k6 j, S' Jread_only_authorized_roles = admin
/ v& ] Z: v2 O, G
2 U+ r: L/ z4 j3 g) f# The roles that are allowed to access the API on behalf of another tenant.; B5 n" N* E7 A" H# B- R
# For example, a service can POST metrics to another tenant if they are a member of the "delegate" role.
. r: q8 h9 L6 edelegate_authorized_roles = admin5 X1 J5 \1 I5 ]
1 n" F, Z% I8 l: Y: K f[kafka]
7 n. z( f c% [# N2 A# d# The endpoint to the kafka server
- }# D- m6 k X8 p# J& ~ yuri = localhost:9092: h' [! c3 l! P. U; g: ~: @
3 y7 t* ~( Q, Z7 T4 Q[influxdb]6 k/ D/ i8 [* f3 E# F
# Only needed if Influxdb database is used for backend.4 i( L: r7 X' u% k
# The IP address of the InfluxDB service.1 L# c9 ^# O$ l& o
ip_address = localhost$ e9 o! L0 z! f/ w
* [' j1 r9 d, w! h1 m# The port number that the InfluxDB service is listening on.1 Z o* f, D% d) Z# a" |& q
port = 8086+ u* F+ ~" b& ?" W! m
' i! w& F! @/ C4 Z1 L# The username to authenticate with.
: z' }3 t* i! C" K3 C3 nuser = monasca
) ^) Z' B% o. K% t7 i- w& P9 |/ {9 @1 T5 p6 [9 J, x
# The password to authenticate with.
6 w. z% Q/ |4 r5 |, zpassword = tyun1 T+ C/ n, s! f8 ~/ F7 U$ T
8 O6 ^% j; b" r- k
# The name of the InfluxDB database to use.4 f) `. [6 t1 x4 P7 C+ O1 x
database_name = mon% N1 {7 V* j# g" y l) q
( C0 \9 F4 S G/ S% F9 T0 g8 u[database]
; O" q# I% L/ x- {$ E8 m5 ~% kurl = "mysql+pymysql://monasca:tyun@127.0.0.1/mon"
" J# P7 L/ Y* G1 E0 G
$ m3 ]) ~- r, V4 o
& p! g+ a" p9 C2 X7 a$ z q7 _# m[keystone_authtoken]
( ^ A+ O& O( ^$ ~# b6 l7 |identity_uri = http://192.168.1.11:35357+ J# V* L( }! M- O: Z5 \, ?! G
auth_uri = http://192.168.1.11:5000
c. M2 e5 R' I- z" v+ T! [# tadmin_password = tyun
) I: S1 l5 \: z$ `7 Z1 h, ^1 X& \2 _admin_user = monasca8 b! V( Y' x, Q4 f& s5 X, r
admin_tenant_name = service
& D$ Z( l2 Q0 i* _7 k/ x2 z! k6 Vcafile =! c$ `6 y" M/ W5 t' S
certfile =; `5 B7 h! i+ b7 Y; X8 e
keyfile =
. l! k) b7 J' \% iinsecure = false* d$ I% H* S/ `' h1 t( U( C' n3 S& m$ P
注释掉[mysql]部分,其他部分保持默认。
. I8 O; f$ W/ t! k& n* {, I' Z; E- p$ w( ?创建monasca系统用户并进入目录! S% n$ {+ p" G: T
useradd monasca -U -r
Y- V2 E1 s( z6 c7 ^mkdir /var/log/monasca" Z: _- G, H* X: q! i3 m# U0 a2 T* \
mkdir /var/log/monasca/api
3 L6 k2 t4 J% n4 y' Q0 uchown -R monasca. /var/log/monasca/, i1 Z2 d+ h/ }0 U! l
在openstack控制器节点上,创建monasca用户密码,为租户服务中的用户monasca分配管理员角色。
A6 W5 E2 X9 Xopenstack user create --domain default --password tyun monasca
1 u* i) {' m r0 g6 F$ o$ R) Dopenstack role add --project service --user monasca admin
0 y/ @1 t# o5 k8 @' a1 s/ _1 ?. s. w7 j
openstack service create --name monasca --description "Monasca monitoring service" monitoring
" i( a/ k$ D2 B. o
; g1 Z: x( O' r; @! V$ }create endpoint# O; t9 z2 M/ W: D2 b0 |0 f
openstack endpoint create --region RegionOne monasca public http://192.168.1.143:8082/v2.07 f3 L' t+ X8 |+ j4 S
openstack endpoint create --region RegionOne monasca internal http://192.168.1.143:8082/v2.0; h# y( H d5 U3 d) X: b
openstack endpoint create --region RegionOne monasca admin http://192.168.1.143:8082/v2.0# V* O ?) z+ b+ O8 i' Y: ]$ b4 K
192.168.1.143是我的api虚拟机地址的浮动IP,请将其更改为您的IP。6 P0 e2 F2 x- O) ~
创建monasca api启动脚本,vim /etc/init/monasca-api.conf: g0 x& ^. Y" S
# Startup script for the Monasca API2 {; R9 r4 `0 W" d: J3 ]) N& t! d0 M
& M& x9 P2 z" W) F$ K$ Bdescription "Monasca API Python app"
- C" y, Z+ f% S1 R6 V/ z! _% astart on runlevel [2345]
9 b) E. q6 A/ p8 c# l' w& S" i1 U5 k2 m" f" o. i
console log+ g9 ?6 @2 v5 z- ]- y
respawn
4 p( [0 V0 [- c9 }3 Y2 E _
0 r2 x# G* c5 H- p2 v* k: m, @; lsetgid monasca$ t' f* t/ }2 f% z
setuid monasca
# E1 Z1 ^, f {0 e8 ~8 o0 E5 Yexec /usr/local/bin/gunicorn -n monasca-api -k eventlet --worker-connections=2000 --backlog=1000 --paste /etc/monasca/api-config.ini - 安装monasca-persister
1 X+ x# t- v# ?: o. c创建monasca-persister启动脚本
0 l, Y$ e. ^( Hvim /etc/init/monasca-persister.conf4 e4 L. ^2 y3 L6 }2 B1 f# e/ d1 h$ p# v
# Startup script for the Monasca Persister3 W8 y6 v: y% h6 a1 j
# w) k2 v* k4 P @7 R! Tdescription "Monasca Persister Python app"
8 @7 N) q$ {" S, _start on runlevel [2345]
?5 x2 j7 |- G( [
( K, @0 }' U3 Uconsole log
: X; Y* O1 w7 \- Q0 |" S8 R' @respawn& a& U4 @2 K) K
* Q( n3 O) m# i) W
setgid monasca
6 j( y2 |7 J+ V/ R: @setuid monasca9 n; Q9 q9 b4 x! K( l
exec /usr/bin/java -Dfile.encoding=UTF-8 -cp /opt/monasca/monasca-persister.jar monasca.persister.PersisterApplication server /etc/monasca/persister-config.yml
& a$ w/ ^7 P/ b4 }/ q启动monasca-persister. H" p: m$ \; h$ _# G) R
service monasca-persister start - 安装monasca-notificatoin# Y" Q4 ^7 C3 ]! [, t) ~
pip install --upgrade monasca-notification% v1 B9 h% E. V. y# x2 x
apt-get install sendmail9 i; L, f& \6 x+ K. O
将notification.yaml复制到/etc/monasca/ 创建启动脚本,vim /etc/init/monasca-notification.conf
4 @# F) ^: J0 N9 k- ]$ U+ w1 q. k+ B9 R# Startup script for the monasca_notification) G( d1 |3 }" h3 B5 }3 G; s
; u" M& i6 m C5 a* D. W
description "Monasca Notification daemon") T% Y! ]0 d8 E+ w4 e2 o9 n5 d# s
start on runlevel [2345]
/ F: Y/ H0 R4 f: m. T2 r( f* R# V% O$ ~8 J5 g( W0 y2 ], ]# Z
console log; M7 j( U9 L0 ]0 b2 o" s
respawn
( a. E- r$ R1 P+ K/ y- e
, [1 z& Z/ g' H/ D% X. ~setgid monasca
) J- I1 n( h1 }5 j/ [/ @setuid monasca
/ }1 u4 V; M* h8 rexec /usr/bin/python /usr/local/bin/monasca-notification: o' s# L8 r" k) a) }
启动通知服务$ V7 u, {6 n0 Y8 }! v. C2 T
service monasca-notification start - 安装monasca-thresh 复制monasca-thresh到/etc/init.d/ 复制monasca-thresh.jar到/opt/monasca-thresh/ 复制thresh-config.yml到/etc/monasca /并修改主机以及数据库信息 启动monasca-thresh; F$ C4 R" V! d+ \
service monasca-thresh start - 安装monasca-agent3 t- o. o) t- O
在openstack控制器节点上安装monasca-agent,以便它可以监控openstack服务进程。
) N2 N) e0 J' } Wsudo pip install --upgrade monasca-agent
& N* V. G+ C9 L* y h4 x* \设置monasca-agent,将用户域ID和项目域ID更改为默认值。% {- V2 u8 I I9 O% s
monasca-setup -u monasca -p tyun --user_domain_id e25e0413a70c41449d2ccc2578deb1e4 --project_domain_id e25e0413a70c41449d2ccc2578deb1e4 --user monasca \
& W% R6 O0 M; q0 I" ^& Z--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: i @% b+ y5 m: i- ]) s
加载认证脚本admin-rc.sh,然后运行monasca metric-list。
A& N+ _6 B; ~5 c* X- Z, h+ w 5 \' b4 S! I7 ?' n5 ^5 [4 _
DevStack安装运行Monasca DevStack至少需要一台具有10GB RAM的主机。 可在此处找到安装和运行Devstack的说明: https://docs.openstack.org/devstack/latest/
, ?! g; {! V; E7 q4 G( ^. w要在DevStack中运行Monasca,请执行以下三个步骤。 - 克隆DevStack代码库。
( U, B( N0 J" \; e, g+ l git clone https://git.openstack.org/openstack-dev/devstack
4 P. \; w) y5 K- 将以下内容添加到devstack目录根目录中的DevStack local.conf文件中。如果local.conf不存在,则可能需要创建它。/ y! j/ r8 K) W6 v# [% O3 h; N9 Q
# BEGIN DEVSTACK LOCAL.CONF CONTENTS[[local|localrc]]DATABASE_PASSWORD=secretdatabaseRABBIT_PASSWORD=secretrabbitADMIN_PASSWORD=secretadminSERVICE_PASSWORD=secretserviceSERVICE_TOKEN=111222333444LOGFILE=$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
, }' }9 S0 v& Q5 u- ]+ P2 j- 从devstack目录的根目录运行“ ./stack.sh”。
) Q3 d3 g$ [2 W( i
如果要使用最少的OpenStack组件运行Monasca,可以将以下两行添加到local.conf文件中。 disable_all_servicesenable_service rabbit mysql key7 l+ }) Y" j$ S t- r; H
如果您还希望安装Tempest测试,请添加 tempest enable_service rabbit mysql key tempest8 {; `5 J* R/ L: J# P" D4 f4 Z
要启用Horizon和Monasca UI,请添加 horizon enable_service rabbit mysql key horizon tempest
- K1 v u% q5 N7 u0 U使用VagrantVagrant可用于使用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 DB3 r& _2 |( a* k- |( p9 T% X
Monasca支持同时使用InfluxDB和Vertica来存储指标和告警状态历史记录。默认情况下,在DevStack环境中启用InfluxDB。' c8 K a: v3 D! M/ k5 \
Vertica是Hewlett Packard Enterprise的商业数据库。可以下载免费的Community Edition(CE)安装程序,要启用Vertica,请执行以下操作:
8 P4 h" s' S( J1 Q4 D& A( s8 @
- 注册并下载Vertica Debian安装程序https://my.vertica.com/download/vertica/community-edition/,并将其放在您的主目录中。不幸的是,DevStack安装程序没有可以自动使用的URL,因此必须单独下载该URL,并将其放置在安装程序运行时可以找到它的位置。安装程序假定此位置是您的主目录。使用Vagrant时,您的主目录通常将以“ /vagrant_home”挂载在VM内。
- 修改local.conf中MONASCA_METRICS_DB变量,配置Vertica的支持,如下所示:
2 q& ~" U4 g& G$ j& n7 oMONASCA_METRICS_DB=${MONASCA_METRICS_DB:-vertica}
2 d4 j9 p" S# O6 M/ R" ] 2 c9 Y. t ?- e* U' z. U
- 使用PostgreSQL或MySQL1 e- p2 \: j2 `' m1 r
Monasca支持使用PostgreSQL和MySQL,因此该devstack插件也支持。启用postgresql或mysql。
' T' \& a& w* Z$ O0 C" @8 T% o要使用MySQL设置环境,请使用:4 v' T! N1 b7 H) j2 M
enable_service mysql
4 t, r( D, V3 ?) ]% O( v% c另外,对于PostgreSQL,请使用:
! c1 O: V' C8 uenable_service postgresql - 使用ORM支持
" ?7 y$ ^! q& f3 WORM支持可以通过MONASCA_DATABASE_USE_ORM变量来控制。但是,如果启用了PostgreSQL(也称为数据库后端),则将强制提供ORM支持% r z" O$ H [& H @: n f' j9 W
enable_service postgresql - 加强Apache镜像4 m2 H' W; i" J. X3 q( a0 M/ a
如果由于某种原因APACHE_MIRROR而无法使用,则可以通过以下方式强制执行:
, W( y& K6 L. l* d9 y! F2 l3 zAPACHE_MIRROR=http://www-us.apache.org/dist/ - 使用WSGI4 H" w5 K' n. r- j" n2 k! }" ?
Monasca-api可以使用uwsgi和gunicorn与Apache一起部署。默认情况下,monasca-api在uwsgi下运行。如果您想使用Gunicorn,请确保其中devstack/local.conf包含:& i. r7 U `3 k( H
MONASCA_API_USE_MOD_WSGI=False( t+ M g$ z1 X `# K, b
使用Monasca Dashboard安装完成Monasca Dashboard Plugin后,可以通过web控制台进行查看以及管理相应的监控与告警。 在操作控制台的“Monitoring”栏,单击“Launch Monitoring Dashboard“,这将打开在管理节点上运行的专用OpenStack Horizon门户。 在该面板中,您可以: - 单击OpenStack服务名称,以查看服务告警。
- 单击服务器名称以查看相关设备的告警。
$ c2 p/ m; H1 S d' m+ t
监控信息存储在两个数据库中(Vertica/influxdb与mysql)。备份监控数据时,将同时备份两个数据库。看到 - 监控指标在Vertica中存储7天。
- 配置设置存储在MySQL中。
- 如果监控节点上的服务在高负载(例如15个控制网络和200个计算节点)下停止,则消息队列将在大约6个小时内开始清除。
( g4 ^# W1 S5 k; R
|