ユーザ用ツール

サイト用ツール


01_linux:01_net:29_tgt_thin_provision

差分

このページの2つのバージョン間の差分を表示します。

この比較画面へのリンク

両方とも前のリビジョン前のリビジョン
次のリビジョン
前のリビジョン
01_linux:01_net:29_tgt_thin_provision [2020/03/24 04:36] matsui01_linux:01_net:29_tgt_thin_provision [2020/03/24 10:15] (現在) matsui
行 19: 行 19:
      
         gfs2(5) (since Linux 4.16)         gfs2(5) (since Linux 4.16)
 +
 +
 +[[https://blog.csdn.net/bobpen/article/details/79445104|参考URL]]
  
 ===== 1. Sparseファイル作成 ===== ===== 1. Sparseファイル作成 =====
行 35: 行 38:
   # tgtadm --lld iscsi --op new --mode logicalunit --tid 1 --lun 1 --backing-store /mnt/disk.tgt   # tgtadm --lld iscsi --op new --mode logicalunit --tid 1 --lun 1 --backing-store /mnt/disk.tgt
  
-===== 3.シンプロビジョニングを有効にする =====+===== 3.シンプロビジョニングを有効にする =====
  
   # tgtadm --lld iscsi --mode logicalunit --op update --tid 1 --lun 1 --params thin_provisioning=1    # tgtadm --lld iscsi --mode logicalunit --op update --tid 1 --lun 1 --params thin_provisioning=1 
  
  
-==== 4.設定ファイルの場合 ====+===== 4.設定ファイルの場合 =====
  
-params thin_provisioningで指定する。+params thin_provisioning=1」で指定する。
  
 <code|/etc/tgt/targets.conf> <code|/etc/tgt/targets.conf>
行 52: 行 55:
         params thin_provisioning=1         params thin_provisioning=1
 </target> </target>
 +</code>
 +
 +===== 5. シンプロビジョニングの確認 =====
 +「Thin-provisioning: Yes」となっていればOK
 +
 +<code>
 +# tgt-admin -s
 +        LUN: 1
 +            Type: disk
 +            SCSI ID: IET     00010001
 +            SCSI SN: beaf11
 +            Size: 536871 MB, Block size: 512
 +            Online: Yes
 +            Removable media: No
 +            Prevent removal: No
 +            Readonly: No
 +            SWP: No
 +            Thin-provisioning: Yes
 +            Backing store type: rdwr
 +            Backing store path: /mnt/disk.tgt
 +            Backing store flags:
 +</code>
 +
 +==== クライアントから接続確認 ====
 +
 +[[01_linux:01_net:31_iscsid]]で接続
 +
 +
 +今回はsdcで接続している状況で説明
 +<code>
 +# ll /dev/disk/by-path/| grep sdc
 +lrwxrwxrwx. 1 root root  9 Mar 24 00:40 ip-192.168.10.16:3260-iscsi-iqn.2014-03.storage-server:disk1-lun-1 -> ../../sdc
 +</code>
 +
 +==== discard_granularityを確認 ====
 +
 +thin provisionが有効になっていると、「/sys/block/{BLOCK}/queue/discard_granularity」が0以外になっている
 +
 +  # cat /sys/block/sdc/queue/discard_granularity 
 +  512
 +
 +下記でUNMAPが有効になっている事が分かる。
 +<code>
 +# sg_vpd -p 0xb2 /dev/sdc 
 +Logical block provisioning VPD page (SBC):
 +  Unmap command supported (LBPU): 1
 +  Write same (16) with unmap bit supported (LBWS): 1
 +  Write same (10) with unmap bit supported (LBWS10): 1
 +  Logical block provisioning read zeros (LBPRZ): 1
 +  Anchored LBAs supported (ANC_SUP): 0
 +  Threshold exponent: 0
 +  Descriptor present (DP): 0
 +  Provisioning type: 2
 +</code>
 +
 +===== クライアント側と、サーバ側で交互に確認 =====
 + -o discard でマウントしおくと、下記を自動で行ってくれる
 + LVMの場合は、issue_discards=1 にしておくとOK
 +
 +
 +==== クライアントで確認 ====
 +
 +=== 1.マウントするとちゃんと500Gのディスクとしてマウントしている ===
 +
 +<code>
 +# mkfs.xfs /dev/sdc
 +# mount /dev/sdc /mnt/
 +# df -h | grep mnt
 +/dev/sdc                 500G   33M  500G   1% /mnt
 +</code>
 +
 +=== 3.1Gフィアルを10個作成 ===
 +当然容量は増える
 +<code>
 +# for i in `seq -w 0 10`; do dd if=/dev/zero of=/mnt/$i bs=1M count=1024 ; done
 +# df -h | grep mnt
 +/dev/sdc                 500G   12G  489G   3% /mnt
 +</code>
 +
 +=== 5.ファイルを削除 ===
 +
 +ファイル削除で容量は減る
 +<code>
 +# rm -rvf /mnt/*
 +# df -h | grep mnt
 +/dev/sdc                 500G   33M  500G   1% /mnt
 +</code>
 +
 +=== 7.fstrim ===
 +<code>
 +# fstrim /mnt
 +</code>
 +
 +==== サーバ側で確認 ====
 +
 +=== 2.mkfsで少し容量増えるけど、ほとんど利用されてない状態 ===
 +
 +<code>
 +# du -h /mnt/disk.tgt 
 +251M    /mnt/disk.tgt
 +</code>
 +
 +=== 4.サーバ側でも増えている ===
 +<code>
 +# du -h /mnt/disk.tgt 
 +12G     /mnt/disk.tgt
 +</code>
 +
 +=== 6.サーバ側は減っていない ===
 +<code>
 +# du -h /mnt/disk.tgt 
 +12G    /mnt/disk.tgt
 +</code>
 +
 +=== 8.クライアントでfstrim後はサーバ側でも減っている ===
 +<code>
 +# du -h /mnt/disk.tgt 
 +251M    /mnt/disk.tgt
 </code> </code>
  
 {{tag>iscsi tgt}} {{tag>iscsi tgt}}
01_linux/01_net/29_tgt_thin_provision.1585024604.txt.gz · 最終更新: 2020/03/24 04:36 by matsui