码迷,mamicode.com
首页 > 其他好文 > 详细

nomad安装

时间:2018-01-25 11:02:28      阅读:269      评论:0      收藏:0      [点我收藏+]

标签:cal   python   sign   lease   日志   配置   logrotate   emd   etc   

一、环境要求

操作系统版本: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安装

标签:cal   python   sign   lease   日志   配置   logrotate   emd   etc   

原文地址:http://blog.51cto.com/aaronsa/2064884

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!