以下に、Linux でリソース グループを構成して使用する手順を示します。
1. cgroup を使用するには、「libcgroup」をインストールする必要があります。 」パッケージをシステムにインストールしてください。
# yum install libcgroup
2. cgroups の構成ファイルを作成します (/etc/cgconfig.conf )、以下の設定を追加してください。
# vi /etc/cgconfig.conf
mount {
cpu = /cgroup/cpumem;
cpuset = /cgroup/cpumem;
memory = /cgroup/cpumem;
}
# High priority group
group mysqldb {
cpu {
# Allocate the relative share of CPU resources equal to 75%
cpu.shares="750";
}
cpuset {
# No alternate memory nodes if the system is not NUMA
cpuset.mems="0";
# Allocate CPU cores 2 through 5 to tasks in the cgroup
cpuset.cpus="2-5";
}
memory {
# Allocate at most 8 GB of memory to tasks
memory.limit_in_bytes="8G";
# Allocate at most 16 GB of memory+swap to tasks
memory.memsw.limit_in_bytes="16G";
# Apply a soft limit of 4 GB to tasks
memory.soft_limit_in_bytes="4G";
}
} 3. 以下の設定で cgroup ルール定義ファイル – /etc/cgrules.conf を作成します:
# vi /etc/cgrules.conf # Assign tasks run by the mysql user to mysqldb mysql cpu,cpuset,memory mysqldb
4. cgconfig サービスを開始し、システムの起動時に開始するように構成します。
$ service cgconfig start $ chkconfig cgconfig on
5. この時点で、mysql のリソース グループの準備が整っています。 mysqld を再起動すると、上記の構成とルールに従ってリソースが許可されます。
6. 実行時にリソース グループの制限を見つけて変更することもできます。
a.リソース制限を見つけるには:
$ cgget -r memory.stat mysqldb
b.リソース制限を設定するには:
$ cgset -r blkio.throttle.read_bps_device="8:1 0" iocap1
c.将来の使用のために現在変更されている構成を保存するには:
$ cgsnapshot -s > current_cgconfig.conf
サーバーアプリケーションがリモートサーバーから「接続拒否」を取得する [firewalld または iptables が原因] – CentOS/RHEL 7
CentOS/RHEL – 古い ISCSI ターゲット ノード情報を ISCSI イニシエーター サーバーから削除する方法