找回密码
 注册
查看: 3691|回复: 0

ESXi 5.x 命令行操作

[复制链接]

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
发表于 2017-11-24 12:16:01 | 显示全部楼层 |阅读模式
网络
8 \+ P) {  P0 u9 m6 F% n
( W# G+ r/ Y& V$ l& D$ g" Z很多命令的 -h 都包含了详细的例子- k* E  D, i+ Z6 A# Y: j

" `/ e5 y) N8 w7 e- t& Mesxcli network:2 M6 `, R$ M: E

* ?7 [( k0 [9 {* ~这是一个命令集, 包含了很多子命令( w/ ^3 u4 I- V" M9 Z5 X
0 f3 C, A$ Q' k7 X
esxcli network nic list 查看网卡信息4 Z( H1 n( F. `$ d
esxcli network ip route ipv4 list 查看路由(ipv4)1 R' s- W3 L# i& L
esxcli network ip dns server list 查看 dns2 I0 q  f0 c- l6 q
esxcli network ip interface ipv4 get 查看ip配置(ipv4)& K) S1 g: d( ~& M
esxcfg-route:
1 c+ K& W0 A& I* x# }2 N( [8 T1 c
' s5 t: w/ g  b. I) e6 E0 eesxcfg-route 查看默认路由% x# Z# |- S7 i+ d
esxcfg-nics:
" a- x' w! P2 p  T5 G$ u
  O3 w8 n  O6 O% Resxcfg-nics 等价 esxcli network nic list
$ R. i4 R, _, K( W" Utcpdump-uw:
2 q% D" O+ X- w: E$ z' l2 W+ b5 B
类似于Linux下的 tcpdump, 是 ESX 的抓包工具
; ^" c0 c% b0 c. G/ ^
- l  z# \- j* mvsish
' a& t, [% T) Z: [5 f& D# r# r# n# _0 d; j, K
ESXi命令行修改密码* j7 M  I  W; Q6 S+ H% d, T6 q. u

9 [1 U' ?# Z+ y通过 ssh 登录到 ESXi 系统后, 可以通过 passwd root 来修改密码& B/ G. @' a, H, ^$ c; o
4 f, l( @5 J& U- E- p/ W" I
参考 Changing ESXi Root Password , 里面还说明了如何开启 ESXi ssh 登录.
0 Z& |# A' D1 J* r+ ~; ?5 N+ k! Q9 {4 o
ESXi 的 authorized_keys
& h. w6 `& v5 e; \  v/ f- h: Z! v$ y# W) O- u0 O0 s* l% K
For ESXi 5.0, the location of authorized_keys is: /etc/ssh/keys-<username>/authorized_keys
& `8 @. k  i- j- B+ X' V: |& S5 l( i4 \$ }3 n
参考: Allowing SSH access to ESX hosts with public/private key authentication2 {0 t/ X3 R  s6 ?0 d

) @8 b9 Q3 R- {5 ~7 `控制虚拟机开关机7 P, J( \0 O' W: b* r) I

5 ^& y  ?; g. |# U& bTo power on a virtual machine from the command line:
5 A9 m/ i0 x8 Z2 n7 r0 a8 p# T" o/ X6 E# A0 R0 A
List the inventory ID of the virtual machine with the command:
% ]! |( s; s; N/ [0 k7 q0 }7 t; O2 N9 l) b* c7 i- A
vim-cmd vmsvc/getallvms |grep <vm name>7 x* Z+ e% i: ]) n* h- y5 U" G3 y
Note: The first column of the output shows the vmid.& y6 a! H1 U" [2 F" S4 @$ O& I* k

: x0 G* @5 N! X! H6 I4 S! K8 MCheck the power state of the virtual machine with the command:
) x, K& Z: E( E/ B# V5 T, W" y0 o1 S8 W3 j. x! T% W+ m
vim-cmd vmsvc/power.getstate <vmid>
. k! t  p( x& tPower-on the virtual machine with the command:
; X# f( f& J/ a! Q7 ^3 ~+ d& V; p& y7 w9 B7 z$ Z' F
vim-cmd vmsvc/power.on <vmid>- q7 A, y+ D9 @
关机就是把 power.on 改为 power.off 就可以了.
+ y5 [) M, K" K5 D9 s) \% _. [3 _- H, A$ _, J
参考: Powering on a virtual machine from the command line when the host cannot be managed using vSphere Client+ C9 ?3 d# M$ Q8 i6 Y4 ^$ {
; ?% V$ V. t+ P$ ]* }5 `
另外还有一种方法, 只能控制关机:
0 r3 h# ]) e  _
4 g) j: I4 N0 u1 N0 B! U" P7 v/ h# ]Get a list of running virtual machines, identified by World ID, UUID, Display Name, and path to the .vmx configuration file, using this command:
7 q0 `3 v: q9 e* Y9 Y. w1 k% T+ c! a0 ~1 b. @+ m# ]
esxcli vm process list # 只显示开机的虚拟机列表
) M' ?& N  g# e4 S, Q/ {Power off one of the virtual machines from the list using this command:1 l2 w5 ~  r; A( j6 V) f
( R( W+ F) J. I
esxcli vm process kill --type=[soft,hard,force] --world-id=WorldNumber
( r; B2 U. t4 @* R" VNotes: 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.
1 W5 @* s( N: N& P6 y% b* h7 N% ~9 c$ d- V
Alternate power off command syntax is:
- w* P' ^# _* b3 x1 Y. t" b. v$ G0 j( p; l( I4 P" N: Z3 W
esxcli vm process kill -t [soft,hard,force] -w WorldNumber
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2026-6-12 01:53 , Processed in 0.014200 second(s), 22 queries .

Powered by Discuz! X5.0

© 2001-2026 Discuz! Team.

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