2019年6月5日水曜日

ホスト側のpacemaker化の前に

pacemakerでgfs2を運用する方法がある程度見えてきたので、メインマシンのホスト(sagittarius/aquarius)のpacemaker化を進めたい。
が、その前にやっておかなきゃいけないことがある。

今、KVMホストであるsagittarius/aquariusの2台は、/etc/libvirtと/var/lib/libvirtの2箇所をgfs2で共有している。
が、調べてみたら/etc/libvirtはやはり、共有化してはいけないことが分かった。

というわけで、両サーバとも/etc/libvirtをローカル化(内蔵ディスク化)することにする。
サイズは1GBもあれば十分。
空き領域を確認する。
$ sudo vgdisplay vg-root
Free PE / Size が数十GB空いていればOKだ。(システムバックアップ取得のために、スナップショット領域を必要とするので、1GBきっちりしか空いてなかったらダメだぞ)

$ sudo lvcreate -L 1G -n lv-etc-libvirt vg-root
$ sudo mkfs.ext4 /dev/vg-root/lv-etc-libvirt
暫定のマウントポイントを作成する。
$ sudo mkdir /mnt/libvirt
マウント
$ sudo mount /dev/vg-root/lv-etc-libvirt /mnt/libvirt

そしたら、ファイルをコピーする。
$ cd /etc
$ sudo tar cSf - libvirt | (cd /mnt ; sudo tar xSf -)
$ sudo ls -alR /etc/libvirt > /tmp/etc-libvirt-gfs2.list
$ sudo ls -alR /mnt/libvirt > /tmp/etc-libvirt-ext4.list
$ diff -w /tmp/etc-libvirt-gfs2.list /tmp/etc-libvirt-ext4.list
ディレクトリのサイズ差が若干あるのは、gfs2とext4のファイルシステムの違いによるものだ。lost+foundの有無も同様。

ファイルコピーが終わったら、一時マウントを解除し、暫定マウントポイントを削除する。
$ sudo umount /mnt/libvirt
$ sudo rmdir /mnt/libvirt

続いて、既存の/etc/libvirtをアンマウントし、/etc/fstabを書き換え、新しい/etc/libvirtをマウントする。
$ sudo systemctl stop /etc/libvirt
$ sudo vi /etc/fstab
-----
/etc/libvirtのマウント行をコメント化し、以下の行を追加する。
/dev/mapper/vg--root-lv--etc--libvirt /etc/libvirt ext4 defaults 0 2
-----

マウントする
$ sudo systemctl daemon-reload
$ sudo systemctl start /etc/libvirt
$ df /etc/libvirt
$ grep /etc/libvirt /etc/mtab
新しいファイルシステムの方(vg-rootの方)がマウントされていたら、念の為libvirt-binをリロードする。
$ sudo systemctl reload libvirt-bin
$ virsh list --all

システムバックアップの対象ボリュームが増えたので、定義ファイルを追加しておく。
$ sudo -i
# cd ~/backup/etc/fsconfig
# vi 0030_lv-etc-libvirt
-----
#
# USELVM:
# Area to be backed up or LVM region, simple partition of the flag.
# Specify a Yes in the case of LVM of LVOL area.
#
USELVM=Yes

#
# VOLNAME:
# You want to specify the volume device name of the target volume.
# For simple partition, sda1 and sda2 like.
# You can easily find LVM of LVOL area, specify the LVOL name (lvol1, etc.).
#
VOLNAME=lv-etc-libvirt

#
# MOUNTPOINT:
# Specify the mount point of the target area.
#
MOUNTPOINT=/etc/libvirt

#
# SNAPSIZE:
# If the area of interest was the LVM region, we want to create
# a LVM Snapshot.
# It will specify the capacity of the Snapshot area.
# ex.
#   SNAPSIZE=32M
#   SNAPSIZE=320M
# If you specify a larger size than the capacity of the backup target,
# it will be the same capacity as the size of the backup target.
#
SNAPSIZE=32M
-----

定義ファイルが作成できたら、バックアップを取っておこう。
# cd ~/backup/bin
# ./0000_backup
# exit

sagittarius/aquariusの両方で実施すること。
kvmclusterの方のetc-libvirt(旧/etc/libvirt)は念のために暫く残しておこう。

この後は、sagittarius/aquairusにpacemakerを導入し、gfs2をpacemakerで運用するための設定だ。
そして、1804へのアップグレードも控えている。
うまく進むといいけどな。

0 件のコメント:

コメントを投稿