Copy docker pull elasticsearch:7.7.0
docker run -d --name es -p 9200:9200 -p 9300:9300 -e ES_JAVA_OPTS= "-Xms512m -Xmx512m" -e "discovery.type=single-node" -it elasticsearch:7.7.0
- discovery.type=single-node :单机运行
# 如果启动不起来,设置一下 ·虚拟内存区域的数量·
grep vm.max_map_count /etc/sysctl.conf
vm.max_map_count =262144
Copy {
"name" : "b25918c3dce6" ,
"cluster_name" : "docker-cluster" ,
"cluster_uuid" : "vW2zNEKERoe2rENiSI3oXQ" ,
"version" : {
"number" : "7.7.0" ,
"build_flavor" : "default" ,
"build_type" : "docker" ,
"build_hash" : "81a1e9eda8e6183f5237786246f6dced26a10eaf" ,
"build_date" : "2020-05-12T02:01:37.602180Z" ,
"build_snapshot" : false ,
"lucene_version" : "8.5.1" ,
"minimum_wire_compatibility_version" : "6.8.0" ,
"minimum_index_compatibility_version" : "6.0.0-beta1"
},
"tagline" : "You Know, for Search"
}
Copy docker exec -it es bash # 进入 ElasticSearch 容器
./bin/elasticsearch-plugin install https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v7.7.0/elasticsearch-analysis-ik-7.7.0.zip
docker restart es # 最后再重启一下
Github: https://github.com/mobz/elasticsearch-head/
Copy docker pull mobz/elasticsearch-head:5
docker run -d --name es-head -p 9100:9100 mobz/elasticsearch-head:5
因为前后端分离开发,存在跨域问题,需要在服务端做 CORS 的配置
Copy docker exec -it es /bin/bash
[root@7f213e9fb6bb elasticsearch]# vi config/elasticsearch.yml
# 添加如下两条配置,注意冒号后面有空格,保存并退出。
# 注意在生产环境不要打开这些设置,否则存在安全隐患
http.cors.enabled: true
http.cors.allow-origin: "*"
# 再重启
docker restart es
Copy docker pull kibana:7.7.0
# 单独启动
docker run -d --name kb -p 宿主机端口:5601 kibana:7.7.0
# 链接 ES
docker run -d --name kba -e ELASTICSEARCH_HOSTS=http://10.10.194.244:9200 kibana:7.7.0
or
docker run -d --name 容器名 -p 宿主机端口:5601 -v ./config:/usr/share/kibana/config kibana:7.7.0
## config 配置文件,定义 es 链接, 6.7以后系统开始支持中文了,修改语言只需要添加一行配置即可。
i18n.locale: "zh-CN"
server.name: kibana
server.host: "0"
elasticsearch.hosts: [ "http://10.10.194.244:9200" ]
monitoring.ui.container.elasticsearch.enabled: true