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

Failed to run bootcmd module bootcmd

[复制链接]

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
发表于 2023-9-12 17:00:03 | 显示全部楼层 |阅读模式
Failed to run bootcmd module bootcmd
  i/ o) p; ^7 T! `0 O1 k  N# T  H  k, M5 b6 D

  w( z7 e2 q5 n2 @" \/ C2023-09-12 08:11:12,132 - util.py[WARNING]: Failed to run bootcmd module bootcmd& R, S( U( s' D9 f9 H
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'>) failed2 W3 d- S* }# Q( o2 J' `
. V1 i: Z; H: J
; W0 F% G: D" F/ d
6 S7 q& n" q' V

2 f. b& _! G+ V. c6 u0 n; l$ D7 A) [" l- P1 }8 }5 ]  T% d, G! q
语法格式:cloud-init [参数]
0 h5 [8 _4 A6 S! p. I9 e9 g: ^+ g" j: f& D' B& v8 q/ {  f
常用参数: init 初始化cloud-init并执行初始化模块 + j8 J8 r) ~' F: u9 V' |" V* w
初始化
% v9 c9 z5 p( |7 v* C6 H5 y
- [1 d4 U* f# @: h- a# a! R% z. Jcloud-init并执行初始化模块:( P$ ]9 ], {8 y4 c! ~4 \

& ?' ]! z. s9 N[root@cool ~]# cloud-init init
2 M' E$ b# q! N. p" J& R- b# t5 y
使用给定的配置键激活模块:
6 K  R" z: O* C- T
& Q# Z; Z. H' e1 e[root@cool ~]# cloud-init modules. X, a% c- |7 ~8 X- P6 C- n% F

& h' D" R$ E8 G! `$ N/ h2 J6 |5 P报告云启动状态或等待完成:
, Q' Y5 v; g0 N% |/ \9 U: g, R8 B6 h. L! [
[root@cool ~]# cloud-init status" f& q6 U) V# J% K$ ~: D0 u

1 i- U$ z, N% f: a6 \% ]0 I删除日志和工件,以便重新运行cloud-init:
6 H5 q, _- o' R5 z: C2 d1 S7 c; e8 p3 K0 A
[root@cool ~]# cloud-init clean
* q8 ]2 l. Q) v# b* ]& w( K5 u+ `* M7 {9 o% c
根据以上信息,得知我们需要自动扩容vda3分区(growpart)、扩容LVM和xfs文件系统(runcmd)。
( o  ~  J& X8 ?7 u8 i. M创建文件/etc/cloud/cloud.cfg.d/growpart.cfg! c# E9 |6 x( X; |3 O2 n" a
vim /etc/cloud/cloud.cfg.d/growpart.cfg) G$ l# }( K# [" Y0 k
6 Y" C6 F9 F4 N. s/ [6 v0 y' u* ~4 C1 U/ ?3 y
#cloud-config
2 c# b' v* ?8 F- O3 q, tgrowpart:
" T* H* ]$ A( J) J9 t& y  mode: auto" N' A: o0 m3 ^3 j9 g8 i7 e
  devices: [/dev/vda2]
