🐆

LXD のクラスタリングを試す

2025/01/26に公開

共通

ブートストラップサーバ、メンバーサバとも共通で実施する内容。

apt で lxd をインストールする

$ sudo apt update && sudo apt upgrade && sudo apt install lxd

ホスト名を設定する。
本稿では bootstrap がブートストラップサーバ、 member1 member2 member3 がメンバーサーバ。

$ sudo hostnamectl hostname ホスト名

ブートストラップサーバの開始

初期化

$ sudo lxd init
Would you like to use LXD clustering? (yes/no) [default=no]: yes
What IP address or DNS name should be used to reach this server? [default=192.168.11.52]:
Are you joining an existing cluster? (yes/no) [default=no]:
What member name should be used to identify this server in the cluster? [default=bootstrap]:
Setup password authentication on the cluster? (yes/no) [default=no]:
Do you want to configure a new local storage pool? (yes/no) [default=yes]:
Do you want to configure a new remote storage pool? (yes/no) [default=no]:
Would you like to connect to a MAAS server? (yes/no) [default=no]:
Would you like to configure LXD to use an existing bridge or host interface? (yes/no) [default=no]: yes
Name of the existing bridge or host interface: enp1s0
Would you like stale cached images to be updated automatically? (yes/no) [default=yes]:
Would you like a YAML "lxd init" preseed to be printed? (yes/no) [default=no]:

各メンバーサーバ用のジョイントークンを生成。

$ sudo lxc cluster add メンバーサーバ名
Member member1 join token:

メンバーサーバの開始

各メンバーサーバで初期化する。
ブートストラップサーバで生成したジョイントークを利用して、クラスタにジョインする。

$ sudo lxd init
Would you like to use LXD clustering? (yes/no) [default=no]: yes
What IP address or DNS name should be used to reach this server? [default=192.168.11.53]:
Are you joining an existing cluster? (yes/no) [default=no]: yes
Do you have a join token? (yes/no/[token]) [default=no]: yes
Please provide join token: eyJzZXJ2ZXJfbmFtZSI6Im1lbWJlcjEiLCJmaW5nZXJwcmludCI6IjEyZjZlM2E4MjY3ZGJmZDBjMTczMDY4NjkxN2I0MWJjYzQ1NWRiMTAyYmQxNjczOGVlNTJhMWUzOGM0MGNmMzAiLCJhZGRyZXNzZXMiOlsiMTkyLjE2OC4xMS41Mjo4NDQzIl0sInNlY3JldCI6IjU3ODE1MTJkMTlmYjUxODNhZmZiNTY1OGU0NTYzZmE5NTVkZmMwZDY0MDUyYmU4ZWIxMDM4ZmMxOTUyNTNkMjEiLCJleHBpcmVzX2F0IjoiMjAyNS0wMS0yNVQxMDo1NjowMS4zMzU4NDA0NTZaIn0=
All existing data is lost when joining a cluster, continue? (yes/no) [default=no] yes
Choose "source" property for storage pool "local":
Would you like a YAML "lxd init" preseed to be printed? (yes/no) [default=no]:

クラスタ構成後の確認

$ sudo lxc cluster list
+-----------+----------------------------+------------------+--------------+----------------+-------------+--------+-------------------+
|   NAME    |            URL             |      ROLES       | ARCHITECTURE | FAILURE DOMAIN | DESCRIPTION | STATE  |      MESSAGE      |
+-----------+----------------------------+------------------+--------------+----------------+-------------+--------+-------------------+
| bootstrap | https://192.168.11.52:8443 | database-leader  | aarch64      | default        |             | ONLINE | Fully operational |
|           |                            | database         |              |                |             |        |                   |
+-----------+----------------------------+------------------+--------------+----------------+-------------+--------+-------------------+
| member1   | https://192.168.11.53:8443 | database         | aarch64      | default        |             | ONLINE | Fully operational |
+-----------+----------------------------+------------------+--------------+----------------+-------------+--------+-------------------+
| member2   | https://192.168.11.54:8443 | database         | aarch64      | default        |             | ONLINE | Fully operational |
+-----------+----------------------------+------------------+--------------+----------------+-------------+--------+-------------------+
| member3   | https://192.168.11.55:8443 | database-standby | aarch64      | default        |             | ONLINE | Fully operational |
+-----------+----------------------------+------------------+--------------+----------------+-------------+--------+-------------------+
$ sudo lxc cluster show bootstrap
roles:
- database-leader
- database
failure_domain: default
description: ""
config: {}
groups:
- default
server_name: bootstrap
url: https://192.168.11.52:8443
database: true
status: Online
message: Fully operational
architecture: aarch64

ストレージプール確認

