ESXi7 esxcliコマンドで仮想スイッチの設定、datastoreの名前変更、ポートグループ、チーミング設定

ESXi7 esxcliコマンドで仮想スイッチの設定、datastoreの名前変更、ポートグループ、チーミング設定などができます。

 

個人的に、最近はGUIでの操作が嫌いなので、なるべくコマンドを使用して構築するほうが楽ですし、ミスも少ないです。

 

後、コマンドのほうが設定も早いです。ESXiの構築台数が多い場合は、コマンドを準備しておくと効率がいいですね。

 

そして、実際に構築で参考にさせてもらった情報がこちらです。

kickstart-file-generator/esx-template.cfg at master · trinitor/kickstart-file-generator · GitHub

 

まんま抜粋になりますが、必要なところを拝借して環境合わせて修正することで、そのまま使えます。

 

ESXi5とありますが、ESXi7でも拝借した一部コマンドは問題なく使えました。すべてが使えるかわからないので、検証は必要です。

 

このあたりのシステムのオプションの設定ができるのもいいですね。

---

esxcli system settings advanced set -o /UserVars/ESXiShellInteractiveTimeOut -i 3600
vim-cmd hostsvc/enable_ssh
vim-cmd hostsvc/start_ssh
esxcli system settings advanced set -o /UserVars/SuppressShellWarning -i 1

---

 

 

-----

# VMware ESXi 5.x kickstart file
accepteula
install --firstdisk
rootpw 12345678
#reboot
network --bootproto=static --addvmportgroup=false --device=vmnic0 --ip=%IPADDR% --netmask=%NETMASK% --gateway=%GATEWAY% --nameserver=%DNS% --hostname=%HOSTNAME%

%firstboot --interpreter=busybox
esxcli system hostname set --domain=example.com

esxcli network ip dns search add --domain="example.com,example2.com"

esxcli system maintenanceMode set -e true

vim-cmd hostsvc/datastore/rename datastore1 "%HOSTNAME%_localStorage1"

vim-cmd hostsvc/autostartmanager/enable_autostart true
vim-cmd hostsvc/autostartmanager/update_defaults 120 120 "GuestShutdown" true

cat > /etc/ntp.conf << __NTP_CONFIG__
restrict default kod nomodify notrap noquerynopeer
restrict 127.0.0.1
server 0.de.pool.ntp.org
__NTP_CONFIG__
/sbin/chkconfig ntpd on

esxcli network vswitch standard uplink add --uplink-name vmnic0 --vswitch-name vSwitch0
esxcli network vswitch standard uplink add --uplink-name vmnic1 --vswitch-name vSwitch0
esxcli network vswitch standard portgroup remove --portgroup-name="VM Network" --vswitch-name vSwitch0
esxcli network vswitch standard policy failover set --active-uplinks vmnic0,vmnic1 --vswitch-name vSwitch0

esxcli network vswitch standard portgroup add --portgroup-name VMkernel --vswitch-name vSwitch0
esxcli network ip interface add --interface-name=vmk1 --portgroup-name=VMkernel
vim-cmd hostsvc/vmotion/vnic_set vmk1

esxcli network vswitch standard add --ports 256 --vswitch-name vSwitch1
esxcli network vswitch standard uplink add --uplink-name vmnic2 --vswitch-name vSwitch1
esxcli network vswitch standard uplink add --uplink-name vmnic3 --vswitch-name vSwitch1
esxcli network vswitch standard portgroup add --portgroup-name "VM Network" --vswitch-name vSwitch1
esxcli network vswitch standard policy failover set --active-uplinks vmnic2,vmnic3 --vswitch-name vSwitch1

esxcli system settings advanced set -o /UserVars/ESXiShellInteractiveTimeOut -i 3600
vim-cmd hostsvc/enable_ssh
vim-cmd hostsvc/start_ssh
esxcli system settings advanced set -o /UserVars/SuppressShellWarning -i 1

cp /var/log/hostd.log "/vmfs/volumes/%HOSTNAME%_localStorage1/firstboot-hostd.log"
cp /var/log/esxi_install.log "/vmfs/volumes/%HOSTNAME%_localStorage1/firstboot-esxi_install.log"
esxcli system shutdown reboot -d 60 -r "rebooting after host configurations"

-----

 

ESXiの構築をよくするようなベンダーの方は、こういった構築セットコマンドを簡単に作れるようにしておくと、構築が楽になります。

 

エレコム キーボード ワイヤレス (レシーバー付属) メンブレン 薄型 フルキーボード ブラック TK-FDM110TXBK