github.com/iqoqo/nomad@v0.11.3-0.20200911112621-d7021c74d101/website/pages/docs/install/production/deployment-guide.mdx (about)

     1  ---
     2  layout: docs
     3  page_title: Nomad Deployment Guide
     4  sidebar_title: Reference Install Guide
     5  description: |-
     6    This deployment guide covers the steps required to install and
     7    configure a single HashiCorp Nomad cluster as defined in the
     8    Nomad Reference Architecture
     9  ea_version: 0.9
    10  ---
    11  
    12  # Nomad Reference Install Guide
    13  
    14  This deployment guide covers the steps required to install and configure a single HashiCorp Nomad cluster as defined in the [Nomad Reference Architecture](/docs/install/production/reference-architecture).
    15  
    16  These instructions are for installing and configuring Nomad on Linux hosts running the systemd system and service manager.
    17  
    18  ## Reference Material
    19  
    20  This deployment guide is designed to work in combination with the [Nomad Reference Architecture](/docs/install/production/reference-architecture) and [Consul Deployment Guide](https://www.consul.io/docs/guides/deployment-guide.html). Although it is not a strict requirement to follow the Nomad Reference Architecture, please ensure you are familiar with the overall architecture design. For example, installing Nomad server agents on multiple physical or virtual (with correct anti-affinity) hosts for high-availability.
    21  
    22  ## Overview
    23  
    24  To provide a highly-available single cluster architecture, we recommend Nomad server agents be deployed to more than one host, as shown in the [Nomad Reference Architecture](/docs/install/production/reference-architecture).
    25  
    26  ![Reference diagram](/img/nomad_reference_diagram.png)
    27  
    28  These setup steps should be completed on all Nomad hosts:
    29  
    30  - [Download Nomad](#download-nomad)
    31  - [Install Nomad](#install-nomad)
    32  - [Configure systemd](#configure-systemd)
    33  - [Configure Nomad](#configure-nomad)
    34  - [Start Nomad](#start-nomad)
    35  
    36  ## Download Nomad
    37  
    38  Precompiled Nomad binaries are available for download at [https://releases.hashicorp.com/nomad/](https://releases.hashicorp.com/nomad/) and Nomad Enterprise binaries are available for download by following the instructions made available to HashiCorp Enterprise customers.
    39  
    40  ```text
    41  export NOMAD_VERSION="0.9.0"
    42  curl --silent --remote-name https://releases.hashicorp.com/nomad/${NOMAD_VERSION}/nomad_${NOMAD_VERSION}_linux_amd64.zip
    43  ```
    44  
    45  You may perform checksum verification of the zip packages using the SHA256SUMS and SHA256SUMS.sig files available for the specific release version. HashiCorp provides [a guide on checksum verification](https://www.hashicorp.com/security) for precompiled binaries.
    46  
    47  ## Install Nomad
    48  
    49  Unzip the downloaded package and move the `nomad` binary to `/usr/local/bin/`. Check `nomad` is available on the system path.
    50  
    51  ```text
    52  unzip nomad_${NOMAD_VERSION}_linux_amd64.zip
    53  sudo chown root:root nomad
    54  sudo mv nomad /usr/local/bin/
    55  nomad version
    56  ```
    57  
    58  The `nomad` command features opt-in autocompletion for flags, subcommands, and arguments (where supported). Enable autocompletion.
    59  
    60  ```text
    61  nomad -autocomplete-install
    62  complete -C /usr/local/bin/nomad nomad
    63  ```
    64  
    65  Create a data directory for Nomad.
    66  
    67  ```text
    68  sudo mkdir --parents /opt/nomad
    69  ```
    70  
    71  ## Configure systemd
    72  
    73  Systemd uses [documented sane defaults](https://www.freedesktop.org/software/systemd/man/systemd.directives.html) so only non-default values must be set in the configuration file.
    74  
    75  Create a Nomad service file at `/etc/systemd/system/nomad.service`.
    76  
    77  ```text
    78  sudo touch /etc/systemd/system/nomad.service
    79  ```
    80  
    81  Add this configuration to the Nomad service file:
    82  
    83  ```text
    84  [Unit]
    85  Description=Nomad
    86  Documentation=https://nomadproject.io/docs/
    87  Wants=network-online.target
    88  After=network-online.target
    89  
    90  [Service]
    91  ExecReload=/bin/kill -HUP $MAINPID
    92  ExecStart=/usr/local/bin/nomad agent -config /etc/nomad.d
    93  KillMode=process
    94  KillSignal=SIGINT
    95  LimitNOFILE=infinity
    96  LimitNPROC=infinity
    97  Restart=on-failure
    98  RestartSec=2
    99  StartLimitBurst=3
   100  StartLimitIntervalSec=10
   101  TasksMax=infinity
   102  
   103  [Install]
   104  WantedBy=multi-user.target
   105  ```
   106  
   107  The following parameters are set for the `[Unit]` stanza:
   108  
   109  - [`Description`](https://www.freedesktop.org/software/systemd/man/systemd.unit.html#Description=) - Free-form string describing the nomad service
   110  - [`Documentation`](https://www.freedesktop.org/software/systemd/man/systemd.unit.html#Documentation=) - Link to the nomad documentation
   111  - [`Wants`](https://www.freedesktop.org/software/systemd/man/systemd.unit.html#Wants=) - Configure a dependency on the network service
   112  - [`After`](https://www.freedesktop.org/software/systemd/man/systemd.unit.html#After=) - Configure an ordering dependency on the network service being started before the nomad service
   113  
   114  The following parameters are set for the `[Service]` stanza:
   115  
   116  - [`ExecReload`](https://www.freedesktop.org/software/systemd/man/systemd.service.html#ExecReload=) - Send Nomad a `SIGHUP` signal to trigger a configuration reload
   117  - [`ExecStart`](https://www.freedesktop.org/software/systemd/man/systemd.service.html#ExecStart=) - Start Nomad with the `agent` argument and path to a directory of configuration files
   118  - [`KillMode`](https://www.freedesktop.org/software/systemd/man/systemd.kill.html#KillMode=) - Treat nomad as a single process
   119  - [`LimitNOFILE`, `LimitNPROC`](https://www.freedesktop.org/software/systemd/man/systemd.exec.html#Process%20Properties) - Disable limits for file descriptors and processes
   120  - [`RestartSec`](https://www.freedesktop.org/software/systemd/man/systemd.service.html#RestartSec=) - Restart nomad after 2 seconds of it being considered 'failed'
   121  - [`Restart`](https://www.freedesktop.org/software/systemd/man/systemd.service.html#Restart=) - Restart nomad unless it returned a clean exit code
   122  - [`StartLimitBurst`, `StartLimitIntervalSec`](https://www.freedesktop.org/software/systemd/man/systemd.unit.html#StartLimitIntervalSec=interval) - Configure unit start rate limiting
   123  - [`TasksMax`](https://www.freedesktop.org/software/systemd/man/systemd.resource-control.html#TasksMax=N) - Disable task limits (only available in systemd >= 226)
   124  
   125  The following parameters are set for the `[Install]` stanza:
   126  
   127  - [`WantedBy`](https://www.freedesktop.org/software/systemd/man/systemd.unit.html#WantedBy=) - Creates a weak dependency on nomad being started by the multi-user run level
   128  
   129  ## Configure Nomad
   130  
   131  Nomad uses [documented sane defaults](/docs/configuration) so only non-default values must be set in the configuration file. Configuration can be read from multiple files and is loaded in lexical order. See the [full description](/docs/configuration) for more information about configuration loading and merge semantics.
   132  
   133  Some configuration settings are common to both server and client Nomad agents, while some configuration settings must only exist on one or the other. Follow the [common configuration](#common-configuration) guidance on all hosts and then the specific guidance depending on whether you are configuring a Nomad [server](#server-configuration) or [client](#client-configuration).
   134  
   135  - [Common Nomad configuration](#common-configuration)
   136  - [Configure a Nomad server](#server-configuration)
   137  - [Configure a Nomad client](#client-configuration)
   138  
   139  ### Common configuration
   140  
   141  Create a configuration file at `/etc/nomad.d/nomad.hcl`:
   142  
   143  ```text
   144  sudo mkdir --parents /etc/nomad.d
   145  sudo chmod 700 /etc/nomad.d
   146  sudo touch /etc/nomad.d/nomad.hcl
   147  ```
   148  
   149  Add this configuration to the `nomad.hcl` configuration file:
   150  
   151  ~> **Note:** Replace the `datacenter` parameter value with the identifier you will use for the datacenter this Nomad cluster is deployed in.
   152  
   153  ```hcl
   154  datacenter = "dc1"
   155  data_dir = "/opt/nomad"
   156  ```
   157  
   158  - [`datacenter`](/docs/configuration#datacenter) - The datacenter in which the agent is running.
   159  - [`data_dir`](/docs/configuration#data_dir) - The data directory for the agent to store state.
   160  
   161  ### Server configuration
   162  
   163  Create a configuration file at `/etc/nomad.d/server.hcl`:
   164  
   165  ```text
   166  sudo touch /etc/nomad.d/server.hcl
   167  ```
   168  
   169  Add this configuration to the `server.hcl` configuration file:
   170  
   171  ~> **NOTE** Replace the `bootstrap_expect` value with the number of Nomad servers you will use; three or five [is recommended](/docs/internals/consensus#deployment-table).
   172  
   173  ```hcl
   174  server {
   175    enabled = true
   176    bootstrap_expect = 3
   177  }
   178  ```
   179  
   180  - [`server`](/docs/configuration/server#enabled) - Specifies if this agent should run in server mode. All other server options depend on this value being set.
   181  - [`bootstrap_expect`](/docs/configuration/server#bootstrap_expect) - The number of expected servers in the cluster. Either this value should not be provided or the value must agree with other servers in the cluster.
   182  
   183  ### Client configuration
   184  
   185  Create a configuration file at `/etc/nomad.d/client.hcl`:
   186  
   187  ```text
   188  sudo touch /etc/nomad.d/client.hcl
   189  ```
   190  
   191  Add this configuration to the `client.hcl` configuration file:
   192  
   193  ```hcl
   194  client {
   195    enabled = true
   196  }
   197  ```
   198  
   199  - [`client`](/docs/configuration/client#enabled) - Specifies if this agent should run in client mode. All other client options depend on this value being set.
   200  
   201  ~> **NOTE** The [`options`](/docs/configuration/client#options-parameters) parameter can be used to enable or disable specific configurations on Nomad clients, unique to your use case requirements.
   202  
   203  ### ACL configuration
   204  
   205  The [Access Control](https://learn.hashicorp.com/nomad?track=acls#operations-and-development) guide provides instructions on configuring and enabling ACLs.
   206  
   207  ### TLS configuration
   208  
   209  Securing Nomad's cluster communication with mutual TLS (mTLS) is recommended for production deployments and can even ease operations by preventing mistakes and misconfigurations. Nomad clients and servers should not be publicly accessible without mTLS enabled.
   210  
   211  The [Securing Nomad with TLS](https://learn.hashicorp.com/nomad/transport-security/enable-tls) guide provides instructions on configuring and enabling TLS.
   212  
   213  ## Start Nomad
   214  
   215  Enable and start Nomad using the systemctl command responsible for controlling systemd managed services. Check the status of the nomad service using systemctl.
   216  
   217  ```text
   218  sudo systemctl enable nomad
   219  sudo systemctl start nomad
   220  sudo systemctl status nomad
   221  ```
   222  
   223  ## Next Steps
   224  
   225  - Read [Outage Recovery](https://learn.hashicorp.com/nomad/operating-nomad/outage) to learn
   226    the steps required to recover from a Nomad cluster outage.
   227  - Read [Autopilot](https://learn.hashicorp.com/nomad/operating-nomad/autopilot) to learn about
   228    features in Nomad 0.8 to allow for automatic operator-friendly
   229    management of Nomad servers.