9394952

导航

用命令行初始化VMWARE ESXI主机的脚本(笔记)

#add nic to vswitch
esxcli network vswitch standard uplink add --vswitch-name=vSwitch0 --uplink-name=vmnic1
#add portgroup to vswitch
esxcli network vswitch standard portgroup add -v vSwitch0 -p VLAN-210
esxcli network vswitch standard portgroup set -v 210 -p VLAN-210
#Check network
esxcli network vswitch standard list #Enable a VirtualNic to be used as the vMotion NIC: vim
-cmd hostsvc/vmotion/vnic_set vmk0 #Check vSwitch vMotion configuration: vim-cmd hostsvc/vmotion/netconfig_get | grep selectedVnic #add NFS storage
esxcli storage nfs add --host=192.168.1.1 --share=/volume1/Backup --volume-name=Backup
#rename datastore vim
-cmd hostsvc/datastore/rename datastore1 datastore-100
#Check datastore
vim-cmd hostsvc/datastore/listsummary

#modify vm-hostname
esxcli system hostname set --host=SC-ZB-VM-15
#check vm-hostname
esxcli system hostname get

#add a crond task
echo -E "0 1 * * 0 /vmfs/volumes/Backup/ghettoVCB-master/ghettoVCB.sh -a" >> /var/spool/cron/crontabs/root && crond && cat /var/spool/cron/crontabs/root

 参考文章:

https://kb.vmware.com/s/article/1006989

https://kb.vmware.com/s/article/1008127?lang=zh_CN

https://www.dazhuanlan.com/pockyhey/topics/1507331

https://www.server-world.info/en/note?os=ESXi_7&p=storage&f=2

https://kb.vmware.com/s/article/1010821?lang=zh_CN

 

posted on 2023-06-02 11:22  9394952  阅读(95)  评论(0编辑  收藏  举报