找回密码
 注册
查看: 399|回复: 3

Failed to run bootcmd module bootcmd

[复制链接]

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
发表于 2023-9-12 17:00:03 | 显示全部楼层 |阅读模式
Failed to run bootcmd module bootcmd3 K7 s2 x# e2 e+ ~

5 q3 e9 F( a( q4 X7 E
8 s' W$ [8 o0 K5 B( C4 g! `2023-09-12 08:11:12,132 - util.py[WARNING]: Failed to run bootcmd module bootcmd- s$ }" ^0 w0 S7 n# G
2023-09-12 08:11:12,140 - util.py[WARNING]: Running module bootcmd (<module 'cloudinit.config.cc_bootcmd' from '/usr/lib/python2.7/site-packages/cloudinit/config/cc_bootcmd.pyc'>) failed
& `3 j6 F" D: c4 G& q" X7 W, I& X! Q; ^( z
( T1 S7 I/ ^1 e# j& O/ K
& `* X3 @4 @7 _% Q% r6 w! b

; x. b7 n1 `, @. R8 {* Y* R; u, \+ P; r4 }
语法格式:cloud-init [参数] ; L+ H. O  d2 W4 x4 k
% h+ D" V8 S3 T5 I4 M5 T
常用参数: init 初始化cloud-init并执行初始化模块
3 \9 F) M$ q" z. z+ O4 R初始化$ |4 F" N* V1 }8 k0 p7 W2 Y
' B, [/ J4 N5 P, a
cloud-init并执行初始化模块:
! u$ t1 P; X$ q) a8 @# u1 I8 d0 {* m8 s' C# z
[root@cool ~]# cloud-init init  K: K. n1 f: G1 h8 \' k6 Q1 r

: I* q- z: z$ {6 p5 t" o使用给定的配置键激活模块:5 k2 P# F6 u  s. f

5 p- b/ p3 H/ o  N1 m9 l# N6 f[root@cool ~]# cloud-init modules
# Q5 j/ P0 M: `0 X. F% s9 P2 l; U
6 y% `( b3 x4 c3 _: @! C$ m报告云启动状态或等待完成:$ T. s. X8 C# |2 |8 F

! i$ R- u2 p$ W[root@cool ~]# cloud-init status
' O3 ?. g+ Y9 e8 C& H
/ h, r. F% {; `( I* s0 ^% D删除日志和工件,以便重新运行cloud-init:. `" x, y* \4 T9 }

# I2 j% H" s' [) c0 l[root@cool ~]# cloud-init clean1 B$ Q9 z4 O( y  H+ Y" F8 J

: F( S+ r1 x6 c; u根据以上信息,得知我们需要自动扩容vda3分区(growpart)、扩容LVM和xfs文件系统(runcmd)。
; P. }3 i# K7 e0 w3 @! b创建文件/etc/cloud/cloud.cfg.d/growpart.cfg8 a2 J$ ?! n$ j1 g
vim /etc/cloud/cloud.cfg.d/growpart.cfg
+ H+ N( I* V, H1 M( F2 d$ A" A- G1 g# R% R
#cloud-config+ n& A& v/ A% a4 ?4 b( x6 U- Y
growpart:$ K/ Y  N# C( I4 L" E7 k8 j7 `/ e: M
  mode: auto5 N5 @" v8 g' |9 s
  devices: [/dev/vda2]
$ Q/ @! {! i) Q3 n; ~' e  ignore_growroot_disabled: false
* i$ W9 B# A$ n- D9 E# }runcmd:
5 Z5 r1 B% F# y/ f0 u5 B  - [pvresize,/dev/vda2]) e* _  o! l9 d3 p3 Z- a3 _$ K
  - [lvextend,-l,+100%FREE,/dev/mapper/vklas-root]
6 H+ z6 i% i9 e; K6 j  ^5 I  - [xfs_growfs,/]. z. y6 F0 A6 S& D% E* n1 A$ d

5 V& |! @9 w* C% a注意:文件系统为ext2、ext3、ext4,则采用通过resize2fs 进行调整. h" s* H) y3 U/ i8 M) h

1 t. c( H# C' E% x2.5 每次重启均调整
& X) h) D* H" \
( F  c" A8 c# s1 w9 r5 N2 P该需求涉及到云平台会有调整虚拟机的需求,也就是虚拟机磁盘进行调整后,文件系统也依然需要调整,故衍生出每次调整后自动扩容的了。" X1 x1 \& V; Q# |' f
不同的cloud-init模块有不同的执行频次:once-per-instance 、 always。可以在Modules文档中https://cloudinit.readthedocs.io/en/latest/topics/modules.html7 g2 n0 b" p8 u# T
查看每个模块的Module frequency属性。例如,bootcmd在每次引导时运行,而runcmd只在第一次引导时运行。频次也可以在cloud.cfg配置文件模块列表中覆盖——cloud_init_modules, cloud_config_modules和cloud_final_modules。9 M- z5 J0 C8 F! n. [! O' y) I( N
故我们有bootcmd和runcmd两种方法实现该需求。
$ C% F/ r# s- w  i5 l5 R% M& {+ k' {# v" S; q- a0 m1 \
runcmd# \3 q( |& Y$ d8 o# t
通过修改/etc/cloud/cloud.cfg文件,覆盖模块频次  I/ @/ @' L% r# }0 b
vim /etc/cloud/cloud.cfg+ g: [# W: P+ {! |/ [" g0 W# N

1 t: }+ t4 [' P8 i; D% n4 Kcloud_config_modules:
, C: c3 Y$ v9 X4 a - [runcmd,always]
4 O* B5 r. J; C2 h" H2 j4 ~. d+ j* I, b3 x( U. S" \* P
2.5.2 bootcmd- Q( s5 F+ o6 H) ]/ @3 `, t
修改/etc/cloud/cloud.cfg.d/growpart.cfg,将runcmd替换成bootcmd,全文如下:! L* A3 T% K! D7 i/ P
# M5 J  `: L% \& O
#cloud-config! E- {1 l' P1 d2 Y- N( O9 M5 f
growpart:, E* b' F; _* L$ _- T" z
  mode: auto
. c5 w' Z' j& p$ h3 W& v5 _  devices: [/dev/vda2]- w9 e! j% n. a0 L3 E& w
  ignore_growroot_disabled: false6 T; ^0 p- p  x' A. d) W& m
bootcmd:0 p, u4 t' ^5 }$ D
  - [pvresize,/dev/vda2]9 v6 I* G+ o$ `. k- _8 z9 W( |, c
  - [lvextend,-l,+100%FREE,/dev/mapper/vklas-root]
- X$ T1 K* F3 B( N' W  - [xfs_growfs,/]
; s+ m& H; V; x' B8 Y+ y- ?( r0 J# F
& c9 _6 {" T/ A4 y3 P5 Y5 M在云平台中调整后,还需再次重启才能生效
4 d  d8 X  J1 ?1 x. R; d! Y+ A' c2 W( R' b1 B2 Z% I

4 E( a" J& z1 s& {5 o6 M4 w5 [2 k4 S' L' b) t, d/ U! L

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
 楼主| 发表于 2023-9-12 17:00:04 | 显示全部楼层
初始化
) L* i. I- V2 h( i! j
% i/ m& M3 _8 y; ~4 @cloud-init并执行初始化模块:+ f. ^: Q, ?& \0 i* ~7 \

( R, L) v9 \1 y) |[root@cool ~]# cloud-init init
4 H$ ~1 I$ A: r: E% K0 f& I3 `5 R* M9 w% S# W& D( F5 u
使用给定的配置键激活模块:
* f. Z. R  ~: w6 ?$ ]' c6 F; w, K2 w  D0 [# S. P
[root@cool ~]# cloud-init modules
0 n5 R- j. F/ e; @, x' o" K% O9 t1 v- l6 ^/ Q, ^5 `' A8 J
报告云启动状态或等待完成:
  Z! T) T; K: _9 V- U) |, j! _' |# L) O! i4 t) y4 Z" P  T
