|
monasca的所有组件都可以安装在一个节点上,例如openstack控制器节点上,也可以将其部署在多节点上。本文中,将在我的openstack集群中创建的新VM中安装monasca-api,该VM具有关联的浮动ip。Monasca-agent已安装在控制器节点上。代理节点通过浮动ip将指标发布到api节点。它们在同一子网中。 - 安装我们需要的软件包和工具) c5 i7 e% J! m* W+ t
apt-get install -y git
* Q7 H/ B) j7 S4 Uapt-get install openjdk-7-jre-headless python-pip python-dev - 安装mysql数据库 如果您在openstack控制器节点中安装了monasca-api,则可以跳过安装,将已安装的msyql用于openstack服务。. _6 F* A/ Q/ O2 ~
apt-get install -y mysql-server
9 G" L. v. c$ }' f: l% P S/ ~3 d创建monasca数据库架构,在此处下载mon.sql( https://raw.githubusercontent.com/stackforge/cookbook-monasca-schema/master/files/default/mysql/mon.sql)7 O" d. R6 L. l$ j1 n" L m3 }2 ?
mysql -uroot -ppassword < mon_mysql.sql - 安装Zookeeper 安装Zookeeper并重新启动它。我使用本地主机接口,并且只有一个Zookeeper,因此默认配置文件不需要配置。0 G' ~6 C( ~! C
apt-get install -y zookeeper zookeeperd zookeeper-bin service zookeeper restart( |7 m/ \+ J0 s: G) ]9 W4 Q" [
- 安装和配置kafka
0 Y9 z7 j: _, I* Iwget http://apache.mirrors.tds.net/kafka/0.8.1.1/kafka_2.9.2-0.8.1.1.tgz
9 u' j" {: N5 [mv kafka_2.9.2-0.8.1.1.tgz /opt
9 q" D; `# G9 P* W J. j& a! Zcd /opt
3 Z( L' x! X, Ktar zxf kafka_2.9.2-0.8.1.1.tgz
6 v6 B3 X% e+ }* k' i7 C- f6 Z, Wln -s /opt/kafka_2.9.2-0.8.1.1/ /opt/kafka
^* u! |, t- b @9 C4 v# H8 nln -s /opt/kafka/config /etc/kafka
( x( w) X7 C7 [- J0 L创建kafka系统用户,kafka服务将以该用户身份启动。$ o: n; G# m) H5 S5 i
useradd kafka -U -r
& ]/ N& l- I+ n$ T* q8 Z在/etc/init/kafka.conf中创建kafka启动脚本,将以下内容复制 到/etc/init/kafka.conf中并保存。# b7 U7 \# h' a; {
description "Kafka"
8 ^( Q- b. j" d' C( F+ S8 X9 @7 @& Q
start on runlevel [2345]
$ M: y% T9 P2 d! ~# I' `6 e istop on runlevel [!2345]
j `2 O" ]0 x- H0 i5 E* u- O8 N* ^ G7 C
respawn
( M8 M" D3 K1 M$ x. O/ ~- P3 d) Q, t, b6 n$ h! J
limit nofile 32768 327689 F4 q/ N, R- g
& G( C6 s$ |) Y7 A, u H; X
# If zookeeper is running on this box also give it time to start up properly2 q3 G7 s4 d, B
pre-start script- }2 W3 [) a z; `( n
if [ -e /etc/init.d/zookeeper ]; then0 Y9 B# y6 X- U8 A' y5 v
/etc/init.d/zookeeper restart( Z4 `) I0 O0 ~' S/ ^ A
fi& E& {3 D& N7 ^$ W' A3 p3 D8 r
end script* U! t9 N! `1 G2 s9 @
' G/ P8 Q/ E& A# F0 T% r. z# Rather than using setuid/setgid sudo is used because the pre-start task must run as root9 o, @$ i2 Y& V) N- c, b
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
# D% S1 N( T4 }# J/ t; [* [配置kafka,vim /etc/kafka/server.properties,确保配置了以下内容:
; W. O% ?4 @' Q7 `' Z; Chost.name=localhost W7 i3 y+ Z; L3 V0 G5 T$ A6 U' b, s
advertised.host.name=localhost
! j* [+ F3 U& p/ P' _log.dirs=/var/kafka9 F2 K" h) |9 N
创建 kafka log目录$ g/ j4 J2 }) w5 _# T: c3 k/ S
mkdir /var/kafka- U; O: U }$ n. J" M9 I4 ]
mkdir /var/log/kafka
/ c# V \6 K' w* L- w9 ^; hchown -R kafka. /var/kafka/
& ?2 B$ p/ ~; v# r1 K, ?chown -R kafka. /var/log/kafka/+ D5 f+ ~4 A8 F& ?$ m m
启动kafka服务
' d# }5 r2 m, T+ Pservice kafka start. q8 d/ G- U+ k; M! g2 n
下一步就是创建 kafka topics0 `1 d/ M) T% j
/opt/kafka/bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 64 --topic metrics) I! I# n! v! y& ^& d
/opt/kafka/bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 12 --topic events* n7 d* o- H, X% m7 n0 y
/opt/kafka/bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 12 --topic raw-events
8 }( w' W+ s5 m& y: n, t/opt/kafka/bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 12 --topic transformed-events
1 Z0 s9 {( E4 \6 p+ e: C/opt/kafka/bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 12 --topic stream-definitions
o) Q. ]" n1 ~! E/opt/kafka/bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 12 --topic transform-definitions5 E' S! |. L, y G, |
/opt/kafka/bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 12 --topic alarm-state-transitions
7 x1 P7 d r6 q5 o/opt/kafka/bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 12 --topic alarm-notifications
% L- `; ~0 F, L( i* V/opt/kafka/bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 12 --topic stream-notifications F8 S2 Q; f3 U. b; A/ | j
/opt/kafka/bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 3 --topic retry-notifications - 安装和配置 influxdb% Y5 c& H. z+ D3 c/ e8 C
curl -sL https://repos.influxdata.com/influxdb.key | apt-key add -7 z9 C" w2 D$ C1 Q
echo "deb https://repos.influxdata.com/ubuntu trusty stable" > /etc/apt/sources.list.d/influxdb.list% i- A" w" ?- t; Q! Q
apt-get update9 W) ?; Y# x5 d% I- L
apt-get install -y apt-transport-https
, D: W/ g# T! M2 o% v4 o7 wapt-get install -y influxdb/ a5 i# V# `( C w- ?0 ~4 Q
9 h. f) t% t2 W. Gservice influxdb start
( N ^, R7 C! U, l' Z创建 influxdb database, user, password, retention policy, 同时修改密码。; A7 M0 \$ ~) z0 ]
influx
1 Y7 l6 H4 T7 N6 e* |CREATE DATABASE mon1 L x7 l9 i/ h/ w- o: x! T: V
CREATE USER monasca WITH PASSWORD 'tyun'7 d7 _5 H4 ]- F$ @
CREATE RETENTION POLICY persister_all ON mon DURATION 90d REPLICATION 1 DEFAULT' D! C: q3 k' \3 d
exit - 安装与配置 storm
1 J; L9 F* m: Pwget http://apache.mirrors.tds.net/storm/apache-storm-0.9.6/apache-storm-0.9.6.tar.gz1 h- H9 U* @7 T0 J: u
mkdir /opt/storm
! Z$ t% V! `) K8 Hcp apache-storm-0.9.6.tar.gz /opt/storm/
" }5 ?$ u( I6 L# |9 [; d; \cd /opt/storm/) u+ I: p9 E' q9 S' N' d0 g! g3 z4 ~
tar xzf apache-storm-0.9.6.tar.gz8 @" K5 q# ~6 h- m5 D& J9 C! Y
ln -s /opt/storm/apache-storm-0.9.6 /opt/storm/current7 R% t. [) b9 z6 u
/ K, Y, K# s/ K$ K
useradd storm -U -r2 A) t- y2 c' n3 g
mkdir /var/storm
/ f9 [3 c# i0 n9 g0 v6 t0 Qmkdir /var/log/storm. Y6 A f2 H! F; P L: O
chown -R storm. /var/storm/3 G& b! K1 V" ?& S* B( v, L
chown -R storm. /var/log/storm/5 O8 u+ G8 p9 q0 q. ~
修改storm.yaml, vim current/storm/conf/storm.yaml1 }; C6 z4 [+ O* ^
### base; T5 _/ o0 g: { }5 U2 ]/ |
java.library.path: "/usr/local/lib:/opt/local/lib:/usr/lib"
8 `& f/ {8 w0 a6 i, O1 T* \storm.local.dir: "/var/storm"
$ u" h5 G% o( g! r* w/ E$ }( f# c
### zookeeper.*: C; G, {& \! l' d. ]
storm.zookeeper.servers:
* T. c D- j( H- A0 {, R* W- "localhost"
x% R( |7 }8 gstorm.zookeeper.port: 2181
0 ^ H7 p( L. M1 m+ lstorm.zookeeper.retry.interval: 50004 F) H7 w& J& t& `' R. \9 ~
storm.zookeeper.retry.times: 292 \# \( s& Q4 _) [
storm.zookeeper.root: "/storm"
' s a" e! b% A V, {% {3 R& @5 }storm.zookeeper.session.timeout: 30000
; v+ o- {7 f1 [ s" o
9 \* x; W+ L% n4 @$ S### supervisor.* configs are for node supervisors
) Z+ @ z( I1 T# o4 e5 z: Q& n. T$ Q: z+ Psupervisor.slots.ports:3 B, I$ O+ s0 O: ]
- 6701
+ I* R( ?9 s" k, N- 6702
% e. b- m5 ^* i- L8 ?9 W+ Z/ U- 6703# A* ~8 s% [/ c" @# d
- 6704
) }6 N p/ ^- usupervisor.childopts: "-Xmx1024m"
* r6 w4 ^6 l4 ?) L7 n& R3 J) T. q1 C4 L; W$ K* A9 n0 w5 G8 H5 X+ @5 [
### worker.* configs are for task workers
+ ?/ s) l k3 F F' R$ \worker.childopts: "-Xmx1280m -XX:+UseConcMarkSweepGC -Dcom.sun.management.jmxremote"! U, s$ ^$ Q% ~9 s
L/ s) e, v. W5 X- K### nimbus.* configs are for the masteri
/ H6 c" J/ B. Pnimbus.host: "localhost"1 K& l7 J: _' h- O; H3 N6 O# Z
nimbus.thrift.port: 6627
7 r5 F! D- K3 u- t9 smbus.childopts: "-Xmx1024m"; L. d3 c# x0 B' y% E) g& H" h
; B( c1 K- O- K6 [8 w; P
### ui.* configs are for the master) s& b$ x. T( y6 V
ui.host: 127.0.0.1
/ g6 _) k' _7 tui.port: 80787 \1 z" K& R, i" N/ L
ui.childopts: "-Xmx768m"1 z2 I& ~( @8 v' p9 Q! g/ E
9 S, c0 g4 e4 T* [
### drpc.* configs! o- @- f( s. w9 Z7 J3 `
" u; Q8 O: s8 F: W
### transactional.* configs
1 c I; `& p# Gtransactional.zookeeper.servers:6 B) A) v5 n2 T; a' s# D( I* f
- "localhost"! ~1 C: T8 p+ t2 H* \
transactional.zookeeper.port: 21817 Q$ j* g: | Z: V
transactional.zookeeper.root: "/storm-transactional"
! y. T: U) s$ k, U" r# @1 u" P" y) G, T3 F' }# K ~7 `3 L: r0 P
### topology.* configs are for specific executing storms
0 s/ ?; ^* I4 I* I4 L% gtopology.acker.executors: 1
! l" [; [6 ~) Ctopology.debug: false# }0 H0 {; z2 v
7 y% L' M/ s. N4 m, Mlogviewer.port: 8077
3 I2 p; d' V* Y2 J" ]logviewer.childopts: "-Xmx128m"
4 v% n, a% e% v" ]创建storm supervisor 启动脚本,vim /etc/init/storm-supervisor.conf; k( {, X( g" V' C( {
# Startup script for Storm Supervisor$ S. [; r2 A, Q5 x, o1 N
7 k- W5 J! o1 P- \- W
description "Storm Supervisor daemon"5 {+ h; }5 h& Z" h, x4 W8 q( G
start on runlevel [2345]
0 V) u. V# h& g, j$ I$ H& |" @7 G- n; m+ ]7 T" W. S. h* _
console log- a) q0 d* W1 B+ M
respawn" u+ r J0 `' Q! j9 P
$ E U( I2 D1 k. T0 u9 U
kill timeout 2403 v$ ], U$ S0 U. R) I* A1 M( P
respawn limit 25 59 c. t- J6 _4 E$ u
& m3 r2 P/ y+ \
setgid storm
0 n% E+ s. a: s, qsetuid storm" v0 f. |0 }9 l/ E0 L
chdir /opt/storm/current
4 u8 E% q; ?6 G4 q- J- Aexec /opt/storm/current/bin/storm supervisor# F: m, q+ s; Y' D, @
创建Storm nimbus 启动脚本。vim /etc/init/storm-nimbus.conf
0 h' O W8 }- J4 ?4 l/ R8 e. h0 P# Startup script for Storm Nimbus
: u8 s+ x7 L* R9 g7 V9 [3 q$ K" o; ] p& S. l
description "Storm Nimbus daemon"# K* [8 K. L! s/ `9 k' |% O6 x! B
start on runlevel [2345]
) B: w' C) {) b/ |% d/ a9 ~- V
( }4 |" [9 R0 o( k5 _+ j* Y6 ]console log
. ?) H# V' `, w5 N/ ^2 erespawn
& x( ~) J, E4 O1 C2 H4 ^
% S. ^5 A! c3 W9 b, M. Wkill timeout 2406 M3 U; Y1 ?) `0 d7 \/ {- d
respawn limit 25 5
' U2 y( H! x, |
. B* @, t* H6 x/ _4 ksetgid storm
: c5 N! l$ x2 S' t/ hsetuid storm
# X4 \" r5 y0 q* w3 ]chdir /opt/storm/current9 Y. d4 T ^$ b! F, P5 q
exec /opt/storm/current/bin/storm nimbus! Z6 k: r2 t- ^$ v
启动supervisor 与 nimbus
/ O( r- x- ~( V9 o1 Zservice storm-supervisor start
" {, D' Y3 r, y9 Z2 F: j' F2 U g. yservice storm-nimbus start - 安装monasca api python软件包6 n4 ^2 ^; Y& z" E+ k7 \1 l) X5 R
一些monasca组件同时提供python和java代码,主要是我选择python代码进行部署。
% ~3 y( ]! B' ]* ?* F! k+ @pip install monasca-common" Q# a% y& a3 N7 p
pip install gunicorn
' o! J" M$ c3 ]$ dpip install greenlet # Required for both
6 q& J; @6 I x4 r* v2 A3 U4 f- Lpip install eventlet # For eventlet workers
# H* l+ t y$ }( p2 M1 a& opip install gevent # For gevent workers O8 t1 w1 l. N% x; b/ Y: n* V% P/ ]
pip install monasca-api m6 x$ I3 C$ H$ ?( t6 `
pip install influxdb y% M1 i( [% ~$ X z
vim /etc/monasca/api-config.ini,将主机修改为您的IP地址( x, T! Y3 N3 a3 B. [$ |9 Q
[DEFAULT]
- I; y/ {- e3 K' Bname = monasca_api
5 B6 i4 \. v: d- t5 N) ~. j9 j* A3 |
6 ^! K+ V& D$ Y% o& e[pipeline:main]* G+ J' z1 f, s- @3 {. v" @
# Add validator in the pipeline so the metrics messages can be validated.
6 I Y; I2 G- m( c6 L" fpipeline = auth keystonecontext api
! ^6 j3 ]6 D) n: `& V7 H
" ?4 S9 d. W" g' L7 W5 b( o7 _% d[app:api]. E' {9 c, Z h" O8 z# {/ d9 U3 W n3 ]
paste.app_factory = monasca_api.api.server:launch
@# P# ^! r6 w3 Q8 E& @8 ~( b9 M& Q4 N) K2 A$ ]# V" Q
[filter:auth]. i2 i/ S+ N" t
paste.filter_factory = keystonemiddleware.auth_token:filter_factory. h& Q% }3 f% B
/ w; H0 p; f w4 E# T8 J. _[filter:keystonecontext]' o0 s/ Z( B; i/ [& {6 p3 m: R
paste.filter_factory = monasca_api.middleware.keystone_context_filter:filter_factory, P3 h' w. k# F. y( _; J
4 i' Z+ w% K) T* r) F( W
[server:main]
9 t i0 F1 ?6 m* L6 m y, J9 Ruse = egg:gunicorn#main
$ u8 u, i7 k, r3 m vhost = 192.168.2.23* i) i- S5 M; ~5 F
port = 8082
) H+ r" i! n3 F0 [, I# p6 J" D2 k. j- Tworkers = 1
2 g) E+ I, \" D2 R/ I7 G9 Lproc_name = monasca_api
. n2 W% l+ s1 {1 F1 A! Cvim /etc/monasca/api-config.conf,修改以下内容
3 D) w3 P% v# y) G5 w[DEFAULT]1 P9 H% A: O3 `" u5 d
# logging, make sure that the user under whom the server runs has permission
- p; M/ z3 f0 v Q# to write to the directory.
& X: P- p$ p2 b1 s2 a O5 q( }log_file = monasca-api.log
$ o5 @0 I, U$ |% L$ u* }* }log_dir = /var/log/monasca/api/5 d' S1 L6 ~( h9 P. s7 h& U% f4 D" t" X; g- d
debug=False' D7 M! Z& J$ P; C. C9 J% j
region = RegionOne% J' }. `5 C+ J' \% M: p
[security]
. Z3 u7 e5 N+ ~/ @# The roles that are allowed full access to the API.- M+ U& A# w1 a3 O& Q3 ^; V+ ?
default_authorized_roles = admin, user, domainuser, domainadmin, monasca-user
! u0 X, d& p; s8 \: W& |% ~7 v% }- x5 {5 ?' D* c8 l2 j* G& v; x
# The roles that are allowed to only POST metrics to the API. This role would be used by the Monasca Agent.
3 l$ t1 i, Z0 L7 q+ \5 }9 t& ]agent_authorized_roles = admin
% p8 C& }6 ]* Q, P& s
& R) e* e, ]& X7 f# The roles that are allowed to only GET metrics from the API.
. f5 _" A2 [% ^5 H2 s$ X+ d$ e& ?read_only_authorized_roles = admin
$ T3 |* p/ R% I# j) m3 M5 P! ^
3 k; y7 |" Y# I1 R% a# The roles that are allowed to access the API on behalf of another tenant.
: ]! b& V7 @8 N& C# For example, a service can POST metrics to another tenant if they are a member of the "delegate" role.
% I4 E8 f, B' h- Ddelegate_authorized_roles = admin
4 w3 Z; T9 ^! l
7 d* y {# `1 [8 X( j[kafka]
4 n) k+ N2 X* |9 t. H' ^# The endpoint to the kafka server9 c O: m& p/ ?, i/ k. r% a$ R1 N
uri = localhost:90924 I# S9 R& |1 e Q
0 q# X. n. @+ n; A* d2 U7 L
[influxdb]$ |8 s/ i% [2 X1 u. E$ \5 K
# Only needed if Influxdb database is used for backend.
1 ~2 M6 `( A1 C6 B5 l+ _8 R# The IP address of the InfluxDB service.
& Z' I) a9 r+ d; @! wip_address = localhost8 x* S" |4 P! y
8 w C; q: {% n$ R
# The port number that the InfluxDB service is listening on.
) I0 y' {) v5 `8 {port = 80866 O4 y# ?) `3 j
& [7 |$ d1 R* ^/ d. p( ]& B
# The username to authenticate with.
* \* ]2 x; p, t- ^ Xuser = monasca
# i7 m H) p1 d) }
3 X& u3 z# x. N/ p! T/ I: g" }# The password to authenticate with.! C) w& P I# I! ~% t
password = tyun& n" D7 t- K, P* a7 h
$ v! }3 ]$ W L8 T" t4 `( L
# The name of the InfluxDB database to use.; F! h7 P0 R; K
database_name = mon6 h. j/ M8 h7 c; }" `* O
) I/ w2 `9 C8 [9 L& k5 {
[database]+ H9 R: i- z% X7 D1 b0 d8 }4 E" }
url = "mysql+pymysql://monasca:tyun@127.0.0.1/mon"
% a+ _0 z9 b) ~+ T+ F! u) J0 q. e" O( g+ O! |# I
" x/ B5 v! k, s6 ] T$ V[keystone_authtoken]
, N8 Z( P) G. v$ K1 r* G& Jidentity_uri = http://192.168.1.11:35357( I# D* h) v7 z. Z) f$ `3 W9 b# F
auth_uri = http://192.168.1.11:5000& f6 P7 i$ C7 x, m% O. a3 x$ @
admin_password = tyun; L6 m2 _, g, B& f
admin_user = monasca
( q7 C. E$ C1 F4 M4 Badmin_tenant_name = service
; ?6 h5 G) R7 d! Rcafile =
; n+ J' h2 G& c, ]0 g5 zcertfile =* p2 L2 y, y, Y; \
keyfile =" c/ A& t0 z5 d$ j5 p1 e
insecure = false6 x. }4 T( L1 n: K
注释掉[mysql]部分,其他部分保持默认。
( g* [; O( G0 I+ `5 r6 _创建monasca系统用户并进入目录# ?# C7 m7 n3 R( L) W$ k
useradd monasca -U -r
2 A' M' @9 E8 l2 s3 lmkdir /var/log/monasca
6 G: b( R! T' K& J& `# H1 D- _4 nmkdir /var/log/monasca/api
7 Q8 K8 ?' x4 e2 g; pchown -R monasca. /var/log/monasca/
& Z0 C v# {3 v. _$ T+ g4 ^在openstack控制器节点上,创建monasca用户密码,为租户服务中的用户monasca分配管理员角色。, d' j+ q# F" ]! b$ M7 D8 {1 l! d/ ~
openstack user create --domain default --password tyun monasca
: E2 U% n# I; Kopenstack role add --project service --user monasca admin
8 E2 a1 f2 E; `9 |% l( R3 k
0 I( K6 G0 c- @4 u' o7 Aopenstack service create --name monasca --description "Monasca monitoring service" monitoring+ h/ f( }; c v0 L3 x# d/ U5 }
0 y3 |6 d( [- f' ?- j, C7 mcreate endpoint
' @9 o4 E2 A/ t2 gopenstack endpoint create --region RegionOne monasca public http://192.168.1.143:8082/v2.05 R V( k- C) \! x" R0 g: H8 \
openstack endpoint create --region RegionOne monasca internal http://192.168.1.143:8082/v2.0. S' X/ u- u) `' W, I4 G9 |; E
openstack endpoint create --region RegionOne monasca admin http://192.168.1.143:8082/v2.0
1 Y$ ~+ f; n" S- |8 n' c192.168.1.143是我的api虚拟机地址的浮动IP,请将其更改为您的IP。9 u+ U+ F* |! H f4 m( f# m, U
创建monasca api启动脚本,vim /etc/init/monasca-api.conf
% @4 q; J) @1 v% T8 |4 a# Startup script for the Monasca API ^! p- S5 c; m0 W
" ]4 d* {& n6 S/ i
description "Monasca API Python app"
. e2 V0 I# y0 @5 h: `8 Hstart on runlevel [2345]3 |% g, x# ?1 u8 ?" L5 X( W
% [2 _" A5 e: M6 T$ J5 E, ?6 Q8 ~console log( T, ]$ y" a- q* Q9 W
respawn+ ~/ j( Q( ~/ `* ?, O
) f' w5 L0 _( W `! O
setgid monasca; M4 R* U* V6 ^- `0 P. U/ g
setuid monasca
+ g1 b/ o T4 T; l( O oexec /usr/local/bin/gunicorn -n monasca-api -k eventlet --worker-connections=2000 --backlog=1000 --paste /etc/monasca/api-config.ini - 安装monasca-persister
3 X: I3 c3 M. o2 G- t3 s2 L" a创建monasca-persister启动脚本/ n9 O5 o+ P1 a5 N
vim /etc/init/monasca-persister.conf
- w1 ~$ B8 A8 p( [. t Q# Startup script for the Monasca Persister+ K$ z) _# \$ l$ E1 L
- ~3 R8 Q; v6 }: ldescription "Monasca Persister Python app") r! t% @) ]. o. d F
start on runlevel [2345]
" W: h6 o8 ~5 r. ]9 W0 O3 E( }1 v- r( v" t- R# k8 G
console log+ M) }4 G& z$ Y( b5 q
respawn) a M" b8 f# b+ V
1 z2 \% `6 l( Z" Hsetgid monasca" i, v5 P8 h7 F& S" n
setuid monasca0 M8 {! R2 K- F7 R$ T7 T5 b b
exec /usr/bin/java -Dfile.encoding=UTF-8 -cp /opt/monasca/monasca-persister.jar monasca.persister.PersisterApplication server /etc/monasca/persister-config.yml: ~& R) e; {2 g, P; m+ }& S
启动monasca-persister6 A3 w0 r7 u3 e* d
service monasca-persister start - 安装monasca-notificatoin
$ G- X+ H; j/ j/ ~pip install --upgrade monasca-notification
+ I( B* ~3 ^. ]* n7 fapt-get install sendmail0 }, @& U3 X7 s$ i( R+ N9 m1 t1 _
将notification.yaml复制到/etc/monasca/ 创建启动脚本,vim /etc/init/monasca-notification.conf5 O9 `( L8 W+ r
# Startup script for the monasca_notification: ^8 G" U; Z8 V9 p
$ ?& }$ z5 w, c4 h& J+ `
description "Monasca Notification daemon"8 V) D6 |3 u( E
start on runlevel [2345]( Y, t1 `- E, p2 k* c7 ], W
9 p4 U. z3 ]. N8 Q
console log2 ~- J, q) n, Y( H8 n3 P
respawn
2 {2 }1 s! |4 G& \+ _) r6 `% g* C6 Y+ I8 T6 c$ E
setgid monasca( t* u; o1 v) H' N* @
setuid monasca
- N) f; k" T" r2 |2 [4 O" _exec /usr/bin/python /usr/local/bin/monasca-notification
2 U4 M( k. u2 Q% z# y9 o启动通知服务
& V5 U: h, s# h$ ^9 wservice monasca-notification start - 安装monasca-thresh 复制monasca-thresh到/etc/init.d/ 复制monasca-thresh.jar到/opt/monasca-thresh/ 复制thresh-config.yml到/etc/monasca /并修改主机以及数据库信息 启动monasca-thresh8 v; F- r: H* a& Z, G" a
service monasca-thresh start - 安装monasca-agent: _: e3 q3 y# p# i0 U$ V8 W+ k
在openstack控制器节点上安装monasca-agent,以便它可以监控openstack服务进程。- r3 X" y' [ D- ~! {
sudo pip install --upgrade monasca-agent
+ [6 Y; |3 m+ \# |, L2 C1 j* h& o9 o设置monasca-agent,将用户域ID和项目域ID更改为默认值。. R7 L& N7 Z$ r, Y' P, F6 {# {
monasca-setup -u monasca -p tyun --user_domain_id e25e0413a70c41449d2ccc2578deb1e4 --project_domain_id e25e0413a70c41449d2ccc2578deb1e4 --user monasca \
8 u; o+ Y/ o& g" w) H--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 --overwrite0 ]! F+ o2 `/ f8 [1 Y# @
加载认证脚本admin-rc.sh,然后运行monasca metric-list。
( A; ^! Q9 i3 o) j6 S 1 D, ]" M* |8 S, @) H$ g
DevStack安装运行Monasca DevStack至少需要一台具有10GB RAM的主机。 可在此处找到安装和运行Devstack的说明: https://docs.openstack.org/devstack/latest/5 B$ z1 q! O$ f
要在DevStack中运行Monasca,请执行以下三个步骤。 - 克隆DevStack代码库。
9 f, h& D$ a( J$ _" X git clone https://git.openstack.org/openstack-dev/devstack# ~. c$ c0 n! x5 C$ s' q# [* U7 F
- 将以下内容添加到devstack目录根目录中的DevStack local.conf文件中。如果local.conf不存在,则可能需要创建它。
/ p: U: W- O: g4 ^ # 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
+ T: A; E# p% ~8 Q1 A. x- 从devstack目录的根目录运行“ ./stack.sh”。4 |; x7 J" O9 q \+ @' A2 m
如果要使用最少的OpenStack组件运行Monasca,可以将以下两行添加到local.conf文件中。 disable_all_servicesenable_service rabbit mysql key# Z$ `- \) ]9 v, _' T
如果您还希望安装Tempest测试,请添加 tempest enable_service rabbit mysql key tempest
4 {* l# }0 i4 _' @9 w要启用Horizon和Monasca UI,请添加 horizon enable_service rabbit mysql key horizon tempest
4 @" h# j/ n: R7 @( p" R% E使用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 DB
. t( T, a! M; T4 p4 |* D" ]; P: R; WMonasca支持同时使用InfluxDB和Vertica来存储指标和告警状态历史记录。默认情况下,在DevStack环境中启用InfluxDB。1 `4 d' t, x; x& ~
Vertica是Hewlett Packard Enterprise的商业数据库。可以下载免费的Community Edition(CE)安装程序,要启用Vertica,请执行以下操作:6 u+ ]1 x0 ^" R( J3 }
- 注册并下载Vertica Debian安装程序https://my.vertica.com/download/vertica/community-edition/,并将其放在您的主目录中。不幸的是,DevStack安装程序没有可以自动使用的URL,因此必须单独下载该URL,并将其放置在安装程序运行时可以找到它的位置。安装程序假定此位置是您的主目录。使用Vagrant时,您的主目录通常将以“ /vagrant_home”挂载在VM内。
- 修改local.conf中MONASCA_METRICS_DB变量,配置Vertica的支持,如下所示:: R2 h$ D0 X9 f# h: y9 z. r
MONASCA_METRICS_DB=${MONASCA_METRICS_DB:-vertica}
- h4 N Y4 R7 ~5 _1 ~& m) \
: z3 }; }# B' C4 f- 使用PostgreSQL或MySQL( j, U. h( [3 D$ K7 S' _
Monasca支持使用PostgreSQL和MySQL,因此该devstack插件也支持。启用postgresql或mysql。
4 y1 }. I- b+ F) ]/ A' I# b要使用MySQL设置环境,请使用:- p5 _' [" O0 g3 G
enable_service mysql
9 a( q+ u$ L! w4 I- l另外,对于PostgreSQL,请使用:) {, \% N: [1 N: z; G
enable_service postgresql - 使用ORM支持
1 z: D" ^4 W* I& h. [( jORM支持可以通过MONASCA_DATABASE_USE_ORM变量来控制。但是,如果启用了PostgreSQL(也称为数据库后端),则将强制提供ORM支持& C( t1 u6 g5 b4 Q+ f7 R/ G' g
enable_service postgresql - 加强Apache镜像
9 O2 f2 w9 q+ \( v) d8 ?1 G如果由于某种原因APACHE_MIRROR而无法使用,则可以通过以下方式强制执行:
3 d8 h8 {. `* I- m# aAPACHE_MIRROR=http://www-us.apache.org/dist/ - 使用WSGI
. _8 K: Q- ?! ~! d Q1 m! nMonasca-api可以使用uwsgi和gunicorn与Apache一起部署。默认情况下,monasca-api在uwsgi下运行。如果您想使用Gunicorn,请确保其中devstack/local.conf包含:% T" {4 [0 s0 w3 K6 O# ]1 N
MONASCA_API_USE_MOD_WSGI=False' t0 R j, n/ E _; R* @( s. e7 i# g
使用Monasca Dashboard安装完成Monasca Dashboard Plugin后,可以通过web控制台进行查看以及管理相应的监控与告警。 在操作控制台的“Monitoring”栏,单击“Launch Monitoring Dashboard“,这将打开在管理节点上运行的专用OpenStack Horizon门户。 在该面板中,您可以: - 单击OpenStack服务名称,以查看服务告警。
- 单击服务器名称以查看相关设备的告警。8 M* g+ J$ k( v/ C, ~ j! r
监控信息存储在两个数据库中(Vertica/influxdb与mysql)。备份监控数据时,将同时备份两个数据库。看到 - 监控指标在Vertica中存储7天。
- 配置设置存储在MySQL中。
- 如果监控节点上的服务在高负载(例如15个控制网络和200个计算节点)下停止,则消息队列将在大约6个小时内开始清除。
, T7 K' J/ D5 o. z3 S0 p
|