KVM : VirtualBMC を利用する2025/10/29 |
|
VirtualBMC をインストールして、IPMI コマンドで仮想マシンが操作できるようにします。 |
|
| [1] | KVM ホストで VirtualBMC をインストールします。 |
|
# [/opt/virtualbmc] 配下に Python 仮想環境を作成 dlp:~ # python3 -m venv --system-site-packages /opt/virtualbmc
# VirtualBMC インストール dlp:~ # /opt/virtualbmc/bin/pip3 install virtualbmc # 新規作成 [Unit] Description=Virtual BMC Service After=network.target libvirtd.service [Service] Type=simple ExecStart=/opt/virtualbmc/bin/vbmcd --foreground ExecStop=/bin/kill -HUP $MAINPID User=root Group=root [Install] WantedBy=multi-user.target # 動作確認 (エラーがでなければ問題なし) dlp:~ # /opt/virtualbmc/bin/vbmc list
|
| [2] | 仮想マシンに VirtualBMC を設定します。 |
|
dlp:~ # virsh list --all Id Name State ----------------------------- - opensuse16 shut off - rx-7 shut off - rx-8 shut off # [rx-7] に VirtualBMC を設定 # [address] には KVM ホストのアドレスを指定 # [port], [username], [password] は任意の値で OK dlp:~ # /opt/virtualbmc/bin/vbmc add rx-7 --address 10.0.0.30 --port 6230 --username vbmcadmin --password adminpassword
/opt/virtualbmc/bin/vbmc list +-------------+---------+-----------+------+ | Domain name | Status | Address | Port | +-------------+---------+-----------+------+ | rx-7 | down | 10.0.0.30 | 6230 | +-------------+---------+-----------+------+ # VirtualBMC 起動 dlp:~ # /opt/virtualbmc/bin/vbmc start rx-7
/opt/virtualbmc/bin/vbmc list +-------------+---------+-----------+------+ | Domain name | Status | Address | Port | +-------------+---------+-----------+------+ | rx-7 | running | 10.0.0.30 | 6230 | +-------------+---------+-----------+------+dlp:~ # /opt/virtualbmc/bin/vbmc show rx-7 +-----------------------+----------------+ | Property | Value | +-----------------------+----------------+ | active | True | | address | 10.0.0.30 | | domain_name | rx-7 | | libvirt_sasl_password | *** | | libvirt_sasl_username | None | | libvirt_uri | qemu:///system | | password | *** | | port | 6230 | | status | running | | username | vbmcadmin | +-----------------------+----------------+ # VirtualBMC 経由で [rx-7] のパワーステータス確認 dlp:~ # ipmitool -I lanplus -H 10.0.0.30 -p 6230 -U vbmcadmin -P adminpassword power status Chassis Power is off # 起動 dlp:~ # ipmitool -I lanplus -H 10.0.0.30 -p 6230 -U vbmcadmin -P adminpassword power on Chassis Power Control: Up/On virsh list --all Id Name State ----------------------------- 1 rx-7 running - opensuse16 shut off - rx-8 shut off # 停止 dlp:~ # ipmitool -I lanplus -H 10.0.0.30 -p 6230 -U vbmcadmin -P adminpassword power off Chassis Power Control: Down/Off virsh list --all Id Name State ----------------------------- - opensuse16 shut off - rx-7 shut off - rx-8 shut off |
| [3] | KVM ホストからではなく、他ホストから VirtualBMC を利用する場合は以下のように設定します。 以下で、SSH 鍵をセットした後は、SSH の設定を [PermitRootLogin prohibit-password] に変更しておいた方がよいでしょう。 |
|
# SSH 鍵を生成して自ホストにセット dlp:~ # ssh-keygen -q -N "" Enter file in which to save the key (/root/.ssh/id_ed25519): dlp:~ # mv ~/.ssh/id_ed25519.pub ~/.ssh/authorized_keys
dlp:~ #
dlp:~ # ssh localhost hostname dlp.srv.world virsh list --all Id Name State ----------------------------- - opensuse16 shut off - rx-7 shut off - rx-8 shut off # [rx-8] に VirtualBMC を設定 # [--libvirt-uri] は KVM ホストを指定 dlp:~ # /opt/virtualbmc/bin/vbmc add rx-8 --address 10.0.0.30 --port 6231 --username vbmcadmin --password adminpassword --libvirt-uri qemu+ssh://root@10.0.0.30/system dlp:~ # /opt/virtualbmc/bin/vbmc start rx-8
/opt/virtualbmc/bin/vbmc list +-------------+---------+---------+------+ | Domain name | Status | Address | Port | +-------------+---------+---------+------+ | rx-7 | running | :: | 6230 | | rx-8 | running | :: | 6231 | +-------------+---------+---------+------+dlp:~ # /opt/virtualbmc/bin/vbmc show rx-8 +-----------------------+----------------------------------+ | Property | Value | +-----------------------+----------------------------------+ | active | False | | address | 10.0.0.30 | | domain_name | rx-8 | | libvirt_sasl_password | *** | | libvirt_sasl_username | None | | libvirt_uri | qemu+ssh://root@10.0.0.30/system | | password | *** | | port | 6231 | | status | down | | username | vbmcadmin | +-----------------------+----------------------------------+ # Firewalld 稼働中の場合は 設定したポートを許可 dlp:~ # firewall-cmd --add-port=6231/udp dlp:~ # firewall-cmd --runtime-to-permanent # 以上で設定完了
# なお KVM ホストで生成した SSH 鍵のプライベートキー [id_ed25519] は事前に VirtualBMC を操作したいホストに要転送 # 例として [rx-7] ホストから [rx-8] を [ipmitool] で操作 # 事前に KVM ホストのプライベートキーを取得済み rx-7:~ # ll .ssh total 16 -rw-------. 1 root root 1 Oct 29 09:44 authorized_keys -rw-------. 1 root root 411 Oct 29 12:39 id_ed25519 -rw-------. 1 root root 825 Oct 29 12:39 known_hosts -rw-r--r--. 1 root root 91 Oct 29 12:39 known_hosts.old
rx-7:~ #
ssh 10.0.0.30 hostname dlp.srv.world
rx-7:~ #
ipmitool -I lanplus -H 10.0.0.30 -p 6231 -U vbmcadmin -P adminpassword power status Chassis Power is off
rx-7:~ #
rx-7:~ # ipmitool -I lanplus -H 10.0.0.30 -p 6231 -U vbmcadmin -P adminpassword power on Chassis Power Control: Up/On ssh 10.0.0.30 "virsh list" Id Name State ---------------------- 2 rx-7 running 3 rx-8 running |
| Sponsored Link |
|
|