|
|
网络
/ {0 S1 ~: O- R9 Q+ ~! W3 |6 i1 h' A( A- y/ p; S
很多命令的 -h 都包含了详细的例子5 r) ~: @$ \! ~5 t, D: a
, L: v% A$ _9 s& i- V- H3 n$ X
esxcli network:$ `: j6 i4 F" X6 z4 N: b9 V* x
5 Y& }6 v$ }, s9 x% I. ?0 X
这是一个命令集, 包含了很多子命令. C: j: G0 c- r, J" O0 m k
w2 o1 o% o, U+ \2 p# g
esxcli network nic list 查看网卡信息
$ }3 F; @4 X9 _, G* Mesxcli network ip route ipv4 list 查看路由(ipv4)
! c7 d" I/ L1 F* ~. resxcli network ip dns server list 查看 dns
1 c& h& Y) W! c$ S8 qesxcli network ip interface ipv4 get 查看ip配置(ipv4)0 o- ~. X3 z, S1 W" i
esxcfg-route:' @2 A8 K. X# W r4 [
8 _) o1 v3 _5 b* F# q2 m5 Desxcfg-route 查看默认路由9 o7 _# h; _* U$ S2 h
esxcfg-nics:
9 n: n9 j4 K( N) d! U" u/ Q2 E
( `" ?( R& d$ ?( M4 U9 O; ?& kesxcfg-nics 等价 esxcli network nic list; c! p$ n# g1 K( C: d9 c7 n
tcpdump-uw:
1 ^ @8 o1 R2 ^ i8 a7 ~* M% j6 g2 [* I- J0 W, l
类似于Linux下的 tcpdump, 是 ESX 的抓包工具
0 B T; q7 l# W# I; ?
- K3 Q% o- N& i% p* t' |vsish
" t- [* g5 n, d6 ~( W
4 s' P. Y( R, ]8 FESXi命令行修改密码
; V' [) n" [5 [
9 C* _* \- b0 x; x通过 ssh 登录到 ESXi 系统后, 可以通过 passwd root 来修改密码
& n6 g0 i4 w" P/ g6 L0 J) u
' `5 c7 |3 @; u: @参考 Changing ESXi Root Password , 里面还说明了如何开启 ESXi ssh 登录.( l- \/ x4 i% t% f& u' d
2 Q. W% z" {% q. t- AESXi 的 authorized_keys# n/ @* n. \- o5 `
3 V) Q5 p e. S* u& t) P
For ESXi 5.0, the location of authorized_keys is: /etc/ssh/keys-<username>/authorized_keys
8 |9 X' Z/ R' [+ ?9 z5 C
6 b7 ?" c0 d* X参考: Allowing SSH access to ESX hosts with public/private key authentication
4 q1 E: O0 `& |* p( I
+ k, D) g* p- [" m0 Y1 _- A控制虚拟机开关机
1 u5 [. t3 M6 t D" M( E" G3 ^- Q8 `3 G( |$ N% W) O
To power on a virtual machine from the command line:
: [1 V" Y( d; L' Z4 K) K7 ?3 G$ `5 Z4 u7 U6 ~7 M9 w8 N) p. a& _: Y
List the inventory ID of the virtual machine with the command:
) V: i5 P/ ~' a- g) K o! @! P. n6 b) ]
vim-cmd vmsvc/getallvms |grep <vm name>
; Y6 L: j1 `$ V, qNote: The first column of the output shows the vmid.
; r; G" B) [, Y' k. x' {' p$ w' r( E4 A2 T {
Check the power state of the virtual machine with the command:. P7 z) Y8 V( o8 e' v% c" e
2 p* i8 [0 w; V, f1 m
vim-cmd vmsvc/power.getstate <vmid>
! w1 \$ A! G" I3 K! @Power-on the virtual machine with the command:- u) Z# ]1 g2 `. d/ p$ p; L
* U1 M1 u0 a. |3 u- D }vim-cmd vmsvc/power.on <vmid>8 u+ Y$ O. p# U) v3 F! G
关机就是把 power.on 改为 power.off 就可以了.
5 r8 D6 e+ O# F4 B, y$ r# W& {4 X
参考: Powering on a virtual machine from the command line when the host cannot be managed using vSphere Client6 v G# \6 G( P ~7 g
& R! y1 M1 y, d9 a! n6 ^1 s
另外还有一种方法, 只能控制关机:5 S2 O0 f* p+ a" q0 o) V( Q
- t6 H& z' U& }) |' y3 j
Get a list of running virtual machines, identified by World ID, UUID, Display Name, and path to the .vmx configuration file, using this command:
! `# J+ L' ~! c- e
* P& @8 W: ]1 s, P, Z" iesxcli vm process list # 只显示开机的虚拟机列表
+ F9 I- m5 u. GPower off one of the virtual machines from the list using this command:
8 D1 j, L. C( ~& O( W% z+ R0 b2 y* w2 m0 h7 O
esxcli vm process kill --type=[soft,hard,force] --world-id=WorldNumber$ F1 n. n) Q( y0 _7 T
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.
' N5 a. V& R4 @2 g/ u: H3 E
( P8 I, D& L& y7 o! s3 Z4 jAlternate power off command syntax is:; |3 s* q7 w+ b
( V0 X, y0 `6 j4 a
esxcli vm process kill -t [soft,hard,force] -w WorldNumber |
|