. i! G, }, ?( G' v( Q1 h  ignore_growroot_disabled: false; l, E  E  P3 s) v2 P# C% A# r
runcmd:' P4 R* ]# Z2 P1 f" E0 r$ s# ?" j0 B3 N+ ^
  - [pvresize,/dev/vda2]8 N8 J7 h; X9 O: o, w
  - [lvextend,-l,+100%FREE,/dev/mapper/vklas-root]
  o+ E4 L5 m1 `( L# \1 s* g  - [xfs_growfs,/]! {+ V/ P# P. N% h
, N4 ^$ ]2 x" p4 ^& G$ S! T
注意:文件系统为ext2、ext3、ext4,则采用通过resize2fs 进行调整
" \: e1 _4 D& y3 Z0 ]
& V, i3 e. Z( r9 @' j8 r2.5 每次重启均调整
+ E& Q$ m4 h; m! \% A4 b3 o  U0 h2 Y" ^4 I0 D9 J
该需求涉及到云平台会有调整虚拟机的需求,也就是虚拟机磁盘进行调整后,文件系统也依然需要调整,故衍生出每次调整后自动扩容的了。
, t6 L8 E& O- g不同的cloud-init模块有不同的执行频次:once-per-instance 、 always。可以在Modules文档中https://cloudinit.readthedocs.io/en/latest/topics/modules.html
, T1 I) L+ R8 `8 A查看每个模块的Module frequency属性。例如,bootcmd在每次引导时运行,而runcmd只在第一次引导时运行。频次也可以在cloud.cfg配置文件模块列表中覆盖——cloud_init_modules, cloud_config_modules和cloud_final_modules。( q) `& h6 p) k
故我们有bootcmd和runcmd两种方法实现该需求。! W  w% D# {  u

3 ^$ Z' F' u& hruncmd
8 m' `% r' Z, Z9 @# ~5 t通过修改/etc/cloud/cloud.cfg文件,覆盖模块频次5 G0 P4 D3 a: f- N7 `# X
vim /etc/cloud/cloud.cfg
* m2 w( I: i, A0 D) \3 t- G
7 U) T; k! I8 ~. r7 @; |cloud_config_modules:
5 a2 k3 N2 Y5 p# }6 m - [runcmd,always]
- d1 E4 s& q/ f( l( Z  e% j
  U$ @$ d2 N" h, {/ C  P2.5.2 bootcmd1 o- u4 V5 C& y/ q" X
修改/etc/cloud/cloud.cfg.d/growpart.cfg,将runcmd替换成bootcmd,全文如下:
5 f' v7 E6 Y: |" y5 y. v+ A8 c! Z* [& u' x( a/ ]) N3 ?' g9 l) ~
#cloud-config# `; h; G0 ]0 X. P1 G
growpart:
2 x' S9 ]6 M. K/ o# f1 h3 }; |4 J  mode: auto) h  }% T4 k; W' h  r3 I
  devices: [/dev/vda2]
; u* `" ]2 ^  k) f/ H5 b4 ^  ignore_growroot_disabled: false5 D0 q5 b/ l- G- [
bootcmd:! X& [( A4 q- [* D
  - [pvresize,/dev/vda2]9 c7 B: I2 y9 Z' }, k7 y
  - [lvextend,-l,+100%FREE,/dev/mapper/vklas-root]; M6 L% }  S9 L3 t. R, j& e
  - [xfs_growfs,/]
$ R6 a5 d# ~- b# \4 U
+ O* L+ T! o2 k4 C! W# l  I5 h$ ]& v在云平台中调整后,还需再次重启才能生效
' ^/ f* m) f& m8 O. ]1 L+ N" k# j- L  k2 {, I/ ^

3 ?( n; b( V3 [0 b: W* H* v# g5 I; L; i1 q

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
 楼主| 发表于 2023-9-12 17:00:04 | 显示全部楼层
初始化  b: C0 V- `/ P. q: R( X5 s
% ?) x/ i) P3 h/ \3 u
cloud-init并执行初始化模块:
* `  {* f4 z- P& J5 g# ~% V
, D/ a# {9 y6 t( X  p+ U7 Z" `; R[root@cool ~]# cloud-init init
3 s6 ^1 _9 \+ ]* R1 m" L  r. w2 n3 i7 f3 F
使用给定的配置键激活模块:
4 }3 h, d8 [; Q. C/ K
0 M( z0 k: k$ n[root@cool ~]# cloud-init modules5 s' x( H# e  c' u
2 t  w: v) I3 \) \/ N: [! w  Y
报告云启动状态或等待完成:1 V! l. x! L& Y5 b

  P$ S7 I0 h+ a& C[root@cool ~]# cloud-init status
1 T/ `, v$ t; W9 h, z  }9 N  h8 o& d% S8 \, G2 A0 `! z( d. c9 {
删除日志和工件,以便重新运行cloud-init:6 X  c! C  p9 H6 ?

% o6 s! l* O* _2 K0 P& L[root@cool ~]# cloud-init clean

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
 楼主| 发表于 2023-9-12 17:00:05 | 显示全部楼层
[root@localhost ~]# cloud-init init
# z$ {* y4 I+ }$ s* w6 U1 JCloud-init v. 19.4 running 'init' at Tue, 12 Sep 2023 08:39:50 +0000. Up 2409.94 seconds.9 @/ ~3 q. `" j: R# ]
ci-info: +++++++++++++++++++++++++++++++++++++++Net device info++++++++++++++++++++++++++++++++++++++++ T1 u: E- _; }
ci-info: +--------+------+------------------------------+---------------+--------+-------------------+" ~9 y6 D! I$ s2 S6 ~* ~& M
ci-info: | Device |  Up  |           Address            |      Mask     | Scope  |     Hw-Address    |! N/ {2 D+ J$ `& S! |; W
ci-info: +--------+------+------------------------------+---------------+--------+-------------------+
8 \+ I8 g! ?, @* zci-info: |  ens3  | True |        192.168.8.112         | 255.255.255.0 | global | 52:54:00:4c:ad:0e |/ S' E/ ~1 x; `& n  d3 K$ v
ci-info: |  ens3  | True | fe80::1c64:dcb6:c0e9:4a3e/64 |       .       |  link  | 52:54:00:4c:ad:0e |& e* w' X' M6 i6 Q+ e7 {9 F2 t
ci-info: |   lo   | True |          127.0.0.1           |   255.0.0.0   |  host  |         .         |
  Y8 }# ^: ?6 Vci-info: |   lo   | True |           ::1/128            |       .       |  host  |         .         |! \% B* ^9 u9 F/ @$ \
ci-info: +--------+------+------------------------------+---------------+--------+-------------------+" p( O# m& C4 W# V( z6 [3 ~
ci-info: +++++++++++++++++++++++++++++Route IPv4 info+++++++++++++++++++++++++++++
4 R4 \' ?9 N, O. ^ci-info: +-------+-------------+-------------+---------------+-----------+-------+5 k9 A( ]1 D4 C( w6 Z0 V
ci-info: | Route | Destination |   Gateway   |    Genmask    | Interface | Flags |
) u8 I  W2 c  M% ?& nci-info: +-------+-------------+-------------+---------------+-----------+-------+
5 H9 ?) g. H7 Y; k  g; Gci-info: |   0   |   0.0.0.0   | 192.168.8.1 |    0.0.0.0    |    ens3   |   UG  |! c( [* Z3 r. s# E7 _
ci-info: |   1   | 192.168.8.0 |   0.0.0.0   | 255.255.255.0 |    ens3   |   U   |0 M- [$ z* H  n' e0 s. {
ci-info: +-------+-------------+-------------+---------------+-----------+-------+4 `% ?& h9 m: K
ci-info: +++++++++++++++++++Route IPv6 info+++++++++++++++++++
  O8 v! O( c  q3 \( i, _( fci-info: +-------+-------------+---------+-----------+-------+
; P, A* W/ {* l7 n2 ?8 sci-info: | Route | Destination | Gateway | Interface | Flags |
  n0 t# o3 I% hci-info: +-------+-------------+---------+-----------+-------+
. _9 t4 U5 D2 ^6 t4 P( B# Bci-info: |   9   |  fe80::/64  |    ::   |    ens3   |   U   |- I# \4 a+ r7 R# ]6 H
ci-info: |   13  |   ff00::/8  |    ::   |    ens3   |   U   |( _2 T; b! v+ W8 R/ h
ci-info: +-------+-------------+---------+-----------+-------+/ c$ ^- p' q1 s1 A
2023-09-12 08:39:51,754 - warnings.py[WARNING]: **************************************************************************# O5 K4 f3 b% I
# A new feature in cloud-init identified possible datasources for        #/ m0 q) [4 }( L8 I
# this system as:                                                        #
2 b! q1 Z" e; `' \" b( L; W#   []                                                                   #+ C! X. C9 w$ r7 P
# However, the datasource used was: None                                 #
( e& @# }+ t/ r#                                                                        #$ E( d5 [6 n: o1 l1 K0 M2 a1 P
# In the future, cloud-init will only attempt to use datasources that    #2 W( i: c: Y! P2 w. `' Z
# are identified or specifically configured.                             #
2 ^  n2 I$ |* D5 `# For more information see                                               #
8 t, f8 \8 Q( x( C7 M( q#   https://bugs.launchpad.net/bugs/1669675                              #
/ s$ e& b" Q  c0 B5 [#                                                                        #! M$ z$ X+ s0 e
# If you are seeing this message, please file a bug against              #
( [; }: a- P3 U9 R9 e# cloud-init at                                                          #3 ~7 W" i, D& x
#    https://bugs.launchpad.net/cloud-init/+filebug?field.tags=dsid      #, G0 `+ d1 y5 A% D. ^& P
# Make sure to include the cloud provider your instance is               #8 C4 O+ N2 s2 s0 G( i3 F' S
# running on.                                                            #: p, p! d! i8 {* c( {
#                                                                        #3 v$ q. L9 v, }9 {
# After you have filed a bug, you can disable this warning by launching  #, w; u- Q0 v, n8 ?. H" U2 _/ n
# your instance with the cloud-config below, or putting that content     #
" A. V0 ~3 _; q" b8 L# into /etc/cloud/cloud.cfg.d/99-warnings.cfg                            #
* w5 g# f/ k9 n6 A( ?2 h" u$ `#                                                                        #6 c! |8 R% }: \* T) [
# #cloud-config                                                          #
9 C2 \7 n9 P* g# warnings:                                                              #
7 A! D7 T- E. n7 s& u#   dsid_missing_source: off                                             #/ c9 b+ B/ Y5 d! J) [
**************************************************************************. a2 w. F! _- g" C' [9 Q5 L
3 X* e% N0 S) x7 [1 ]: [% ^3 Y
[root@localhost ~]# cloud-init status  4 D: G7 H/ u/ Y9 p& r
status: running: f& z. s2 H4 ]; s4 @0 ~# _
[root@localhost ~]# 8 t1 X& w. f1 Y+ [$ g5 b

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
 楼主| 发表于 2023-9-12 17:00:06 | 显示全部楼层
[root@localhost ~]# cloud-init modules
) K1 P4 c/ ~/ o% l# C/ T8 |/ z8 zCloud-init v. 19.4 running 'modules:config' at Tue, 12 Sep 2023 08:41:06 +0000. Up 2485.43 seconds.0 e- m0 Y5 h$ D# k! ~1 U6 K
[root@localhost ~]#
5 @0 }0 o8 J) m; e* j4 T! o
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2026-6-12 00:47 , Processed in 0.017068 second(s), 22 queries .

Powered by Discuz! X5.0

© 2001-2026 Discuz! Team.

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