nomad安装

佐手、 提交于 2020-08-10 01:28:34

一、环境要求

操作系统版本: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 <job>.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
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!