$ sudo lxc storage list
+-------+--------+-------------+---------+---------+
| NAME  | DRIVER | DESCRIPTION | USED BY |  STATE  |
+-------+--------+-------------+---------+---------+
| local | dir    |             | 1       | CREATED |
+-------+--------+-------------+---------+---------+

$ sudo lxc storage info local
info:
  description: ""
  driver: dir
  name: local
  space used: 1.17GiB
  total space: 7.71GiB
used by:
  profiles:
  - default
$ sudo lxc storage show local
config: {}
description: ""
name: local
driver: dir
used_by:
- /1.0/instances/debian-c1
- /1.0/instances/debian-c2
- /1.0/profiles/default
status: Created
locations:
- bootstrap
- member1
- member2
- member3

ネットワーク

$ sudo lxc network list
+--------+----------+---------+------+------+-------------+---------+-------+
|  NAME  |   TYPE   | MANAGED | IPV4 | IPV6 | DESCRIPTION | USED BY | STATE |
+--------+----------+---------+------+------+-------------+---------+-------+
| enp1s0 | physical | NO      |      |      |             | 1       |       |
+--------+----------+---------+------+------+-------------+---------+-------+

プロファイル

$ sudo lxc profile list
+---------+---------------------+---------+
|  NAME   |     DESCRIPTION     | USED BY |
+---------+---------------------+---------+
| default | Default LXD profile | 0       |
+---------+---------------------+---------+

$ sudo lxc profile show default
config: {}
description: Default LXD profile
devices:
  eth0:
    name: eth0
    nictype: macvlan
    parent: enp1s0
    type: nic
  root:
    path: /
    pool: local
    type: disk
name: default
used_by: []

インスタンス管理

まずはリポジトリを追加

$ sudo lxc remote list
+-----------------+------------------------------------------+---------------+-------------+--------+--------+--------+
|      NAME       |                   URL                    |   PROTOCOL    |  AUTH TYPE  | PUBLIC | STATIC | GLOBAL |
+-----------------+------------------------------------------+---------------+-------------+--------+--------+--------+
| images          | https://images.linuxcontainers.org       | simplestreams | none        | YES    | NO     | NO     |
+-----------------+------------------------------------------+---------------+-------------+--------+--------+--------+
| local (current) | unix://                                  | lxd           | file access | NO     | YES    | NO     |
+-----------------+------------------------------------------+---------------+-------------+--------+--------+--------+
| ubuntu          | https://cloud-images.ubuntu.com/releases | simplestreams | none        | YES    | YES    | NO     |
+-----------------+------------------------------------------+---------------+-------------+--------+--------+--------+
| ubuntu-daily    | https://cloud-images.ubuntu.com/daily    | simplestreams | none        | YES    | YES    | NO     |
+-----------------+------------------------------------------+---------------+-------------+--------+--------+--------+

$ sudo lxc remote add canonical https://images.lxd.canonical.com --protocol=simplestreams

$ sudo lxc remote list
+-----------------+------------------------------------------+---------------+-------------+--------+--------+--------+
|      NAME       |                   URL                    |   PROTOCOL    |  AUTH TYPE  | PUBLIC | STATIC | GLOBAL |
+-----------------+------------------------------------------+---------------+-------------+--------+--------+--------+
| canonical       | https://images.lxd.canonical.com         | simplestreams | none        | YES    | NO     | NO     |
+-----------------+------------------------------------------+---------------+-------------+--------+--------+--------+
| images          | https://images.linuxcontainers.org       | simplestreams | none        | YES    | NO     | NO     |
+-----------------+------------------------------------------+---------------+-------------+--------+--------+--------+
| local (current) | unix://                                  | lxd           | file access | NO     | YES    | NO     |
+-----------------+------------------------------------------+---------------+-------------+--------+--------+--------+
| ubuntu          | https://cloud-images.ubuntu.com/releases | simplestreams | none        | YES    | YES    | NO     |
+-----------------+------------------------------------------+---------------+-------------+--------+--------+--------+
| ubuntu-daily    | https://cloud-images.ubuntu.com/daily    | simplestreams | none        | YES    | YES    | NO     |
+-----------------+------------------------------------------+---------------+-------------+--------+--------+--------+

$ sudo lxc image list canonical:debian/12/arm64
+--------------------+--------------+--------+---------------------------------------+--------------+-----------+---------+-------------------------------+
|       ALIAS        | FINGERPRINT  | PUBLIC |              DESCRIPTION              | ARCHITECTURE |   TYPE    |  SIZE   |          UPLOAD DATE          |
+--------------------+--------------+--------+---------------------------------------+--------------+-----------+---------+-------------------------------+
| debian/12 (7 more) | 19949b40ff99 | yes    | Debian bookworm arm64 (20250120_0004) | aarch64      | CONTAINER | 93.16MB | Jan 20, 2025 at 12:00am (UTC) |
+--------------------+--------------+--------+---------------------------------------+--------------+-----------+---------+-------------------------------+

