前回の記事では、LinuxにXen仮想化ソフトウェアをインストールし、virt-managerを使用してVMを起動する方法を見たことがあるでしょうか。今日は、 virt-cloneを使用してXenHyperVisorでVMのクローンを作成する方法を見ていきます。 。
ステップ1:まず、を見つける必要がありますvirt-clone ユーティリティは、次のコマンドを使用して使用できます。
#rpm -qa | grep 'virtinst\|libvirt' libvirt-0.8.2-29.el5_9.1 libvirt-python-0.8.2-29.el5_9.1 python-virtinst-0.400.3-13.el5
または
#which virt-clone /usr/bin/virt-clone Wed Oct 21>#
virt-cloneの場合 ユーティリティが見つからない場合は、 libvirtをインストールする必要があります およびvirtinst yumを使用したパッケージ インストーラー。
#yum install virtinst libvirt
ステップ2:以下のコマンドを使用してVMのリストを検索します:
#xm list Domain Name ID Mem(MiB) VCPUs State Time(s) Domain-0 0 5911 4 r----- 15870.6 centos-2 6 1032 1 ------ 4.6
次に、次のいずれかのコマンドを使用して、クローンを作成する仮想マシンをシャットダウンします。
#xm shutdown <domain-name>
または
#virsh -c xen:/// Welcome to virsh, the virtualization interactive terminal.
Type: 'help' for help with commands 'quit' to quit
virsh # shutdown <domain-name>
ステップ3:virt-cloneコマンドを使用して、以下に示すようにクローンを作成します:
以下に示すように、特定の質問が表示されますが、それに答える必要があります。
#virt-clone --connect xen:/// --prompt What is the name of the original virtual machine? centos-2 What is the name for the cloned virtual machine? centos-clone-2 ERROR Domain with devices to clone must be paused or shutoff.
注:クローンを作成する予定のVMをシャットダウン/一時停止しないと、上記のエラーが発生します。
#virt-clone --connect xen:/// --prompt What is the name of the original virtual machine? centos-2 What is the name for the cloned virtual machine? centos-clone-2 What would you like to use as the cloned disk (file path) for '/var/lib/xen/images/centos-2-3.img'? /var/lib/xen/images/centos-2-4.img Cloning /var/lib/xen/images/centos-2-3.img | 7.8 GB 01:04 Clone 'centos-clone-2' created successfully.
または
元のVM名がわかっている場合は、次のコマンドを直接実行できます。
#virt-clone --original centos-2 --name centos-clone-2 --file /var/lib/xen/images/centos-clone-2.img
ステップ4:次に、以下に示すように、新しいクローンVMを起動します。
#xm create centos-clone-2 Using config file "/etc/xen/centos-2". Started domain centos-2
ステップ5:ネットワーク設定を適切に行う:
次のコマンドでMACアドレスを見つけます:
#ifconfig -a | grep HWaddr eth0 Link encap:Ethernet HWaddr 00:16:3E:3D:48:8D
次のファイルを開きます: / etc / sysconfig / network-scripts / ifcfg-eth0 それに応じてIPアドレスとMACアドレスを変更します。
ネットワークサービスが稼働していることを確認してください。これで、VMがネットワーク経由で利用できるようになりました。