码迷,mamicode.com
首页 > 其他好文 > 详细

nomad 集群搭建

时间:2018-07-08 16:39:02      阅读:200      评论:0      收藏:0      [点我收藏+]

标签:row   hostname   efault   table   node   user   debug   system   inf   

比较简单的集群搭建

一个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
```code
# 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

nomad 集群搭建

标签:row   hostname   efault   table   node   user   debug   system   inf   

原文地址:https://www.cnblogs.com/rongfengliang/p/9280186.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!