Ubuntu 24.04
Sponsored Link

OpenStack Dalmatian : インスタンスを起動する2024/10/04

 

仮想マシンインスタンスを起動します。

[1] Openstack 用の環境変数を設定した任意のユーザーでログインして、仮想マシンインスタンスを作成/起動します。
# 利用可能な [flavor] 確認

ubuntu@dlp ~(keystone)$
openstack flavor list

+----+-----------+-------+------+-----------+-------+-----------+
| ID | Name      |   RAM | Disk | Ephemeral | VCPUs | Is Public |
+----+-----------+-------+------+-----------+-------+-----------+
| 1  | m1.tiny   |  2048 |   10 |         0 |     1 | True      |
| 2  | m1.small  |  4096 |   10 |         0 |     2 | True      |
| 3  | m1.medium |  8192 |   10 |         0 |     4 | True      |
| 4  | m1.large  | 16384 |   10 |         0 |     8 | True      |
| 5  | m2.medium |  8192 |   10 |        10 |     4 | True      |
+----+-----------+-------+------+-----------+-------+-----------+

# 利用可能なイメージ確認

ubuntu@dlp ~(keystone)$
openstack image list

+--------------------------------------+------------+--------+
| ID                                   | Name       | Status |
+--------------------------------------+------------+--------+
| a9d10f1d-d836-424d-8117-ff3fc8c5e966 | Ubuntu2404 | active |
+--------------------------------------+------------+--------+

# 利用可能なネットワーク確認

ubuntu@dlp ~(keystone)$
openstack network list

+--------------------------------+------------+--------------------------------+
| ID                             | Name       | Subnets                        |
+--------------------------------+------------+--------------------------------+
| 7398c285-1333-4aa7-a487-       | sharednet1 | 7097c0b5-34be-4179-8316-       |
| 1d37e5e27eb9                   |            | 7b9131d61308                   |
+--------------------------------+------------+--------------------------------+

# インスタンス用のセキュリティグループを作成

ubuntu@dlp ~(keystone)$
openstack security group create secgroup01

+-----------------+------------------------------------------------------------+
| Field           | Value                                                      |
+-----------------+------------------------------------------------------------+
| created_at      | 2024-10-04T01:57:20Z                                       |
| description     | secgroup01                                                 |
| id              | f1f9a564-53aa-4c02-b302-d89928deef8b                       |
| name            | secgroup01                                                 |
| project_id      | 84e315c8d65e4b3cb33aaf69c9eed0c3                           |
| revision_number | 1                                                          |
| rules           | created_at='2024-10-04T01:57:20Z', direction='egress',     |
|                 | ethertype='IPv4',                                          |
|                 | id='5934759e-8a12-41ce-8022-1828cfe11edc',                 |
|                 | standard_attr_id='20', updated_at='2024-10-04T01:57:20Z'   |
|                 | created_at='2024-10-04T01:57:20Z', direction='egress',     |
|                 | ethertype='IPv6',                                          |
|                 | id='c93b5106-6f45-4bd7-8ffd-7b74d7408f65',                 |
|                 | standard_attr_id='21', updated_at='2024-10-04T01:57:20Z'   |
| shared          | False                                                      |
| stateful        | True                                                       |
| tags            | []                                                         |
| updated_at      | 2024-10-04T01:57:20Z                                       |
+-----------------+------------------------------------------------------------+

ubuntu@dlp ~(keystone)$
openstack security group list

+------------------+------------+------------------+--------------------+------+
| ID               | Name       | Description      | Project            | Tags |
+------------------+------------+------------------+--------------------+------+
| e7031ca4-f693-   | default    | Default security | 84e315c8d65e4b3cb3 | []   |
| 4184-87f8-       |            | group            | 3aaf69c9eed0c3     |      |
| 9099b24faef7     |            |                  |                    |      |
| f1f9a564-53aa-   | secgroup01 | secgroup01       | 84e315c8d65e4b3cb3 | []   |
| 4c02-b302-       |            |                  | 3aaf69c9eed0c3     |      |
| d89928deef8b     |            |                  |                    |      |
+------------------+------------+------------------+--------------------+------+

