Red Hat Training
A Red Hat training course is available for OpenShift Container Platform
3.9.2. シンプールストレージの設定
Docker に含まれる docker-storage-setup スクリプトを使用してシンプールデバイスを作成し、Docker ストレージドライバーを設定できます。これは Docker のインストール後に実行でき、イメージまたはコンテナーの作成前に実行する必要があります。このスクリプトは /etc/sysconfig/docker-storage-setup ファイルから設定オプションを読み取り、論理ボリュームを作成するための 3 つのオプションをサポートします。
- 追加のブロックデバイスを使用する。
- 既存の、指定されたボリュームグループを使用する。
- root ファイルシステムが置かれている残りのボリュームグループの空きスペースを使用する。
追加のブロックデバイスを使用することは最も信頼性の高いオプションですが、Docker ストレージを設定する前に他のブロックデバイスをホストに追加する必要があります。他のオプションはいずれも、ホストのプロビジョニング時に利用可能な空きスペースを残しておく必要があります。ルートファイルシステムボリュームグループの残りの空きスペースを使用すると、Red Hat Mobile Application Platform (RHMAP) などの一部のアプリケーションで問題が生じることが確認されています。
以下の 3 つのオプションのいずれかを使用して docker-pool ボリュームを作成します。
追加のブロックデバイスを使用するには、以下を実行します。
/etc/sysconfig/docker-storage-setup で、使用するブロックデバイスのパスに DEVS を設定します。作成するボリュームグループ名に VG を設定します (docker-vg など)。以下は例になります。
# cat <<EOF > /etc/sysconfig/docker-storage-setup DEVS=/dev/vdc VG=docker-vg EOF
docker-storage-setup を実行し、出力で docker-pool ボリュームが作成されたことを確認します。
# docker-storage-setup [5/1868] 0 Checking that no-one is using this disk right now ... OK Disk /dev/vdc: 31207 cylinders, 16 heads, 63 sectors/track sfdisk: /dev/vdc: unrecognized partition table type Old situation: sfdisk: No partitions found New situation: Units: sectors of 512 bytes, counting from 0 Device Boot Start End #sectors Id System /dev/vdc1 2048 31457279 31455232 8e Linux LVM /dev/vdc2 0 - 0 0 Empty /dev/vdc3 0 - 0 0 Empty /dev/vdc4 0 - 0 0 Empty Warning: partition 1 does not start at a cylinder boundary Warning: partition 1 does not end at a cylinder boundary Warning: no primary partition is marked bootable (active) This does not matter for LILO, but the DOS MBR will not boot this disk. Successfully wrote the new partition table Re-reading the partition table ... If you created or changed a DOS partition, /dev/foo7, say, then use dd(1) to zero the first 512 bytes: dd if=/dev/zero of=/dev/foo7 bs=512 count=1 (See fdisk(8).) Physical volume "/dev/vdc1" successfully created Volume group "docker-vg" successfully created Rounding up size to full physical extent 16.00 MiB Logical volume "docker-poolmeta" created. Logical volume "docker-pool" created. WARNING: Converting logical volume docker-vg/docker-pool and docker-vg/docker-poolmeta to pool's data and metadata volumes. THIS WILL DESTROY CONTENT OF LOGICAL VOLUME (filesystem etc.) Converted docker-vg/docker-pool to thin pool. Logical volume "docker-pool" changed.
既存の、指定されたボリュームグループを使用するには、以下を実行します。
/etc/sysconfig/docker-storage-setup で、VG をボリュームグループに設定します。以下は例になります。
# cat <<EOF > /etc/sysconfig/docker-storage-setup VG=docker-vg EOF
次に docker-storage-setup を実行し、出力で docker-pool ボリュームが作成されたことを確認します。
# docker-storage-setup Rounding up size to full physical extent 16.00 MiB Logical volume "docker-poolmeta" created. Logical volume "docker-pool" created. WARNING: Converting logical volume docker-vg/docker-pool and docker-vg/docker-poolmeta to pool's data and metadata volumes. THIS WILL DESTROY CONTENT OF LOGICAL VOLUME (filesystem etc.) Converted docker-vg/docker-pool to thin pool. Logical volume "docker-pool" changed.
root ファイルシステムが置かれているボリュームグループの残りの空きスペースを使用するには、以下を実行します。
root ファイルシステムが置かれているボリュームグループに必要な空きスペースがあることを確認してから、docker-storage-setup を実行して、出力で docker-pool ボリュームが作成されていることを確認します。
# docker-storage-setup Rounding up size to full physical extent 32.00 MiB Logical volume "docker-poolmeta" created. Logical volume "docker-pool" created. WARNING: Converting logical volume rhel/docker-pool and rhel/docker-poolmeta to pool's data and metadata volumes. THIS WILL DESTROY CONTENT OF LOGICAL VOLUME (filesystem etc.) Converted rhel/docker-pool to thin pool. Logical volume "docker-pool" changed.
設定を確認します。/etc/sysconfig/docker-storage ファイルに dm.thinpooldev および docker-pool 論理ボリュームの値があることを確認します。
# cat /etc/sysconfig/docker-storage DOCKER_STORAGE_OPTIONS="--storage-driver devicemapper --storage-opt dm.fs=xfs --storage-opt dm.thinpooldev=/dev/mapper/rhel-docker--pool --storage-opt dm.use_deferred_removal=true --storage-opt dm.use_deferred_deletion=true " # lvs LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert docker-pool rhel twi-a-t--- 9.29g 0.00 0.12
重要Docker または OpenShift Container Platform を使用する前に、docker-pool 論理ボリュームが要求を満たすサイズであることを確認します。docker-pool ボリュームは利用可能なボリュームグループの 60% である必要があり、これは LVM モニターリングによって拡張し、ボリュームグループを埋めていきます。
Docker を起動するか、または再起動します。
Docker がホストでまだ起動されていない場合は、サービスを有効にしてから起動し、それが実行されていることを確認します。
# systemctl enable docker # systemctl start docker # systemctl is-active docker
Docker がすでに実行されている場合は、以下を実行します。
Docker を再初期化します。
警告これは現在ホストにあるコンテナーまたはイメージを破棄します。
# systemctl stop docker # rm -rf /var/lib/docker/* # systemctl restart docker
- /var/lib/docker/ フォルダーのコンテンツを削除します。