esx命令行操作

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@dell1 root]# service –status-all
crond (pid 2263) is running…
Chain INPUT (policy ACCEPT 1794K packets, 90M bytes)
pkts bytes target prot opt in out source destination
Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
Chain OUTPUT (policy ACCEPT 2532K packets, 3521M bytes)
pkts bytes target prot opt in out source destination
Incoming and outgoing ports blocked by default.
Enabled services: CIMSLP aam VCB CIMHttpsServer vpxHeartbeats LicenseClient sshServer CIMHttpServer
Opened ports:
NaviCLI : port 6390 tcp.in
NaviCLI : port 443 tcp.out
NaviCLI : port 6391 tcp.in
NaviCLI : port 6389 tcp.in tcp.out
NaviCLI : port 2163 tcp.out udp.in
NaviCLI : port 6392 tcp.in
NaviInitTool : port 2162 udp.out
gpm (pid 2215) is running…
ipmi_msghandler module loaded.
ipmi_si_drv module loaded.
ipmi_devintf module loaded.
/dev/ipmi0 exists.
Table: filter
Chain INPUT (policy ACCEPT)
target prot opt source destination
Chain FORWARD (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
irqbalance is stopped
iSCSI driver is not loaded
vmware-hostd is stopped
/etc/init.d/microcode_ctl: reading microcode status is not yet supported
Usage: /etc/init.d/mptctlnode {start|stop|restart}
naviagent (pid 2011) is running…
Configured devices:
lo eth1 vswif0
Currently active devices:
lo vmnic2 vmnic1 vmnic0 vswif0
rpc.mountd is stopped
nfsd is stopped
rpc.statd is stopped
nscd is stopped
ntpd is stopped
cimserver (pid 2374) is running…
portmap is stopped
Ramchecker is not running
The random data source exists
rdisc is stopped
saslauthd is stopped
smartd is stopped
snmpd is stopped
snmptrapd is stopped
sshd (pid 5568 5364 2106) is running…
syslogd (pid 1882) is running…
klogd (pid 1886) is running…
Usage: (halt|reboot|start) {start}
The vmnixmod kernel module is loaded.
The VMkernel is loaded.
At least one virtual machine is still running.
Usage: /etc/init.d/VMWAREAAM51_vmware { start | stop }
NOTE: VMware HA Agent attach artifacts cleared from /tmp
none
VMware VMkernel authorization daemon is running (pid 2274).
vmware-vpxa is running
webAccess (pid 6860) is running…
winbindd is stopped
wsmand (pid 2393) is running…
xinetd (pid 2206) is running…
ypbind is stopped
Nightly yum update is disabled.
[root@dell1 root]#
发现vmware-hostd is stopped
[root@dell1 root]# service mgmt-vmware status
vmware-hostd is stopped

3、重启mgmt-vmware服务,过一会后vmware-hostd is stopped
[root@dell1 root]# service mgmt-vmware restart
Stopping VMware ESX Server Management services:
VMware ESX Server Host Agent Services [ OK ]
VMware ESX Server Host Agent Watchdog [ OK ]
VMware ESX Server Host Agent [ OK ]
Starting VMware ESX Server Management services:
VMware ESX Server Host Agent (background) [ OK ]
Availability report startup (background) [ OK ]

4、查看磁盘空间使用情况:
[root@dell1 root]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sdg7 4.5G 4.5G 0 100% /
/dev/sdg1 99M 26M 68M 28% /boot
none 132M 0 132M 0% /dev/shm
/dev/sdg3 981M 47M 885M 6% /var/log
发现磁盘没有剩余可用空间,进一步分析:
[root@dell1 root]# cd /var/core/
[root@dell1 core]# du . -sh
3.1G .
[root@dell1 core]# ls
23045.core 23072.core 23099.core 23127.core 23156.core 23193.core 23230.core 23260.core 23294.core 23337.core 23364.core
23046.core 23073.core 23100.core 23128.core 23157.core 23194.core 23231.core 23261.core 23295.core 23338.core 23365.core
23047.core 23074.core 23101.core 23129.core 23161.core 23195.core 23232.core 23262.core 23297.core 23339.core 23366.core
23048.core 23075.core 23102.core 23130.core 23162.core 23196.core 23233.core 23263.core 23298.core 23340.core 23367.core
23049.core 23076.core 23103.core 23131.core 23163.core 23197.core 23234.core 23264.core 23299.core 23341.core 23368.core
23050.core 23077.core 23104.core 23132.core 23164.core 23198.core 23235.core 23265.core 23300.core 23342.core 23369.core
23051.core 23078.core 23105.core 23133.core 23165.core 23199.core 23236.core 23266.core 23301.core 23343.core 23370.core
23052.core 23079.core 23106.core 23134.core 23166.core 23200.core 23237.core 23267.core 23302.core 23344.core 23371.core
23053.core 23080.core 23107.core 23135.core 23167.core 23202.core 23238.core 23268.core 23303.core 23345.core 23372.core
23054.core 23081.core 23108.core 23136.core 23169.core 23206.core 23239.core 23269.core 23305.core 23346.core 23373.core
23055.core 23082.core 23109.core 23137.core 23170.core 23207.core 23241.core 23271.core 23307.core 23347.core 23374.core
23056.core 23083.core 23110.core 23138.core 23171.core 23208.core 23244.core 23273.core 23308.core 23348.core 26261.core
23057.core 23084.core 23111.core 23139.core 23172.core 23209.core 23245.core 23274.core 23309.core 23349.core 7363.core
23058.core 23085.core 23112.core 23140.core 23173.core 23212.core 23246.core 23275.core 23310.core 23350.core 8628.core
23059.core 23086.core 23113.core 23141.core 23174.core 23213.core 23247.core 23276.core 23311.core 23351.core 8643.core
23060.core 23087.core 23114.core 23142.core 23175.core 23214.core 23248.core 23277.core 23315.core 23352.core 8657.core
23061.core 23088.core 23115.core 23143.core 23177.core 2321.core 23249.core 23278.core 23316.core 23353.core 8671.core
23062.core 23089.core 23116.core 23144.core 23179.core 23220.core 23250.core 23280.core 23317.core 23354.core 8685.core
23063.core 23090.core 23117.core 23145.core 23181.core 23221.core 23251.core 23284.core 23318.core 23355.core 8699.core
23064.core 23091.core 23118.core 23146.core 23182.core 23222.core 23252.core 23285.core 23319.core 23356.core
23065.core 23092.core 23119.core 23147.core 23183.core 23223.core 23253.core 23286.core 23323.core 23357.core
23066.core 23093.core 23120.core 23149.core 23184.core 23224.core 23254.core 23288.core 23324.core 23358.core
23067.core 23094.core 23121.core 23150.core 23185.core 23225.core 23255.core 23289.core 23326.core 23359.core
23068.core 23095.core 23123.core 23151.core 23187.core 23226.core 23256.core 23290.core 23331.core 23360.core
23069.core 23096.core 23124.core 23152.core 23190.core 23227.core 23257.core 23291.core 23333.core 23361.core
23070.core 23097.core 23125.core 23153.core 23191.core 23228.core 23258.core 23292.core 23335.core 23362.core
23071.core 23098.core 23126.core 23154.core 23192.core 23229.core 23259.core 23293.core 23336.core 23363.core
原来是var/core磁盘空间溢出,清理/var/core后:
[root@dell1 core]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sdg7 4.5G 1.4G 2.9G 33% /
/dev/sdg1 99M 26M 68M 28% /boot
none 132M 0 132M 0% /dev/shm
/dev/sdg3 981M 47M 885M 6% /var/log

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

[root@dell1 core]# service mgmt-vmware restart
Stopping VMware ESX Server Management services:
VMware ESX Server Host Agent Services [ OK ]
VMware ESX Server Host Agent Watchdog [ OK ]
VMware ESX Server Host Agent [ OK ]
Starting VMware ESX Server Management services:
VMware ESX Server Host Agent (background) [ OK ]
Availability report startup (background) [ OK ]
[root@dell1 core]#
[root@dell1 core]# service mgmt-vmware status
vmware-hostd (pid 10339) is running…
[root@dell1 core]#

6、重新使用VMware Infrastructure Client连接服务器成功

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值