Nomad 多job/group/task调度测试
目录
- Nomad 多job/group/task调度测试
- 1 搭建nomad集群
- 2 测试driver=docker
- 2.1 多job测试
- 2.2 多group测试
- 2.3 多task测试
- 3 测试driver=raw_exec
- 3.1 多job测试
- 3.2 多group测试
- 3.3 多task测试
- 3.4 小结
Nomad 多job/group/task调度测试
关系:job 包含 group 包含 task
1 搭建nomad集群
本测试使用三台ubuntu18.04虚拟机,IP地址分别为:
虚拟机1:192.168.60.10
虚拟机2:192.168.60.11
虚拟机3:192.168.60.12
具体搭建方法见Nomad集群 自身高可用测试。
2 测试driver=docker
使用的docker镜像为nginx的本地拷贝镜像nginx:v1
,见Nomad Nginx 暴露IP端口和重启/重调度验证。
2.1 多job测试
将以下job同时执行四次nomad job run nginx[1-4].nomad
,注意每次都要将job、group、task名字修改:
job "nginx1" {datacenters = ["dc1"]type = "service"group "nginxg1" {count = 1network {port "nginxport" {static = 8765to = 80}}task "nginxt1" {driver = "docker"config {image = "nginx:v1"ports = ["nginxport"]}}}
}
static = 8765这个端口号需要不同,否则肯定会分配到不同的虚拟机上,避免端口被占用。
再执行nomad job status
如下:
ubuntu1@ubuntu1$ nomad job status
ID Type Priority Status Submit Date
nginx1 service 50 running 2021-08-30T13:35:02+08:00
nginx2 service 50 running 2021-08-30T13:35:16+08:00
nginx3 service 50 running 2021-08-30T13:36:17+08:00
nginx4 service 50 running 2021-08-30T13:36:34+08:00
在每个虚拟机中docker ps
查看结果,虚拟机2运行了4个nginx。
如果我在第一个job里规定只能在虚拟机1运行,后面三个也都会在虚拟机1运行。
这个机制我也不太明白,可能是这些job还不够占资源。
停止job:
nomad job stop nginx1
nomad job stop nginx2
nomad job stop nginx3
nomad job stop nginx4
2.2 多group测试
执行以下job文件nomad job run nginx.nomad
,1个job包含了4个group,每个group有1个task:
job "nginx" {datacenters = ["dc1"]group "nginxg1" {count = 1network {port "nginxport" {static = 8765to = 80}}task "nginxt1" {driver = "docker"config {image = "nginx:v2"ports = ["nginxport"]}}}group "nginxg2" {count = 1network {port "nginxport" {static = 8764to = 80}}task "nginxt2" {driver = "docker"config {image = "nginx:v2"ports = ["nginxport"]}}}group "nginxg3" {count = 1network {port "nginxport" {static = 8763to = 80}}task "nginxt3" {driver = "docker"config {image = "nginx:v2"ports = ["nginxport"]}}}group "nginxg4" {count = 1network {port "nginxport" {static = 8762to = 80}}task "nginxt4" {driver = "docker"config {image = "nginx:v2"ports = ["nginxport"]}}}
}
结果与2.1 多job测试
相同。
停止job:nomad job stop nginx
2.3 多task测试
执行以下job文件nomad job run nginx.nomad
,1个job包含了1个group,每个group有4个task:
job "nginx" {datacenters = ["home"]group "nginxg" {count = 1network {port "nginxport1" {static = 8765to = 80}port "nginxport2" {static = 8764to = 80}port "nginxport3" {static = 8763to = 80}port "nginxport4" {static = 8762to = 80}}task "nginxt1" {driver = "docker"config {image = "nginx:v2"ports = ["nginxport1"]}}task "nginxt2" {driver = "docker"config {image = "nginx:v2"ports = ["nginxport2"]}}task "nginxt3" {driver = "docker"config {image = "nginx:v2"ports = ["nginxport3"]}}task "nginxt4" {driver = "docker"config {image = "nginx:v2"ports = ["nginxport4"]}}}
}
运行后发现,虚拟机2上运行了4个nginx:
ubuntu2@ubuntu2:~$ sudo docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
4be8151eaf2a nginx:v1 "/docker-entrypoint.…" 20 seconds ago Up 18 seconds 192.168.60.11:8762->80/tcp, 192.168.60.11:8762->80/udp nginxt4-bd4038a2-a662-eb24-e8e5-f83906a2ece6
b090014faf2e nginx:v1 "/docker-entrypoint.…" 20 seconds ago Up 18 seconds 192.168.60.11:8764->80/tcp, 192.168.60.11:8764->80/udp nginxt2-bd4038a2-a662-eb24-e8e5-f83906a2ece6
fc3be23df0ea nginx:v1 "/docker-entrypoint.…" 20 seconds ago Up 18 seconds 192.168.60.11:8765->80/tcp, 192.168.60.11:8765->80/udp nginxt1-bd4038a2-a662-eb24-e8e5-f83906a2ece6
b2670ffe0f10 nginx:v1 "/docker-entrypoint.…" 20 seconds ago Up 18 seconds 192.168.60.11:8763->80/tcp, 192.168.60.11:8763->80/udp nginxt3-bd4038a2-a662-eb24-e8e5-f83906a2ece6
说明在driver=docker(type=service)时,1个group内的所有task都会被分配到同一个client上。
3 测试driver=raw_exec
编写简单程序main.c
:
#include <stdio.h>
int main()
{while(1){sleep(10);}return 0;
}
gcc main.c -o main.out
编译。
sudo cp main.out /usr/
将main.out拷贝到/usr下面。
在/etc/nomad.d/nomad.hcl
文件中添加以下内容:
plugin "raw_exec" {config {enabled = true}
}
三个虚拟机都要完成以上操作。
3.1 多job测试
将以下job同时执行4次nomad job run exec[1-4].nomad
,注意每次都要将job、group、task名字修改:
job "exec1" {datacenters = ["dc1"]type = "batch"group "execg1" {count = 1task "exect1" {driver = "raw_exec"config {command = "/usr/main.out"}}}
}
再执行nomad job status
如下:
ubuntu1@ubuntu1$ nomad job status
ID Type Priority Status Submit Date
exec1 batch 50 running 2021-08-31T11:11:09+08:00
exec2 batch 50 running 2021-08-31T11:11:13+08:00
exec3 batch 50 running 2021-08-31T11:11:16+08:00
exec4 batch 50 running 2021-08-31T11:11:19+08:00
发现在ubuntu2和ubuntu3下分别都运行了2个main.out进程,ubuntu1没有。
说明在driver=raw_exec(type=batch)时,1个client可以运行多个job,且并不会优先分配给没有job的client。
停止job:
nomad job stop exec1
nomad job stop exec2
nomad job stop exec3
nomad job stop exec4
3.2 多group测试
执行以下job文件nomad job run exec.nomad
,1个job包含了4个group,每个group有1个task:
job "exec" {datacenters = ["dc1"]type = "batch"group "execg1" {count = 1task "exect1" {driver = "raw_exec"config {command = "/usr/main.out"}}}group "execg2" {count = 1task "exect2" {driver = "raw_exec"config {command = "/usr/main.out"}}}group "execg3" {count = 1task "exect3" {driver = "raw_exec"config {command = "/usr/main.out"}}}group "execg4" {count = 1task "exect4" {driver = "raw_exec"config {command = "/usr/main.out"}}}
}
也可以只有1个group,但是count=4,效果相同
结果ubuntu1运行了1个main.out进程,ubuntu3运行了3个,ubuntu2没有。
说明在driver=raw_exec(type=batch)时,1个client可以运行多个group,且并不会优先分配给没有group的client。
停止job:nomad job stop exec
3.3 多task测试
执行以下job文件nomad job run exec.nomad
,1个job包含了1个group,每个group有4个task:
job "exec" {datacenters = ["dc1"]type = "batch"group "execg" {count = 1task "exect1" {driver = "raw_exec"config {command = "/usr/main.out"}}task "exect2" {driver = "raw_exec"config {command = "/usr/main.out"}}task "exect3" {driver = "raw_exec"config {command = "/usr/main.out"}}task "exect4" {driver = "raw_exec"config {command = "/usr/main.out"}}}
}
结果ubuntu1上运行了4个main.out进程,2和3没有。
说明1个group内的所有task都会被分配到同一个client上。
3.4 小结
driver=raw_exec(type=batch)时:
- group是运行任务的基本单位(task是最小单位)
- 每个client(node)可以执行多个group
- 同属于一个group的task,都会在同一个client运行
Nomad 多job/group/task调度测试相关推荐
- Nomad集群 自身高可用测试
目录 Nomad集群 自身高可用测试 1.搭建nomad集群 2.测试driver=docker 3.测试driver=raw_exec Nomad集群 自身高可用测试 1.搭建nomad集群 本测试 ...
- 关于owner group others的测试
第五章 Linux的文件权限与目录配置 命令总结 关于owner group others的测试 在创建的dennisA用户下创建a.txt [dennisA@localhost ~]$ ls -l ...
- 两个非常有意思的适合桌面使用的Linux task调度器: BFS和MuqSS
大家都知道Linux内核task调度器经历了O(n),O(1)调度器,目前是CFS,期间也出现了几个优秀的候选调度器,但最终都没能并入内核,我们只能从一些零散的patch和文章中知道它们的存在. 但L ...
- 从HashiCorp Nomad对上百万容器进行调度所学到的经验
Docker在2013年三月实现了开源发布,它的出现让软件开发行业对于现代化应用的打包以及部署方式发生了巨大的变化.紧随着Docker的发布,各种具有竞争性.致敬性以及支持性的容器技术纷纷涌现,为这一 ...
- [dhtmlx]group task 失效问题解决
1. 问题描述 使用了Gantt 的Group功能, 但是在进行系统调优,开启smart_rendering的设置后却出现如下状况: "Group by 时,总有部分task未group&q ...
- 一文搞懂Spark的Task调度器(TaskScheduler)
TaskScheduler的核心任务是提交TaskSet到集群运算并汇报结果. 为TaskSet创建和维护一个TaskSetManager, 并追踪任务的本地性及错误信息. 遇到Straggle任务会 ...
- 车间调度标准测试集汇总-FJSP、PFSP、JSP、HFSP和分布式车间调度测试集
组合优化问题 OR-Library http://people.brunel.ac.uk/~mastjjb/jeb/info.html 混合流水车间调度问题 有很多测试集的网站,如混合流水调度HFSP ...
- MySQL高可用框架--组复制(group replication)搭建测试
一.框架搭建 1.首先备份主库数据,有两种方法,冷备份和热备份.冷备份需要先停止master服务,sudo/etc/init.d/mysql stop,然后通过cp或者scp等命令将数据文 ...
- mysql group where_[MySQL] 测试where group by order by的索引问题
1. select * from test where a=xx group by b order by c 如何加索引 CREATE TABLE `index_test` ( `id` int ...
最新文章
- SQLserver创建与主外键的看法
- 剑指Offer——网易笔试之解救小易
- 程序自动启动_如何在Gnome Shell上自动启动程序
- Android网格视图(GridView)
- select、poll、epoll区别总结
- Rocketmq技术分享
- 文件服务器 ftp服务器的优缺点,FTP服务器优缺点分析.doc
- VC++_2010_学习版_下载教程
- 采集百度搜索引擎的10个经典方法
- mysql随机生成中文姓名_mysql 生成随机手机号和随机中文名-阿里云开发者社区
- 行人重识别论文阅读8-FastReID京东快速行人重识别
- 给红米Note3高配版手机刷入Linux系统postmarketOS
- bootstrap table
- HTML静态页面项目:英雄联盟官网网站 的实现
- 广西大学计算机考研资料汇总
- python 爬取糗百
- java 中的NIO
- MATLAB中排序sort函数的用法
- 2018.1.7 计算机算法课后习题总结
- 第六章 Arm 微架构「System」