ユーザ用ツール

サイト用ツール


01_linux:21_centos7:07_cgroup

差分

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

この比較画面へのリンク

次のリビジョン
前のリビジョン
01_linux:21_centos7:07_cgroup [2020/05/22 06:48] – 作成 matsui01_linux:21_centos7:07_cgroup [2021/07/24 08:30] (現在) matsui
行 3: 行 3:
  
 [[https://legitwhiz.github.io/technology_memo/Resource_control_using_cgroups(RHEL7).html]] [[https://legitwhiz.github.io/technology_memo/Resource_control_using_cgroups(RHEL7).html]]
 +
 +===== cgroupsのインストール =====
 +
 +  yum install libcgroup libcgroup-tools
 +
 +===== cgroupsの起動設定 =====
 +
 +  /usr/bin/systemctl enable cgconfig
 +  /usr/bin/systemctl enable cgred
 +
 +===== QOS =====
 +
 +※ディスクIDは、lsblkで確認
 +下記は/dev/sda(8:0)を100IOPS でlimitをかける場合
 +
 +  [/etc/cgconfig.conf]
 +  
 +  group DiskIO_Group  {
 +      blkio {
 +          blkio.throttle.read_iops_device = "8:0 100";
 +          blkio.throttle.write_iops_device = "8:0 100";
 +      }
 +  }
 +
 +  [/etc/cgrules.conf]
 +  root blkio DiskIO_Group
 +
 +
 +==== cgconfig.confで複数ディスクへ設定する場合 ====
 +groupを複数書いておく
 +
 +  [/etc/cgconfig.conf]
 +  
 +  group DiskIO_Group  {
 +      blkio {
 +          blkio.throttle.read_iops_device = "8:0 100";
 +          blkio.throttle.write_iops_device = "8:0 100";
 +      }
 +  }
 +  group DiskIO_Group  {
 +      blkio {
 +          blkio.throttle.read_iops_device = "251:0 100";
 +          blkio.throttle.write_iops_device = "251:0 100";
 +      }
 +  }
 +
 +こうするとちゃんと反映される
 +<code>
 +# cat /sys/fs/cgroup/blkio/DiskIO_Group/blkio.throttle.write_iops_device 
 +8:0 100
 +251:0 100
 +</code>
 +===== 反映 =====
 +反映にはcgconfigとcgredプロセスを再起動で反映されます。
 +
 +  systemctl restart cgconfig && systemctl restart cgred
 +
 +===== 確認 =====
 +
 +4k block , count=1000が10秒ほどかかる。
 +1000 / 100IOPS = 10s 
 +
 +<code>
 +# dd if=/dev/zero of=AAA bs=512 count=100 oflag=direct
 +100+0 records in
 +100+0 records out
 +51200 bytes (51 kB) copied, 0.925756 s, 55.3 kB/s
 +
 +# dd if=/dev/zero of=AAA bs=512 count=1000 oflag=direct
 +1000+0 records in
 +1000+0 records out
 +512000 bytes (512 kB) copied, 9.92528 s, 51.6 kB/s
 +</code>
 +
 +
 +===== コマンドラインで実行の場合 =====
 +
 +==== CGruleを先に設定しておく ====
 +  echo "root blkio DiskIO_Group" >>  /etc/cgrules.conf
 +  systemctl restart cgred
 +
 +==== グループ作成 ====
 +
 +  cgcreate -g blkio:/DiskIO_Group
 +
 +==== 設定追加 ====
 +
 +  cgset -r blkio.throttle.write_iops_device="8:0 10" DiskIO_Group
 +
 +==== 設定確認 ====
 +
 +  cgget blkio.throttle.write_iops_device DiskIO_Group
 +
 +  # cgget -r blkio.throttle.write_iops_device DiskIO_Group
 +  DiskIO_Group:
 +  blkio.throttle.write_iops_device: 8:0 10
 +  
 +下記でも確認できる
 +  # cat /sys/fs/cgroup/blkio/DiskIO_Group/blkio.throttle.write_iops_device
 +  8:0 10
 +
 +==== 設定削除 ====
 +  cgdelete blkio:/DiskIO_Group
 +
  
 {{tag>centos}} {{tag>centos}}
01_linux/21_centos7/07_cgroup.1590130101.txt.gz · 最終更新: 2020/05/22 06:48 by matsui