Skip to content

Deploy Elasticsearch⚓︎

1 Preparation⚓︎

1.1 Enviroment Information⚓︎

  • Information of Elasticsearch server:
192.168.100.51

2 Docker Installation and Deployment⚓︎

2.1 Docker Installation⚓︎

yum install -y yum-utils device-mapper-persistent-data lvm2
yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
sed -i 's+download.docker.com+mirrors.aliyun.com/docker-ce+' /etc/yum.repos.d/docker-ce.repo
yum makecache fast
yum -y install docker-ce

2.2 Docker Deployment⚓︎

mkdir /etc/docker/
vi /etc/docker/daemon.json
{
  "live-restore": true,
  "registry-mirrors": ["https://hub-mirror.c.163.com", "https://bmtrgdvx.mirror.aliyuncs.com", "http://f1361db2.m.daocloud.io"],
  "log-driver": "json-file",
  "log-opts": {"max-file": "3", "max-size": "10m"}
}

2.3 Start Docker⚓︎

systemctl enable docker
systemctl start docker

3 Elasticsearch Installation and Deployment⚓︎

3.1 Download Elasticsearch mirror⚓︎

docker pull docker.elastic.co/elasticsearch/elasticsearch:7.17.6
7a0437f04f83: Pull complete
7718d2f58c47: Pull complete
cc5c16bd8bb9: Pull complete
e3d829b4b297: Pull complete
1ad944c92c79: Pull complete
373fb8fbaf74: Pull complete
5908d3eb2989: Pull complete
Digest: sha256:81c126e4eddbc5576285670cb3e23d7ef7892ee5e757d6d9ba870b6fe99f1219
Status: Downloaded newer image for docker.elastic.co/elasticsearch/elasticsearch:7.17.6
docker.elastic.co/elasticsearch/elasticsearch:7.17.6

3.2 Create persistent data directory of Elasticsearch⚓︎

mkdir -p /opt/jumpserver/elasticsearch/data /opt/jumpserver/elasticsearch/logs

3.3 Start Elasticsearch service⚓︎

## Please change your account and password by yourself and remember that if lost, you can delete the container and create a new password. Data will not be lost
# 9200                                  # Port of Web
# 9300                                  # Port of cluster deployment
# discovery.type=single-node            # Single node deployment
# bootstrap.memory_lock="true"          # Locked using physical memory, Do not use swap
# xpack.security.enabled="true"         # Enable security module
# TAKE_FILE_OWNERSHIP="true"            # Automatically modify the user who owns the mounted folder
# ES_JAVA_OPTS="-Xms512m -Xmx512m"      # Memory size fo JVM, The recommended value is half of the host memory
# elastic                               # Elasticsearch Account
# ELASTIC_PASSWORD=KXOeyNgDeTdpeu9q     # Elasticsearch Password
docker run --name jms_es -d -p 9200:9200 -p 9300:9300 -e cluster.name=docker-cluster -e discovery.type=single-node -e network.host=0.0.0.0 -e bootstrap.memory_lock="true" -e xpack.security.enabled="true" -e TAKE_FILE_OWNERSHIP="true" -e ES_JAVA_OPTS="-Xms512m -Xmx512m" -e ELASTIC_PASSWORD=KXOeyNgDeTdpeu9q -v /opt/jumpserver/elasticsearch/data:/usr/share/elasticsearch/data -v /opt/jumpserver/elasticsearch/logs:/usr/share/elasticsearch/logs --restart=always docker.elastic.co/elasticsearch/elasticsearch:7.17.6

3.4 Configure Elasticsearch in JumpServer⚓︎

  • Access JumpServer Web and login with admin.
  • Clicking [Terminal Management] on left side menu bar,select [Storage Configuration] on the top of page,and then select [Create] under the [Command Storage] for 'Elasticsearch'
  • Fill in the fields below, save and update all components on the [Terminal Management] page, select [jms-es] for command storage, and submit.
Name Reference value Description
Name (Name) jms-es Identification, non repeatable
Type (Type) Elasticsearch Fixed, cannot be changed
Host (Hosts) http://elastic:KXOeyNgDeTdpeu9q@192.168.100.51:9200 http://es_host:es_port
Index (Index) jumpserver Index
Ignor the cetificate authentication https Self-signed ssl
Default Storage The new component will automatically use this storage