esx命令行操作

thone00 2010-04-08

esx上特有的命令很多,有些是很方便,就用这个来记录我平时在esx上用到的命令

1:看你的esx版本。

vmware -v

2:列出esx里知道的服务

esxcfg-firewall -s

3:查看具体服务的情况

esxcfg-firewall -q sshclinet

4:重新启动vmware服务

service mgmt-vmware restart

 

5: 修改root的密码

passwd root

6:列出你当前的虚拟交换机

esxcfg-vswitch -l

7:查看控制台的设置

esxcfg-vswif -l

8:列出系统的网卡

esxcfg-nics -l

9:添加一个虚拟交换机,名字叫(internal)连接到两块物理网卡,(重新启动服务,vi就能看见了)

esxcfg-vswitch -a vSwitch1

esxcfg-vswitch -A internal vSwitch1

esxcfg-vswitch -L vmnic1 vSwitch1

esxcfg-vswitch -L vmnic2 vSwitch1

10:删除交换机,(注意,别把控制台的交换机也删了)

esxcfg-vswitch -D vSwitch1

11:删除交换机上的网卡

esxcfg-vswitch -u vmnic1 vswitch2

12:删除portgroup

esxcfg-vswitch -D internel vswitch1

13:创建 vmkernel switch ,如果你希望使用vmotion,iscsi的这些功能,你必须创建( 通常是不需要添加网关的)

esxcfg-vswitch -l

esxcfg-vswitch -a vswitch2

esxcfg-vswitch -A "vm kernel" vswitch2

esxcfg-vswitch -L vmnic3 vswitch2

esxcfg-vmknic -a "vm kernel" -i 172.16.1.141 -n 255.255.252.0

esxcfg-route 172.16.0.254

14:打开防火墙ssh端口

esxcfg-firewall -e sshclient

esxcfg-firewall -d sshclient

15: 创建控制台

esxcfg-vswitch -a vSwitch0

esxcfg-vswitch -A "service console" vSwitch0

esxcfg-vswitch -L vmnic0 vSwitch0

esxcfg-vswif -a vswif0 -p "service console" -i 172.16.1.140 -n 255.255.252.0

16: 添加nas设备(a 添加标签,-o,是nas服务器的名字或ip,-s 是nas输入的共享名字)

esxcfg-nas -a isos -o nas.vmwar.cn -s isos

17:列出nas连接

esxcfg-nas -l

18: 强迫esx去连接nas服务器(用esxcfg-nas -l 来看看结果)

esxcfg-nas -r

esxcfg-nas -l

19:连接iscsi 设备(e:enable q:查询 d:disable s:强迫搜索)

esxcfg-swiscsi -e

20:设置targetip

vmkiscsi-tool -D -a 172.16.1.133 vmhba40

21:列出和target的连接

vmkiscsi-tool -l -T vmhba40

22:列出当前的磁盘

ls -l /vmfs/devices/disks

1、使用VMware Infrastructure Client连接服务器失败,如下图所示:

2、查看系统服务状态:

[root@dell1root]#service–status-all

crond(pid2263)isrunning…

ChainINPUT(policyACCEPT1794Kpackets,90Mbytes)

pktsbytestargetprotoptinoutsourcedestination

ChainFORWARD(policyACCEPT0packets,0bytes)

pktsbytestargetprotoptinoutsourcedestination

ChainOUTPUT(policyACCEPT2532Kpackets,3521Mbytes)

pktsbytestargetprotoptinoutsourcedestination

Incomingandoutgoingportsblockedbydefault.

Enabledservices:CIMSLPaamVCBCIMHttpsServervpxHeartbeatsLicenseClientsshServerCIMHttpServer

Openedports:

NaviCLI:port6390tcp.in

NaviCLI:port443tcp.out

NaviCLI:port6391tcp.in

NaviCLI:port6389tcp.intcp.out

NaviCLI:port2163tcp.outudp.in

NaviCLI:port6392tcp.in

NaviInitTool:port2162udp.out

gpm(pid2215)isrunning…

ipmi_msghandlermoduleloaded.

ipmi_si_drvmoduleloaded.

ipmi_devintfmoduleloaded.

/dev/ipmi0exists.

Table:filter

ChainINPUT(policyACCEPT)

targetprotoptsourcedestination

ChainFORWARD(policyACCEPT)

targetprotoptsourcedestination

ChainOUTPUT(policyACCEPT)

targetprotoptsourcedestination

irqbalanceisstopped

iSCSIdriverisnotloaded

vmware-hostdisstopped

/etc/init.d/microcode_ctl:readingmicrocodestatusisnotyetsupported

Usage:/etc/init.d/mptctlnode{start|stop|restart}

naviagent(pid2011)isrunning…

Configureddevices:

loeth1vswif0

Currentlyactivedevices:

lovmnic2vmnic1vmnic0vswif0

rpc.mountdisstopped

nfsdisstopped

rpc.statdisstopped

nscdisstopped

ntpdisstopped

cimserver(pid2374)isrunning…

portmapisstopped

Ramcheckerisnotrunning

Therandomdatasourceexists

rdiscisstopped

saslauthdisstopped

smartdisstopped

snmpdisstopped

snmptrapdisstopped

sshd(pid556853642106)isrunning…

syslogd(pid1882)isrunning…

klogd(pid1886)isrunning…

Usage:(halt|reboot|start){start}

Thevmnixmodkernelmoduleisloaded.

TheVMkernelisloaded.

Atleastonevirtualmachineisstillrunning.

Usage:/etc/init.d/VMWAREAAM51_vmware{start|stop}

