nomad 集群搭建
比较简单的集群搭建
一个server 三个client (单机) 参考代码 https://github.com/rongfengliang/nomad-cluster-demo
server 配置
# Increase log verbosity
log_level = "DEBUG"
# Setup data dir 实际配置参考自己的配置路径,必须是绝对路径
data_dir = "/Users/dalong/mylearning/nomad-cluster/server/node1/data"
# Enable the server
server {
enabled = true
# Self-elect, should be 3 or 5 for production
bootstrap_expect = 1
}
客户端配置
三个
- client1
# Increase log verbosity
log_level = "DEBUG"
# Setup data dir
data_dir = "/Users/dalong/mylearning/nomad-cluster/client/client1"
# Give the agent a unique name. Defaults to hostname
name = "client1"
# Enable the client
client {
enabled = true
# For demo assume we are talking to server1. For production,
# this should be like "nomad.service.consul:4647" and a system
# like Consul used for service discovery.
servers = ["127.0.0.1:4647"]
}
# Modify our port to avoid a collision with server1
ports {
http = 5656
}
- client2
# Increase log verbosity
log_level = "DEBUG"
# Setup data dir
data_dir = "/Users/dalong/mylearning/nomad-cluster/client/client2"
# Give the agent a unique name. Defaults to hostname
name = "client2"
# Enable the client
client {
enabled = true
# For demo assume we are talking to server1. For production,
# this should be like "nomad.service.consul:4647" and a system
# like Consul used for service discovery.
servers = ["127.0.0.1:4647"]
}
# Modify our port to avoid a collision with server1
ports {
http = 5657
}
- client3
# Increase log verbosity
log_level = "DEBUG"
# Setup data dir
data_dir = "/Users/dalong/mylearning/nomad-cluster/client/client3"
# Give the agent a unique name. Defaults to hostname
name = "client3"
# Enable the client
client {
enabled = true
# For demo assume we are talking to server1. For production,
# this should be like "nomad.service.consul:4647" and a system
# like Consul used for service discovery.
servers = ["127.0.0.1:4647"]
}
# Modify our port to avoid a collision with server1
ports {
http = 5658
}
启动server && client
- 启动consul
测试,使用单
consul agent --dev
- server
nomad agent -config server.hcl
- client(1、2、3)
按照实际,进入目录进行启动
nomad agent -config client(1、2、3).hcl
参考界面
- consul
-
nomad server
-
client
运行job
- 生成参考代码
nomad init
- 修改运行个数为5
实际代码可以参考github
group "cache" {
count = 5
- 运行
nomad run example.nomad
- 参考界面
consul dns 测试
说明
实际环境中我们使用集群环境,同时结合coredns 可以实现一些比较强大的功能。
参考资料
https://www.nomadproject.io/intro/getting-started/cluster.html
https://github.com/rongfengliang/nomad-cluster-demo
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· .NET10 - 预览版1新功能体验(一)
2017-07-08 秘密共享
2017-07-08 Let’s Encrypt 将于 2018 年免费提供通配符证书