# インスタンス接続用の SSH キーペア作成

ubuntu@dlp ~(keystone)$
ssh-keygen -q -N ""

Enter file in which to save the key (/home/ubuntu/.ssh/id_ed25519):
# 公開鍵登録

ubuntu@dlp ~(keystone)$
openstack keypair create --public-key ~/.ssh/id_ed25519.pub mykey

+-------------+-------------------------------------------------+
| Field       | Value                                           |
+-------------+-------------------------------------------------+
| created_at  | None                                            |
| fingerprint | ca:3f:20:19:6b:52:fc:c8:78:9e:d9:99:fe:1b:b5:0d |
| id          | mykey                                           |
| is_deleted  | None                                            |
| name        | mykey                                           |
| type        | ssh                                             |
| user_id     | d97d1aef1b234c469ad3757bcd51dfa4                |
+-------------+-------------------------------------------------+

ubuntu@dlp ~(keystone)$
openstack keypair list

+-------+-------------------------------------------------+------+
| Name  | Fingerprint                                     | Type |
+-------+-------------------------------------------------+------+
| mykey | ca:3f:20:19:6b:52:fc:c8:78:9e:d9:99:fe:1b:b5:0d | ssh  |
+-------+-------------------------------------------------+------+

ubuntu@dlp ~(keystone)$
netID=$(openstack network list | grep sharednet1 | awk '{ print $2 }')

# インスタンス作成/起動

ubuntu@dlp ~(keystone)$
openstack server create --flavor m1.small --image Ubuntu2404 --security-group secgroup01 --nic net-id=$netID --key-name mykey Ubuntu-2404
+-------------------------------------+----------------------------------------+
| Field                               | Value                                  |
+-------------------------------------+----------------------------------------+
| OS-DCF:diskConfig                   | MANUAL                                 |
| OS-EXT-AZ:availability_zone         | None                                   |
| OS-EXT-SRV-ATTR:host                | None                                   |
| OS-EXT-SRV-ATTR:hostname            | ubuntu-2404                            |
| OS-EXT-SRV-ATTR:hypervisor_hostname | None                                   |
| OS-EXT-SRV-ATTR:instance_name       | None                                   |
| OS-EXT-SRV-ATTR:kernel_id           | None                                   |
| OS-EXT-SRV-ATTR:launch_index        | None                                   |
| OS-EXT-SRV-ATTR:ramdisk_id          | None                                   |
| OS-EXT-SRV-ATTR:reservation_id      | None                                   |
| OS-EXT-SRV-ATTR:root_device_name    | None                                   |
| OS-EXT-SRV-ATTR:user_data           | None                                   |
| OS-EXT-STS:power_state              | N/A                                    |
| OS-EXT-STS:task_state               | scheduling                             |
| OS-EXT-STS:vm_state                 | building                               |
| OS-SRV-USG:launched_at              | None                                   |
| OS-SRV-USG:terminated_at            | None                                   |
| accessIPv4                          | None                                   |
| accessIPv6                          | None                                   |
| addresses                           | N/A                                    |
| adminPass                           | UhTB2oTeq9Nz                           |
| config_drive                        | None                                   |
| created                             | 2024-10-04T02:00:29Z                   |
| description                         | None                                   |
| flavor                              | description=, disk='10',               |
|                                     | ephemeral='0', , id='m1.small',        |
|                                     | is_disabled=, is_public='True',        |
|                                     | location=, name='m1.small',            |
|                                     | original_name='m1.small', ram='4096',  |
|                                     | rxtx_factor=, swap='0', vcpus='2'      |
| hostId                              | None                                   |
| host_status                         | None                                   |
| id                                  | 885b6f1a-3e80-4e0d-b6a7-9781ac46bd1a   |
| image                               | Ubuntu2404                             |
|                                     | (a9d10f1d-d836-424d-8117-ff3fc8c5e966) |
| key_name                            | mykey                                  |
| locked                              | None                                   |
| locked_reason                       | None                                   |
| name                                | Ubuntu-2404                            |
| pinned_availability_zone            | None                                   |
| progress                            | None                                   |
| project_id                          | 84e315c8d65e4b3cb33aaf69c9eed0c3       |
| properties                          | None                                   |
| security_groups                     | name='f1f9a564-53aa-4c02-b302-         |
|                                     | d89928deef8b'                          |
| server_groups                       | None                                   |
| status                              | BUILD                                  |
| tags                                |                                        |
| trusted_image_certificates          | None                                   |
| updated                             | 2024-10-04T02:00:29Z                   |
| user_id                             | d97d1aef1b234c469ad3757bcd51dfa4       |
| volumes_attached                    |                                        |
+-------------------------------------+----------------------------------------+

