コンテンツにスキップ

Proxmox VE

DebianベースのKVM/LXCアプライアンスディストリビューション

インストール

自宅サーバーのProxmox VE 5.1 - 3 nodes cluster環境の構築 を参照。

基本設定

時刻同期

https://pve.proxmox.com/wiki/Time_Synchronization

sed -i -e 's/#NTP=/NTP=192.168.122.31/' /etc/systemd/timesyncd.conf
systemctl restart systemd-timesyncd
journalctl --since -1h -u systemd-timesyncd

Let's Encryptの証明書でHTTPS対応

https://pve.proxmox.com/wiki/HTTPS_Certificate_Configuration_(Version_4.x,_5.0_and_5.1)#Install_certificate_chain_and_key

for node in pve01 pve02 pve03; do cp fullchain.pem /etc/pve/nodes/${node}/pveproxy-ssl.pem; done
for node in pve01 pve02 pve03; do cp private-key.pem /etc/pve/nodes/${node}/pveproxy-ssl.key; done
systemctl restart pveproxy

Note

  • /etc/pve/nodes は同期されているので証明書のコピーはクラスタ構成の1台だけで実行すればいい
  • systemctl restart pveproxy は全ノードで必要

No valid subscription ダイアログの場所

# grep -B5 "getNoSubKeyHtml(" /usr/share/javascript/proxmox-widget-toolkit/proxmoxlib.js
                    if (res === null || res === undefined || !res || res
                        .data.status.toLowerCase() !== 'active') {
                        Ext.Msg.show({
                            title: gettext('No valid subscription'),
                            icon: Ext.Msg.WARNING,
                            message: Proxmox.Utils.getNoSubKeyHtml(res.data.url),

Cloud-init

Cloud-initをサポートするようになった https://pve.proxmox.com/wiki/Cloud-Init_Support

blog書いた: http://www.ainoniwa.net/pelican/2018/0916a.html

テンプレートの作成

Ubuntuイメージを取得して、テンプレートマシンにイメージを登録

wget https://cloud-images.ubuntu.com/bionic/current/bionic-server-cloudimg-amd64.img
qm create 9000 --memory 2048 --net0 virtio,bridge=vmbr0
qm importdisk 9000 bionic-server-cloudimg-amd64.img local-lvm
qm set 9000 --scsihw virtio-scsi-pci --scsi0 local-lvm:vm-9000-disk-1

Cloud-initデバイスの追加、起動順位の変更、シリアルコンソールの追加をして、テンプレートとして登録

qm set 9000 --ide2 local-lvm:cloudinit
qm set 9000 --boot c --bootdisk scsi0
qm set 9000 --serial0 socket --vga serial0
qm template 9000

削除するときは qm set 9000 --delete serial0 のように --delete <option-name> とする。

Note

以前はserial0を追加しないとcloud-initが動かない場合が多いけど、serial0がつながっているとProxmox VEはLiveMigrationが出来ないという悲しい現実があるったけど、今は直ってる。

イメージのデプロイ

qm clone 9000 111 --name ubuntu2
qm set 111 --ipconfig0 ip=192.168.122.49/24,gw=192.168.122.1 --nameserver 192.168.122.31 --ciuser yuki

公開鍵はGUIから入れた方が楽かも。自分用のイメージなら、DNSやユーザー名はテンプレート側に設定しておいて使い回した方が便利。

Cephクラスタ

この辺のパラメータは内部的に決め打ちらしい。 osd pool default min size = 2 なので、2台同時に故障するとI/Oを受け付けられなくなるのはちょっと困る気がする。

     osd journal size = 5120
     osd pool default min size = 2
     osd pool default size = 3

Cephの状態確認コマンドなど

# ceph -s
  cluster:
    id:     379c9ad8-dd15-4bf1-b9fc-f5206a75fe3f
    health: HEALTH_OK

  services:
    mon: 3 daemons, quorum pve01,pve02,pve03
    mgr: pve02(active), standbys: pve03, pve01
    osd: 3 osds: 3 up, 3 in

  data:
    pools:   1 pools, 64 pgs
    objects: 143.25k objects, 550GiB
    usage:   1.59TiB used, 1.23TiB / 2.82TiB avail
    pgs:     64 active+clean

  io:
    client:   824KiB/s wr, 0op/s rd, 38op/s wr

Diskの交換手順

  • PVE 5.4 + Ceph Luminous 12.2

Ceph disk交換処理

  1. GUIからOSDの停止
    • pve01: osd.0 Out
    • pve01: osd.0 Stop
    • pve01: osd.0 Destroy
      • 既に取り外しが終わっている場合は Cleanup disks のチェックを外す
  2. pve01 $ poweroff
  3. 物理作業
  4. GUIからOSDの追加
    • Create: OSD
      • Disk: /dev/sdb
      • Journal/DB Disk: /dev/sda
      • Bluestore: [X]
  5. 同期を待って完了
# ceph health 
HEALTH_OK

Note

バージョン進むにつれてGUIはちょこちょこ変わっているので参考程度に

LVMコピー移動

LVMに作ったVMイメージを、別のLVMに引っ越しする時に使った。

ssh root@remote pv -L 100M /dev/qemu-img/qemu-example-disk > /dev/qemu-img/qemu-example-disk

Management UI on IPv6

Warning

Proxmox VE 6.4以降はデフォルトでIPv4/IPv6両方LISTENするようになりました。
https://pve.proxmox.com/wiki/Roadmap#Proxmox_VE_6.4
また、以下の手順をクラスタ環境で実施して再起動すると、クラスタピアを見つけられなくなります。
シングル構成であれば使えるけど、避けた方が無難。

デフォルトではIPv4のみ待ち受ける。

# ss -pant | grep pveproxy
LISTEN      0        128               0.0.0.0:8006              0.0.0.0:*       users:(("pveproxy worker",pid=487752,fd=6),("pveproxy worker",pid=487751,fd=6),("pveproxy worker",pid=487750,fd=6),("pveproxy",pid=487749,fd=6))

/etc/hosts で以下のように ::1 を付与する。

- 192.168.1.28 pve03.ainoniwa.net pve03 pvelocalhost
+ ::1 192.168.1.28 pve03.ainoniwa.net pve03 pvelocalhost

pveproxy を再起動するとIPv4/IPv6両方待ち受けるようになる。

# systemctl restart pveproxy
# ss -pant | grep pveproxy
LISTEN      0        128                     *:8006                    *:*       users:(("pveproxy worker",pid=489318,fd=6),("pveproxy worker",pid=489317,fd=6),("pveproxy worker",pid=489316,fd=6),("pveproxy",pid=489315,fd=6))

Qemu guest agent

https://pve.proxmox.com/wiki/Qemu-guest-agent

入れるとSummaryの画面でIPが分かるようになる。(DHCPの時に便利)

/nodes/{node}/qemu/{vmid}/agent/network-get-interfaces を叩くと、以下のようにデータも取れる。

{
  "data": {
    "result": [
      {
        "hardware-address": "00:00:00:00:00:00",
        "name": "lo",
        "statistics": {
          "tx-packets": 92,
          "rx-packets": 92,
          "tx-bytes": 7100,
          "rx-bytes": 7100,
          "tx-dropped": 0,
          "rx-dropped": 0,
          "tx-errs": 0,
          "rx-errs": 0
        },
        "ip-addresses": [
          {
            "ip-address": "127.0.0.1",
            "ip-address-type": "ipv4",
            "prefix": 8
          },
          {
            "prefix": 128,
            "ip-address-type": "ipv6",
            "ip-address": "::1"
          }
        ]
      },
      {
        "name": "eth0",
        "statistics": {
          "tx-packets": 278,
          "rx-packets": 2137,
          "tx-bytes": 21490,
          "rx-bytes": 717392,
          "tx-errs": 0,
...

便利コマンド

クラスタのノードリソース一覧

root@pve01:~# pvesh get /cluster/resources -type node --noborder
id         type    cpu disk      hastate level maxcpu   maxdisk    maxmem mem       node  pool status storage uptime
node/pve01 node 10.68% 16.71 GiB                    4 27.74 GiB 62.74 GiB 22.68 GiB pve01      online         8w 3d 9h 59m 58s
node/pve02 node  2.63% 7.40 GiB                     8 27.74 GiB 31.29 GiB 15.20 GiB pve02      online         8w 3d 9h 59m 48s
node/pve03 node  1.30% 5.88 GiB                     8 29.49 GiB 31.28 GiB 11.94 GiB pve03      online         8w 3d 9h 59m 56s

クラスタのVMリソース一覧

root@pve01:~# pvesh get /cluster/resources -type vm --noborder
id        type   cpu disk   hastate level maxcpu    maxdisk     maxmem mem        node  pool status  storage uptime
qemu/100  qemu 0.00% 0.00 B                    1 128.00 MiB   1.00 GiB 0.00 B     pve01      stopped         
qemu/1042 qemu 3.08% 0.00 B                    1  32.00 GiB   1.00 GiB 922.39 MiB pve02      running         8w 3d 5h 54m 26s
qemu/1043 qemu 0.10% 0.00 B                    1  16.00 GiB   1.00 GiB 737.23 MiB pve03      running         8w 3d 5h 9m 21s
qemu/9000 qemu 0.00% 0.00 B                    1   2.20 GiB   2.00 GiB 0.00 B     pve01      stopped         

クラスタのストレージリソース一覧

root@pve01:~# pvesh get /cluster/resources -type storage --noborder
id                      type    cpu disk       hastate level maxcpu    maxdisk maxmem mem node  pool status    storage   uptime
storage/pve01/local     storage     16.71 GiB                        27.74 GiB            pve01      available local     
storage/pve01/local-lvm storage     3.16 GiB                         61.91 GiB            pve01      available local-lvm 
storage/pve02/local     storage     7.40 GiB                         27.74 GiB            pve02      available local     
storage/pve02/local-lvm storage     0.00 B                           61.91 GiB            pve02      available local-lvm 
storage/pve03/local     storage     5.88 GiB                         29.49 GiB            pve03      available local     
storage/pve03/local-lvm storage     0.00 B                           66.74 GiB            pve03      available local-lvm 

エラーケース

root@pve02:~# apt update
Hit:1 http://security.debian.org stretch/updates InRelease
Ign:2 http://ftp.jp.debian.org/debian stretch InRelease                                                                                 
Hit:3 http://ftp.jp.debian.org/debian stretch Release                                                                                   
Hit:5 http://download.proxmox.com/debian/ceph-luminous stretch InRelease                
Err:5 http://download.proxmox.com/debian/ceph-luminous stretch InRelease
  The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 0D9A1950E2EF0603
Get:6 http://download.proxmox.com/debian stretch InRelease [3,052 B]
Err:6 http://download.proxmox.com/debian stretch InRelease
  The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 0D9A1950E2EF0603
Fetched 3,052 B in 0s (3,712 B/s)
Reading package lists... Done
Building dependency tree       
Reading state information... Done
All packages are up to date.
W: An error occurred during the signature verification. The repository is not updated and the previous index files will be used. GPG error: http://download.proxmox.com/debian/ceph-luminous stretch InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 0D9A1950E2EF0603
W: An error occurred during the signature verification. The repository is not updated and the previous index files will be used. GPG error: http://download.proxmox.com/debian stretch InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 0D9A1950E2EF0603
W: Failed to fetch http://download.proxmox.com/debian/ceph-luminous/dists/stretch/InRelease  The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 0D9A1950E2EF0603
W: Failed to fetch http://download.proxmox.com/debian/dists/stretch/InRelease  The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 0D9A1950E2EF0603
W: Some index files failed to download. They have been ignored, or old ones used instead.

Cluster manager

https://pve.proxmox.com/wiki/Cluster_Manager

  • シングル構成を後からクラスタ構成に拡張することは可能
    • シングル構成をクラスタ構成に変更する場合は、稼働中のシングル構成ノードでクラスタを作成する
      • VMIDをクラスタ内部で管理を統一するため、2つのシングル構成をマージすることはできない
      • 真っ新なクラスタ構成に、既存のシングル構成を参加させることはできない
    • クラスタ構成に変更後、Cephなどの分散ストレージにオンラインでMove storageすることができる
      • cloud-init diskはMove storageすることが出来ないので、cloud-init利用時はクラスタ構成に変更後に一度もVMの電源を切る必要がある
      • Templateは base-* という名前でDiskが作られているとMigrationできない
        • Template化した後にDiskを接続するとDisk名が vm-* のままなので、Migrationできる

hookのサンプル

https://gist.github.com/kiler129/215e2c8de853209ca429ad5ed40ce128


最終更新日: 2023-06-23 05:05:52