解决vcenter中esxi离线与datastore inaccessible

解决vcenter中esxi离线与datastore inaccessible

一、故障现象

某地数据中心不正常停电,导致vcenter中的esxi服务没正常启动,管理页面打不开,通过service-control --start --all全部启动服务后,能正常进管理页面,但此时esxi全部离线。逐个esxi右键---reConnect主机,基本能正常添加。只有一台死活添加不上,在解决的过程中遇到的一连串无厘头问题(==实际还更多==),下面将重点列几个。

二、处理

  1. 处理datastore遗留问题

添加不上只能手动删除离线的esxi,但再重新添加时提示如下:

Datastore 'datastore_ssd' conflicts with an existing datastore in the datacenter that has the same URL

google得知需要进数据库删除datastore,否则旧的datastore一直存在,永远添加不了。执行如下步骤

  • 停止vpxd服务,service-control --stop vpxd
  • 进postGresql /opt/vmware/vpostgres/current/bin/psql -d VCDB -U postgres
  • 查询 select * from vpx_datastore 得到要处理的id。

image-20231217153633784

我这里需要删的id是24,然后

  • 执行sql语句删除datastore
 delete from vpx_ds_assignment where ds_id=24;
 delete from vpx_vm_ds_space where ds_id=24;
 delete from vpx_datastore where id=24;
 delete from vpx_entity where id=24;
  • \q退出,service-contorl --start vpxd
  1. 改时间

经过上面的修改后,重新添加时一开始还提示证书失败什么的(==unable to push signed certificate to host==),由于没动过服务器,猜测是时间差别过大改成的。对比esxi与vcenter的时间,果然不一样,差了几个小时,然后去修改vcenter的时间。

改时间,utc+8=cst。==vcenter改时间要到:5480上改,差且官方说不支持cst格式,只能用utc,与esxi的cst格式不同,所以需要知道换算,虽然直接改为跟随host就可以==,改时间后,没再提示证书失败问题,但还是连接不上,提示:

`An error occurred while communicating with the remote host
  1. 还原

既然改时间重新添加也不行,那干脆对vcenter做还原吧。顺利还原后以为一切OK,谁知进vcenter后esxi还是离线状态,重新添加又报不能与远程主机通讯,实际上esxi是正常工作的,也能单独进esxi管理界面。

  1. 换IP测试

还原都不行的话,大概率是esxi这边的问题,因为其它esxi是能正常添加的。由于这个esxi上有两个kernel网卡,于是用另一个网卡来添加host(==这里又要重复之前的步骤了,因为datastore不会自动删除==)。经测试,另一个网段的ip添加正常,并且添加时会弹出证书确认提示。到esxi的security & users---certificates,查看证书,果然证书都过期了,而且证书里显示的ip指向的是备用IP的。怀疑这就是导致vcenter能添加备用 ip却不能添加主Ip的原因。

  1. 更新证书
  • 查看证书 openssl s_client -connect localhost:443 |grep notBefore
  • 更新证书 /sbin/generate-certificates,UI界面上的更新证书不知咋用,还是命令行快。
  • 重启hostd /etc/init.d/hostd restart

经过上面几个步骤,vcenter重新添加esxi,久违的界面终于回来了!

三、总结

这次故障排查花了几个小时,主要是界面没任何提示,只告诉你An error occurred while communicating with the remote host.,vpxd里只有这个错误:

[VpxLRO] -- FINISH task-1073
2023-12-16T18:40:49.007Z error vpxd[04152] [Originator@6876 sub=licenseClient opID=xxxx-969-auto-qz-h5:70000527-8c-LicenseClientUnregisterHostAsync-xxxx9] Swallowing exception 'Fault cause: vim.fault.LicenseEntityNotFound
--> ' thrown when unregister entity 'host-203'
2023-12-16T18:40:49.006Z info vpxd[09890] [Originator@6876 sub=Default opID=lqxxxxy-969-auto-qz-h5:70000527-8c] [VpxLRO] -- ERROR task-1073 -- group-h4 -- vim.Folder.addStandaloneHost: vmodl.fault.HostCommunication:
--> Result:
--> (vmodl.fault.HostCommunication) {
-->    faultCause = (vmodl.MethodFault) null,
-->    faultMessage = <unset>
-->    msg = ""
--> }
--> Args:

根本看不出哪里有问题(==LicenseEntityNotFound,这里也确认过了,即使把esxi都移除,只添加一台esxi,也会报错==),只能逐个排除。

评论已关闭