コンテナ起動

$ sudo lxc launch canonical:debian/12 debian-c1
Creating debian-c1
Starting debian-c1


$ sudo lxc list
+-----------+---------+----------------------+-----------------------------------------------+-----------+-----------+-----------+
|   NAME    |  STATE  |         IPV4         |                     IPV6                      |   TYPE    | SNAPSHOTS | LOCATION  |
+-----------+---------+----------------------+-----------------------------------------------+-----------+-----------+-----------+
| debian-c1 | RUNNING | 192.168.11.98 (eth0) | 2405:6580:d400:2900:216:3eff:fe67:181d (eth0) | CONTAINER | 0         | bootstrap |
+-----------+---------+----------------------+-----------------------------------------------+-----------+-----------+-----------+

合計6台起動後

$ sudo lxc list
+-----------+---------+-----------------------+-----------------------------------------------+-----------+-----------+-----------+
|   NAME    |  STATE  |         IPV4          |                     IPV6                      |   TYPE    | SNAPSHOTS | LOCATION  |
+-----------+---------+-----------------------+-----------------------------------------------+-----------+-----------+-----------+
| debian-c1 | RUNNING | 192.168.11.98 (eth0)  | 2405:6580:d400:2900:216:3eff:fe67:181d (eth0) | CONTAINER | 0         | bootstrap |
+-----------+---------+-----------------------+-----------------------------------------------+-----------+-----------+-----------+
| debian-c2 | RUNNING | 192.168.11.108 (eth0) | 2405:6580:d400:2900:216:3eff:fe6e:3961 (eth0) | CONTAINER | 0         | member1   |
+-----------+---------+-----------------------+-----------------------------------------------+-----------+-----------+-----------+
| debian-c3 | RUNNING | 192.168.11.116 (eth0) | 2405:6580:d400:2900:216:3eff:fed6:c4bf (eth0) | CONTAINER | 0         | member2   |
+-----------+---------+-----------------------+-----------------------------------------------+-----------+-----------+-----------+
| debian-c4 | RUNNING | 192.168.11.117 (eth0) | 2405:6580:d400:2900:216:3eff:fe2c:8bde (eth0) | CONTAINER | 0         | member3   |
+-----------+---------+-----------------------+-----------------------------------------------+-----------+-----------+-----------+
| debian-c5 | RUNNING | 192.168.11.106 (eth0) | 2405:6580:d400:2900:216:3eff:fed2:c1b0 (eth0) | CONTAINER | 0         | bootstrap |
+-----------+---------+-----------------------+-----------------------------------------------+-----------+-----------+-----------+
| debian-c6 | RUNNING | 192.168.11.107 (eth0) | 2405:6580:d400:2900:216:3eff:fe1e:4828 (eth0) | CONTAINER | 0         | member1   |
+-----------+---------+-----------------------+-----------------------------------------------+-----------+-----------+-----------+

コンテナ停止

$ sudo lxc stop debian-c3

$ sudo lxc list
+-----------+---------+-----------------------+-----------------------------------------------+-----------+-----------+-----------+
|   NAME    |  STATE  |         IPV4          |                     IPV6                      |   TYPE    | SNAPSHOTS | LOCATION  |
+-----------+---------+-----------------------+-----------------------------------------------+-----------+-----------+-----------+
| debian-c1 | RUNNING | 192.168.11.98 (eth0)  | 2405:6580:d400:2900:216:3eff:fe67:181d (eth0) | CONTAINER | 0         | bootstrap |
+-----------+---------+-----------------------+-----------------------------------------------+-----------+-----------+-----------+
| debian-c2 | RUNNING | 192.168.11.108 (eth0) | 2405:6580:d400:2900:216:3eff:fe6e:3961 (eth0) | CONTAINER | 0         | member1   |
+-----------+---------+-----------------------+-----------------------------------------------+-----------+-----------+-----------+
| debian-c3 | STOPPED |                       |                                               | CONTAINER | 0         | member2   |
+-----------+---------+-----------------------+-----------------------------------------------+-----------+-----------+-----------+
| debian-c4 | RUNNING | 192.168.11.117 (eth0) | 2405:6580:d400:2900:216:3eff:fe2c:8bde (eth0) | CONTAINER | 0         | member3   |
+-----------+---------+-----------------------+-----------------------------------------------+-----------+-----------+-----------+
| debian-c5 | RUNNING | 192.168.11.106 (eth0) | 2405:6580:d400:2900:216:3eff:fed2:c1b0 (eth0) | CONTAINER | 0         | bootstrap |
+-----------+---------+-----------------------+-----------------------------------------------+-----------+-----------+-----------+
| debian-c6 | RUNNING | 192.168.11.107 (eth0) | 2405:6580:d400:2900:216:3eff:fe1e:4828 (eth0) | CONTAINER | 0         | member1   |
+-----------+---------+-----------------------+-----------------------------------------------+-----------+-----------+-----------+

