今度ははじかれた側のKVMホスト上で初めてゲストOSをインストールします。
インストール先は LUN1 とします。
# virsh list --all Id Name State -------------------- # virt-install --name guest-iscsi-1 --arch x86_64 --os-type g eneric --vcpus 4 --memory 4096 --disk vol=iscsipool1/unit:0:0:1 --network bridge=br0 --graphics vnc,keymap=ja --location /home/iso/CentOS-8.1.1911-x86_64-dvd1.iso --initrd-inject /home/iso/CentOS811911-ks.cfg --noautoconsole --extra-args "ks=file:/CentOS811911-ks.cfg text console=tty0 console=ttyS0,115200n8r" Starting install... Retrieving file .treeinfo... | 1.5 kB 00:00 Retrieving file vmlinuz... | 7.7 MB 00:00 Retrieving file initrd.img... | 59 MB 00:00 Domain installation still in progress. You can reconnect to the console to complete the installation process. # ls -l /var/lib/libvirt/lockd/scsivolumes/ -rw------- 1 root root 0 3月 15 22:26 36001405b56906a6f1b64077ba05c0f4b -rw------- 1 root root 0 3月 15 22:45 36001405e6ea60493c19463baec9aa7c6 # virsh list --all Id Name State ------------------------------- 3 guest-iscsi-1 running root@newsol:~# virsh console guest-iscsi-1 Connected to domain guest-iscsi-1 Escape character is ^] unbound-libs.x86_64 (287/436) のインストール中 python3-unbound.x86_64 (288/436) のインストール中 kernel-modules.x86_64 (289/436) のインストール中
まだインストールが始まった直後ですが、ロックファイルが生成されています。
インストールが終わると shutdown された状態になります。従来通りです。
起動してゲストにログインして ping しながらライブなマイグレーションを試してみます。
“–undefinesource” オプションを指定するので、
こちらからあちらにゲストOSが移動して後には何も残りません。
# virsh shutdown guest-iscsi-1 # virsh console guest-iscsi-1 CentOS Linux 8 (Core) Kernel 4.18.0-147.el8.x86_64 on an x86_64 pc13 login: root パスワード: 前回のログイン: Sun Mar 15 23:00:17 端末: ttyS0 [root@pc13 ~]# ping 192.168.1.1 PING 192.168.1.1 (192.168.1.1) 56(84) bytes of data. 64 bytes from 192.168.1.1: icmp_seq=1 ttl=255 time=0.688 ms 64 bytes from 192.168.1.1: icmp_seq=2 ttl=255 time=0.356 ms 64 bytes from 192.168.1.1: icmp_seq=3 ttl=255 time=0.357 ms 64 bytes from 192.168.1.1: icmp_seq=4 ttl=255 time=0.356 ms 64 bytes from 192.168.1.1: icmp_seq=5 ttl=255 time=0.508 ms 64 bytes from 192.168.1.1: icmp_seq=6 ttl=255 time=0.330 ms ^] # コンソールから一時的に抜けます。 # ssh root@172.16.1.93 "hostname;whoami;hostname" # time virsh migrate --undefinesource --persistent \ --live guest-iscsi-1 qemu+ssh://172.16.1.93/system real 0m7.170s user 0m0.021s sys 0m0.008s # virsh list --all Id Name State --------------------
移行先のKVMホストで確認します。
# virsh list --all Id Name State --------------------------------- 4 guest-local-hdd running 6 guest-iscsi-0 running 8 guest-iscsi-1 running # virsh console guest-iscsi-1 Connected to domain guest-iscsi-1 Escape character is ^] 64 bytes from 192.168.1.1: icmp_seq=186 ttl=255 time=0.357 ms 64 bytes from 192.168.1.1: icmp_seq=187 ttl=255 time=0.253 ms 64 bytes from 192.168.1.1: icmp_seq=188 ttl=255 time=0.272 ms 64 bytes from 192.168.1.1: icmp_seq=189 ttl=255 time=0.223 ms 64 bytes from 192.168.1.1: icmp_seq=190 ttl=255 time=0.247 ms --- 192.168.1.1 ping statistics --- 190 packets transmitted, 190 received, 0% packet loss, time 628ms rtt min/avg/max/mdev = 0.200/0.361/1.587/0.167 ms
という感じでたまたまかもしれませんが、1秒周期の ICMP エコー要求、応答を取りこぼさない程度にライブな移行ができています。
“–undefinesource” オプションを指定しない場合にはややこしくなります。
移行元では ”shut off” となり、エントリーはまだ残っています。
# ssh root@172.16.1.100 "hostname;whoami;hostname" newsol root newsol # time virsh migrate --persistent \ --live guest-iscsi-1 qemu+ssh://172.16.1.100/system real 0m7.168s user 0m0.033s sys 0m0.008s # virsh list --all Id Name State ---------------------------------- 4 guest-local-hdd running 6 guest-iscsi-0 running - guest-iscsi-1 shut off
移行先では以下の通り”runring”です。
# virsh list --all Id Name State ------------------------------- 7 guest-iscsi-1 running # virsh console guest-iscsi-1 Connected to domain guest-iscsi-1 Escape character is ^] 64 bytes from 192.168.1.1: icmp_seq=157 ttl=255 time=0.356 ms 64 bytes from 192.168.1.1: icmp_seq=158 ttl=255 time=0.317 ms 64 bytes from 192.168.1.1: icmp_seq=159 ttl=255 time=0.286 ms 64 bytes from 192.168.1.1: icmp_seq=160 ttl=255 time=0.264 ms --- 192.168.1.1 ping statistics --- 160 packets transmitted, 160 received, 0% packet loss, time 218ms rtt min/avg/max/mdev = 0.197/0.374/1.780/0.238 ms
ここであえて、故意に移行元で “shut off”のゲストOSを起動すると何が起きるでしょうか?どうあるべきでしょうか?試してみます。
# virsh list --all Id Name State ---------------------------------- 4 guest-local-hdd running 6 guest-iscsi-0 running - guest-iscsi-1 shut off # virsh start guest-iscsi-1 error: Failed to start domain guest-iscsi-1 error: resource busy: Lockspace resource '36001405e6ea60493c19463baec9aa7c6' is locked
ちゃんと起動しませんでした。ロックファイルの仕組みがちゃんと動いているようです。これを実現するためにはファイル、ディレクトリの排他制御がちゃんと動いている必要があります。