目录

  • 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调度测试相关推荐

  1. Nomad集群 自身高可用测试

    目录 Nomad集群 自身高可用测试 1.搭建nomad集群 2.测试driver=docker 3.测试driver=raw_exec Nomad集群 自身高可用测试 1.搭建nomad集群 本测试 ...

  2. 关于owner group others的测试

    第五章 Linux的文件权限与目录配置 命令总结 关于owner group others的测试 在创建的dennisA用户下创建a.txt [dennisA@localhost ~]$ ls -l ...

  3. 两个非常有意思的适合桌面使用的Linux task调度器: BFS和MuqSS

    大家都知道Linux内核task调度器经历了O(n),O(1)调度器,目前是CFS,期间也出现了几个优秀的候选调度器,但最终都没能并入内核,我们只能从一些零散的patch和文章中知道它们的存在. 但L ...

  4. 从HashiCorp Nomad对上百万容器进行调度所学到的经验

    Docker在2013年三月实现了开源发布,它的出现让软件开发行业对于现代化应用的打包以及部署方式发生了巨大的变化.紧随着Docker的发布,各种具有竞争性.致敬性以及支持性的容器技术纷纷涌现,为这一 ...

  5. [dhtmlx]group task 失效问题解决

    1. 问题描述 使用了Gantt 的Group功能, 但是在进行系统调优,开启smart_rendering的设置后却出现如下状况: "Group by 时,总有部分task未group&q ...

  6. 一文搞懂Spark的Task调度器(TaskScheduler)

    TaskScheduler的核心任务是提交TaskSet到集群运算并汇报结果. 为TaskSet创建和维护一个TaskSetManager, 并追踪任务的本地性及错误信息. 遇到Straggle任务会 ...

  7. 车间调度标准测试集汇总-FJSP、PFSP、JSP、HFSP和分布式车间调度测试集

    组合优化问题 OR-Library http://people.brunel.ac.uk/~mastjjb/jeb/info.html 混合流水车间调度问题 有很多测试集的网站,如混合流水调度HFSP ...

  8. MySQL高可用框架--组复制(group replication)搭建测试

    一.框架搭建       1.首先备份主库数据,有两种方法,冷备份和热备份.冷备份需要先停止master服务,sudo/etc/init.d/mysql stop,然后通过cp或者scp等命令将数据文 ...

  9. 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 ...

最新文章

  1. SQLserver创建与主外键的看法
  2. 剑指Offer——网易笔试之解救小易
  3. 程序自动启动_如何在Gnome Shell上自动启动程序
  4. Android网格视图(GridView)
  5. select、poll、epoll区别总结
  6. Rocketmq技术分享
  7. 文件服务器 ftp服务器的优缺点,FTP服务器优缺点分析.doc
  8. VC++_2010_学习版_下载教程
  9. 采集百度搜索引擎的10个经典方法
  10. mysql随机生成中文姓名_mysql 生成随机手机号和随机中文名-阿里云开发者社区
  11. 行人重识别论文阅读8-FastReID京东快速行人重识别
  12. 给红米Note3高配版手机刷入Linux系统postmarketOS
  13. bootstrap table
  14. HTML静态页面项目:英雄联盟官网网站 的实现
  15. 广西大学计算机考研资料汇总
  16. python 爬取糗百
  17. java 中的NIO
  18. MATLAB中排序sort函数的用法
  19. 2018.1.7 计算机算法课后习题总结
  20. 第六章 Arm 微架构「System」

热门文章

  1. 计算机领域国家自然科学基金,计算机学院获批国家自然科学基金委人工智能代码(F06)首个重大项目...
  2. 加密算法详解AES/HmacSHA1/DES
  3. MO call与MT call
  4. makefile编写helloworld
  5. 隐私保护深度学习技术综述
  6. js实现图片连续滚动播放
  7. Ubuntu关机和重启的命令
  8. xeon bronze 3106
  9. CodeSmith Professional 5.0破解下载地址 注册机 keygen
  10. 删除mysql中的函数