Merge branch '9309-centos-7-install-guide-wip'
[arvados.git] / doc / install / install-compute-node.html.textile.liquid
1 ---
2 layout: default
3 navsection: installguide
4 title: Install a compute node
5 ...
6
7 h2. Install dependencies
8
9 First, "add the appropriate package repository for your distribution":{{ site.baseurl }}/install/install-manual-prerequisites.html#repos.
10
11 {% include 'note_python_sc' %}
12
13 On CentOS 6 and RHEL 6:
14
15 <notextile>
16 <pre><code>~$ <span class="userinput">sudo yum install perl python27-python-virtualenv fuse python27-python-arvados-python-client python27-python-arvados-fuse crunchrunner crunchstat arvados-docker-cleaner iptables ca-certificates</span>
17 </code></pre>
18 </notextile>
19
20 On other Red Hat-based systems:
21
22 <notextile>
23 <pre><code>~$ <span class="userinput">echo 'exclude=python2-llfuse' | sudo tee -a /etc/yum.conf</span>
24 ~$ <span class="userinput">sudo yum install perl python-virtualenv fuse python-arvados-python-client python-arvados-fuse crunchrunner crunchstat arvados-docker-cleaner iptables ca-certificates</span>
25 </code></pre>
26 </notextile>
27
28 On Debian-based systems:
29
30 <notextile>
31 <pre><code>~$ <span class="userinput">sudo apt-get install perl python-virtualenv fuse python-arvados-python-client python-arvados-fuse crunchrunner crunchstat arvados-docker-cleaner iptables ca-certificates</span>
32 </code></pre>
33 </notextile>
34
35 h2. Install Docker
36
37 Compute nodes must have Docker installed to run jobs inside containers.  This requires a relatively recent version of Linux (at least upstream version 3.10, or a distribution version with the appropriate patches backported).  Follow the "Docker Engine installation documentation":https://docs.docker.com/ for your distribution.
38
39 For Debian-based systems, the Arvados package repository includes a backported @docker.io@ package with a known-good version you can install.
40
41 h2. Configure Docker
42
43 Crunch runs jobs in Docker containers with relatively little configuration.  You may need to start the Docker daemon with specific options to make sure these jobs run smoothly in your environment.  This section highlights options that are useful to most installations.  Refer to the "Docker daemon reference":https://docs.docker.com/reference/commandline/daemon/ for complete information about all available options.
44
45 The best way to configure these options varies by distribution.
46
47 * If you're using our backported @docker.io@ package, you can list these options in the @DOCKER_OPTS@ setting in @/etc/default/docker.io@.
48 * If you're using another Debian-based package, you can list these options in the @DOCKER_OPTS@ setting in @/etc/default/docker@.
49 * On Red Hat-based distributions, you can list these options in the @other_args@ setting in @/etc/sysconfig/docker@.
50
51 h3. Default ulimits
52
53 Docker containers inherit ulimits from the Docker daemon.  However, the ulimits for a single Unix daemon may not accommodate a long-running Crunch job.  You may want to increase default limits for compute jobs by passing @--default-ulimit@ options to the Docker daemon.  For example, to allow jobs to open 10,000 files, set @--default-ulimit nofile=10000:10000@.
54
55 h3. DNS
56
57 Your containers must be able to resolve the hostname in the ARVADOS_API_HOST environment variable (provided by the Crunch dispatcher) and any hostnames returned in Keep service records.  If these names are not in public DNS records, you may need to set a DNS resolver for the containers by specifying the @--dns@ address with the IP address of an appropriate nameserver.  You may specify this option more than once to use multiple nameservers.
58
59 h2. Set up SLURM
60
61 Install SLURM following "the same process you used to install the Crunch dispatcher":install-crunch-dispatch.html#slurm.
62
63 h2. Copy configuration files from the dispatcher (API server)
64
65 The @slurm.conf@ and @/etc/munge/munge.key@ files need to be identical across the dispatcher and all compute nodes. Copy the files you created in the "Install the Crunch dispatcher":install-crunch-dispatch.html step to this compute node.
66
67 h2. Configure FUSE
68
69 Install this file as @/etc/fuse.conf@:
70
71 <notextile>
72 <pre>
73 # Set the maximum number of FUSE mounts allowed to non-root users.
74 # The default is 1000.
75 #
76 #mount_max = 1000
77
78 # Allow non-root users to specify the 'allow_other' or 'allow_root'
79 # mount options.
80 #
81 user_allow_other
82 </pre>
83 </notextile>
84
85 h2. Configure the Docker cleaner
86
87 The arvados-docker-cleaner program removes least recently used docker images as needed to keep disk usage below a configured limit.
88
89 {% include 'notebox_begin' %}
90 This also removes all containers as soon as they exit, as if they were run with @docker run --rm@. If you need to debug or inspect containers after they stop, temporarily stop arvados-docker-cleaner or run it with @--remove-stopped-containers never@.
91 {% include 'notebox_end' %}
92
93 Install runit to supervise the Docker cleaner daemon.  {% include 'install_runit' %}
94
95 Configure runit to run the image cleaner using a suitable quota for your compute nodes and workload:
96
97 <notextile>
98 <pre><code>~$ <span class="userinput">sudo mkdir -p /etc/sv</span>
99 ~$ <span class="userinput">cd /etc/sv</span>
100 /etc/sv$ <span class="userinput">sudo mkdir arvados-docker-cleaner; cd arvados-docker-cleaner</span>
101 /etc/sv/arvados-docker-cleaner$ <span class="userinput">sudo mkdir log log/main</span>
102 /etc/sv/arvados-docker-cleaner$ <span class="userinput">sudo sh -c 'cat &gt;log/run' &lt;&lt;'EOF'
103 #!/bin/sh
104 exec svlogd -tt main
105 EOF</span>
106 /etc/sv/arvados-docker-cleaner$ <span class="userinput">sudo sh -c 'cat &gt;run' &lt;&lt;'EOF'
107 #!/bin/sh
108 if [ -d /opt/rh/python33 ]; then
109   source scl_source enable python33
110 fi
111 exec python3 -m arvados_docker.cleaner --quota <b>50G</b>
112 EOF</span>
113 /etc/sv/arvados-docker-cleaner$ <span class="userinput">sudo chmod +x run log/run</span>
114 /etc/sv/arvados-docker-cleaner$ <span class="userinput">sudo ln -s "$(pwd)" /etc/service/</span>
115 </code></pre>
116 </notextile>
117
118 If you are using a different daemon supervisor, or if you want to test the daemon in a terminal window, an equivalent shell command to run arvados-docker-cleaner is:
119
120 <notextile>
121 <pre><code><span class="userinput">python3 -m arvados_docker.cleaner --quota <b>50G</b></span>
122 </code></pre>
123 </notextile>
124
125 h2. Add a Crunch user account
126
127 Create a Crunch user account, and add it to the @fuse@ and @docker@ groups so it can use those tools:
128
129 <notextile>
130 <pre><code>~$ <span class="userinput">sudo useradd --groups fuse,docker crunch</span>
131 </code></pre>
132 </notextile>
133
134 The crunch user should have the same UID, GID, and home directory across all compute nodes and the dispatcher (API server).
135
136 h2. Tell the API server about this compute node
137
138 Load your API superuser token on the compute node:
139
140 <notextile>
141 <pre><code>
142 ~$ <span class="userinput">HISTIGNORE=$HISTIGNORE:'export ARVADOS_API_TOKEN=*'</span>
143 ~$ <span class="userinput">export ARVADOS_API_TOKEN=@your-superuser-token@</span>
144 ~$ <span class="userinput">export ARVADOS_API_HOST=@uuid_prefix.your.domain@</span>
145 ~$ <span class="userinput">unset ARVADOS_API_HOST_INSECURE</span>
146 </code>
147 </pre>
148 </notextile>
149
150 Then execute this script to create a compute node object, and set up a cron job to have the compute node ping the API server every five minutes:
151
152 <notextile>
153 <pre><code>
154 #!/bin/bash
155 set -e
156 if ! test -f /root/node.json ; then
157     python - &lt;&lt;EOF
158 import arvados, json, socket
159 fqdn = socket.getfqdn()
160 hostname, _, domain = fqdn.partition('.')
161 node = arvados.api('v1').nodes().create(body={'hostname': hostname, 'domain': domain}).execute()
162 with open('/root/node.json', 'w') as node_file:
163     json.dump(node, node_file, indent=2)
164 EOF
165
166     # Make sure /dev/fuse permissions are correct (the device appears after fuse is loaded)
167     chmod 1660 /dev/fuse && chgrp fuse /dev/fuse
168 fi
169
170 UUID=`grep \"uuid\" /root/node.json  |cut -f4 -d\"`
171 PING_SECRET=`grep \"ping_secret\" /root/node.json  |cut -f4 -d\"`
172
173 if ! test -f /etc/cron.d/node_ping ; then
174     echo "*/5 * * * * root /usr/bin/curl -k -d ping_secret=$PING_SECRET https://$ARVADOS_API_HOST/arvados/v1/nodes/$UUID/ping" > /etc/cron.d/node_ping
175 fi
176
177 /usr/bin/curl -k -d ping_secret=$PING_SECRET https://$ARVADOS_API_HOST/arvados/v1/nodes/$UUID/ping?ping_secret=$PING_SECRET
178 </code>
179 </pre>
180 </notextile>
181
182 And remove your token from the environment:
183
184 <notextile>
185 <pre><code>
186 ~$ <span class="userinput">unset ARVADOS_API_TOKEN</span>
187 ~$ <span class="userinput">unset ARVADOS_API_HOST</span>
188 </code>
189 </pre>
190 </notextile>