|
|
将node_exporter加入systemd管理
. `& E/ ~4 l4 E, D/ c3 d. t
3 Q+ s5 H2 c- x(1) 启用node_exporter的HTTP认证
* @5 J" l" E, ?2 T. S" v; l7 q: Z- T) H" b& s# y
1) 生成加密密码
; k3 a2 _% O' h$ J" _
6 T! B# a$ q t7 u# yum install httpd-tools -y: V& S& u' f$ t4 s7 l7 L
* N. @3 L) B- K
# htpasswd -nBC 12 '' | tr -d ':\n'0 {( f7 b5 ?3 d' H" }8 p/ u
3 y% S& Q! P3 R( S) m3 g9 w
New password: qwert123! }- ~' y/ j8 E& f
# F9 ?5 Y: ^2 R
Re-type new password: qwert123
1 X) o. X+ o. s+ V H6 f: p5 t0 p* Q; {5 o8 T7 C4 ?9 j/ S4 I
$2y$12$2pXFHMwfe9Kmwl86GtzTcOjYzSsyLPMvGRynX0WXx7UZY2rSaIwJ.: J# L( ~* f! t4 |0 [6 E) @
% ?( y5 a6 S! w' k( n' a2) 配置认证文件8 \( Z4 a$ _1 I* n
0 [7 T @9 t" d0 u# vim /usr/local/node_exporter/config.yml
& W6 Q/ U/ i+ `1 o9 g+ Q# ]1 J7 l% k3 M# e- j/ b7 F
basic_auth_users:
& \8 N b) N, C6 {4 ]5 `
1 P. q. Y* |, p/ F/ [; o9 i prometheus: $2y$12$2pXFHMwfe9Kmwl86GtzTcOjYzSsyLPMvGRynX0WXx7UZY2rSaIwJ.
' [. r. G* U' k8 `+ H- q2 \
' l8 y9 n# B0 U2 u/ _2 |& S! s: J" m6 M2 f! N
(2) 启动服务
! f8 `* ~! G- E4 P$ `$ h6 F8 W0 R3 }9 E- @" I& P- S/ H
# vim /usr/lib/systemd/system/node_exporter.service
! V# ]+ v( k1 D4 s6 F) i: @5 X, E0 T7 {+ [* q# |6 x/ N. b7 Q
[Unit]
' v( Y! ]3 a% t7 I5 p+ B! @1 y: A& w2 p( ]+ x
Description=node_exporter+ W+ j4 t* y" o5 g/ q9 Z
" u; J5 R+ j7 v/ K! o# y2 |# T( v! q[Service]8 s3 t. ]! u+ B$ h; k* @: `
! b( N% `8 f- f2 _4 K( R1 v
ExecStart=/usr/local/bin/node_exporter --web.config=/usr/local/bin/config.yml4 I( ?' W0 R% l* V
/ V! Q) W8 A9 ?3 L
ExecReload=/bin/kill -HUP $MAINPID$ Y. g. n, ~# v, k6 X
- _- _* |% O" W3 y) p& ^ [
KillMode=process
' P) q* J9 K. `8 g7 v- n4 B8 d, h) e. G9 N3 L9 T
Restart=on-failure
! S+ c# e$ |2 M: U( B# i
+ z6 H6 G8 I. q+ {! b[Install]
v- V0 n% c) l+ E# X( Y3 O+ S0 }6 ~$ b, [/ e
WantedBy=multi-user.target% c T7 v3 H3 Q8 f
! k3 B% x- I2 Y/ P% d- I- H* g+ Q/ R" r# ]. M9 _8 P8 W
8 {: f) K _ ?# systemctl daemon-reload
% I# f, `6 y- u. A! ]7 b$ d6 }
$ d5 |4 p- _( W$ X1 U; p# systemctl start node_exporter
8 O$ f8 E# K2 }# n, G1 W% `9 i0 \6 ]/ O4 s: x; c
# systemctl enable node_exporter
4 ]$ d7 S, B2 x0 _
' O( w% x, X5 q7 s
: p {# H1 @9 k6 V! H& F# ~% w1 _4 a, {
|
|