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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM