This repository has been archived by the owner on Jun 16, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
资源分组
Longda edited this page Apr 10, 2014
·
3 revisions
随着机器规模的扩大, 不同部门都开始使用公共的JStorm集群, 这个时候,就迫切需要将每个部门的自己进行隔离开来, 避免其他部门的应用影响到其他人, 这个时候就很有必要打开资源分组功能, 为每个部门,设置一个group,在这个group里面限制CPU、Memory,Disk、network的资源数量,从而保证各部门相互间不再冲突。
#nimbus 打开资源分组功能
在nimbus节点的机器上 修改$JSTORM_HOME/conf/storm.yaml
修改nimbus.groupfile.path选项, 将这个选项指向分组的配置文件, 注意必须是绝对路径,而且启动nimbus时的用户对这个文件有读权限
默认的配置文件格式如下
; all sections' name must be group
[group] ;所有的section名字必须是group
;the name of group
; 设置group的名字
NAME=group1
;the group's cpu pool size,
;if it hasn't been set it or is negative number, it will be Integer.MAX
; 该group的cpu pool的大小, 如果没有设置或小于0, 则自动被认为不受限制,直到集群资源被使用光
CPU=128
;the group's mem pool size,
;if it hasn't been set it or is negative number, it will be Integer.MAX
; 该group的内存 pool的大小, 如果没有设置或小于0, 则自动被认为不受限制,直到集群资源被使用光
MEM=128
;the group's disk pool size,
;if it hasn't been set it or is negative number, it will be Integer.MAX
; 该group的disk pool的大小, 如果没有设置或小于0, 则自动被认为不受限制,直到集群资源被使用光
DISK=32
;the group's network pool size,
;if it hasn't been set it or is negative number, it will be Integer.MAX
; 该group的disk pool的大小, 如果没有设置或小于0, 则自动被认为不受限制,直到集群资源被使用光
NET=128
[group]
; 依次同理配置第二个group
NAME=group2
CPU=32
MEM=32
DISK=20
NET=32
当配置结束后, 重启nimbus 在ui的首页上 "Group Model" 会显示true 在"Group Summary" 会显示各分组的资源列表
一旦代开nimbus 资源分组功能, 提交的jar 都必须设置group,否则无法提交jar 有两种方式设置group,
# if you want to submit topology on the nimbus with group
# module, you must set your gourp name (user.group)here or
# in your topology;The user.name and the user.password is
# useless in this version
# 设置user.group 的名字
user.group: null
user.name: null
user.password: null
然后提交jar, 提交的jar就自动使用该分组名字
public static void setUserGroup(Map conf, String groupName) {
conf.put(USER_GROUP, groupName);
}
推荐使用第一种方式, 因为这样代码无需hardcode 为每个部门在提交jar的机器上开通一个账号,并提前设置好~/.jstorm/storm.yaml, 这样这个部门的所有提交jar的动作都在这个账号下执行, 都自动使用了group名字