메뉴 닫기

오픈스택 queens 버전 suspended 인스턴스 마이그레이션.

오픈스택에서 인스턴스가 정지상태인 suspended 에선 마이그레이션이 지원 되질 않습니다.

이럴 경우엔 수동으로 작업을 해줘야 하며 데이터베이스 까지 수정해야 합니다.

테스트는 우분투 18.04 OS에서 오픈스택 queens 버전으로 하였으며 최근 버전에서는 데이터베이스 부분에서 현재 버전과 달라 작업시 문제가 발생할수 있습니다.

또한 이전하는 호스트 서버와 이전되는 호스트 서버 하드웨어는 동일해야 해야 하며 cpu 모델은 필히 동일하게 합니다. 

 


 

  • 테스트할 인스턴스 생성

    root@controller:~# source testuser_openrc

    root@controller:~# neutron port-create testnet
    neutron CLI is deprecated and will be removed in the future. Use openstack CLI instead.
    Created a new port:
    ..
    ..
    | id | 553512f7-7485-4f05-abde-5c8a1e734d21 |
    ..

    ..

    root@controller:~# openstack server create –image Ubuntu_20.04_x86 –flavor flavor100 –port 553512f7-7485-4f05-abde-5c8a1e734d21 jyh

    root@controller:~# openstack floating ip create provider
    ..
    ..
    | name | xx.xx.xx.x.167 |
    ..
    ..
    +———————+————————————–+

    root@controller:~# openstack server add floating ip jyh xx.xx.xx.x.167

    root@controller:~# openstack server list
    +————————————–+—————-+——–+————————————-+——————+———-+
    | ID | Name | Status | Networks | Image | Flavor |
    +————————————–+—————-+——–+————————————-+——————+———-+
    | f575163f-d78a-42b7-b03c-602486ea5017 | jyh | ACTIVE | testnet=10.101.0.14, xx.xx.xx.x.167 | Ubuntu_20.04_x86 | flavor100 |
    +————————————–+—————-+——–+————————————-+——————+———-+

  • 호스트 서버, 인스턴스 이름 정보 확인 및 데이터 쓰기.

    root@controller:~# source admin_openrc

    root@controller:~# nova show f575163f-d78a-42b7-b03c-602486ea5017 |egrep “compute|instance”
    | OS-EXT-SRV-ATTR:host | compute1 |
    | OS-EXT-SRV-ATTR:hypervisor_hostname | compute1 |
    | OS-EXT-SRV-ATTR:instance_name | instance-000004ec

    root@controller:~# ssh xx.xx.xx.x.167 -p 22

    root@jyh:~# dd if=/dev/zero of=./erase bs=1K count=1000000
    1000000+0 records in
    1000000+0 records out
    1024000000 bytes (1.0 GB, 977 MiB) copied, 3.71851 s, 275 MB/s

    root@jyh:~# logout

  • 인스턴스 정지

    root@controller:~# openstack server suspend jyh

    root@controller:~# nova list
    +————————————–+—————-+———–+————+————-+————————————-+
    | ID | Name | Status | Task State | Power State | Networks |
    +————————————–+—————-+———–+————+————-+————————————-+
    | f575163f-d78a-42b7-b03c-602486ea5017 | jyh | SUSPENDED | – | Shutdown | dicaniu=10.101.0.14, xx.xx.xx.x.167 |
    +————————————–+—————-+———–+————+————-+————————————-+

  • 실 사용 호스트에서 데이터 이전.

    root@compute1:~# virsh list –all
    Id Name State
    —————————————————-
    4 instance-0000026d running
    – instance-000004ec shut off

    root@compute1:~# ll -h /var/lib/libvirt/qemu/save/
    total 482M
    drwxr-xr-x 2 libvirt-qemu kvm 4.0K Feb 8 15:40 ./
    drwxr-x— 9 libvirt-qemu kvm 4.0K Feb 8 15:40 ../
    -rw——- 1 root root 482M Feb 8 15:40 instance-000004ec.save

    root@compute1:~# scp /var/lib/libvirt/qemu/save/instance-000004ec.save root@compute2:/var/lib/libvirt/qemu/save/
    Warning: Permanently added ‘[compute2]:7504,[172.16.248.42]:7504’ (ECDSA) to the list of known hosts.
    instance-000004ec.save 100% 482MB 110.8MB/s 00:04

    root@compute1:~# qemu-img info /var/lib/nova/instances/f575163f-d78a-42b7-b03c-602486ea5017/disk
    ..
    ..
    backing file: /var/lib/nova/instances/_base/890f837a210a6e693e612789f08fabdf6b58a1ae

    ..
    ..
    root@compute1:~# scp -r /var/lib/nova/instances/f575163f-d78a-42b7-b03c-602486ea5017 nova@compute2:/var/lib/nova/instances/
    Warning: Permanently added ‘[compute2]:7504,[172.16.248.42]:7504’ (ECDSA) to the list of known hosts.
    disk.info 100% 79 167.1KB/s 00:00
    console.log 100% 84KB 30.8MB/s 00:00
    disk

    root@compute2:~# scp /var/lib/nova/instances/_base/890f837a210a6e693e612789f08fabdf6b58a1ae root@compute2:/var/lib/nova/instances/_base/
    # backing file이 이미 있다면 복사 하지 않는다….

     

  • 옴겨질 호스트 서버에서 옴겨온 파일 정보(컴튜느 노드 아이피) 수정

    root@compute2:~# virsh save-image-dumpxml /var/lib/libvirt/qemu/save/instance-000004ec.save |grep 172.16.248.47
    <graphics type=’spice’ autoport=’yes’ listen=’172.16.248.47′ keymap=’en-us’>
    <listen type=’address’ address=’172.16.248.47’/>

    root@compute2:~# virsh save-image-edit /var/lib/libvirt/qemu/save/instance-000004ec.save
    State file /var/lib/libvirt/qemu/save/instance-000004ec.save edited.

    root@compute2:~# virsh save-image-dumpxml /var/lib/libvirt/qemu/save/instance-000004ec.save |grep 172.16.248.42
    <graphics type=’spice’ autoport=’yes’ listen=’172.16.248.42′ keymap=’en-us’>
    <listen type=’address’ address=’172.16.248.42’/>

    root@compute2:~# logout

     

  • 포트, 호스트 서버 정보 수정

    root@controller:~# source admin_openrc

    root@controller:~# neutron port-show 553512f7-7485-4f05-abde-5c8a1e734d21 |grep host
    neutron CLI is deprecated and will be removed in the future. Use openstack CLI instead.
    | binding:host_id | compute1

    root@controller:~# neutron port-update –binding:host_id=compute2 553512f7-7485-4f05-abde-5c8a1e734d21
    neutron CLI is deprecated and will be removed in the future. Use openstack CLI instead.
    Updated port: 553512f7-7485-4f05-abde-5c8a1e734d21

    root@controller:~# neutron port-show 553512f7-7485-4f05-abde-5c8a1e734d21 |grep host
    neutron CLI is deprecated and will be removed in the future. Use openstack CLI instead.
    | binding:host_id | compute2

    root@controller:~# mysql
    Welcome to the MariaDB monitor. Commands end with ; or \g.
    Your MariaDB connection id is 866569

    MariaDB [(none)]> use nova
    Reading table information for completion of table and column names
    You can turn off this feature to get a quicker startup with -A

    Database changed

    MariaDB [nova]> select node,launched_on,host from instances where uuid=’f575163f-d78a-42b7-b03c-602486ea5017′;
    +———–+————-+———–+
    | node | launched_on | host |
    +———–+————-+———–+
    | compute1 | compute1 | compute1 |
    +———–+————-+———–+
    1 row in set (0.00 sec)

    MariaDB [nova]> update instances set node=’compute2′,launched_on=’compute2′,host=’compute2′ where uuid=’f575163f-d78a-42b7-b03c-602486ea5017′;
    Query OK, 1 row affected (0.03 sec)
    Rows matched: 1 Changed: 1 Warnings: 0

    MariaDB [nova]> select node,launched_on,host from instances where uuid=’f575163f-d78a-42b7-b03c-602486ea5017′;
    +———–+————-+———–+
    | node | launched_on | host |
    +———–+————-+———–+
    | compute2 | compute2 | compute2 |
    +———–+————-+———–+
    1 row in set (0.00 sec)

    MariaDB [nova]> quit

  • 인스턴스 재가동

    root@controller:~# source testuser_openrc

    root@controller:~# nova list
    +————————————–+—————-+———–+————+————-+————————————-+
    | ID | Name | Status | Task State | Power State | Networks |
    +————————————–+—————-+———–+————+————-+————————————-+
    | f575163f-d78a-42b7-b03c-602486ea5017 | jyh | SUSPENDED | – | Shutdown | testnet=10.101.0.14, xx.xx.xx.x.167 |
    +————————————–+—————-+———–+————+————-+————————————-+

    root@controller:~# openstack server resume jyh

    root@controller:~# nova list
    +————————————–+—————-+——–+————+————-+————————————-+
    | ID | Name | Status | Task State | Power State | Networks |
    +————————————–+—————-+——–+————+————-+————————————-+
    | f575163f-d78a-42b7-b03c-602486ea5017 | jyh | ACTIVE | – | Running | testnet=10.101.0.14, xx.xx.xx.x.167 |
    +————————————–+—————-+——–+————+————-+————————————-+

    root@controller:~# ping xx.xx.xx.x.167
    PING xx.xx.xx.x.167 (xx.xx.xx.x.167) 56(84) bytes of data.
    64 bytes from xx.xx.xx.x.167: icmp_seq=1 ttl=62 time=1.36 ms

    root@controller:~# ssh xx.xx.xx.x.167 -p 22

    root@jyh:~# uptime
    06:42:17 up 12 min, 1 user, load average: 0.00, 0.05, 0.08

  • resource provider 정보 수정

    root@controller:~# mysql
    Welcome to the MariaDB monitor. Commands end with ; or \g.
    Your MariaDB connection id is 866599
    Server version: 10.1.47-MariaDB-0ubuntu0.18.04.1 Ubuntu 18.04

    MariaDB [(none)]> use nova_api;
    Reading table information for completion of table and column names
    You can turn off this feature to get a quicker startup with -A

    Database changed
    MariaDB [nova_api]> select * from resource_providers where name=’compute1′;
    +———————+———————+—-+————————————–+———–+————+———-+——————+——————–+
    | created_at | updated_at | id | uuid | name | generation | can_host | root_provider_id | parent_provider_id |
    +———————+———————+—-+————————————–+———–+————+———-+——————+——————–+
    | 2021-04-23 07:14:03 | 2022-02-08 06:29:46 | 28 | 896c5265-e52c-4516-8120-073ac2de7fe2 | compute1 | 22 | NULL | 28 | NULL |
    +———————+———————+—-+————————————–+———–+————+———-+——————+——————–+
    1 row in set (0.00 sec)

    MariaDB [nova_api]> select * from resource_providers where name=’compute2′;
    +———————+———————+—-+————————————–+———–+————+———-+——————+——————–+
    | created_at | updated_at | id | uuid | name | generation | can_host | root_provider_id | parent_provider_id |
    +———————+———————+—-+————————————–+———–+————+———-+——————+——————–+
    | 2021-01-20 05:24:40 | 2021-12-31 11:04:47 | 8 | e8761491-8af3-4a56-be81-628c98523906 | compute2 | 40 | NULL | 8 | NULL |
    +———————+———————+—-+————————————–+———–+————+———-+——————+——————–+
    1 row in set (0.00 sec)

    MariaDB [nova_api]> select * from allocations where consumer_id=’f575163f-d78a-42b7-b03c-602486ea5017′;
    +———————+————+——+———————-+————————————–+——————-+——+
    | created_at | updated_at | id | resource_provider_id | consumer_id | resource_class_id | used |
    +———————+————+——+———————-+————————————–+——————-+——+
    | 2022-02-08 06:29:46 | NULL | 5863 | 28 | f575163f-d78a-42b7-b03c-602486ea5017 | 0 | 1 |
    | 2022-02-08 06:29:46 | NULL | 5864 | 28 | f575163f-d78a-42b7-b03c-602486ea5017 | 1 | 2048 |
    | 2022-02-08 06:29:46 | NULL | 5865 | 28 | f575163f-d78a-42b7-b03c-602486ea5017 | 2 | 25 |
    +———————+————+——+———————-+————————————–+——————-+——+
    3 rows in set (0.00 sec)

    MariaDB [nova_api]> update allocations set resource_provider_id=’8′ where consumer_id=’f575163f-d78a-42b7-b03c-602486ea5017′;
    Query OK, 3 rows affected (0.00 sec)
    Rows matched: 3 Changed: 3 Warnings: 0

    MariaDB [nova_api]>
    MariaDB [nova_api]> select * from allocations where consumer_id=’f575163f-d78a-42b7-b03c-602486ea5017′;
    +———————+————+——+———————-+————————————–+——————-+——+
    | created_at | updated_at | id | resource_provider_id | consumer_id | resource_class_id | used |
    +———————+————+——+———————-+————————————–+——————-+——+
    | 2022-02-08 06:29:46 | NULL | 5863 | 8 | f575163f-d78a-42b7-b03c-602486ea5017 | 0 | 1 |
    | 2022-02-08 06:29:46 | NULL | 5864 | 8 | f575163f-d78a-42b7-b03c-602486ea5017 | 1 | 2048 |
    | 2022-02-08 06:29:46 | NULL | 5865 | 8 | f575163f-d78a-42b7-b03c-602486ea5017 | 2 | 25 |
    +———————+————+——+———————-+————————————–+——————-+——+
    3 rows in set (0.00 sec)

    MariaDB [nova_api]> quit
    Bye

    root@controller:~# token=`openstack token issue -f value -c id`

    root@controller:~# curl http://controller:8778/resource_providers/e8761491-8af3-4a56-be81-628c98523906/allocations -H “x-auth-token: $token” | python3 -m json.tool
    % Total % Received % Xferd Average Speed Time Time Time Current
    Dload Upload Total Spent Left Speed
    100 563 100 563 0 0 2416 0 –:–:– –:–:– –:–:– 2416
    {
    “resource_provider_generation”: 40,
    “allocations”: {
    “dae37e6c-12d2-4d1f-a756-e4756ed73ca9”: {
    “resources”: {
    “VCPU”: 1,
    “MEMORY_MB”: 2048,
    “DISK_GB”: 25
    }
    },
    “f575163f-d78a-42b7-b03c-602486ea5017”: {
    “resources”: {
    “VCPU”: 1,
    “MEMORY_MB”: 2048,
    “DISK_GB”: 25
    }
    },
    “b453b7d6-9b01-4796-b564-ddafb9b7d0ef”: {
    “resources”: {
    “VCPU”: 2,
    “MEMORY_MB”: 8192,
    “DISK_GB”: 25
    }
    },
    “a9b90ccf-2d70-4144-a9ac-21d7c349d0d3”: {
    “resources”: {
    “VCPU”: 1,
    “MEMORY_MB”: 2048,
    “DISK_GB”: 25
    }
    },
    “28f8f609-f020-4f87-b9ad-324d165eada3”: {
    “resources”: {
    “VCPU”: 2,
    “MEMORY_MB”: 4096,
    “DISK_GB”: 50
    }
    }
    }
    }
    root@controller:~# nova list –all –host compute2
    +————————————–+——————+———————————-+———+————+————-+—————————————+
    | ID | Name | Tenant ID | Status | Task State | Power State | Networks |
    +————————————–+——————+———————————-+———+————+————-+—————————————+
    | f575163f-d78a-42b7-b03c-602486ea5017 | jyh | ffbce1eef55d46fdb51ef2379401c9bd | ACTIVE | – | Running | testnet=10.101.0.14, xx.xx.xx.x.167 |
    | b453b7d6-9b01-4796-b564-ddafb9b7d0ef | xxxxxx_122050 | 9d0e4ac9e7574fcdb09e8785901ac051 | SHUTOFF | – | Shutdown | xx.xx.xx=10.101.0.11, xx.xx.xx.x.57 |
    | 28f8f609-f020-4f87-b9ad-324d165eada3 | xxxxxxxxx_155223 | a1134d46971142489d46f97f33432eeb | ACTIVE | – | Running | xxxxxxxxx=10.101.0.45, xx.xx.xx.x.161 |
    | a9b90ccf-2d70-4144-a9ac-21d7c349d0d3 | xxxxxxxx_125614 | 64d9952461644a6d83c395153165974b | SHUTOFF | – | Shutdown | xxxxxxxx=10.101.0.10, xx.xx.xx.x.187 |
    | dae37e6c-12d2-4d1f-a756-e4756ed73ca9 | xxxxxxx_123821 | 23f29b7f4e9d4df3afde87a41719894a | ACTIVE | – | Running | xxxxxxx=10.101.0.15, xx.xx.xx.x.100 |
    +————————————–+——————+———————————-+———+————+————-+—————————————+

  • 기존 호스트 서버에서 옴겨진 인스턴스 정보 삭제

    root@compute1:~# virsh list –all
    Id Name State
    —————————————————-
    4 instance-0000026d running
    – instance-000004ec shut off
    root@compute1:~# tail -f /var/log/nova/nova-compute.log
    ..
    ..
    2022-02-08 16:18:18.403 3981 WARNING nova.compute.manager [req-18a38ea4-849a-45f4-8f20-9005d33cd64e – – – – -] While synchronizing instance power states, found 1 instances in the database and 2 instances on the hypervisor.
    ..
    ..

    root@compute1:~# virsh start instance-000004ec
    Domain instance-000004ec started

    root@compute1:~# virsh destroy instance-000004ec
    Domain instance-000004ec destroyed

    root@compute1:~# virsh undefine instance-000004ec Domain instance-000004ec has been undefined

    root@compute1:~# virsh list –all
    Id Name State
    —————————————————-
    4 instance-0000026d running

    root@compute1:/var/lib/nova/instances# ls 386af9e5-0677-4825-8135-04228298be8b
    _base compute_nodes f575163f-d78a-42b7-b03c-602486ea5017 locks snapshots

    root@compute1:/var/lib/nova/instances# rm -rf f575163f-d78a-42b7-b03c-602486ea5017
    removed ‘f575163f-d78a-42b7-b03c-602486ea5017/disk.info’
    removed ‘f575163f-d78a-42b7-b03c-602486ea5017/console.log’
    removed ‘f575163f-d78a-42b7-b03c-602486ea5017/disk’
    removed directory ‘f575163f-d78a-42b7-b03c-602486ea5017’

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x