Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setting-envars-docs #3582 #7400

Merged
merged 4 commits into from
Jul 9, 2024
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 44 additions & 1 deletion _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 the following ways.

### Arguments as start up
AntonEliatra marked this conversation as resolved.
Show resolved Hide resolved

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 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, as shown in the following command:
AntonEliatra marked this conversation as resolved.
Show resolved Hide resolved

```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 Expand Up @@ -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
```
```
Loading