コンテナの移動

移動したいコンテナは停止する必要がある。

$ sudo lxc move debian-c3 --target member3

$ sudo lxc list
+-----------+---------+-----------------------+-----------------------------------------------+-----------+-----------+-----------+
|   NAME    |  STATE  |         IPV4          |                     IPV6                      |   TYPE    | SNAPSHOTS | LOCATION  |
+-----------+---------+-----------------------+-----------------------------------------------+-----------+-----------+-----------+
| debian-c1 | RUNNING | 192.168.11.98 (eth0)  | 2405:6580:d400:2900:216:3eff:fe67:181d (eth0) | CONTAINER | 0         | bootstrap |
+-----------+---------+-----------------------+-----------------------------------------------+-----------+-----------+-----------+
| debian-c2 | RUNNING | 192.168.11.108 (eth0) | 2405:6580:d400:2900:216:3eff:fe6e:3961 (eth0) | CONTAINER | 0         | member1   |
+-----------+---------+-----------------------+-----------------------------------------------+-----------+-----------+-----------+
| debian-c3 | STOPPED |                       |                                               | CONTAINER | 0         | member3   |
+-----------+---------+-----------------------+-----------------------------------------------+-----------+-----------+-----------+
| debian-c4 | RUNNING | 192.168.11.117 (eth0) | 2405:6580:d400:2900:216:3eff:fe2c:8bde (eth0) | CONTAINER | 0         | member3   |
+-----------+---------+-----------------------+-----------------------------------------------+-----------+-----------+-----------+
| debian-c5 | RUNNING | 192.168.11.106 (eth0) | 2405:6580:d400:2900:216:3eff:fed2:c1b0 (eth0) | CONTAINER | 0         | bootstrap |
+-----------+---------+-----------------------+-----------------------------------------------+-----------+-----------+-----------+
| debian-c6 | RUNNING | 192.168.11.107 (eth0) | 2405:6580:d400:2900:216:3eff:fe1e:4828 (eth0) | CONTAINER | 0         | member1   |
+-----------+---------+-----------------------+-----------------------------------------------+-----------+-----------+-----------+

移動したらコンテナ起動する。

$ sudo lxc start debian-c3

$ sudo lxc list
+-----------+---------+-----------------------+-----------------------------------------------+-----------+-----------+-----------+
|   NAME    |  STATE  |         IPV4          |                     IPV6                      |   TYPE    | SNAPSHOTS | LOCATION  |
+-----------+---------+-----------------------+-----------------------------------------------+-----------+-----------+-----------+
| debian-c1 | RUNNING | 192.168.11.98 (eth0)  | 2405:6580:d400:2900:216:3eff:fe67:181d (eth0) | CONTAINER | 0         | bootstrap |
+-----------+---------+-----------------------+-----------------------------------------------+-----------+-----------+-----------+
| debian-c2 | RUNNING | 192.168.11.108 (eth0) | 2405:6580:d400:2900:216:3eff:fe6e:3961 (eth0) | CONTAINER | 0         | member1   |
+-----------+---------+-----------------------+-----------------------------------------------+-----------+-----------+-----------+
| debian-c3 | RUNNING | 192.168.11.62 (eth0)  | 2405:6580:d400:2900:216:3eff:fed6:c4bf (eth0) | CONTAINER | 0         | member3   |
+-----------+---------+-----------------------+-----------------------------------------------+-----------+-----------+-----------+
| debian-c4 | RUNNING | 192.168.11.117 (eth0) | 2405:6580:d400:2900:216:3eff:fe2c:8bde (eth0) | CONTAINER | 0         | member3   |
+-----------+---------+-----------------------+-----------------------------------------------+-----------+-----------+-----------+
| debian-c5 | RUNNING | 192.168.11.106 (eth0) | 2405:6580:d400:2900:216:3eff:fed2:c1b0 (eth0) | CONTAINER | 0         | bootstrap |
+-----------+---------+-----------------------+-----------------------------------------------+-----------+-----------+-----------+
| debian-c6 | RUNNING | 192.168.11.107 (eth0) | 2405:6580:d400:2900:216:3eff:fe1e:4828 (eth0) | CONTAINER | 0         | member1   |
+-----------+---------+-----------------------+-----------------------------------------------+-----------+-----------+-----------+

クラスタ管理

クラスタメンバーの退避

$ sudo lxc cluster evacuate member2
Are you sure you want to evacuate cluster member "member2"? (yes/no) [default=no]: yes

