1、安装

1
2
3
wget https://releases.hashicorp.com/nomad/0.8.6/nomad_0.8.6_linux_amd64.zip
tar -xvf nomad_0.8.6_linux_amd64.zip
cp nomad /usr/local/bin

2、配置

1
vi agent.conf
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
log_level = "DEBUG"
data_dir = "/data/tmp/nomad"
name = "client1"
bind_addr = "0.0.0.0"
advertise {
  http = "192.168.33.51"
  rpc = "192.168.33.51"
  serf = "192.168.33.51"
}
ports {
  http = 4646
  rpc  = 4647
  serf = 4648
}
client {
  enabled = true
  servers = ["192.168.33.51:4647"]
  options {
    "driver.raw_exec.enable" = "1"
  }
}
server {
  enabled = true
  bootstrap_expect = 1
}
1
/usr/local/bin/nomad agent -config=/data/tmp/nomad/agent.conf

3、systemd

4、调度example

1
vi job_batch.nomad
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
job "demo-job" {
  type = "batch"
  datacenters = ["dc1"]
  group "example" {
    count = 10
    task "webservice" {
      driver = "raw_exec"
      config {
        command = "uname"
        args    = ["--all"]
      }
    }
    task "test" {
      driver = "raw_exec"
      config {
        command = "uptime"
      }
    }

  }
}
1
2
#发起调度
nomad run job_batch.nomad

5、参考

Schedulers