|
|
网络
; b$ {+ @6 l" R# r+ K" X
w) u1 x& c y( a% `; H9 m0 B很多命令的 -h 都包含了详细的例子
4 S% e$ m" O# f: C, e& Y
( R8 Q- s' V$ G3 c1 K! }esxcli network:5 y1 c7 y! b1 W: @4 V
8 `6 d! C: }9 s# l' O) ^& X( o
这是一个命令集, 包含了很多子命令2 ]- [; r. ?9 P$ X$ A$ w) L
, z: I8 B3 o$ P @
esxcli network nic list 查看网卡信息
7 p/ Q: l4 N* K/ W3 A! resxcli network ip route ipv4 list 查看路由(ipv4)
1 ^- K }$ c$ i% y# c% pesxcli network ip dns server list 查看 dns/ k: @ }9 ^/ `6 W" m, @6 b! U$ v4 ?
esxcli network ip interface ipv4 get 查看ip配置(ipv4) l: ~+ H# t$ q# Y J( J
esxcfg-route:
5 w" @5 Q0 l9 g! m+ v2 C) W3 A. {# i0 A J/ L8 }+ o/ U
esxcfg-route 查看默认路由: B' q/ g' f1 o% b! M' J* L6 e( [( J
esxcfg-nics:2 g1 d# h9 O) D! a% N6 G
; u! k: L- W& ]% r/ k
esxcfg-nics 等价 esxcli network nic list
; Q: X4 j$ Y. U. ftcpdump-uw:% t9 R& {3 N: ^1 d+ v7 A7 Q0 f1 T3 z3 H
7 d0 ^# z+ C% h6 @/ o/ `; N% n) x+ h$ h类似于Linux下的 tcpdump, 是 ESX 的抓包工具
4 Y' s1 m9 p D( C5 m ?4 z6 W# ?- w# f4 T* h( P0 i
vsish4 d3 j I8 D$ K, w& h$ I( V
/ O& A+ h8 W5 {) Y0 R+ z7 i- E# _# a4 aESXi命令行修改密码 `4 f" C$ b& [5 S1 R
6 Z. `5 R" x& r" ?) c4 C
通过 ssh 登录到 ESXi 系统后, 可以通过 passwd root 来修改密码5 o+ p# @3 P5 ]7 O
( I) I& ~7 n: c& s. B参考 Changing ESXi Root Password , 里面还说明了如何开启 ESXi ssh 登录.0 V q, V7 b. w: O. D+ ]( ~& ~/ r
8 {5 @5 o2 d% f. w( E; EESXi 的 authorized_keys
- o) z2 x$ @' K1 s$ B9 D0 E9 o; Y. R9 I& ~' ]7 S6 C
For ESXi 5.0, the location of authorized_keys is: /etc/ssh/keys-<username>/authorized_keys
2 J/ G5 Z" \; D
1 X; I" A& \, K) f9 O1 g7 n' ~参考: Allowing SSH access to ESX hosts with public/private key authentication
* [9 Q' }2 R1 |' | D6 `& N- @ Q) z2 [: T$ U( b- r7 Z
控制虚拟机开关机0 |% o- t* E0 h! g. s2 b: Z
5 h# I9 E' `1 r2 A
To power on a virtual machine from the command line:
8 C. z- I9 f- b. f* [' R; a- `" M3 K' P. E* Z+ w
List the inventory ID of the virtual machine with the command:
8 n0 A, q6 s+ e0 Q( O4 v* m7 r: Y" C& @. h1 t4 u* F
vim-cmd vmsvc/getallvms |grep <vm name>. _# C; z3 S& v* j6 j9 V
Note: The first column of the output shows the vmid.
" S0 N5 Q# y( ?
+ }. }7 Z% D3 H+ W1 uCheck the power state of the virtual machine with the command:
- Y* Q/ J/ w0 F6 L; B, Z h% m: H& G9 }8 d7 u* Q4 n$ W9 I
vim-cmd vmsvc/power.getstate <vmid>
/ r( X- |6 q) @6 r TPower-on the virtual machine with the command:& M8 q1 j, m6 d* Z& Q; Z/ O: m
1 f' q1 z( b) H |4 n' `vim-cmd vmsvc/power.on <vmid>8 b' g+ a+ G+ C. v
关机就是把 power.on 改为 power.off 就可以了.
/ S7 p+ R; a. X5 T, C5 L! _ U( Z0 O
, h( V9 i+ ?. G- r# ^$ M# r: {参考: Powering on a virtual machine from the command line when the host cannot be managed using vSphere Client& G* P% V/ z9 R6 G( u+ B1 m& P0 O
M3 \, r, o* f r5 ~4 g7 A
另外还有一种方法, 只能控制关机:7 s0 v+ ]+ P' `% o$ J2 ]* k, S
& M8 Q8 S5 y8 i- T }0 T4 kGet a list of running virtual machines, identified by World ID, UUID, Display Name, and path to the .vmx configuration file, using this command:5 e. d D( R0 v- j. |8 g2 x9 ^
' K0 J) \0 h, E3 l* _' t" g9 r
esxcli vm process list # 只显示开机的虚拟机列表
' E2 r' b/ y F6 NPower off one of the virtual machines from the list using this command:. S- }4 ?3 r+ X3 v9 v3 e
; r/ t8 h! ?7 V! |, T# o7 ?* R1 I
esxcli vm process kill --type=[soft,hard,force] --world-id=WorldNumber5 P, ^' X. Y# q4 y+ O$ |9 s
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.
4 I& N6 k& l+ X/ {5 y
8 d- |& x( G# q" {Alternate power off command syntax is:
1 G9 b2 ^% ?" s |3 Z. j/ n- M q$ Q& r% [% x' w
esxcli vm process kill -t [soft,hard,force] -w WorldNumber |
|