# 動作確認 (起動直後しばらくは [BUILD] ステータスとなっている)

ubuntu@dlp ~(keystone)$
openstack server list

+----------------+-------------+--------+----------+------------+----------+
| ID             | Name        | Status | Networks | Image      | Flavor   |
+----------------+-------------+--------+----------+------------+----------+
| 885b6f1a-3e80- | Ubuntu-2404 | BUILD  |          | Ubuntu2404 | m1.small |
| 4e0d-b6a7-     |             |        |          |            |          |
| 9781ac46bd1a   |             |        |          |            |          |
+----------------+-------------+--------+----------+------------+----------+

# 正常に起動すると [ACTIVE] ステータスとなる

ubuntu@dlp ~(keystone)$
openstack server list

+--------------+-------------+--------+---------------+------------+----------+
| ID           | Name        | Status | Networks      | Image      | Flavor   |
+--------------+-------------+--------+---------------+------------+----------+
| 885b6f1a-    | Ubuntu-2404 | ACTIVE | sharednet1=10 | Ubuntu2404 | m1.small |
| 3e80-4e0d-   |             |        | .0.0.224      |            |          |
| b6a7-        |             |        |               |            |          |
| 9781ac46bd1a |             |        |               |            |          |
+--------------+-------------+--------+---------------+------------+----------+
[2] 起動した仮想マシンインスタンスに SSH 接続できるように、先に作成したセキュリティグループにポート許可の設定を追加します。
# ICMP 許可

ubuntu@dlp ~(keystone)$
openstack security group rule create --protocol icmp --ingress secgroup01

+-------------------------+--------------------------------------+
| Field                   | Value                                |
+-------------------------+--------------------------------------+
| belongs_to_default_sg   | False                                |
| created_at              | 2024-10-04T02:02:16Z                 |
| description             |                                      |
| direction               | ingress                              |
| ether_type              | IPv4                                 |
| id                      | bceea50a-7ea5-4205-befa-79db37cd1ffe |
| name                    | None                                 |
| normalized_cidr         | 0.0.0.0/0                            |
| port_range_max          | None                                 |
| port_range_min          | None                                 |
| project_id              | 84e315c8d65e4b3cb33aaf69c9eed0c3     |
| protocol                | icmp                                 |
| remote_address_group_id | None                                 |
| remote_group_id         | None                                 |
| remote_ip_prefix        | 0.0.0.0/0                            |
| revision_number         | 0                                    |
| security_group_id       | f1f9a564-53aa-4c02-b302-d89928deef8b |
| tags                    | []                                   |
| updated_at              | 2024-10-04T02:02:16Z                 |
+-------------------------+--------------------------------------+

# SSH 許可

ubuntu@dlp ~(keystone)$
openstack security group rule create --protocol tcp --dst-port 22:22 secgroup01

+-------------------------+--------------------------------------+
| Field                   | Value                                |
+-------------------------+--------------------------------------+
| belongs_to_default_sg   | False                                |
| created_at              | 2024-10-04T02:02:45Z                 |
| description             |                                      |
| direction               | ingress                              |
| ether_type              | IPv4                                 |
| id                      | 87bd5993-77ed-45db-ac10-2192ba029aff |
| name                    | None                                 |
| normalized_cidr         | 0.0.0.0/0                            |
| port_range_max          | 22                                   |
| port_range_min          | 22                                   |
| project_id              | 84e315c8d65e4b3cb33aaf69c9eed0c3     |
| protocol                | tcp                                  |
| remote_address_group_id | None                                 |
| remote_group_id         | None                                 |
| remote_ip_prefix        | 0.0.0.0/0                            |
| revision_number         | 0                                    |
| security_group_id       | f1f9a564-53aa-4c02-b302-d89928deef8b |
| tags                    | []                                   |
| updated_at              | 2024-10-04T02:02:45Z                 |
+-------------------------+--------------------------------------+