[root@cool ~]# cloud-init status7 c. \, |! B) w( H/ ]8 ]. t
. {: f5 i  `+ a  v% ?
删除日志和工件,以便重新运行cloud-init:0 Q  J: [' U9 ~  b  t
# s* M! a7 e, s" y- h8 p3 p
[root@cool ~]# cloud-init clean

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
 楼主| 发表于 2023-9-12 17:00:05 | 显示全部楼层
[root@localhost ~]# cloud-init init7 l( w' M  z* X, T( g
Cloud-init v. 19.4 running 'init' at Tue, 12 Sep 2023 08:39:50 +0000. Up 2409.94 seconds.
6 K/ l6 k) o! \. [$ m( @$ Nci-info: +++++++++++++++++++++++++++++++++++++++Net device info+++++++++++++++++++++++++++++++++++++++
* |4 s' j- b  ?/ n6 A* P4 Vci-info: +--------+------+------------------------------+---------------+--------+-------------------+' O6 q! |) R' t* v' b5 `
ci-info: | Device |  Up  |           Address            |      Mask     | Scope  |     Hw-Address    |
$ F4 M. x; i, Vci-info: +--------+------+------------------------------+---------------+--------+-------------------+2 P% K& u2 q0 l& M, b$ H
ci-info: |  ens3  | True |        192.168.8.112         | 255.255.255.0 | global | 52:54:00:4c:ad:0e |& N/ Y1 @1 n4 r) U# q0 l
ci-info: |  ens3  | True | fe80::1c64:dcb6:c0e9:4a3e/64 |       .       |  link  | 52:54:00:4c:ad:0e |
& U5 @  @" e' ~4 Nci-info: |   lo   | True |          127.0.0.1           |   255.0.0.0   |  host  |         .         |/ p: e2 B9 x. E
ci-info: |   lo   | True |           ::1/128            |       .       |  host  |         .         |, a" W: p- c) E, l4 q- T
ci-info: +--------+------+------------------------------+---------------+--------+-------------------+
; V3 V; G3 g1 H( [2 E, mci-info: +++++++++++++++++++++++++++++Route IPv4 info+++++++++++++++++++++++++++++
  v) v0 X4 V/ Q! f9 i/ Eci-info: +-------+-------------+-------------+---------------+-----------+-------+
# c6 {( I6 v& u. B5 o. L" X' {9 p8 `ci-info: | Route | Destination |   Gateway   |    Genmask    | Interface | Flags |
4 B/ v9 |- h  R$ w# Y, ?- Qci-info: +-------+-------------+-------------+---------------+-----------+-------+
5 }  g* r! a, _3 U1 nci-info: |   0   |   0.0.0.0   | 192.168.8.1 |    0.0.0.0    |    ens3   |   UG  |
* B3 q( k& E8 C7 @ci-info: |   1   | 192.168.8.0 |   0.0.0.0   | 255.255.255.0 |    ens3   |   U   |
! v3 ?9 N- ?# n. i" _1 c3 }* \ci-info: +-------+-------------+-------------+---------------+-----------+-------+
: T* D. b# b' ^ci-info: +++++++++++++++++++Route IPv6 info+++++++++++++++++++
# k+ L6 a9 j, z6 bci-info: +-------+-------------+---------+-----------+-------+
, w' A: Y# t) B5 R4 Y6 f/ A0 rci-info: | Route | Destination | Gateway | Interface | Flags |
7 O  V1 O! B  p2 k/ m0 O& \+ rci-info: +-------+-------------+---------+-----------+-------+" A8 |! e( Z; k, t- U2 _. U6 N
ci-info: |   9   |  fe80::/64  |    ::   |    ens3   |   U   |/ C, {5 c2 c- K2 u
ci-info: |   13  |   ff00::/8  |    ::   |    ens3   |   U   |  l0 ^) p  O$ ~% ~" `$ E
ci-info: +-------+-------------+---------+-----------+-------+
7 c, n( U5 N+ g2023-09-12 08:39:51,754 - warnings.py[WARNING]: **************************************************************************
$ S: B" x. z! Z# A new feature in cloud-init identified possible datasources for        #
# x) R0 K; E" ?, s* n4 w( ]# this system as:                                                        #
8 t, p( X5 ]: Z3 v#   []                                                                   #
: h: R/ H: T& b/ _2 {# However, the datasource used was: None                                 #
" m. z( V6 h9 h! r#                                                                        #
6 P2 D8 @+ u9 `4 E$ g0 k# In the future, cloud-init will only attempt to use datasources that    #: T0 X6 L9 y' |8 f& \6 V6 _
# are identified or specifically configured.                             #
/ H7 I% G9 ^: b7 h" f  l; w: h# For more information see                                               #
6 I5 {6 w8 |1 i; P5 n# y" i3 \6 m#   https://bugs.launchpad.net/bugs/1669675                              #
6 D% F4 K4 m; h7 A" `5 J+ a#                                                                        #! }# P' W, b: L5 ~1 o' r
# If you are seeing this message, please file a bug against              #* s5 @4 b( `9 n
# cloud-init at                                                          #
- p* N1 _: x6 v3 Q+ C/ W+ t#    https://bugs.launchpad.net/cloud-init/+filebug?field.tags=dsid      #
2 C1 R0 I1 n& F# Make sure to include the cloud provider your instance is               #2 l9 O) M: v% R* F* L9 O
# running on.                                                            #
1 U9 `+ {5 ~& Q! O: S" c#                                                                        #
. ]  ?5 g2 |) N, B$ ]+ u  s# After you have filed a bug, you can disable this warning by launching  #
( K' m( h+ L5 o8 K7 m, J0 X# your instance with the cloud-config below, or putting that content     #
4 K/ ]9 m: o" M$ c# into /etc/cloud/cloud.cfg.d/99-warnings.cfg                            #
% q( p3 |6 Z0 @8 I$ s. E#                                                                        #
" P8 ~0 \6 \4 j) P. Y# #cloud-config                                                          #
1 R: A4 K) ]3 G/ i  S& ^; ~' V# warnings:                                                              #) a6 c# m& n) D2 f( J" \
#   dsid_missing_source: off                                             #! i, t: m! b) i/ n9 r$ U' @
**************************************************************************4 W2 R; @: F+ J  S: q) {
5 J3 t# x' w! u0 O6 Q* w- V9 b
[root@localhost ~]# cloud-init status  
$ r5 C- g8 t& l* Nstatus: running
* V2 w* R$ x, ^$ C0 Y$ a! W& O; o[root@localhost ~]# + e+ a' g/ t0 o5 E8 O8 [

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
 楼主| 发表于 2023-9-12 17:00:06 | 显示全部楼层
[root@localhost ~]# cloud-init modules " ~' X* D/ {3 l: M/ M
Cloud-init v. 19.4 running 'modules:config' at Tue, 12 Sep 2023 08:41:06 +0000. Up 2485.43 seconds.
! Y4 `7 a9 Q- c/ G# a' F[root@localhost ~]# ' k0 J! O/ [5 @
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

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

Powered by Discuz! X5.0

© 2001-2026 Discuz! Team.

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