no about note

エンジニアのメモ書き

esxcliの便利な使い方

CLI

概要

ESXiで使えるコマンドラインツール「esxcli」で便利だったコマンド。

1台ならいいけど、GUIで設定してもいいが、複数台あるとしんどいので。
GUIでポチポチしなくていいのは楽。

使用するにはsshログインかコンソールへのログイン(ESXi Shell)が必要

参考:
ESXi 5.x および 6.0 での ESXi Shell の使用 (2014831)

ESXiネットワーク情報取得

vSwich一覧取得

# esxcli network vswitch standard list

ポートグループ一覧

# esxcli network vswitch standard portgroup list

ESXiネットワーク設定

vSwitch設定

vSwitchに物理nicを接続する

# esxcfg-vswitch --link=vmnic0 vSwitch0

ManagementPortのVLAN ID変更

## 設定確認
# esxcli network vswitch standard portgroup list | head -3
Name                Virtual Switch  Active Clients  VLAN ID
------------------  --------------  --------------  -------
Management Network  vSwitch0                     1

## 設定変更
# esxcli network vswitch standard portgroup set -p "Management Network" --vlan-id 100

# esxcli network vswitch standard portgroup list | head -3
# esxcli network vswitch standard portgroup list
Name                Virtual Switch  Active Clients  VLAN ID
------------------  --------------  --------------  -------
Management Network  vSwitch0                     1      200

※物理スイッチがネイティブVLANになっている場合、
パケットがネイティブVLANからタグVLANになるので、このコマンドを打った時点でライアントと疎通が取れなくなる。
物理スイッチにVLANの設定をするまで疎通が取れないので注意。

PortGroup作成

「VLAN100」というPortGroupを作成

# esxcfg-vswitch --add-pg=VLAN100 vSwitch0

PortGroupにVLANID設定

「VLAN100」に「VLAN ID100」を設定

# esxcfg-vswitch --vlan=100 --pg=VLAN100 vSwitch0

ESXiストレージ設定

情報を取得

# esxcli storage
Usage: esxcli storage {cmd} [cmd options]

Available Namespaces:
  core                  VMware core storage commands.
  nfs                   Operations to create, manage, and remove Network Attached Storage filesystems.
  nmp                   VMware Native Multipath Plugin (NMP). This is the VMware default implementation of the Pluggable Storage Architecture.
  san                   IO device management operations to the SAN devices on the system.
  vflash                virtual flash Management Operations on the system.
  vmfs                  VMFS operations.
  filesystem            Operations pertaining to filesystems, also known as datastores, on the ESX host.
# esxcli storage nfs
Usage: esxcli storage nfs {cmd} [cmd options]

Available Namespaces:
  param                 Operations on volume parameters of NAS filesystems.

Available Commands:
  add                   Add a new NAS volume to the ESX Host and mount it with the given volume name.
  list                  List the NAS volumes currently known to the ESX host.
  remove                Remove an existing NAS volume from the ESX host.

nfsストレージを追加

## esxcli storage nfs add -H (NFS_IP|NFS_HOSTNAME) -s (Share_mount_point_on_the_NFS) -v (Volume-name)

# esxcli storage nfs add -H 192.168.1.1 -s /export/nfs/ -v nfsserver

## 確認
# esxcli storage nfs list

SNMP設定

## コミュニティ名に「public」を設定
# esxcli system snmp set --communities public

## SNMPを有効化
# esxcli system snmp set --enable true

## 確認
# esxcli system snmp get
   Authentication:
   Communities: public
   Enable: true
   Engineid: 00000063000000a100000000
   Hwsrc: indications
   Largestorage: true
   Loglevel: info
   Notraps:
   Port: 161
   Privacy:
   Remoteusers:
   Syscontact:
   Syslocation:
   Targets:
   Users:
   V3targets:

パッチの適用

## zipファイルのパッチファイルを適用する

# esxcli software vib install -d "/vmfs/volumes/datastore1/patch-directory/ESXi500-201111001.zip"

ESXi 5.x/6.x ホストにコマンド ラインからパッチをインストールする (2092895)

esxcliのコマンドリファレンス

コマンドリストを取得

# esxcli esxcli command list | head
Namespace                                           Command
--------------------------------------------------  -----------
esxcli.command                                      list
fcoe.adapter                                        list
fcoe.nic                                            disable
fcoe.nic                                            discover
fcoe.nic                                            list
hardware.bootdevice                                 list
hardware.clock                                      get
hardware.clock                                      set
~~~省略~~~~

参考

こちらもよければ。

noaboutsnote.hatenablog.com

noaboutsnote.hatenablog.com