about Nomad
Nomad is a tool that manages the machine cluster and runs the application on the cluster.
Nomad Features: Jobs that support Docker,nomad can deploy applications to the cluster using Docker drivers. Nomad installs only a single binary in Linux and does not require additional service coordination, and Nomad integrates the capabilities of the Resource manager and scheduler into one system. Multiple data centers that can be dispatched across data centers. Distributed high availability, support for multiple drivers (Docker, VMS, Java) run job, support for multiple systems (Linux, Windows, BSD, OSX). Nomad Installation
In general, install Vagrant First, and use vagrant to connect to local VirtualBox to create a local test environment. However, due to the lack of components in the local Win7 environment during the learning process, the vagrant cannot be installed and used.
So use a Linux virtual machine directly to learn. This environment uses Ubuntu16.04,docker version 17.09.0-ce.
Download the Nomad binaries and select the appropriate installation package for your system.
# wget Https://releases.hashicorp.com/nomad/0.7.0/nomad_0.7.0_linux_amd64.zip?_ga= 2.169483045.503594617.1512349197-1498904827.1511322624
Unzip the installation package and place the Nomad file under/usr/local/bin.
# unzip-o nomad_0.7.0_linux_amd64.zip-d/usr/local/bin/
# cd/usr/local/bin
# chmod +x Nomad
Terminal Input Nomad, you can see the NOMAD hint that the installation was successful.
Start Nomad
To run in a simple way, we run the Nomad agent in development mode. The development model can quickly launch server-side and client-side, test-learning nomad.
# Nomad Agent-dev ==> starting Nomad agent ... ==> nomad agent Configuration:Client:true Log level:debug Region:global (DC:DC1) server:true ==> Nomad Agent started! Log data would stream in below: [INFO] serf:EventMemberJoin:nomad.global 127.0.0.1 [INFO] nomad:starting 4 sche Duling worker (s) for [service batch _core] [info] client:using alloc directory/tmp/nomadclient599911093 [INFO] R Aft:node at 127.0.0.1:4647 [Follower] Entering Follower State [INFO] nomad:adding server Nomad.global (addr:127.0.0 .1:4647) (DC:DC1) [WARN] Fingerprint.network:Ethtool not found, checking/sys/net speed file [WARN] Raft:heartb Eat timeout reached, starting election [INFO] Raft:node at 127.0.0.1:4647 [candidate] entering candidate state [D Ebug] Raft:votes needed:1 [DEBUG] raft:vote granted. tally:1 [INFO] Raft:election won. tally:1 [INFO] Raft:node at 127.0.0.1:46[Leader] Entering Leader State [INFO] raft:disabling Enablesinglenode (bootstrap) [DEBUG] Raft:node 127.0.0.1 : 4647 updated Peer set (2): [127.0.0.1:4647] [INFO] nomad:cluster leadership acquired [DEBUG] client:applied fin Gerprints [Arch CPU host Memory storage network] [debug] client:available drivers [docker exec Java] [debug] Clie Nt:node registration Complete [DEBUG] client:updated allocations at index 1 (0 allocs) [Debug] Client:allocs: ( Added 0) (removed 0) (updated 0) (ignore 0) [DEBUG] client:state updated to Ready
As seen in the terminal output, both server and client are true, indicating that both server and client are turned on. Nomad cluster Nodes
# Nomad Node-status
ID DC Name Class Drain status
fb533fd8 DC1 yc-jumpbox <none> false ready
The output shows our node ID, which is a randomly generated UUID, its data center, node name, node category, funnel mode, and current state. We can see that our node is in the ready state.
# Nomad Server-members
Name Address Port Status Leader Protocol Build Datacenter Region
yc-jumpbox.global 10.30.0.52 4648 Alive true 2 0.7.0 DC1 Global
The output shows our own server, the running address, the health, some version information, and the data center and region. Stop Nomad Agent
You can use Ctrl-c to interrupt the agent. By default, all signals cause the agent to be forced to shut down. Nomad Job
Job is our main interactive content with Nomad. Sample Job
Enter your working directory using the NOMAD init command. It generates a Example.nomad in the current directory, which is an example of the Nomad job configuration file.
# cd/tmp
# Nomad init
Example job file written to Example.nomad
To run this job, we use the Nomad Run command.
# Nomad Run Example.nomad
==> monitoring Evaluation "13EBB66D"
evaluation triggered by job "example"
Allocation "883269BF" Created:node "e42d6f19", Group "cache"
Evaluation within Deployment: "B0a84e74"
Evaluation status changed: ' Pending ', ' complete '
==> Evaluation ' 13ebb66d ' finished with status ' complete '
To view the job status, we use the Nomad status command
# Nomad Status Example
ID = Example
Name = Example
Submit Date = 12/05/17 10:58:40 UTC
Type = Service
Priority =
datacenters = DC1
Status = running
periodic = False
parameterized = False
Summary
Task Group Queued starting Running Failed Complete Lost
cache 0 0 1 0 0 0
Latest Deployment
ID = B0a84e74
Status = successful
Description = Deployment completed successfully
Deployed
Task Group desired Placed Healthy unhealthy
cache 1 1 1 0
Allocations
ID Node ID Task Group Version desired Status Created
at 883269BF e42d6f19 cache 0 run running 12/05/17 10:58:40 UTC
To check the job assignment, we use the Nomad alloc-status command.
# Nomad alloc-status 83269BF id = 83269bf Eval id = 3ebb66d Name = EXAMPLE.CAC HE[0] Node id = e42d6f19 Job id = Example Job Version = 0 Client Status = running C Lient Description = <none> desired Status = run desired Description = <none> Created at = 12/05 /17 10:58:49 UTC Deployment ID = b0a84e74 Deployment health = Healthy Task "Redis" is "Running" task Resources CP U Memory Disk IOPS Addresses 8/500 MHz 6.3 mib/256 MiB 0 db:127.0.0.1:22672 Task Ev
ents:started at = 12/05/17 10:58:49 UTC finished at = n/A total restarts = 0 Last Restart = N/A recent Events: Time Type Description 10/31/17 22:58:49 UTC Started Task Started by client 10/31/17 22:58:40 UTC Driver downloading image redis:3.2 10/31/17 22:58:40 UTC task Setup Building task Directory 10/31/17 22:58:40 UTC Received Task REceived by client
To view the job log, we use the Nomad Logs command. Note the parameters that follow the logs are UUID and task names. The UUID can be obtained through the Nomad status Example command, and the task name is defined in the Example.nomad configuration file.
# Nomad Logs 883269bf Redis
_._
_.-' __ '-._
_.-' . `_. '' -._