Skip to content

Commit

Permalink
setting-envars-docs opensearch-project#3582
Browse files Browse the repository at this point in the history
Signed-off-by: AntonEliatra <[email protected]>
  • Loading branch information
AntonEliatra committed Jun 17, 2024
1 parent 639cb38 commit f9ea9db
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions _install-and-configure/configuring-opensearch/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,56 @@ Certain operations are static and require you to modify the `opensearch.yml` [co

## Specifying settings as environment variables

You can specify environment variables in different ways.

### Arguments as start up

You can specify environment variables as arguments using `-E` when launching OpenSearch:

```bash
./opensearch -Ecluster.name=opensearch-cluster -Enode.name=opensearch-node1 -Ehttp.host=0.0.0.0 -Ediscovery.type=single-node
```
{% include copy.html %}

### Directly in the shell environment

You can configure the environment variables directly in shell before starting OpenSearch:

```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:

```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:

```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:

```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:
Expand Down

0 comments on commit f9ea9db

Please sign in to comment.