ubuntu@dlp ~(keystone)$
openstack security group rule list secgroup01

+----------+-------------+-----------+----------+------------+-----------+-----------------------+----------------------+
| ID       | IP Protocol | Ethertype | IP Range | Port Range | Direction | Remote Security Group | Remote Address Group |
+----------+-------------+-----------+----------+------------+-----------+-----------------------+----------------------+
| 5934759e | None        | IPv4      | 0.0.0.0/ |            | egress    | None                  | None                 |
| -8a12-   |             |           | 0        |            |           |                       |                      |
| 41ce-    |             |           |          |            |           |                       |                      |
| 8022-    |             |           |          |            |           |                       |                      |
| 1828cfe1 |             |           |          |            |           |                       |                      |
| 1edc     |             |           |          |            |           |                       |                      |
| 87bd5993 | tcp         | IPv4      | 0.0.0.0/ | 22:22      | ingress   | None                  | None                 |
| -77ed-   |             |           | 0        |            |           |                       |                      |
| 45db-ac1 |             |           |          |            |           |                       |                      |
| 0-       |             |           |          |            |           |                       |                      |
| 2192ba02 |             |           |          |            |           |                       |                      |
| 9aff     |             |           |          |            |           |                       |                      |
| bceea50a | icmp        | IPv4      | 0.0.0.0/ |            | ingress   | None                  | None                 |
| -7ea5-   |             |           | 0        |            |           |                       |                      |
| 4205-    |             |           |          |            |           |                       |                      |
| befa-    |             |           |          |            |           |                       |                      |
| 79db37cd |             |           |          |            |           |                       |                      |
| 1ffe     |             |           |          |            |           |                       |                      |
| c93b5106 | None        | IPv6      | ::/0     |            | egress    | None                  | None                 |
| -6f45-   |             |           |          |            |           |                       |                      |
| 4bd7-    |             |           |          |            |           |                       |                      |
| 8ffd-    |             |           |          |            |           |                       |                      |
| 7b74d740 |             |           |          |            |           |                       |                      |
| 8f65     |             |           |          |            |           |                       |                      |
+----------+-------------+-----------+----------+------------+-----------+-----------------------+----------------------+
[3] 起動した仮想マシンインスタンスに SSH ログインします。
ubuntu@dlp ~(keystone)$
openstack server list

+--------------+-------------+--------+---------------+------------+----------+
| ID           | Name        | Status | Networks      | Image      | Flavor   |
+--------------+-------------+--------+---------------+------------+----------+
| 885b6f1a-    | Ubuntu-2404 | ACTIVE | sharednet1=10 | Ubuntu2404 | m1.small |
| 3e80-4e0d-   |             |        | .0.0.224      |            |          |
| b6a7-        |             |        |               |            |          |
| 9781ac46bd1a |             |        |               |            |          |
+--------------+-------------+--------+---------------+------------+----------+

# ping 応答が返ってくれば OK

ubuntu@dlp ~(keystone)$
ping 10.0.0.224 -c3

PING 10.0.0.224 (10.0.0.224) 56(84) bytes of data.
64 bytes from 10.0.0.224: icmp_seq=1 ttl=64 time=1.14 ms
64 bytes from 10.0.0.224: icmp_seq=2 ttl=64 time=0.643 ms
64 bytes from 10.0.0.224: icmp_seq=3 ttl=64 time=0.491 ms

--- 10.0.0.224 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2064ms
rtt min/avg/max/mdev = 0.491/0.757/1.139/0.276 ms

# SSH でログイン

