配置yum源

elasticsearch

[elasticsearch]
name=Elasticsearch repository for 7.x packages
baseurl=https://artifacts.elastic.co/packages/7.x/yum
gpgcheck=1
gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch
enabled=0
autorefresh=1
type=rpm-md

kibana

[kibana-7.x]
name=Kibana repository for 7.x packages
baseurl=https://artifacts.elastic.co/packages/7.x/yum
gpgcheck=1
gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch
enabled=1
autorefresh=1
type=rpm-md

logstash

[logstash-7.x]
name=Elastic repository for 7.x packages
baseurl=https://artifacts.elastic.co/packages/7.x/yum
gpgcheck=1
gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch
enabled=1
autorefresh=1
type=rpm-md

安装

sudo yum install elasticsearch
sudo yum install kibana
sudo yum install logstash

启动

systemctl start elasticsearch
systemctl start kibana
systemctl start logstash

docker 安装

使用官方docker 仓库

注:使用官方的,比较慢,老是超时

sudo docker pull docker.elastic.co/elasticsearch/elasticsearch:7.5.1
sudo docker pull docker.elastic.co/kibana/kibana:7.5.1
sudo docker pull docker.elastic.co/logstash/logstash:7.5.1

使用docker hub

注:docker hub配置个国内加速器,比较快

sudo docker pull elasticsearch:7.5.1
sudo docker pull kibana:7.5.1
sudo docker pull logstash:7.5.1

启动

elasticsearch

  • 开发环境
docker run -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" elasticsearch:7.5.1
  • 生产环境(使用docker-composse管理)
  1. 添加配置文件
version: '2.2'
services:
  elasticsearch:
    image: docker.elastic.co/elasticsearch/elasticsearch:7.5.1
    container_name: elasticsearch
    environment:
      - cluster.name=docker-cluster
      - bootstrap.memory_lock=true
      - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
    ulimits:
      memlock:
        soft: -1
        hard: -1
    volumes:
      - esdata1:/usr/share/elasticsearch/data
    ports:
      - 9200:9200
    networks:
      - esnet
  elasticsearch2:
    image: docker.elastic.co/elasticsearch/elasticsearch:7.5.1
    container_name: elasticsearch2
    environment:
      - cluster.name=docker-cluster
      - bootstrap.memory_lock=true
      - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
      - "discovery.zen.ping.unicast.hosts=elasticsearch"
    ulimits:
      memlock:
        soft: -1
        hard: -1
    volumes:
      - esdata2:/usr/share/elasticsearch/data
    networks:
      - esnet

volumes:
  esdata1:
    driver: local
  esdata2:
    driver: local

networks:
  esnet:
  1. 启动
docker-compose up
docker-compose down

3.检查es状态

curl http://127.0.0.1:9200/_cat/health

kibana

  • 开发环境
docker run --link YOUR_ELASTICSEARCH_CONTAINER_NAME_OR_ID:elasticsearch -p 5601:5601 {docker-repo}:{version}
  • 生产环境
  1. 前提:vm.max_map_count此内核参数最小值262144
  2. 配置
version: '2'
services:
  kibana:
    image: docker.elastic.co/kibana/kibana:7.5.1
    volumes:
      - ./kibana.yml:/usr/share/kibana/config/kibana.yml

logstash

  • pipline方式
docker run --rm -it -v ~/pipeline/:/usr/share/logstash/pipeline/ docker.elastic.co/logstash/logstash:7.5.1
  • yml配置方式
docker run --rm -it -v ~/settings/:/usr/share/logstash/config/ docker.elastic.co/logstash/logstash:6.2.4
#或者使用单独一个文件
docker run --rm -it -v ~/settings/logstash.yml:/usr/share/logstash/config/logstash.yml docker.elastic.co/logstash/logstash:6.2.4

使用二进制文件

这里下载好二进制文件,解压就可以用了,不再赘述,这里附上下载地址

https://www.elastic.co/cn/downloads/elasticsearch
https://www.elastic.co/cn/downloads/kibana
https://www.elastic.co/cn/downloads/logstash