Elasticsearch7.12的两种安装方式

来源:https://mp.weixin.qq.com/s/pgYIzfEwGSLjTx7xOuAILg

es安装

es有两种安装方式,一种直接在linux系统安装,另一种基于容器安装。

1.在linux系统下安装es7需先安装好jdk11或以上版本,容器安装不需要考虑,下面以docker安装为例。

2.基于centos7以上的docker安装

1)docker方式拉去镜像

docker pull docker.elastic.co/elasticsearch/elasticsearch:7.12.0

2)单节点启动

docker run -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" docker.elastic.co/elasticsearch/elasticsearch:7.12.0

docker-compose方式

1)创建docker-compose.yml 单机的伪集群

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单节点模式

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  后台运行,并且分别执行docker logs es01,docker logs es02,ocker logs es03  查看日志

最后注意在linux下设置:vm.max_map_count

grep vm.max_map_count /etc/sysctl.conf

vm

.max_map_count=262144

3)再次docker-compose ps -a 查看容器运行情况

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.重新启动es即可

来源:https://mp.weixin.qq.com/s/pgYIzfEwGSLjTx7xOuAILg

你可能感兴趣的:(Elasticsearch7.12的两种安装方式)