$ sudo lxc cluster list
+-----------+----------------------------+------------------+--------------+----------------+-------------+-----------+--------------------------------+
|   NAME    |            URL             |      ROLES       | ARCHITECTURE | FAILURE DOMAIN | DESCRIPTION |   STATE   |            MESSAGE             |
+-----------+----------------------------+------------------+--------------+----------------+-------------+-----------+--------------------------------+
| bootstrap | https://192.168.11.52:8443 | database-leader  | aarch64      | default        |             | ONLINE    | Fully operational              |
|           |                            | database         |              |                |             |           |                                |
+-----------+----------------------------+------------------+--------------+----------------+-------------+-----------+--------------------------------+
| member1   | https://192.168.11.53:8443 | database         | aarch64      | default        |             | ONLINE    | Fully operational              |
+-----------+----------------------------+------------------+--------------+----------------+-------------+-----------+--------------------------------+
| member2   | https://192.168.11.54:8443 | database         | aarch64      | default        |             | EVACUATED | Unavailable due to maintenance |
+-----------+----------------------------+------------------+--------------+----------------+-------------+-----------+--------------------------------+
| member3   | https://192.168.11.55:8443 | database-standby | aarch64      | default        |             | ONLINE    | Fully operational              |
+-----------+----------------------------+------------------+--------------+----------------+-------------+-----------+--------------------------------+

退避したメンバーの復元

$ sudo lxc cluster restore member2
Are you sure you want to restore cluster member "member2"? (yes/no) [default=no]: yes

$ sudo lxc cluster list
+-----------+----------------------------+------------------+--------------+----------------+-------------+--------+-------------------+
|   NAME    |            URL             |      ROLES       | ARCHITECTURE | FAILURE DOMAIN | DESCRIPTION | STATE  |      MESSAGE      |
+-----------+----------------------------+------------------+--------------+----------------+-------------+--------+-------------------+
| bootstrap | https://192.168.11.52:8443 | database-leader  | aarch64      | default        |             | ONLINE | Fully operational |
|           |                            | database         |              |                |             |        |                   |
+-----------+----------------------------+------------------+--------------+----------------+-------------+--------+-------------------+
| member1   | https://192.168.11.53:8443 | database         | aarch64      | default        |             | ONLINE | Fully operational |
+-----------+----------------------------+------------------+--------------+----------------+-------------+--------+-------------------+
| member2   | https://192.168.11.54:8443 | database-standby | aarch64      | default        |             | ONLINE | Fully operational |
+-----------+----------------------------+------------------+--------------+----------------+-------------+--------+-------------------+
| member3   | https://192.168.11.55:8443 | database         | aarch64      | default        |             | ONLINE | Fully operational |
+-----------+----------------------------+------------------+--------------+----------------+-------------+--------+-------------------+

コンテナが起動したままの退避

コンテナが起動している状態でメンバーを退避するとき、コンテナは安全に停止してくれる。

$ sudo lxc cluster evacuate member3
Are you sure you want to evacuate cluster member "member3"? (yes/no) [default=no]: yes

$ sudo lxc cluster list
+-----------+----------------------------+------------------+--------------+----------------+-------------+-----------+--------------------------------+
|   NAME    |            URL             |      ROLES       | ARCHITECTURE | FAILURE DOMAIN | DESCRIPTION |   STATE   |            MESSAGE             |
+-----------+----------------------------+------------------+--------------+----------------+-------------+-----------+--------------------------------+
| bootstrap | https://192.168.11.52:8443 | database-leader  | aarch64      | default        |             | ONLINE    | Fully operational              |
|           |                            | database         |              |                |             |           |                                |
+-----------+----------------------------+------------------+--------------+----------------+-------------+-----------+--------------------------------+
| member1   | https://192.168.11.53:8443 | database         | aarch64      | default        |             | ONLINE    | Fully operational              |
+-----------+----------------------------+------------------+--------------+----------------+-------------+-----------+--------------------------------+
| member2   | https://192.168.11.54:8443 | database-standby | aarch64      | default        |             | ONLINE    | Fully operational              |
+-----------+----------------------------+------------------+--------------+----------------+-------------+-----------+--------------------------------+
| member3   | https://192.168.11.55:8443 | database         | aarch64      | default        |             | EVACUATED | Unavailable due to maintenance |
+-----------+----------------------------+------------------+--------------+----------------+-------------+-----------+--------------------------------+

