Docker安装es
1. 基于Docker安装Elasticsearch
1.1. 创建网络
因为需要部署kibana容器,因此需要让es和kibana容器互联。
docker network create es-net
1.2. 拉取镜像
以安装Elasticsearch 8.6.0 版本为例
docker pull elasticsearch:8.6.0
1.3. 创建挂载点目录
mkdir -p ./es/data ./es/config ./es/plugins
变为可执行文件
chmod 777 ./es/data
chmod 777 ./es/config
chmod 777 ./es/plugins
1.4. 部署单点es,创建es容器
docker run -d \
--restart=always \
--name es \
--network es-net \
-p 9200:9200 \
-p 9300:9300 \
--privileged \
-v /Users/wyx/MyFile/Docker/es/data:/usr/share/elasticsearch/data \
-v /Users/wyx/MyFile/Docker/es/plugins:/usr/share/elasticsearch/plugins \
-e "discovery.type=single-node" \
-e "ES_JAVA_OPTS=-Xms512m -Xmx512m" \
elasticsearch:8.6.0
1.5. 进入es容器
docker exec -it es /bin/bash
编写elasticsearch.yml
跳转到config目录下
cd config
echo 'xpack.security.enabled: false' >> elasticsearch.yml
echo 'xpack.security.http.ssl.enabled: false' >> elasticsearch.yml
重置密码
记住New value: **0000000
docker exec -it elasticsearch1 /bin/bash
启用密码
想启用密码打开即可
xpack.security.enabled: true
设置 JVM 内存参数(可选设置)
docker exec -it elasticsearch1 /bin/bash
vi /usr/share/elasticsearch/config/jvm.options修改如下配置:
################################################################
## IMPORTANT: JVM heap size
################################################################
##
## The heap size is automatically configured by Elasticsearch
## based on the available memory in your system and the roles
## each node is configured to fulfill. If specifying heap is
## required, it should be done through a file in jvm.options.d,
## which should be named with .options suffix, and the min and
## max should be set to the same value. For example, to set the
## heap to 4 GB, create a new file in the jvm.options.d
## directory containing these lines:
##
## -Xms4g
## -Xmx4g
##
## See https://www.elastic.co/guide/en/elasticsearch/reference/8.9/heap-size.html
## for more information
##
################################################################
-Xms1g
-Xmx1g
基于Docker安装IK分词器
注意:安装IK分词器的版本,必须和Elasticsearch的版本一致,
上文安装的是Elasticsearch 8.6.0的,所以接下来安装的IK分词器版本是8.6.0
直接执行即可
./bin/elasticsearch-plugin install https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v8.6.0/elasticsearch-analysis-ik-8.6.0.zip
如果需要安装其他版本的IK分词器,需要把版本号修改即可
./bin/elasticsearch-plugin install https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v7.4.2/elasticsearch-analysis-ik-7.4.2.zip
./bin/elasticsearch-plugin install https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v8.6.0/elasticsearch-analysis-ik-8.6.0.zip
1.6. 重启es容器
docker restart es
测试
2. 基于Docker安装Kibana
docker pull kibana:8.6.0
2.1. 创建挂载点目录
mkdir -p ./kibana/config ./kibana/data
chmod 777 /usr/local/kibana/data
chmod 777 /usr/local/kibana/config
2.2. 部署kibana,创建kibana容器
docker run -d \
--restart=always \
--name kibana \
--network es-net \
-p 5601:5601 \
-e ELASTICSEARCH_HOSTS=http://es:9200 \
kibana:8.6.0
2.3. 测试Kibana是否安装成功
访问虚拟机地址+端口号,前面配置Kibana 的端口号为:5601