> For the complete documentation index, see [llms.txt](https://docs.junyangz.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.junyangz.com/ops/elasticsearch-in-production.md).

# 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)
