# Elasticsearch In Production

## Install Elasticsearch with RPM manually

```bash
sudo rpm --install elasticsearch-6.6.0.rpm
sudo chkconfig --add elasticsearch
```

## Configure Elasticsearch

`/etc/elasticsearch/elasticsearch.yml`

`/etc/sysconfig/elasticsearch` #SysV init

`/etc/elasticsearch/jvm.options` #Xmx <= 32G

```bash
sed -n '/^#/!p' /etc/elasticsearch/elasticsearch.yml
####
cluster.name: crs2-es
node.name: ${HOSTNAME}
path.data: /data3/elasticsearch/data
path.logs: /data3/elasticsearch/log

bootstrap.system_call_filter: false #set to false as SecComp fails on CentOS 6
bootstrap.memory_lock: true
network.host: [10.0.0.1, 127.0.0.1]
http.port: 9200
discovery.zen.ping.unicast.hosts: ["10.0.0.1", "10.0.0.2", "10.0.0.3"]
#########################################

sed -n '/^#/!p' /etc/sysconfig/elasticsearch
####
JAVA_HOME=/opt/apps/java/jdk1.8.0_171
ES_PATH_CONF=/etc/elasticsearch
ES_STARTUP_SLEEP_TIME=5
MAX_LOCKED_MEMORY=unlimited
#########################################

sed -n '/^#/!p'  /etc/elasticsearch/jvm.options |egrep Xm[sx]
####
-Xms24g
-Xmx24g
```

```bash
mkdir -p  /data3/elasticsearch/{data,log}
chmod -R 775 /data3/elasticsearch/
chown elasticsearch:elasticsearch /data3/elasticsearch/{data,log}
```

## Run Elasticsearch

`sudo -i service elasticsearch start`

## Check status(cluster)

`curl -XGET 'localhost:9200/_cluster/state?pretty'`

## Reference

* [Elasticsearch Reference \[6.6\]](https://www.elastic.co/guide/en/elasticsearch/reference/current/rpm.html#rpm)
* [Elasticsearch In Production — Deployment Best Practices](https://medium.com/@abhidrona/elasticsearch-deployment-best-practices-d6c1323b25d7)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.junyangz.com/ops/elasticsearch-in-production.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
