docker安装ElasticSearch
https://www.elastic.co/guide/en/elasticsearch/reference/current/docker.html
编写docker-compose.yml
version: '3.8'
services:
elasticsearch:
image: docker.io/elasticsearch:7.8.1
container_name: es
restart: always
ports:
- 9200:9200
environment:
- cluster.name=es-cluster
- discovery.type=single-node
# - discovery.seed_hosts=es
kibana:
image: docker.io/kibana:7.8.1
container_name: kibana
restart: always
ports:
- 5601:5601
environment:
- elasticsearch_hosts="es:9200"
#- ELASTICSEARCH_SSL_VERIFICATIONMODE=none
#- ELASTICSEARCH_USERNAME=admin
#- ELASTICSEARCH_PASSWORD=123456nw
depends_on:
- elasticsearch
启动
docker-compose up -d
查看实时日志
docker-compose logs -f
docker安装Kibana
https://www.elastic.co/guide/en/kibana/current/docker.html
docker pull docker.io/kibana:7.8.1
查看ES是否安装成功
浏览器中访问:http://10.168.1.229:9200/
{
"name": "892c3581f8fa",
"cluster_name": "es-cluster",
"cluster_uuid": "PlqXCFzDTEWRYlnHsEPWMg",
"version": {
"number": "7.8.1",
"build_flavor": "default",
"build_type": "docker",
"build_hash": "b5ca9c58fb664ca8bf9e4057fc229b3396bf3a89",
"build_date": "2020-07-21T16:40:44.668009Z",
"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"
}
查看Kibana是否安装成功
浏览器中访问: http://10.168.1.229:5601
安装IK分词器和拼音分词器
下载与ES版本号对应的拼音分词器:https://github.com/medcl/elasticsearch-analysis-pinyin
下载与ES版本号对应的IK分词器:https://github.com/medcl/elasticsearch-analysis-ik/releases
将IK分词器插件ZIP包复制到ES容器内,放到/usr/share/elasticsearch/plugins目录下,创建ik目录,并将插件解压到该目录下
切记:安装完成插件后必须把zip压缩包删除,否则无法启动ES
# 复制ik分词zip压缩包至容器内/usr/share/elasticsearch/plugins目录
docker cp ./elasticsearch-analysis-ik-7.8.1.zip es:/usr/share/elasticsearch/plugins
# 进入ES容器
docker exec -it es bash
# 进入ES存放插件的目录
cd /usr/share/elasticsearch/plugins
# 创建目录
mkdir ik
#解压ik分词器zip压缩包,解压至/usr/share/elasticsearch/plugins/ik目录下
unzip elasticsearch-analysis-ik-7.8.1.zip -d ./ik
修改配置文件
- 修改挂载的容器数据卷目录的权限,这样启动过程中可以修改容器数据卷的文件
chmod chmod +777 /docker/elasticsearch/ - 修改单个jvm支持的最大线程数,ES要求至少262144个线程
vim /etc/sysctl.conf,并在sysctl.conf配置文件最后加上如下语句,并执行sysctl -p使配置生效
vm.max_map_count=262144
ES的默认端口说明
9300端口: 集群和TCPClient使用,基于tcp协议
9200端口: ES节点和外部通讯使用,提供了基于http协议的restful接口
如果要达到单个JVM开启100w以上的线程数,需要配置vm.max_map_count=2048000或者以上
chmod 777 /usr/share/elasticsearch/data
- kibana查看索引信息
ElasticSearch安装目录下的目录介绍
ElasticSearch-head插件安装
elasticvue插件