$ sudo lxc list
+-----------+---------+-----------------------+-----------------------------------------------+-----------+-----------+-----------+
|   NAME    |  STATE  |         IPV4          |                     IPV6                      |   TYPE    | SNAPSHOTS | LOCATION  |
+-----------+---------+-----------------------+-----------------------------------------------+-----------+-----------+-----------+
| debian-c1 | RUNNING | 192.168.11.98 (eth0)  | 2405:6580:d400:2900:216:3eff:fe67:181d (eth0) | CONTAINER | 0         | bootstrap |
+-----------+---------+-----------------------+-----------------------------------------------+-----------+-----------+-----------+
| debian-c2 | RUNNING | 192.168.11.108 (eth0) | 2405:6580:d400:2900:216:3eff:fe6e:3961 (eth0) | CONTAINER | 0         | member1   |
+-----------+---------+-----------------------+-----------------------------------------------+-----------+-----------+-----------+
| debian-c3 | STOPPED |                       |                                               | CONTAINER | 0         | member3   |
+-----------+---------+-----------------------+-----------------------------------------------+-----------+-----------+-----------+
| debian-c4 | STOPPED |                       |                                               | CONTAINER | 0         | member3   |
+-----------+---------+-----------------------+-----------------------------------------------+-----------+-----------+-----------+
| debian-c5 | RUNNING | 192.168.11.106 (eth0) | 2405:6580:d400:2900:216:3eff:fed2:c1b0 (eth0) | CONTAINER | 0         | bootstrap |
+-----------+---------+-----------------------+-----------------------------------------------+-----------+-----------+-----------+
| debian-c6 | RUNNING | 192.168.11.107 (eth0) | 2405:6580:d400:2900:216:3eff:fe1e:4828 (eth0) | CONTAINER | 0         | member1   |
+-----------+---------+-----------------------+-----------------------------------------------+-----------+-----------+-----------+

復元

メンバーサーバを復元したとき、自動ではコンテナを起動してくれない。

$ sudo lxc cluster restore member3
Are you sure you want to restore cluster member "member3"? (yes/no) [default=no]: yes

$ sudo lxc cluster list
+-----------+----------------------------+------------------+--------------+----------------+-------------+--------+-------------------+
|   NAME    |            URL             |      ROLES       | ARCHITECTURE | FAILURE DOMAIN | DESCRIPTION | STATE  |      MESSAGE      |
+-----------+----------------------------+------------------+--------------+----------------+-------------+--------+-------------------+
| bootstrap | https://192.168.11.52:8443 | database-leader  | aarch64      | default        |             | ONLINE | Fully operational |
|           |                            | database         |              |                |             |        |                   |
+-----------+----------------------------+------------------+--------------+----------------+-------------+--------+-------------------+
| member1   | https://192.168.11.53:8443 | database         | aarch64      | default        |             | ONLINE | Fully operational |
+-----------+----------------------------+------------------+--------------+----------------+-------------+--------+-------------------+
| member2   | https://192.168.11.54:8443 | database         | aarch64      | default        |             | ONLINE | Fully operational |
+-----------+----------------------------+------------------+--------------+----------------+-------------+--------+-------------------+
| member3   | https://192.168.11.55:8443 | database-standby | aarch64      | default        |             | ONLINE | Fully operational |
+-----------+----------------------------+------------------+--------------+----------------+-------------+--------+-------------------+

$ sudo lxc list
+-----------+---------+-----------------------+-----------------------------------------------+-----------+-----------+-----------+
|   NAME    |  STATE  |         IPV4          |                     IPV6                      |   TYPE    | SNAPSHOTS | LOCATION  |
+-----------+---------+-----------------------+-----------------------------------------------+-----------+-----------+-----------+
| debian-c1 | RUNNING | 192.168.11.98 (eth0)  | 2405:6580:d400:2900:216:3eff:fe67:181d (eth0) | CONTAINER | 0         | bootstrap |
+-----------+---------+-----------------------+-----------------------------------------------+-----------+-----------+-----------+
| debian-c2 | RUNNING | 192.168.11.108 (eth0) | 2405:6580:d400:2900:216:3eff:fe6e:3961 (eth0) | CONTAINER | 0         | member1   |
+-----------+---------+-----------------------+-----------------------------------------------+-----------+-----------+-----------+
| debian-c3 | STOPPED |                       |                                               | CONTAINER | 0         | member3   |
+-----------+---------+-----------------------+-----------------------------------------------+-----------+-----------+-----------+
| debian-c4 | STOPPED |                       |                                               | CONTAINER | 0         | member3   |
+-----------+---------+-----------------------+-----------------------------------------------+-----------+-----------+-----------+
| debian-c5 | RUNNING | 192.168.11.106 (eth0) | 2405:6580:d400:2900:216:3eff:fed2:c1b0 (eth0) | CONTAINER | 0         | bootstrap |
+-----------+---------+-----------------------+-----------------------------------------------+-----------+-----------+-----------+
| debian-c6 | RUNNING | 192.168.11.107 (eth0) | 2405:6580:d400:2900:216:3eff:fe1e:4828 (eth0) | CONTAINER | 0         | member1   |
+-----------+---------+-----------------------+-----------------------------------------------+-----------+-----------+-----------+

手動でコンテナを立ち上げる。

$ sudo lxc start debian-c3
$ sudo lxc start debian-c4

