本文共 2988 字,大约阅读时间需要 9 分钟。
一、环境要求
操作系统版本: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/nomadKillSignal=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 = trueregion = "区域"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 = trueregion = "区域"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.confrm -rf /etc/logrotate.d/nomadecho ':programname, isequal, "nomad" /var/log/nomad.log' >> /etc/rsyslog.d/nomad.confecho '& ~' >> /etc/rsyslog.d/nomad.confecho '/var/log/nomad.log' >> /etc/logrotate.d/nomadecho '{' >> /etc/logrotate.d/nomadecho ' daily' >> /etc/logrotate.d/nomadecho ' rotate 7' >> /etc/logrotate.d/nomadecho ' missingok' >> /etc/logrotate.d/nomadecho ' dateext' >> /etc/logrotate.d/nomadecho ' copytruncate' >> /etc/logrotate.d/nomadecho ' compress' >> /etc/logrotate.d/nomadecho '}' >> /etc/logrotate.d/nomad重启服务/bin/systemctl restart nomad配置开机启动echo "/bin/systemctl start nomad" >> /etc/rc.local
转载于:https://blog.51cto.com/aaronsa/2064884