來源:https://mp.weixin.qq.com/s/pgYIzfEwGSLjTx7xOuAILg
es安裝
es有兩種安裝方式,一種直接在linux系統(tǒng)安裝椎扬,另一種基于容器安裝惫搏。
1.在linux系統(tǒng)下安裝es7需先安裝好jdk11或以上版本具温,容器安裝不需要考慮蚕涤,下面以docker安裝為例。
2.基于centos7以上的docker安裝
1)docker方式拉去鏡像
docker pull docker.elastic.co/elasticsearch/elasticsearch:7.12.0
2)單節(jié)點(diǎn)啟動(dòng)
docker run -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" docker.elastic.co/elasticsearch/elasticsearch:7.12.0
docker-compose方式
1)創(chuàng)建docker-compose.yml 單機(jī)的偽集群
version: '2.2'
services:
? es01:
? ? image: docker.elastic.co/elasticsearch/elasticsearch:7.12.0
container_name: es01
environment:
? ? ? -node.name=es01
- cluster.name=es-docker-cluster
-discovery.seed_hosts=es02,es03
-cluster.initial_master_nodes=es01,es02,es03
-bootstrap.memory_lock=true
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"ulimits:
? ? ? memlock:
? ? ? ? soft: -1
hard: -1
volumes:
? ? ? - data01:/usr/share/elasticsearch/data
ports:
? ? ? - 9200:9200
networks:
? ? ? -elastic
es02:
? ? image: docker.elastic.co/elasticsearch/elasticsearch:7.12.0
container_name: es02
environment:
? ? ? -node.name=es02
- cluster.name=es-docker-cluster
-discovery.seed_hosts=es01,es03
-cluster.initial_master_nodes=es01,es02,es03
-bootstrap.memory_lock=true
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"ulimits:
? ? ? memlock:
? ? ? ? soft: -1
hard: -1
volumes:
? ? ? - data02:/usr/share/elasticsearch/data
networks:
? ? ? -elastic
es03:
? ? image: docker.elastic.co/elasticsearch/elasticsearch:7.12.0
container_name: es03
environment:
? ? ? -node.name=es03
- cluster.name=es-docker-cluster
-discovery.seed_hosts=es01,es02
-cluster.initial_master_nodes=es01,es02,es03
-bootstrap.memory_lock=true
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"ulimits:
? ? ? memlock:
? ? ? ? soft: -1
hard: -1
volumes:
? ? ? - data03:/usr/share/elasticsearch/data
networks:
? ? ? -elastic
volumes:
? data01:
? ? driver: local
data02:
? ? driver: local
data03:
? ? driver: local
networks:
? elastic:
? ? driver: bridge
docker-compose單節(jié)點(diǎn)模式
version:'3'
services:
elasticsearch:
? image: docker.elastic.co/elasticsearch/elasticsearch:7.12.0
? restart: always?
? hostname: es1
? container_name: es-single
? volumes:
? - /home/docker/elasticsearch/data:/home/docker/elasticsearch/data
? - /home/docker/elasticsearch/plugins:/home/docker/elasticsearch/plugins
? - /home/docker/elasticsearch/config/elasticsearch.yml:/home/docker/elasticsearch/config/elasticsearch.yml
? environment:
? - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
? - discovery.type=single-node
? ports:
? ? - '9200:9200'? ?
? ? - '9300:9300'?
? privileged: true?
docker-compose up -d? 后臺(tái)運(yùn)行铣猩,并且分別執(zhí)行docker logs es01揖铜,docker logs es02,ocker logs es03? 查看日志
最后注意在linux下設(shè)置:vm.max_map_count
grep vm.max_map_count /etc/sysctl.conf
vm
.max_map_count=262144
3)再次docker-compose ps -a 查看容器運(yùn)行情況
Es中文分詞離不開ik插件达皿,下面介紹ik插件的安裝
IK插件安裝
1.下載idk插件 https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v7.12.0/elasticsearch-analysis-ik-7.12.0.zip
2.放入plugins的目錄下解壓
3.重新啟動(dòng)es即可
來源:https://mp.weixin.qq.com/s/pgYIzfEwGSLjTx7xOuAILg