$ sudo lxc list
+-----------+---------+-----------------------+-----------------------------------------------+-----------+-----------+-----------+
|   NAME    |  STATE  |         IPV4          |                     IPV6                      |   TYPE    | SNAPSHOTS | LOCATION  |
+-----------+---------+-----------------------+-----------------------------------------------+-----------+-----------+-----------+
| debian-c1 | RUNNING | 192.168.11.98 (eth0)  | 2405:6580:d400:2900:216:3eff:fe67:181d (eth0) | CONTAINER | 0         | bootstrap |
+-----------+---------+-----------------------+-----------------------------------------------+-----------+-----------+-----------+
| debian-c2 | RUNNING | 192.168.11.108 (eth0) | 2405:6580:d400:2900:216:3eff:fe6e:3961 (eth0) | CONTAINER | 0         | member1   |
+-----------+---------+-----------------------+-----------------------------------------------+-----------+-----------+-----------+
| debian-c3 | RUNNING | 192.168.11.62 (eth0)  | 2405:6580:d400:2900:216:3eff:fed6:c4bf (eth0) | CONTAINER | 0         | member3   |
+-----------+---------+-----------------------+-----------------------------------------------+-----------+-----------+-----------+
| debian-c4 | RUNNING | 192.168.11.2 (eth0)   | 2405:6580:d400:2900:216:3eff:fe2c:8bde (eth0) | CONTAINER | 0         | member3   |
+-----------+---------+-----------------------+-----------------------------------------------+-----------+-----------+-----------+
| debian-c5 | RUNNING | 192.168.11.106 (eth0) | 2405:6580:d400:2900:216:3eff:fed2:c1b0 (eth0) | CONTAINER | 0         | bootstrap |
+-----------+---------+-----------------------+-----------------------------------------------+-----------+-----------+-----------+
| debian-c6 | RUNNING | 192.168.11.107 (eth0) | 2405:6580:d400:2900:216:3eff:fe1e:4828 (eth0) | CONTAINER | 0         | member1   |
+-----------+---------+-----------------------+-----------------------------------------------+-----------+-----------+-----------+

クラスタメンバー削除

$ sudo lxc cluster remove member2


$ sudo lxc cluster list
+-----------+----------------------------+-----------------+--------------+----------------+-------------+--------+-------------------+
|   NAME    |            URL             |      ROLES      | ARCHITECTURE | FAILURE DOMAIN | DESCRIPTION | STATE  |      MESSAGE      |
+-----------+----------------------------+-----------------+--------------+----------------+-------------+--------+-------------------+
| bootstrap | https://192.168.11.52:8443 | database-leader | aarch64      | default        |             | ONLINE | Fully operational |
|           |                            | database        |              |                |             |        |                   |
+-----------+----------------------------+-----------------+--------------+----------------+-------------+--------+-------------------+
| member1   | https://192.168.11.53:8443 | database        | aarch64      | default        |             | ONLINE | Fully operational |
+-----------+----------------------------+-----------------+--------------+----------------+-------------+--------+-------------------+
| member3   | https://192.168.11.55:8443 | database        | aarch64      | default        |             | ONLINE | Fully operational |
+-----------+----------------------------+-----------------+--------------+----------------+-------------+--------+-------------------+

サーバシャットダウン

1台落としてみる

$ sudo lxc cluster list
+-----------+----------------------------+-----------------+--------------+----------------+-------------+---------+----------------------------------------------------------------------------+
|   NAME    |            URL             |      ROLES      | ARCHITECTURE | FAILURE DOMAIN | DESCRIPTION |  STATE  |                                  MESSAGE                                   |
+-----------+----------------------------+-----------------+--------------+----------------+-------------+---------+----------------------------------------------------------------------------+
| bootstrap | https://192.168.11.52:8443 | database-leader | aarch64      | default        |             | ONLINE  | Fully operational                                                          |
|           |                            | database        |              |                |             |         |                                                                            |
+-----------+----------------------------+-----------------+--------------+----------------+-------------+---------+----------------------------------------------------------------------------+
| member1   | https://192.168.11.53:8443 | database        | aarch64      | default        |             | ONLINE  | Fully operational                                                          |
+-----------+----------------------------+-----------------+--------------+----------------+-------------+---------+----------------------------------------------------------------------------+
| member3   | https://192.168.11.55:8443 | database        | aarch64      | default        |             | OFFLINE | No heartbeat for 3m47.796567276s (2025-01-25 21:51:48.924713263 +0000 UTC) |
+-----------+----------------------------+-----------------+--------------+----------------+-------------+---------+----------------------------------------------------------------------------+

