|
|
网络2 R7 j6 v7 D% @2 L
6 p0 b' b7 N1 _. @
很多命令的 -h 都包含了详细的例子
2 Q$ _0 X6 C" J
2 t Y1 h) J2 c1 p7 v7 l6 uesxcli network:; \' r' J% m: ~$ a2 m' `- Q
: E5 o( J" N, `2 s9 _这是一个命令集, 包含了很多子命令0 X/ V$ p; f& z1 ]$ ~
% i! a C0 a& p# eesxcli network nic list 查看网卡信息( q( M8 P9 I9 m4 p
esxcli network ip route ipv4 list 查看路由(ipv4)& k" Q; @ Q, V, |! |" l
esxcli network ip dns server list 查看 dns+ t8 C. ?, O, b" A: l
esxcli network ip interface ipv4 get 查看ip配置(ipv4)
3 U8 T' T3 @: N% T( Iesxcfg-route:: c k- z, Y$ h5 T6 _+ b. A' A
6 s0 r% ~- D0 D1 W, r( Y" A; Xesxcfg-route 查看默认路由
6 p1 ?8 b& R5 f+ U0 R. ]esxcfg-nics:$ Y% A, U& k2 \3 D. }: G
/ v+ g( d4 m3 ~9 i0 z1 zesxcfg-nics 等价 esxcli network nic list# N5 P# n; I) f6 W2 i8 I
tcpdump-uw:
0 o% L) j ?! Y( ~
! u( \' P/ G' O3 ~; T类似于Linux下的 tcpdump, 是 ESX 的抓包工具' q8 r: r# J3 I* P
9 m7 ?/ G9 r G' Z/ f; z3 T; z7 Rvsish
5 [5 h/ ^; L. {' |% }, e3 t( n% d7 z. U# G i9 x* J0 k
ESXi命令行修改密码
# ]; E& d5 k4 I1 X- e& d' ]
. N+ `* i) w% [2 @# S通过 ssh 登录到 ESXi 系统后, 可以通过 passwd root 来修改密码$ V" G7 B9 |) T7 `* Z L
6 R8 S; f: e8 L* E4 N参考 Changing ESXi Root Password , 里面还说明了如何开启 ESXi ssh 登录.
2 |- Y4 C: w7 J: k6 k) d* d. k
& y% r2 R8 {1 y& Q3 w6 T- {ESXi 的 authorized_keys
4 t( E) B7 y: m# H! K/ p! _
! w% k* s( c3 _For ESXi 5.0, the location of authorized_keys is: /etc/ssh/keys-<username>/authorized_keys @6 }0 z$ d# D/ c9 l" O
# J3 S- ]; f' x3 V M. f
参考: Allowing SSH access to ESX hosts with public/private key authentication' N' ^) Q' B2 N) r
2 V% o4 T+ [% m; a+ n
控制虚拟机开关机% K9 O' |- I8 w8 \
% |% m6 |3 h" ]; {! p5 G" CTo power on a virtual machine from the command line:
8 C" b: }, y6 d. F) s) ?' @
9 o9 L! {- X) d) ]) dList the inventory ID of the virtual machine with the command:' [* N+ e' b: i1 k6 |
% \: N/ c( l6 C4 s8 F4 Lvim-cmd vmsvc/getallvms |grep <vm name>
; `; u) Q/ _" b- L) ANote: The first column of the output shows the vmid.8 a3 ]+ P+ J! ]8 g0 d8 v" l
( M. X; X: v9 Y" }Check the power state of the virtual machine with the command:
7 P- r8 x5 s' U6 F1 Z
# e% _) M* z6 p, Z- \5 a: z- H% t; ivim-cmd vmsvc/power.getstate <vmid>3 Y" R4 f: m4 [. N
Power-on the virtual machine with the command:# ^9 S* G: b2 @6 O) x
6 O1 B# v% W% y& ` dvim-cmd vmsvc/power.on <vmid>$ P2 U. y! B7 x- M: C
关机就是把 power.on 改为 power.off 就可以了.
$ K0 H& S- X5 V# p \" n; N4 C8 x; q8 H
参考: Powering on a virtual machine from the command line when the host cannot be managed using vSphere Client
2 N N! ?6 U8 I$ K: F/ \
( [1 n$ F+ e! ~. U5 w$ \0 H ?另外还有一种方法, 只能控制关机:
% U+ h$ b3 R$ M. ^# u: q. q7 ^8 D# A+ `" f
Get a list of running virtual machines, identified by World ID, UUID, Display Name, and path to the .vmx configuration file, using this command:
: P, ~1 |, ^6 F1 b
# ^) p+ {* n# f, Pesxcli vm process list # 只显示开机的虚拟机列表
' ~$ N& F- J k2 f6 L" xPower off one of the virtual machines from the list using this command:* G# {- S D4 a2 X$ F1 g* e) h
* A0 s, Z+ h) r6 K
esxcli vm process kill --type=[soft,hard,force] --world-id=WorldNumber4 M& M( [" q. `3 Z! T" ]5 e
Notes: Three power-off methods are available. Soft is the most graceful, hard performs an immediate shutdown, and force should be used as a last resort.
6 @- ~7 p+ h2 S* z: `+ _$ w+ I* A D
Alternate power off command syntax is:
7 l9 f; E) G4 V; k% M9 D. h, o! M+ ` @8 J, r* x
esxcli vm process kill -t [soft,hard,force] -w WorldNumber |
|