NOTE:VMwareHAAgentattachartifactsclearedfrom/tmp

none

VMwareVMkernelauthorizationdaemonisrunning(pid2274).

vmware-vpxaisrunning

webAccess(pid6860)isrunning…

winbinddisstopped

wsmand(pid2393)isrunning…

xinetd(pid2206)isrunning…

ypbindisstopped

Nightlyyumupdateisdisabled.

[root@dell1root]#

发现vmware-hostdisstopped

[root@dell1root]#servicemgmt-vmwarestatus

vmware-hostdisstopped

3、重启mgmt-vmware服务,过一会后vmware-hostdisstopped

[root@dell1root]#servicemgmt-vmwarerestart

StoppingVMwareESXServerManagementservices:

VMwareESXServerHostAgentServices[OK]

VMwareESXServerHostAgentWatchdog[OK]

VMwareESXServerHostAgent[OK]

StartingVMwareESXServerManagementservices:

VMwareESXServerHostAgent(background)[OK]

Availabilityreportstartup(background)[OK]

4、查看磁盘空间使用情况:

[root@dell1root]#df-h

FilesystemSizeUsedAvailUse%Mountedon

/dev/sdg74.5G4.5G0100%/

/dev/sdg199M26M68M28%/boot

none132M0132M0%/dev/shm

/dev/sdg3981M47M885M6%/var/log

发现磁盘没有剩余可用空间,进一步分析:

[root@dell1root]#cd/var/core/

[root@dell1core]#du.-sh

3.1G.

[root@dell1core]#ls

23045.core23072.core23099.core23127.core23156.core23193.core23230.core23260.core23294.core23337.core23364.core

23046.core23073.core23100.core23128.core23157.core23194.core23231.core23261.core23295.core23338.core23365.core

23047.core23074.core23101.core23129.core23161.core23195.core23232.core23262.core23297.core23339.core23366.core

23048.core23075.core23102.core23130.core23162.core23196.core23233.core23263.core23298.core23340.core23367.core

23049.core23076.core23103.core23131.core23163.core23197.core23234.core23264.core23299.core23341.core23368.core

23050.core23077.core23104.core23132.core23164.core23198.core23235.core23265.core23300.core23342.core23369.core

23051.core23078.core23105.core23133.core23165.core23199.core23236.core23266.core23301.core23343.core23370.core

23052.core23079.core23106.core23134.core23166.core23200.core23237.core23267.core23302.core23344.core23371.core

23053.core23080.core23107.core23135.core23167.core23202.core23238.core23268.core23303.core23345.core23372.core

23054.core23081.core23108.core23136.core23169.core23206.core23239.core23269.core23305.core23346.core23373.core

23055.core23082.core23109.core23137.core23170.core23207.core23241.core23271.core23307.core23347.core23374.core

23056.core23083.core23110.core23138.core23171.core23208.core23244.core23273.core23308.core23348.core26261.core

23057.core23084.core23111.core23139.core23172.core23209.core23245.core23274.core23309.core23349.core7363.core

23058.core23085.core23112.core23140.core23173.core23212.core23246.core23275.core23310.core23350.core8628.core

23059.core23086.core23113.core23141.core23174.core23213.core23247.core23276.core23311.core23351.core8643.core

23060.core23087.core23114.core23142.core23175.core23214.core23248.core23277.core23315.core23352.core8657.core

23061.core23088.core23115.core23143.core23177.core2321.core23249.core23278.core23316.core23353.core8671.core

23062.core23089.core23116.core23144.core23179.core23220.core23250.core23280.core23317.core23354.core8685.core

23063.core23090.core23117.core23145.core23181.core23221.core23251.core23284.core23318.core23355.core8699.core

23064.core23091.core23118.core23146.core23182.core23222.core23252.core23285.core23319.core23356.core

23065.core23092.core23119.core23147.core23183.core23223.core23253.core23286.core23323.core23357.core

23066.core23093.core23120.core23149.core23184.core23224.core23254.core23288.core23324.core23358.core

23067.core23094.core23121.core23150.core23185.core23225.core23255.core23289.core23326.core23359.core

23068.core23095.core23123.core23151.core23187.core23226.core23256.core23290.core23331.core23360.core

23069.core23096.core23124.core23152.core23190.core23227.core23257.core23291.core23333.core23361.core

23070.core23097.core23125.core23153.core23191.core23228.core23258.core23292.core23335.core23362.core

23071.core23098.core23126.core23154.core23192.core23229.core23259.core23293.core23336.core23363.core

原来是var/core磁盘空间溢出,清理/var/core后:

[root@dell1core]#df-h

FilesystemSizeUsedAvailUse%Mountedon

/dev/sdg74.5G1.4G2.9G33%/

/dev/sdg199M26M68M28%/boot

none132M0132M0%/dev/shm

/dev/sdg3981M47M885M6%/var/log

5、重新启动mgmt-vmware服务:

[root@dell1core]#servicemgmt-vmwarerestart

StoppingVMwareESXServerManagementservices:

VMwareESXServerHostAgentServices[OK]

VMwareESXServerHostAgentWatchdog[OK]

VMwareESXServerHostAgent[OK]

StartingVMwareESXServerManagementservices:

VMwareESXServerHostAgent(background)[OK]

Availabilityreportstartup(background)[OK]

[root@dell1core]#

[root@dell1core]#servicemgmt-vmwarestatus

vmware-hostd(pid10339)isrunning…

[root@dell1core]#

6、重新使用VMwareInfrastructureClient连接服务器成功

相关推荐

yanghan / 0评论 2011-06-30