docker elasticsearch 7.6.1, elasticsearch-head, kibana7.6.1

Install elasticsearch

Pull mirror

docker pull elasticsearch:7.6.1

Run the container

  • Run the command to create the startup container:
docker run -d --name es -p 9200:9200 -p 9300:9300 \
-e "discovery.type=single-node" elasticsearch:7.6.1

discovery.type=single-node: add this parameter directly for stand-alone learning, which means that a single node is running, avoiding errors in the boot check of es during startup

  • Copy the configuration file and data directory for mounting:
docker cp es:/usr/share/elasticsearch/config /usr/local/docker/elasticsearch/
docker cp es:/usr/share/elasticsearch/data/ /usr/local/docker/elasticsearch/
  • Set to allow cross-domain access, otherwise you will not be able to connect after installing elasticsearch-head
#进入配置文件目录
cd /usr/local/docker/elasticsearch/config

#修改elasticsearch.yml
vim elasticsearch.yml

#添加这2行
http.cors.enabled: true
http.cors.allow-origin: "*"
  • Destroy the container and run it again in mount mode:
#销毁
docker rm -f es
#挂载配置文件
docker run -d --name es -p 9200:9200 -p 9300:9300 \
-v /usr/local/docker/elasticsearch/config/:/usr/share/elasticsearch/config/ \
-v /usr/local/docker/elasticsearch/data/:/usr/share/elasticsearch/data/ \
-e "discovery.type=single-node" \
elasticsearch:7.6.1
  •  

Install elasticsearch-head

Pull mirror

docker pull mobz/elasticsearch-head:5

Run the container

docker run -d --name es-head -p 9100:9100 \
mobz/elasticsearch-head:5

Open the browser 9100 address, the default connection is localhost:9200, if es is installed on other servers, just change localhost to the corresponding IP, but you need to modify the IP every time, you can use the following settings.

拷出容器的app.js、vendor.js,待会有用
docker cp es-head:/usr/src/app/_site/app.js /usr/local/docker/elasticsearch-head/
docker cp es-head:/usr/src/app/_site/vendor.js /usr/local/docker/elasticsearch-head/
  • Modify app.js
把默认连接地址localhost改成对应的IP
cd /usr/local/docker/elasticsearch-head/
vim app.js

Insert picture description here

  • Modify vendor.js (es-head 5 is not compatible with higher version es, the query will report HTTP 406 status code error, here you can modify the contentType to solve it)
#搜索application/x-www-form-urlencoded,改成application/json;charset=UTF-8
#总的有2个地方
vim vendor.js
  • Insert picture description here
    Insert picture description here
  • Destroy the container and rerun
# 销毁容器
docker rm -f es-head
#重新运行容器
docker run -d --name es-head -p 9100:9100 \
-v /usr/local/docker/elasticsearch-head/app.js:/usr/src/app/_site/app.js \
-v /usr/local/docker/elasticsearch-head/vendor.js:/usr/src/app/_site/vendor.js \
mobz/elasticsearch-head:5

Install the vim tool directly in docker, and it is also possible to edit js. I can’t install it because of network problems, so I use mount

  • Open elasticsearch-head, the default connection at this time is the modified IP address
    Insert picture description here
  • At this step, the installation is basically completed.

Since the kibana version must be consistent with es, the kibana installation introduced here is also version 7.6.1.

Pull mirror

docker pull kibana:7.6.1
  •  

Run the container

  • Run the container first
docker run -d --name kibana -p 5601:5601 kibana:7.6.1
  • The old rules, copy out the configuration file, and then do the mounting
# 拷贝
docker cp kibana:/usr/share/kibana/config/ /usr/local/docker/kibana/

# 修改配置
cd /usr/local/docker/kibana/config/
vim kibana.yml
  • Modify elasticsearch.hosts to a specific IP address:

Insert picture description here

  • Mount and run
# 先销毁容器
docker rm -f kibana

# 运行容器
docker run -d --name kibana -p 5601:5601 \
-v /usr/local/docker/kibana/config:/usr/share/kibana/config \
kibana:7.6.1
  • Open the kibana address: http://xxxxx:5601
    Insert picture description here

Set Chinese interface

The kibana visual interface is in English by default. You can change it to Chinese by modifying the configuration file. The operation is as follows:

# 编辑kibana.yml
cd /usr/local/docker/kibana/config
vim kibana.yml
# 在最后面加上这句
i18n.locale: "zh-CN"

Restart the kibana container

Insert picture description here

The official website download is too slow, you can download this:

Link: https://pan.baidu.com/s/1EKKcnbQMSfCQEeIY-X5oKQ 
Extraction code: zjrv

Guess you like

Origin blog.csdn.net/u014748504/article/details/108294600