株式会社ヴァンデミックシステム

Blog

<スポンサーリンク>

今まで、GUI環境のvirt-managerでやっていたけど、CLIでも結構簡単にできるみたい。

KVMインストール

# 前提条件チェック
cat /proc/cpuinfo  | grep -e svm -e vmx

# パッケージインストール
yum -y groupinstall "Virtualization Host"
yum -y install virt-install virt-top

# 仮想化サービス有効化
systemctl start libvirtd
systemctl enable libvirtd

# ブリッジモード設定
nmcli connection add type  bridge  autoconnect yes con-name br0 ifname br0
nmcli connection modify br0 ipv4.addresses 192.168.0.141/24 ipv4.method manual
nmcli connection modify br0 ipv4.gateway 192.168.0.1
nmcli connection modify br0 ipv4.dns 192.168.0.1
nmcli connection delete eth0
nmcli connection add type bridge-slave autoconnect yes con-name eth0 ifname eth0 master br0 

# カーネルパラメータ設定
modprobe br_netfilter
vim /etc/sysctl.conf
net.bridge.bridge-nf-call-ip6tables = 0
net.bridge.bridge-nf-call-iptables = 0
net.bridge.bridge-nf-call-arptables = 0
sysctl -p

仮想マシンインストール

# isoファイルダウンロード
wget http://ftp.iij.ad.jp/pub/linux/centos/7.6.1810/isos/x86_64/CentOS-7-x86_64-Minimal-1810.iso

# 仮想ディスク作成
qemu-img create -f qcow2 /var/lib/libvirt/images/centos76.img 20G

# インストール
virt-install --connect=qemu:///system \
--name=centos76 \
--vcpus=1 \
--ram=512 \
--accelerate \
--hvm \
--disk path=/var/lib/libvirt/images/centos76.img,size=20,format=qcow2 \
--location='/tmp/CentOS-7-x86_64-Minimal-1810.iso' \
--network bridge=br0 \
--nographics \
--extra-args='console=tty0 console=ttyS0,115200n8'

「!」が出ている項目を選んで、設定する。

よく使うコマンド

# 仮想マシン一覧
virsh list --all

# 仮想マシン起動
virsh start centos76

# 仮想マシン停止
virsh stop centos76

# 仮想マシンコンソールログイン
virsh console centos76

ちなみにHyper-V上の仮想マシンにKVMを入れ、さらに仮想マシンを立てるっている、ネスト構造をやったので、ホストOSからKVM仮想マシンに対して、以下コマンドを実行しているよ。
ネストの許可と、マックアドレススプーリング(無差別モード的な)の許可

PS C:\Users\administrator.CHASE> Set-VMProcessor -VMName KVM -ExposeVirtualizationExtensions $true
PS C:\Users\administrator.CHASE> Get-VMNetworkAdapter -VMName KVM | Set-VMNetworkAdapter -MacAddressSpoofing On

<スポンサーリンク>

4 Comments

4 Records

  1. on 2019年4月30日 at 8:41 PM
    たに wrote:

    CPUの前提条件が必要かと思うのですが、ちなみになんでしょうか?
    聞く前に、自分で調べろ、って話ですが…。

    返信
    • on 2019年5月2日 at 6:18 AM
      yuta wrote:

      あれですか、仮想化支援機能のことですかね??

      返信
      • on 2019年5月2日 at 9:31 AM
        たに wrote:

        はい。そのあたりの話です。

        返信
        • on 2019年5月17日 at 5:37 AM
          yuta wrote:

          この結果が真ならいけます!

          # 前提条件チェック
          cat /proc/cpuinfo | grep -e svm -e vmx

          返信

コメントを残す

Allowed tags:  you may use these HTML tags and attributes: <a href="">, <strong>, <em>, <h1>, <h2>, <h3>
Please note:  all comments go through moderation.

*

日本語が含まれない投稿は無視されますのでご注意ください。(スパム対策)