nomadインストール


一、環境要求
      :centos7.2
      :4.8.4
    :yum
    (200G    ):/data
      :4646、4647、4648

二、インストールファイルのダウンロード
wget https://releases.hashicorp.com/nomad/0.6.1/nomad_0.6.1_linux_amd64.zip

三、インストールファイルを解凍する
unzip nomad_0.6.1_linux_amd64.zip -d /usr/bin

四、起動ファイルの作成
vim /lib/systemd/system/nomad.service
[Unit]
Description=nomad
[Service]
ExecStart=/usr/bin/nomad agent -config /etc/nomad
KillSignal=SIGTERM

五、構成ファイルの作成
        :mkdir /etc/nomad
########################client  ##########################
####  client.hcl#####
client {
  enabled = true
  options {
    "driver.raw_exec.enable" = "1"
    "driver.exec.enable" = "1"
    "driver.exec.java" = "1"
    "docker.volumes.enabled" = "true"
    "max_kill_timeout" = "30s"
  }
  meta {
    "key" = "vaule"
    "key2" = "vaule2"
 }
 }
 ####  consul.hcl#####
 consul {
  address = "consul  IP  :8500"
  server_service_name = "nomad"
  server_auto_join = true
  client_service_name = "nomad-client"
  client_auto_join = true
  auto_advertise = true
  token   = "consul token"
}
 ####  nomad.hcl#####
 log_level = "INFO"
data_dir = "/var/run/nomad"
bind_addr = "0.0.0.0"
leave_on_terminate = true
region = "  "
datacenter = "      "
advertise {
  http = "  IP:4646"
  rpc = "  IP:4647"
  serf = "  IP:4648"
}
telemetry {
  publish_allocation_metrics = true
  publish_node_metrics       = true
}

########################master  ##########################
####  client.hcl#####
client {
  enabled = true
  options {
    "driver.raw_exec.enable" = "1"
    "driver.exec.enable" = "1"
    "driver.exec.java" = "1"
    "docker.volumes.enabled" = "true"
    "max_kill_timeout" = "30s"
  }
  meta {
    "key" = "vaule"
    "key2" = "vaule2"
 }
 }
 ####  consul.hcl#####
 consul {
  address = "consul  IP  :8500"
  server_service_name = "nomad"
  server_auto_join = true
  client_service_name = "nomad-client"
  client_auto_join = true
  auto_advertise = true
  token   = "consul token"
}
 ####  nomad.hcl#####
 log_level = "INFO"
data_dir = "/var/run/nomad"
bind_addr = "0.0.0.0"
leave_on_terminate = true
region = "  "
datacenter = "      "
advertise {
  http = "  IP:4646"
  rpc = "  IP:4647"
  serf = "  IP:4648"
}
telemetry {
  publish_allocation_metrics = true
  publish_node_metrics       = true
}
####  server.hcl#####
server {
  enabled = true
  bootstrap_expect = 3
}

六、サービスを開始する
systemctl start nomad
  Python  json  :nomad run -output .nomad

七、ログ構成
rm -rf /etc/rsyslog.d/nomad.conf
rm -rf /etc/logrotate.d/nomad
echo ':programname, isequal, "nomad" /var/log/nomad.log' >> /etc/rsyslog.d/nomad.conf
echo '& ~' >> /etc/rsyslog.d/nomad.conf
echo '/var/log/nomad.log' >> /etc/logrotate.d/nomad
echo '{' >> /etc/logrotate.d/nomad
echo '    daily' >> /etc/logrotate.d/nomad
echo '    rotate 7' >> /etc/logrotate.d/nomad
echo '    missingok' >> /etc/logrotate.d/nomad
echo '    dateext' >> /etc/logrotate.d/nomad
echo '    copytruncate' >> /etc/logrotate.d/nomad
echo '    compress' >> /etc/logrotate.d/nomad
echo '}' >> /etc/logrotate.d/nomad
    
/bin/systemctl restart nomad
      
echo "/bin/systemctl start nomad" >> /etc/rc.local