ubuntu@dlp ~(keystone)$
ssh ubuntu@10.0.0.224
The authenticity of host '10.0.0.224 (10.0.0.224)' can't be established.
ED25519 key fingerprint is SHA256:rLGF9nr6DzWZiy7HDWehAgjJJBGwPusD8fOp8lWeyW0.
This key is not known by any other names.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '10.0.0.224' (ED25519) to the list of known hosts.
Welcome to Ubuntu 24.04.1 LTS (GNU/Linux 6.8.0-44-generic x86_64)

.....
.....

To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.

ubuntu@ubuntu-2404:~$     # ログインできた
[4] 一旦作成して起動した仮想マシンインスタンスを停止/起動する場合は、以下のように [start/stop] コマンドで制御できます。
ubuntu@dlp ~(keystone)$
openstack server list

+--------------+-------------+--------+---------------+------------+----------+
| ID           | Name        | Status | Networks      | Image      | Flavor   |
+--------------+-------------+--------+---------------+------------+----------+
| 885b6f1a-    | Ubuntu-2404 | ACTIVE | sharednet1=10 | Ubuntu2404 | m1.small |
| 3e80-4e0d-   |             |        | .0.0.224      |            |          |
| b6a7-        |             |        |               |            |          |
| 9781ac46bd1a |             |        |               |            |          |
+--------------+-------------+--------+---------------+------------+----------+

# インスタンス停止

ubuntu@dlp ~(keystone)$
openstack server stop Ubuntu-2404

ubuntu@dlp ~(keystone)$
openstack server list

+--------------+-------------+---------+---------------+------------+----------+
| ID           | Name        | Status  | Networks      | Image      | Flavor   |
+--------------+-------------+---------+---------------+------------+----------+
| e499117a-    | Ubuntu-2404 | SHUTOFF | sharednet1=10 | Ubuntu2404 | m1.small |
| 58e4-4c75-   |             |         | .0.0.224      |            |          |
| 9712-        |             |         |               |            |          |
| 836d4fbe5572 |             |         |               |            |          |
+--------------+-------------+---------+---------------+------------+----------+

# インスタンスを起動する

ubuntu@dlp ~(keystone)$
openstack server start Ubuntu-2404

ubuntu@dlp ~(keystone)$
openstack server list

+--------------+-------------+--------+---------------+------------+----------+
| ID           | Name        | Status | Networks      | Image      | Flavor   |
+--------------+-------------+--------+---------------+------------+----------+
| 885b6f1a-    | Ubuntu-2404 | ACTIVE | sharednet1=10 | Ubuntu2404 | m1.small |
| 3e80-4e0d-   |             |        | .0.0.224      |            |          |
| b6a7-        |             |        |               |            |          |
| 9781ac46bd1a |             |        |               |            |          |
+--------------+-------------+--------+---------------+------------+----------+
[5] VNC コンソールを取得して Web ブラウザーでのアクセスも可能です。
ubuntu@dlp ~(keystone)$
openstack server list

+--------------+-------------+--------+---------------+------------+----------+
| ID           | Name        | Status | Networks      | Image      | Flavor   |
+--------------+-------------+--------+---------------+------------+----------+
| 885b6f1a-    | Ubuntu-2404 | ACTIVE | sharednet1=10 | Ubuntu2404 | m1.small |
| 3e80-4e0d-   |             |        | .0.0.224      |            |          |
| b6a7-        |             |        |               |            |          |
| 9781ac46bd1a |             |        |               |            |          |
+--------------+-------------+--------+---------------+------------+----------+

ubuntu@dlp ~(keystone)$
openstack console url show Ubuntu-2404

+----------+-------------------------------------------------------------------+
| Field    | Value                                                             |
+----------+-------------------------------------------------------------------+
| protocol | vnc                                                               |
| type     | novnc                                                             |
| url      | https://dlp.srv.world:6080/vnc_auto.html?path=%3Ftoken%3D1e2cedc3 |
|          | -b636-47a3-b624-568b74a236f3                                      |
+----------+-------------------------------------------------------------------+
[6] 上記コマンドで表示された URL に Web アクセスすると、インスタンスに接続され、操作が可能となります。
関連コンテンツ