nomad安装

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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 <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

以上是关于nomad安装的主要内容,如果未能解决你的问题,请参考以下文章

nomad 集群搭建

nomad拖拽和移动有啥区别

滑板nomad和prd那个好用

为 Nomad 客户端启用 ACL 的目的

如何将两个 docker 容器与 nomad 连接

重塑 Prometheus 的 Nomad 指标