From ae2a16dc8e2bf6d46cdb453c59b67601f09decc1 Mon Sep 17 00:00:00 2001 From: "opensearch-trigger-bot[bot]" <98922864+opensearch-trigger-bot[bot]@users.noreply.github.com> Date: Tue, 9 Jul 2024 16:50:29 +0000 Subject: [PATCH] Setting-envars-docs #3582 (#7400) (#7658) --- .../configuring-opensearch/index.md | 45 ++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/_install-and-configure/configuring-opensearch/index.md b/_install-and-configure/configuring-opensearch/index.md index ecbce1310d..c2ffbf571b 100755 --- a/_install-and-configure/configuring-opensearch/index.md +++ b/_install-and-configure/configuring-opensearch/index.md @@ -25,6 +25,10 @@ Certain operations are static and require you to modify the `opensearch.yml` [co ## Specifying settings as environment variables +You can specify environment variables in the following ways. + +### Arguments at startup + You can specify environment variables as arguments using `-E` when launching OpenSearch: ```bash @@ -32,6 +36,45 @@ You can specify environment variables as arguments using `-E` when launching Ope ``` {% include copy.html %} +### Directly in the shell environment + +You can configure the environment variables directly in a shell environment before starting OpenSearch, as shown in the following example: + +```bash +export OPENSEARCH_JAVA_OPTS="-Xms2g -Xmx2g" +export OPENSEARCH_PATH_CONF="/etc/opensearch" +./opensearch +``` +{% include copy.html %} + +### Systemd service file + +When running OpenSearch as a service managed by `systemd`, you can specify environment variables in the service file, as shown in the following example: + +```bash +# /etc/systemd/system/opensearch.service.d/override.conf +[Service] +Environment="OPENSEARCH_JAVA_OPTS=-Xms2g -Xmx2g" +Environment="OPENSEARCH_PATH_CONF=/etc/opensearch" +``` +After creating or modifying the file, reload the systemd configuration and restart the service using the following command: + +```bash +sudo systemctl daemon-reload +sudo systemctl restart opensearch +``` +{% include copy.html %} + +### Docker environment variables + +When running OpenSearch in Docker, you can specify environment variables using the `-e` option with `docker run` command, as shown in the following command: + +```bash +docker run -e "OPENSEARCH_JAVA_OPTS=-Xms2g -Xmx2g" -e "OPENSEARCH_PATH_CONF=/usr/share/opensearch/config" opensearchproject/opensearch:latest +``` +{% include copy.html %} + + ## Updating cluster settings using the API The first step in changing a setting is to view the current settings by sending the following request: @@ -113,4 +156,4 @@ If you are working on a client application running against an OpenSearch cluster - http.cors.enabled:true - http.cors.allow-headers:X-Requested-With,X-Auth-Token,Content-Type,Content-Length,Authorization - http.cors.allow-credentials:true -``` \ No newline at end of file +```