$ sudo lxc list
+-----------+---------+-----------------------+-----------------------------------------------+-----------+-----------+-----------+
|   NAME    |  STATE  |         IPV4          |                     IPV6                      |   TYPE    | SNAPSHOTS | LOCATION  |
+-----------+---------+-----------------------+-----------------------------------------------+-----------+-----------+-----------+
| debian-c1 | RUNNING | 192.168.11.98 (eth0)  | 2405:6580:d400:2900:216:3eff:fe67:181d (eth0) | CONTAINER | 0         | bootstrap |
+-----------+---------+-----------------------+-----------------------------------------------+-----------+-----------+-----------+
| debian-c2 | RUNNING | 192.168.11.108 (eth0) | 2405:6580:d400:2900:216:3eff:fe6e:3961 (eth0) | CONTAINER | 0         | member1   |
+-----------+---------+-----------------------+-----------------------------------------------+-----------+-----------+-----------+
| debian-c3 | ERROR   |                       |                                               | CONTAINER | 0         | member3   |
+-----------+---------+-----------------------+-----------------------------------------------+-----------+-----------+-----------+
| debian-c4 | ERROR   |                       |                                               | CONTAINER | 0         | member3   |
+-----------+---------+-----------------------+-----------------------------------------------+-----------+-----------+-----------+
| debian-c5 | RUNNING | 192.168.11.106 (eth0) | 2405:6580:d400:2900:216:3eff:fed2:c1b0 (eth0) | CONTAINER | 0         | bootstrap |
+-----------+---------+-----------------------+-----------------------------------------------+-----------+-----------+-----------+
| debian-c6 | RUNNING | 192.168.11.107 (eth0) | 2405:6580:d400:2900:216:3eff:fe1e:4828 (eth0) | CONTAINER | 0         | member1   |
+-----------+---------+-----------------------+-----------------------------------------------+-----------+-----------+-----------+

落としたサーバを上げてみる

$ sudo lxc cluster list
+-----------+----------------------------+-----------------+--------------+----------------+-------------+--------+-------------------+
|   NAME    |            URL             |      ROLES      | ARCHITECTURE | FAILURE DOMAIN | DESCRIPTION | STATE  |      MESSAGE      |
+-----------+----------------------------+-----------------+--------------+----------------+-------------+--------+-------------------+
| bootstrap | https://192.168.11.52:8443 | database-leader | aarch64      | default        |             | ONLINE | Fully operational |
|           |                            | database        |              |                |             |        |                   |
+-----------+----------------------------+-----------------+--------------+----------------+-------------+--------+-------------------+
| member1   | https://192.168.11.53:8443 | database        | aarch64      | default        |             | ONLINE | Fully operational |
+-----------+----------------------------+-----------------+--------------+----------------+-------------+--------+-------------------+
| member3   | https://192.168.11.55:8443 | database        | aarch64      | default        |             | ONLINE | Fully operational |
+-----------+----------------------------+-----------------+--------------+----------------+-------------+--------+-------------------+

$ sudo lxc list
+-----------+---------+-----------------------+-----------------------------------------------+-----------+-----------+-----------+
|   NAME    |  STATE  |         IPV4          |                     IPV6                      |   TYPE    | SNAPSHOTS | LOCATION  |
+-----------+---------+-----------------------+-----------------------------------------------+-----------+-----------+-----------+
| debian-c1 | RUNNING | 192.168.11.98 (eth0)  | 2405:6580:d400:2900:216:3eff:fe67:181d (eth0) | CONTAINER | 0         | bootstrap |
+-----------+---------+-----------------------+-----------------------------------------------+-----------+-----------+-----------+
| debian-c2 | RUNNING | 192.168.11.108 (eth0) | 2405:6580:d400:2900:216:3eff:fe6e:3961 (eth0) | CONTAINER | 0         | member1   |
+-----------+---------+-----------------------+-----------------------------------------------+-----------+-----------+-----------+
| debian-c3 | RUNNING | 192.168.11.62 (eth0)  | 2405:6580:d400:2900:216:3eff:fed6:c4bf (eth0) | CONTAINER | 0         | member3   |
+-----------+---------+-----------------------+-----------------------------------------------+-----------+-----------+-----------+
| debian-c4 | RUNNING | 192.168.11.2 (eth0)   | 2405:6580:d400:2900:216:3eff:fe2c:8bde (eth0) | CONTAINER | 0         | member3   |
+-----------+---------+-----------------------+-----------------------------------------------+-----------+-----------+-----------+
| debian-c5 | RUNNING | 192.168.11.106 (eth0) | 2405:6580:d400:2900:216:3eff:fed2:c1b0 (eth0) | CONTAINER | 0         | bootstrap |
+-----------+---------+-----------------------+-----------------------------------------------+-----------+-----------+-----------+
| debian-c6 | RUNNING | 192.168.11.107 (eth0) | 2405:6580:d400:2900:216:3eff:fe1e:4828 (eth0) | CONTAINER | 0         | member1   |
+-----------+---------+-----------------------+-----------------------------------------------+-----------+-----------+-----------+
GitHubで編集を提案

Discussion