|
1 | | -Set Up Elasticsearch |
2 | | -==================== |
3 | | - |
4 | | -Zammad's search function can be powered by Elasticsearch (which is **highly |
5 | | -recommended**). |
| 1 | +Elasticsearch |
| 2 | +============= |
6 | 3 |
|
7 | 4 | .. include:: /install/includes/hosted-services.rst |
8 | 5 |
|
9 | | -.. note:: Some steps may be required depending on your Elasticsearch version and |
10 | | - configuration. See remarks in the configuration steps below. |
11 | | - |
12 | | -Step 1: Installation |
13 | | --------------------- |
14 | | - |
15 | | -Elasticsearch offers different versions. Currently, the versions 7, 8 and 9 |
16 | | -are supported by Zammad. For installation instructions, you should first and |
17 | | -foremost follow |
18 | | -`Elastic's installation documentation <https://www.elastic.co/docs/deploy-manage/deploy/self-managed/installing-elasticsearch>`_. |
19 | | -Use the dropdown in the top right corner to choose which version you want to |
20 | | -install. |
21 | | - |
22 | | -However, if you want go with Elasticsearch 7 (which is slightly easier to |
23 | | -install), you can find the consolidated installation steps below. |
24 | | -Be aware that the maintenance of version 7 might be stopped earlier than for |
25 | | -later versions, which also come with some additional security features. |
26 | | - |
27 | | -.. hint:: If you are installing Elasticsearch 8 or newer and want to follow our |
28 | | - standard configuration in step 2, make sure to copy/save the password which |
29 | | - is shown while installing Elasticsearch. |
30 | | - |
31 | | -.. tabs:: |
32 | | - |
33 | | - .. tab:: Ubuntu/Debian |
34 | | - |
35 | | - .. code-block:: console |
36 | | -
|
37 | | - $ sudo apt install apt-transport-https sudo wget curl gnupg |
38 | | -
|
39 | | - .. code-block:: console |
40 | | -
|
41 | | - $ curl -fsSL https://artifacts.elastic.co/GPG-KEY-elasticsearch | \ |
42 | | - gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/elasticsearch.gpg> /dev/null |
43 | | -
|
44 | | - .. tabs:: |
45 | | - |
46 | | - .. tab:: Deb822 format |
47 | | - |
48 | | - In this tab, the repository is added by using the |
49 | | - `deb822 format <https://repolib.readthedocs.io/en/latest/deb822-format.html>`_. |
50 | | - If you run a distribution which doesn't support it, use the legacy |
51 | | - format instead. |
52 | | - |
53 | | - .. code-block:: console |
54 | | -
|
55 | | - $ printf "Types: deb |
56 | | - URIs: https://artifacts.elastic.co/packages/7.x/apt |
57 | | - Suites: stable |
58 | | - Components: main |
59 | | - Signed-By: /etc/apt/trusted.gpg.d/elasticsearch.gpg" | \ |
60 | | - sudo tee /etc/apt/sources.list.d/elastic-7.x.sources > /dev/null |
61 | | -
|
62 | | - .. tab:: Legacy format |
63 | | - |
64 | | - .. code-block:: console |
65 | | -
|
66 | | - $ echo "deb [signed-by=/etc/apt/trusted.gpg.d/elasticsearch.gpg] https://artifacts.elastic.co/packages/7.x/apt stable main"| \ |
67 | | - sudo tee -a /etc/apt/sources.list.d/elastic-7.x.list > /dev/null |
68 | | -
|
69 | | - .. code-block:: console |
70 | | -
|
71 | | - $ sudo apt update |
72 | | -
|
73 | | - .. code-block:: console |
74 | | -
|
75 | | - $ sudo apt install elasticsearch |
76 | | -
|
77 | | - .. code-block:: console |
78 | | -
|
79 | | - $ /usr/share/elasticsearch/bin/elasticsearch-plugin install ingest-attachment |
80 | | -
|
81 | | - .. tab:: CentOS |
82 | | - |
83 | | - .. code-block:: console |
84 | | -
|
85 | | - $ sudo rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch |
86 | | -
|
87 | | - .. code-block:: console |
88 | | -
|
89 | | - $ echo "[elasticsearch-7.x] |
90 | | - name=Elasticsearch repository for 7.x packages |
91 | | - baseurl=https://artifacts.elastic.co/packages/7.x/yum |
92 | | - gpgcheck=1 |
93 | | - gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch |
94 | | - enabled=1 |
95 | | - autorefresh=1 |
96 | | - type=rpm-md"| sudo tee /etc/yum.repos.d/elasticsearch-7.x.repo |
97 | | -
|
98 | | - .. code-block:: console |
99 | | -
|
100 | | - $ sudo yum install -y elasticsearch |
101 | | -
|
102 | | - .. code-block:: console |
103 | | -
|
104 | | - $ /usr/share/elasticsearch/bin/elasticsearch-plugin install ingest-attachment |
105 | | -
|
106 | | - .. tab:: OpenSUSE |
107 | | - |
108 | | - .. code-block:: console |
109 | | -
|
110 | | - $ sudo rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch |
111 | | -
|
112 | | - .. code-block:: console |
113 | | -
|
114 | | - $ echo "[elasticsearch-7.x] |
115 | | - name=Elasticsearch repository for 7.x packages |
116 | | - baseurl=https://artifacts.elastic.co/packages/7.x/yum |
117 | | - gpgcheck=1 |
118 | | - gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch |
119 | | - enabled=1 |
120 | | - autorefresh=1 |
121 | | - type=rpm-md"| sudo tee /etc/zypp/repos.d/elasticsearch-7.x.repo |
122 | | -
|
123 | | - .. code-block:: console |
124 | | -
|
125 | | - $ sudo zypper install elasticsearch |
126 | | -
|
127 | | - .. code-block:: console |
128 | | -
|
129 | | - $ /usr/share/elasticsearch/bin/elasticsearch-plugin install ingest-attachment |
130 | | -
|
131 | | - .. tab:: Direct Download |
132 | | - |
133 | | - Find the latest release on the |
134 | | - `downloads page <https://www.elastic.co/downloads/elasticsearch>`_, |
135 | | - or see the |
136 | | - `installation guide <https://www.elastic.co/guide/en/elasticsearch/reference/current/install-elasticsearch.html>`_ |
137 | | - for in-depth instructions. Ensure to also install the fitting |
138 | | - (and mandatory!) attachment plugin for Elasticsearch, if installing |
139 | | - version 7. |
140 | | - |
141 | | - Install the attachment plugin: |
142 | | - |
143 | | - .. code-block:: console |
144 | | -
|
145 | | - $ /usr/share/elasticsearch/bin/elasticsearch-plugin install ingest-attachment |
146 | | -
|
147 | | - Increase the virtual memory map limit: |
148 | | - |
149 | | - .. code-block:: console |
150 | | -
|
151 | | - $ sudo sysctl -w vm.max_map_count=262144 |
152 | | -
|
153 | | -After you installed Elasticsearch and its attachment plugin, |
154 | | -ensure to enable it by default and start it. |
155 | | - |
156 | | -.. code-block:: console |
157 | | -
|
158 | | - $ sudo systemctl start elasticsearch |
159 | | -
|
160 | | -.. code-block:: console |
161 | | -
|
162 | | - $ sudo systemctl enable elasticsearch |
163 | | -
|
164 | | -Step 2: Configuration |
165 | | ---------------------- |
166 | | - |
167 | | -Install ingest-plugin (only for Elasticsearch <= 7) |
168 | | - .. code-block:: console |
169 | | -
|
170 | | - $ /usr/share/elasticsearch/bin/elasticsearch-plugin install ingest-attachment |
171 | | -
|
172 | | -Increase virtual memory map limit |
173 | | - .. code-block:: console |
174 | | -
|
175 | | - $ sudo sysctl -w vm.max_map_count=262144 |
176 | | -
|
177 | | -Adjust ``/etc/elasticsearch/elasticsearch.yml`` |
178 | | - We use the following settings to optimize the performance of our Elasticsearch |
179 | | - servers. You may want to append that to your ``elasticsearch.yml`` as a useful |
180 | | - basic configuration. |
181 | | - |
182 | | - .. code-block:: text |
183 | | -
|
184 | | - # /etc/elasticsearch/elasticsearch.yml |
185 | | -
|
186 | | - # Tickets above this size (articles + attachments + metadata) |
187 | | - # may fail to be properly indexed (Default: 100mb). |
188 | | - # |
189 | | - # When Zammad sends tickets to Elasticsearch for indexing, |
190 | | - # it bundles together all the data on each individual ticket |
191 | | - # and issues a single HTTP request for it. |
192 | | - # Payloads exceeding this threshold will be truncated. |
193 | | - # |
194 | | - # Performance may suffer if it is set too high. |
195 | | - http.max_content_length: 400mb |
196 | | -
|
197 | | - # Allows the engine to generate larger (more complex) search queries. |
198 | | - # Elasticsearch will raise an error or deprecation notice if this value is too low, |
199 | | - # but setting it too high can overload system resources (Default: 1024). |
200 | | - # |
201 | | - # Available in version 6.6+ only. |
202 | | - indices.query.bool.max_clause_count: 2000 |
203 | | -
|
204 | | -Enable and start Elasticsearch |
205 | | - .. code-block:: console |
206 | | -
|
207 | | - $ sudo systemctl start elasticsearch |
208 | | -
|
209 | | - .. code-block:: console |
210 | | -
|
211 | | - $ sudo systemctl enable elasticsearch |
212 | | -
|
213 | | -.. _configure_zammad_with_elasticsearch: |
214 | | - |
215 | | -Step 3: Connecting Zammad with Elasticsearch |
216 | | --------------------------------------------- |
217 | | - |
218 | | -Before proceeding here, make sure to install Zammad before running below |
219 | | -commands, as this will fail otherwise. |
220 | | - |
221 | | -* Install from :doc:`package <package>` |
222 | | -* Install with :doc:`Docker <docker-compose>` (the default stack already includes Elasticsearch) |
223 | | - |
224 | | -.. note:: |
225 | | - This guide uses the ``zammad run`` command prefix in command line examples. |
226 | | - This prefix is only applicable to package installations. |
227 | | - Check the :doc:`console guide </admin/console>` for more information. |
228 | | - |
229 | | -Elasticsearch URL |
230 | | - Set the Elasticsearch server address; adapt it to your scenario. |
231 | | - |
232 | | - Elasticsearch 7: |
233 | | - |
234 | | - .. code-block:: console |
235 | | -
|
236 | | - $ zammad run rails r "Setting.set('es_url', 'http://localhost:9200')" |
237 | | -
|
238 | | - Elasticsearch 8+: |
239 | | - |
240 | | - .. code-block:: console |
241 | | -
|
242 | | - $ zammad run rails r "Setting.set('es_url', 'https://localhost:9200')" |
243 | | -
|
244 | | -
|
245 | | -Elasticsearch user and password (only for Elasticsearch >= 8) |
246 | | - Now you need your password which was shown during the installation. |
247 | | - |
248 | | - Set Elasticsearch user: |
249 | | - |
250 | | - .. code-block:: console |
251 | | -
|
252 | | - $ zammad run rails r "Setting.set('es_user', 'elastic')" |
253 | | -
|
254 | | - Set Elasticsearch password: |
255 | | - |
256 | | - .. code-block:: console |
257 | | -
|
258 | | - $ zammad run rails r "Setting.set('es_password', '<password>')" |
259 | | -
|
260 | | -Add certificate to Zammad (only for Elasticsearch >= 8) |
261 | | - Show and copy the auto-generated certificate from Elasticsearch and add it |
262 | | - to Zammad. Make sure to copy/paste the delimiters |
263 | | - (e.g. ``-----BEGIN CERTIFICATE-----``) too. |
264 | | - |
265 | | - .. code-block:: console |
266 | | -
|
267 | | - $ sudo cat /etc/elasticsearch/certs/http_ca.crt |
268 | | -
|
269 | | - Go to the admin panel of Zammad and add your copied certificate under |
270 | | - :admin-docs:`SSL Certificates </settings/security/ssl-certificates.html>`. |
271 | | - |
272 | | - .. figure:: /images/install/elasticsearch/admin-certificate-management.png |
273 | | - :alt: Screenshot shows certificate management in Zammad's admin panel |
274 | | - :align: center |
275 | | - |
276 | | -.. _es-rebuild-searchindex: |
277 | | - |
278 | | -Build/rebuild the searchindex |
279 | | - .. hint:: |
280 | | - - The rebuild may take many hours or even days, if a lot of data is |
281 | | - already present in a productive environment. However, you can safely |
282 | | - run this during operating times without the risk of loosing data. As a |
283 | | - downside, it could lead to reduced performance and that some data may |
284 | | - not be shown in search results. |
285 | | - - Consider specifying a number of CPU cores to be used for the rebuild |
286 | | - (see example below). |
287 | | - |
288 | | - Without specifying CPU cores: |
289 | | - |
290 | | - .. code-block:: console |
291 | | -
|
292 | | - $ zammad run rake zammad:searchindex:rebuild |
293 | | -
|
294 | | - Example with specifying 8 CPU cores: |
295 | | - |
296 | | - .. code-block:: console |
297 | | -
|
298 | | - $ zammad run rake zammad:searchindex:rebuild[8] |
299 | | -
|
300 | | -
|
301 | | -Optional settings |
302 | | ------------------ |
303 | | - |
304 | | -We collected some useful settings you may want to apply. For further |
305 | | -information please have a look at |
306 | | -`Elastic's documentation <https://www.elastic.co/guide/en/elasticsearch/reference/current/index.html>`_. |
307 | | - |
308 | | -.. tabs:: |
309 | | - |
310 | | - .. tab:: Index namespacing |
311 | | - |
312 | | - Useful when connecting multiple services or Zammad instances |
313 | | - to a single Elasticsearch server (to prevent name collisions during indexing). |
314 | | - |
315 | | - .. code-block:: console |
316 | | -
|
317 | | - $ zammad run rails r "Setting.set('es_index', Socket.gethostname.downcase + '_zammad')" |
318 | | -
|
319 | | - .. tab:: File-attachment indexing rules |
320 | | - |
321 | | - Zammad supports searching by the contents of file attachments, which means |
322 | | - Elasticsearch has to index those, too. Limiting such indexing can help |
323 | | - conserve system resources. |
324 | | - |
325 | | - Files with these extensions will not be indexed: |
326 | | - |
327 | | - .. code-block:: console |
328 | | -
|
329 | | - $ zammad run rails r "Setting.set('es_attachment_ignore',\ |
330 | | - [ '.png', '.jpg', '.jpeg', '.mpeg', '.mpg', '.mov', '.bin', '.exe', '.box', '.mbox' ] )" |
331 | | -
|
332 | | - Files larger than this size (in MB) will not be indexed: |
333 | | - |
334 | | - .. code-block:: console |
335 | | -
|
336 | | - $ zammad run rails r "Setting.set('es_attachment_max_size_in_mb', 50)" |
337 | | -
|
338 | | - .. tab:: Remote host |
339 | | - |
340 | | - Change your Elasticsearch URL if you have a separate Elasticsearch server. |
341 | | - Default is ``localhost``. |
342 | | - |
343 | | - .. code-block:: console |
344 | | -
|
345 | | - $ zammad run rails r "Setting.set('es_url', 'https://example.com')" |
346 | | -
|
347 | | - .. tab:: SSL Verification |
348 | | - |
349 | | - You can disable SSL verification, which is not recommended. Default is |
350 | | - ``true``. |
351 | | - |
352 | | - .. code-block:: console |
353 | | -
|
354 | | - $ zammad run rails r "Setting.set('es_ssl_verify', false)" |
355 | | -
|
356 | | - If you want to use custom certificates, you can find information about |
357 | | - how to use them in Zammad |
358 | | - :admin-docs:`here </settings/security/ssl-certificates.html>`. |
359 | | - |
360 | | - .. tab:: Asciifold |
361 | | - |
362 | | - By default, the |
363 | | - `Asciifold <https://www.elastic.co/docs/reference/text-analysis/analysis-asciifolding-tokenfilter>`_ |
364 | | - feature of Elasticsearch is enabled. This can be useful if you deal with |
365 | | - text which includes diacritics and/or umlauts. |
366 | | - |
367 | | - In case you need a more exact search, you can turn it off: |
| 6 | +Zammad's search function can be powered by Elasticsearch (which is **highly |
| 7 | +recommended**). |
368 | 8 |
|
369 | | - .. code-block:: console |
| 9 | +The order for a package installation of Zammad is like this: |
370 | 10 |
|
371 | | - $ zammad run rails r "Setting.set('es_asciifolding', false)" |
| 11 | +1. :doc:`Install Elasticsearch (version 9 recommended) <elasticsearch/install-elasticsearch-9>` |
| 12 | +2. :doc:`Install Zammad <./package>` |
| 13 | +3. :doc:`Connect and configure Elasticsearch <elasticsearch/connect-configure-elasticsearch>` |
372 | 14 |
|
373 | | -Appendix |
374 | | --------- |
| 15 | +.. hint:: For a transition period, there is also a |
| 16 | + :doc:`installation guide for Elasticsearch 7 <elasticsearch/install-elasticsearch-7>` available. |
375 | 17 |
|
376 | 18 | .. toctree:: |
377 | 19 | :maxdepth: 0 |
378 | | - :titlesonly: |
| 20 | + :hidden: |
379 | 21 |
|
380 | | - elasticsearch/indexed-attributes |
381 | | - elasticsearch/troubleshooting |
| 22 | + elasticsearch/install-elasticsearch-7 |
| 23 | + elasticsearch/install-elasticsearch-9 |
| 24 | + elasticsearch/connect-configure-elasticsearch |
0 commit comments