Centos7-Docker环境下Elasticsearch安装

565 阅读1分钟

Centos7-Docker环境下Elasticsearch安装

环境准备之docker的安装

  1. yum工具的安装
yum install -y yum-utils
  1. 配置镜像源-阿里云
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
  1. 安装社区版docker
yum install -y docker-ce docker-ce-cli containerd.io
  1. 启动
docker sysctl start docker
  1. 验证是否安装成功
docker run hello-world

安装成功则有如下信息显示

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (amd64)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/

Docker下安装Elasticsearch

1.去官网上找到对应的镜像资源 https://hub.docker.com/_/elasticsearch?tab=tags

docker pull elasticsearch:7.13.2

2.设置一个进程可以拥有的VMA(虚拟内存区域)的数量,设置好后重启服务。先查看当前值sysctl -a|grep vm.max_map_count

vim /etc/sysctl.conf
添加
vm.max_map_count = 262144

3.运行elasticsearch容器

docker run -p 9200:9200 -p 9300:9300 --name es -d -e "discovery.type=single-node" elasticsearch:7.13.2

4.查日志 docker logs es 5.验证 curl http://localhost:9200

# curl http://localhost:9200
{
  "name" : "0f109518f297",
  "cluster_name" : "docker-cluster",
  "cluster_uuid" : "uE_-vUGVTju7stYLCGo8nA",
  "version" : {
    "number" : "7.13.2",
    "build_flavor" : "default",
    "build_type" : "docker",
    "build_hash" : "4d960a0733be83dd2543ca018aa4ddc42e956800",
    "build_date" : "2021-06-10T21:01:55.251515791Z",
    "build_snapshot" : false,
    "lucene_version" : "8.8.2",
    "minimum_wire_compatibility_version" : "6.8.0",
    "minimum_index_compatibility_version" : "6.0.0-beta1"
  },
  "tagline" : "You Know, for Search"
}