cgroup限制nodemanager、regionserver的资源

cgroup限制nodemanager、regionserver的资源

用系统自带的cgroup服务来限制nodemanager、regionserver的cpu使用率。

安装cgroup服务,
1
2
3
4
5
6
7
##  centos 7.1 系统安装 cgroup
chattr -i /etc/passwd /etc/shadow /etc/group /etc/gshadow
yum install -y libcgroup libcgroup-tools

## centos 6 系统安装 cgroup
chattr -i /etc/passwd /etc/shadow /etc/group /etc/gshadow
yum install -y libcgroup
编辑cgroup配置文件

cpu 32盒 最大使用 90% ,
yarn 32 0.9 100000 = 2880000 ,
hbase 600000 6盒cpu 600 * 1000

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
vim /etc/cgconfig.conf
group yarn {
perm {
task {
uid = hadoop;
gid = hadoop;
}
admin {
uid = hadoop;
gid = hadoop;
}
}
cpu {
cpu.cfs_period_us= 100000;
cpu.cfs_quota_us= 2880000;
}
}
group yarn/hbase {
perm {
task {
uid = hadoop;
gid = hadoop;
}
admin {
uid = hadoop;
gid = hadoop;
}
}
cpu {
cpu.cfs_period_us= 100000;
cpu.cfs_quota_us= 600000;
}
}
启动cgroup服务
1
2
systemctl restart cgconfig.service
systemctl enable cgconfig.service
重新启动 nodemanager 和 regionserver 服务
1
2
3
4
5
6
7
8
su - hadoop

yarn-daemon.sh stop nodemanager
cgexec -g cpu:yarn yarn-daemon.sh start nodemanager


hbase-daemon.sh stop regionserver
cgexec -g cpu:yarn/hbase hbase-daemon.sh start regionserver
检查 服务
1
2
3
4
5
cd /sys/fs/cgroup/cpu/yarn
cat tasks | grep "nodemanager PID"

cd /sys/fs/cgroup/cpu/yarn/hbase
cat tasks | grep "regsionserver PID"
感谢您的支持!