|
|
[root@compute01 ~]# vim /etc/sysconfig/libvirtd 修改文件:
( V- L' v4 K% z9 R
$ D9 @ n& V" F[root@compute01 ~]# vim /etc/sysconfig/libvirtd
7 x( D7 p- o5 k- c: e! ELIBVIRTD_ARGS="--timeout 86400 " #时间设置
$ {- @) F; a" c1 C& J3 X5 s8 TLIBVIRTD_CONFIG=/etc/libvirt/libvirtd.conf #配置文件
3 O' @& ~8 F, W. u- p. ^# m1 x
( q4 e& d6 d" {! }4 n5 T
h& ^; u p7 x8 W* w[root@compute01 ~]# libvirtd -d
# u/ R# a, T* {, V" Ylibvirtd: error: Unable to obtain pidfile. Check /var/log/messages or run without --daemon for more info. 说明已经启动了。
9 o) c! t/ e' Z2 ]( ]% A! [" \2 e' u* z
[root@compute01 ~]# ps -ef |grep libvirtd 查看进程:
# t- W1 P( ]/ ]: ]root 9051 1 0 08:47 ? 00:00:00 libvirtd -d3 o& A ^2 T3 F0 @; h& C6 [$ K
root 9171 2791 0 08:48 pts/1 00:00:00 grep --color=auto libvirtd) s9 k% M) s8 p% ^& [ ~) g5 x5 L
# J% x8 R5 J* ^9 p; I! e3 b! c" N6 [* l
$ M* b+ V' j7 S- b
停止程序:; s3 a4 E) @$ v- I/ f3 O% z
[root@compute01 ~]# kill -9 9051/ d) p0 \" j i) C
/ b+ `% D, M/ y+ d5 W2 r! ][root@compute01 ~]# ps -ef |grep libvirt8 I7 f9 I/ }; z+ ^9 w0 K
dnsmasq 9124 1 0 08:47 ? 00:00:00 /usr/sbin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/default.conf --leasefile-ro --dhcp-script=/usr/libexec/libvirt_leaseshelper
9 s/ O G9 K! j( B; J* c6 i3 C6 \root 9125 9124 0 08:47 ? 00:00:00 /usr/sbin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/default.conf --leasefile-ro --dhcp-script=/usr/libexec/libvirt_leaseshelper
. o- y! H6 V4 P1 f7 }9 _* }8 s; Xroot 9173 2791 0 08:49 pts/1 00:00:00 grep --color=auto libvirt
7 Y6 D6 s, t4 S4 v& n% K b[root@compute01 ~]# kill -9 9124 9125
4 y: h6 b% d& P) n1 W2 I& E# B% D; `% S- \; ^9 d- M( M
/ @! w- i5 a- d6 l2 y- K[root@compute01 ~]# ps -ef |grep libvirt
: i e' D; l5 Y( o7 ]: `1 troot 9183 2791 0 08:49 pts/1 00:00:00 grep --color=auto libvirt
* z: H1 q& L P: X. v; M- ^* `: S[root@compute01 ~]# ps -ef |grep libvirt# `2 f# x! }6 W% L
root 9185 2791 0 08:49 pts/1 00:00:00 grep --color=auto libvirt
) i$ h4 J* T( F7 M* c" d+ q5 e
8 R7 G$ k, f5 Y1 {
6 S+ }' N/ k3 O, P7 o3 L8 v[root@compute01 ~]# virsh list 0 V0 Y# }- u1 c2 Z
error: failed to connect to the hypervisor$ r( u' P# ]$ P) z
" d) d e& X# W7 V! K6 b' D) berror: Failed to connect socket to '/var/run/libvirt/libvirt-sock': Connection refused
3 G' t+ p. [ K1 L( R/ U/ G, {% x" |7 }9 @; i) `4 V( @6 T; u4 ?
( X8 D N0 V0 K! i) h! J
检查状态:
% W1 N: ]) S, l
4 A, L s4 V0 {3 ][root@compute01 ~]# systemctl status libvirtd.service * @# w) w& p* [$ B
● libvirtd.service - Virtualization daemon
- a; a2 m5 P- I d1 A8 @7 N. d' B Loaded: loaded (/usr/lib/systemd/system/libvirtd.service; disabled; vendor preset: enabled)# @) J0 ~% C! x$ \! v
Active: failed (Result: exit-code) since Sun 2022-05-08 08:47:37 CST; 2min 3s ago
- ^! g; U3 j7 z; {# V( F Docs: man:libvirtd(8). S9 U( b+ p% y
https://libvirt.org: P( d* `9 n( B6 X8 S, A
Process: 9028 ExecStart=/usr/sbin/libvirtd $LIBVIRTD_ARGS (code=exited, status=6)- y! }" C% k4 @
Main PID: 9028 (code=exited, status=6)
: H v( ~/ y. oMay 08 08:47:37 compute01 systemd[1]: libvirtd.service: Service RestartSec=100ms expired, scheduling restart.
( j) z5 o n G9 R: R7 f+ YMay 08 08:47:37 compute01 systemd[1]: libvirtd.service: Scheduled restart job, restart counter is at 5.7 b- I4 f" b3 ]2 f: Z( }
May 08 08:47:37 compute01 systemd[1]: Stopped Virtualization daemon.
. V! P- M- O- z3 pMay 08 08:47:37 compute01 systemd[1]: libvirtd.service: Start request repeated too quickly.
# T; ] h& U3 Q% a+ M5 C- lMay 08 08:47:37 compute01 systemd[1]: libvirtd.service: Failed with result 'exit-code'.4 E. {3 h" Q$ G& ?' B
May 08 08:47:37 compute01 systemd[1]: Failed to start Virtualization daemon.' V. Z3 Y7 n2 u! r5 O$ g; v
_. |5 F( S' W" f
启动:/ f& z7 Q( E( w7 o0 \1 r- b+ X
[root@compute01 ~]# systemctl start libvirtd.service " Z0 Y! o0 E# Y4 ?+ V, K
7 s1 c3 T1 @5 F# c$ Y# G; N* E
* D/ p9 E# n6 }# C1 U
[root@compute01 ~]# systemctl status libvirtd.service
4 m) D& B) T+ f● libvirtd.service - Virtualization daemon0 J0 M* w) s; s1 J. l2 R
Loaded: loaded (/usr/lib/systemd/system/libvirtd.service; disabled; vendor preset: enabled)
: j# K) d: F, c/ _ Active: active (running) since Sun 2022-05-08 08:49:45 CST; 1s ago
( K' W2 ~) x& x& Q Docs: man:libvirtd(8)/ W, }) O# w" [: C* h5 E% J( J
https://libvirt.org4 Z/ t5 t; D5 V# c9 ^ z0 R
Main PID: 9196 (libvirtd)% C7 Q$ z4 g% f$ ]# W
Tasks: 21 (limit: 32768): _1 S7 p* A4 `: m+ [. e9 B
Memory: 14.8M$ ]( u. ?. L5 _. @0 |3 f
CGroup: /system.slice/libvirtd.service
: [2 m% v. M1 N* {) r5 I3 a0 o, b ├─9196 /usr/sbin/libvirtd --timeout 86400
2 m) _4 i5 q) Z( O8 ` c* Q, O, z ├─9269 /usr/sbin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/default.conf --leasefile-ro --dhcp-scr>4 Q+ Z* I$ _; h p
└─9270 /usr/sbin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/default.conf --leasefile-ro --dhcp-scr>
# R, \ n* v6 n8 F6 SMay 08 08:49:46 compute01 dnsmasq[9266]: listening on virbr0(#7): 192.168.124.1# B: @5 l7 l" [3 V1 A
May 08 08:49:46 compute01 dnsmasq[9269]: started, version 2.79 cachesize 150# S# N- X9 ?% p1 W# D
May 08 08:49:46 compute01 dnsmasq[9269]: compile time options: IPv6 GNU-getopt DBus no-i18n IDN2 DHCP DHCPv6 no>
7 B r* b: p. x. g" l% j: _* w6 [! qMay 08 08:49:46 compute01 dnsmasq-dhcp[9269]: DHCP, IP range 192.168.124.2 -- 192.168.124.254, lease time 1h
5 u8 \/ L. w. i' B* o% Y, QMay 08 08:49:46 compute01 dnsmasq-dhcp[9269]: DHCP, sockets bound exclusively to interface virbr0
' t, ^6 |4 J! @; ]1 @ }' ], H6 a% `May 08 08:49:46 compute01 dnsmasq[9269]: reading /etc/resolv.conf
0 K! M! `) w$ k7 g) X) iMay 08 08:49:46 compute01 dnsmasq[9269]: using nameserver 202.106.0.20#53
+ x+ A- a3 P. c! _, CMay 08 08:49:46 compute01 dnsmasq[9269]: read /etc/hosts - 4 addresses5 p& O- d9 X4 x5 n \
May 08 08:49:46 compute01 dnsmasq[9269]: read /var/lib/libvirt/dnsmasq/default.addnhosts - 0 addresses% ^) ~' h+ ?5 R8 A V) g+ N
May 08 08:49:46 compute01 dnsmasq-dhcp[9269]: read /var/lib/libvirt/dnsmasq/default.hostsfile( u& [" ^( K! B' T3 H8 P
8 @( C3 u- `( r. h: n$ o) v9 x- B$ M) c( d% `
[root@compute01 ~]# virsh list
% Z# u$ I/ D, O( b& v2 ? j Id Name State% x$ d: x. e0 P0 A5 D# q1 i
--------------------
& T3 v# a6 k& ]
C7 r( w& U( o3 l2 p/ U
, j- R x/ G& p+ \4 l8 G) {7 d[root@compute01 ~]# ps -ef |grep libirt8 c& e/ Z; _' j1 |% R) i* K
root 9296 2791 0 08:50 pts/1 00:00:00 grep --color=auto libirt
3 ` {; E5 H% U# \- ~& w! I[root@compute01 ~]# ps -ef |grep libvirt4 q5 j8 `# V4 l2 _: W
root 9196 1 1 08:49 ? 00:00:00 /usr/sbin/libvirtd --timeout 86400
3 H+ M- m5 q) h0 F r& z; Rdnsmasq 9269 1 0 08:49 ? 00:00:00 /usr/sbin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/default.conf --leasefile-ro --dhcp-script=/usr/libexec/libvirt_leaseshelper
, N4 u! w/ D6 v5 Droot 9270 9269 0 08:49 ? 00:00:00 /usr/sbin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/default.conf --leasefile-ro --dhcp-script=/usr/libexec/libvirt_leaseshelper
4 G% a' u& G) }, D3 | v8 Kroot 9300 2791 0 08:50 pts/1 00:00:00 grep --color=auto libvirt* }" C# U9 z' w Z2 L
4 y) y8 H: q: ~$ ?) Y$ i0 O
( H8 |0 N! P+ O ^# b[root@compute01 ~]# virsh list
2 N0 O, o7 p/ U$ p8 ^ Id Name State+ ~5 ?( f j# m1 a0 [. P
--------------------3 y1 x* I0 \, A8 \1 V2 f8 \
[root@compute01 ~]# virsh net-list
# a0 i9 _# u3 q6 u. X Name State Autostart Persistent
# G, ^- \- i1 o& h# _- j--------------------------------------------
* j3 h! j4 U4 K1 r7 m5 h default active yes yes( P- D, O9 \1 P ?: v4 O- C& j
, a) S& L( U2 wkvm系统停止default网络:
9 v4 [ o& f% l: _0 M7 Q3 T6 {! i[root@compute01 ~]# virsh net-destroy default
. M { [5 g' K7 d( uNetwork default destroyed/ r6 ]; T( s) W b; j6 V
, _1 H0 ~ n) [2 V7 f- J, n5 h3 p
启动default网络:
@8 s& _' s- B. p! D3 w[root@compute01 ~]# virsh net-start --network default
$ C! p* H# r2 o) D8 h, g. B( \Network default started
5 @- @& {( L `6 v+ q) ]+ o
$ Q8 e, L w; \6 Y[root@compute01 ~]# virsh list : q% A8 @3 U: \; H9 w! @5 H. D
Id Name State* y$ Z5 P' M+ Y* ]! R E. x: ?0 V
--------------------
2 O" i0 M; w3 S5 b
U4 X) l& }9 C2 ^6 r[root@compute01 ~]# virsh net-list
& n9 l! Q! H* ?& ^4 E: u3 ] Name State Autostart Persistent& o6 l; e3 K0 G' S
--------------------------------------------. I0 F3 Z, C4 m% b
default active yes yes- E8 E. m1 [. z/ C+ L4 b4 I- M
: o8 P6 g. @" M4 L5 {视乎解决了。
3 T7 }+ }: g0 {2 T' q观察下吧。
/ o5 K+ l: _1 p. \ |
|