Skip to content

Commit 3ccfdf3

Browse files
committed
better start-stop page"
1 parent a2c3c24 commit 3ccfdf3

File tree

1 file changed

+7
-156
lines changed

1 file changed

+7
-156
lines changed

deploy-manage/maintenance/start-stop-services/start-stop-elasticsearch.md

Lines changed: 7 additions & 156 deletions
Original file line numberDiff line numberDiff line change
@@ -40,170 +40,21 @@ If you installed {{es}} on Windows with a `.zip` package, you can start {{es}} f
4040

4141
If you're starting {{es}} for the first time, then {{es}} also enables and configures security. [Learn more](/deploy-manage/deploy/self-managed/install-elasticsearch-with-zip-on-windows.md#security-at-startup).
4242

43-
### Debian packages [start-deb]
43+
### Debian or RPM packages (using `systemd`) [start-deb]
4444

45-
#### Running {{es}} with `systemd` [start-es-deb-systemd]
46-
47-
To configure {{es}} to start automatically when the system boots up, run the following commands:
48-
49-
```sh
50-
sudo /bin/systemctl daemon-reload
51-
sudo /bin/systemctl enable elasticsearch.service
52-
```
53-
54-
{{es}} can be started and stopped as follows:
55-
56-
```sh
57-
sudo systemctl start elasticsearch.service
58-
sudo systemctl stop elasticsearch.service
59-
```
60-
61-
These commands provide no feedback as to whether {{es}} was started successfully or not. Instead, this information will be written in the log files located in `/var/log/{{es}}/`.
62-
63-
If you have password-protected your {{es}} keystore, you will need to provide `systemd` with the keystore password using a local file and systemd environment variables. This local file should be protected while it exists and may be safely deleted once {{es}} is up and running.
64-
65-
```sh
66-
echo "keystore_password" > /path/to/my_pwd_file.tmp
67-
chmod 600 /path/to/my_pwd_file.tmp
68-
sudo systemctl set-environment ES_KEYSTORE_PASSPHRASE_FILE=/path/to/my_pwd_file.tmp
69-
sudo systemctl start elasticsearch.service
70-
```
71-
72-
By default the {{es}} service doesn’t log information in the `systemd` journal. To enable `journalctl` logging, the `--quiet` option must be removed from the `ExecStart` command line in the `elasticsearch.service` file.
73-
74-
When `systemd` logging is enabled, the logging information are available using the `journalctl` commands:
75-
76-
To tail the journal:
77-
78-
```sh
79-
sudo journalctl -f
80-
```
81-
82-
To list journal entries for the {{es}} service:
83-
84-
```sh
85-
sudo journalctl --unit elasticsearch
86-
```
87-
88-
To list journal entries for the {{es}} service starting from a given time:
89-
90-
```sh
91-
sudo journalctl --unit elasticsearch --since "2016-10-30 18:17:16"
92-
```
93-
94-
Check `man journalctl` or [https://www.freedesktop.org/software/systemd/man/journalctl.html](https://www.freedesktop.org/software/systemd/man/journalctl.html) for more command line options.
95-
96-
::::{admonition} Startup timeouts with older systemd versions
97-
:class: tip
98-
99-
By default {{es}} sets the `TimeoutStartSec` parameter to `systemd` to `900s`. If you are running at least version 238 of `systemd` then {{es}} can automatically extend the startup timeout, and will do so repeatedly until startup is complete even if it takes longer than 900s.
100-
101-
Versions of `systemd` prior to 238 do not support the timeout extension mechanism and will terminate the {{es}} process if it has not fully started up within the configured timeout. If this happens, {{es}} will report in its logs that it was shut down normally a short time after it started:
102-
103-
```text
104-
[2022-01-31T01:22:31,077][INFO ][o.e.n.Node ] [instance-0000000123] starting ...
105-
...
106-
[2022-01-31T01:37:15,077][INFO ][o.e.n.Node ] [instance-0000000123] stopping ...
107-
```
108-
109-
However the `systemd` logs will report that the startup timed out:
110-
111-
```text
112-
Jan 31 01:22:30 debian systemd[1]: Starting elasticsearch...
113-
Jan 31 01:37:15 debian systemd[1]: elasticsearch.service: Start operation timed out. Terminating.
114-
Jan 31 01:37:15 debian systemd[1]: elasticsearch.service: Main process exited, code=killed, status=15/TERM
115-
Jan 31 01:37:15 debian systemd[1]: elasticsearch.service: Failed with result 'timeout'.
116-
Jan 31 01:37:15 debian systemd[1]: Failed to start elasticsearch.
117-
```
45+
:::{include} /deploy-manage/deploy/self-managed/_snippets/systemd-startup.md
46+
:::
11847

119-
To avoid this, upgrade your `systemd` to at least version 238. You can also temporarily work around the problem by extending the `TimeoutStartSec` parameter.
48+
:::{include} /deploy-manage/deploy/self-managed/_snippets/systemd.md
49+
:::
12050

121-
::::
51+
:::{include} /deploy-manage/deploy/self-managed/_snippets/systemd-startup-timeout.md
52+
:::
12253

12354
### Docker images [start-docker]
12455

12556
If you installed a Docker image, you can start {{es}} from the command line. There are different methods depending on whether you’re using development mode or production mode. See [](../../../deploy-manage/deploy/self-managed/install-elasticsearch-with-docker.md).
12657

127-
### RPM packages [start-rpm]
128-
129-
#### Running {{es}} with `systemd` [start-es-rpm-systemd]
130-
131-
To configure {{es}} to start automatically when the system boots up, run the following commands:
132-
133-
```sh
134-
sudo /bin/systemctl daemon-reload
135-
sudo /bin/systemctl enable elasticsearch.service
136-
```
137-
138-
{{es}} can be started and stopped as follows:
139-
140-
```sh
141-
sudo systemctl start elasticsearch.service
142-
sudo systemctl stop elasticsearch.service
143-
```
144-
145-
These commands provide no feedback as to whether {{es}} was started successfully or not. Instead, this information will be written in the log files located in `/var/log/{{es}}/`.
146-
147-
If you have password-protected your {{es}} keystore, you will need to provide `systemd` with the keystore password using a local file and systemd environment variables. This local file should be protected while it exists and may be safely deleted once {{es}} is up and running.
148-
149-
```sh
150-
echo "keystore_password" > /path/to/my_pwd_file.tmp
151-
chmod 600 /path/to/my_pwd_file.tmp
152-
sudo systemctl set-environment ES_KEYSTORE_PASSPHRASE_FILE=/path/to/my_pwd_file.tmp
153-
sudo systemctl start elasticsearch.service
154-
```
155-
156-
By default the {{es}} service doesn’t log information in the `systemd` journal. To enable `journalctl` logging, the `--quiet` option must be removed from the `ExecStart` command line in the `elasticsearch.service` file.
157-
158-
When `systemd` logging is enabled, the logging information are available using the `journalctl` commands:
159-
160-
To tail the journal:
161-
162-
```sh
163-
sudo journalctl -f
164-
```
165-
166-
To list journal entries for the {{es}} service:
167-
168-
```sh
169-
sudo journalctl --unit elasticsearch
170-
```
171-
172-
To list journal entries for the {{es}} service starting from a given time:
173-
174-
```sh
175-
sudo journalctl --unit elasticsearch --since "2016-10-30 18:17:16"
176-
```
177-
178-
Check `man journalctl` or [https://www.freedesktop.org/software/systemd/man/journalctl.html](https://www.freedesktop.org/software/systemd/man/journalctl.html) for more command line options.
179-
180-
::::{admonition} Startup timeouts with older systemd versions
181-
:class: tip
182-
183-
By default {{es}} sets the `TimeoutStartSec` parameter to `systemd` to `900s`. If you are running at least version 238 of `systemd` then {{es}} can automatically extend the startup timeout, and will do so repeatedly until startup is complete even if it takes longer than 900s.
184-
185-
Versions of `systemd` prior to 238 do not support the timeout extension mechanism and will terminate the {{es}} process if it has not fully started up within the configured timeout. If this happens, {{es}} will report in its logs that it was shut down normally a short time after it started:
186-
187-
```text
188-
[2022-01-31T01:22:31,077][INFO ][o.e.n.Node ] [instance-0000000123] starting ...
189-
...
190-
[2022-01-31T01:37:15,077][INFO ][o.e.n.Node ] [instance-0000000123] stopping ...
191-
```
192-
193-
However the `systemd` logs will report that the startup timed out:
194-
195-
```text
196-
Jan 31 01:22:30 debian systemd[1]: Starting elasticsearch...
197-
Jan 31 01:37:15 debian systemd[1]: elasticsearch.service: Start operation timed out. Terminating.
198-
Jan 31 01:37:15 debian systemd[1]: elasticsearch.service: Main process exited, code=killed, status=15/TERM
199-
Jan 31 01:37:15 debian systemd[1]: elasticsearch.service: Failed with result 'timeout'.
200-
Jan 31 01:37:15 debian systemd[1]: Failed to start elasticsearch.
201-
```
202-
203-
To avoid this, upgrade your `systemd` to at least version 238. You can also temporarily work around the problem by extending the `TimeoutStartSec` parameter.
204-
205-
::::
206-
20758
## Stopping {{es}} [stopping-elasticsearch]
20859

20960
An orderly shutdown of {{es}} ensures that {{es}} has a chance to cleanup and close outstanding resources. For example, a node that is shutdown in an orderly fashion will remove itself from the cluster, sync translogs to disk, and perform other related cleanup activities. You can help ensure an orderly shutdown by properly stopping {{es}}.

0 commit comments

Comments
 (0)