docker部署es集群

参考文档
https://www.elastic.co/guide/en/elasticsearch/reference/6.8/rpm.html
https://www.elastic.co/guide/en/elasticsearch/reference/6.8/docker.html
https://mp.weixin.qq.com/s/butkGiFGW_xfymHRsVgdww
https://blog.csdn.net/belonghuang157405/article/details/83301937


docker-compose

github下载 “docker-compose-Linux-x86_64”文件上传到服务器上,然后执行如下命令

mv docker-compose-Linux-x86_64 /usr/bin/docker-compose
chmod +x /usr/bin/docker-compose 
docker-compose -v

内核调整

echo "vm.max_map_count=262144" >> /etc/sysctl.conf
sysctl -p

重启docker

systemctl restart docker

vim /etc/security/limits.conf

root soft nofile 65535
root hard nofile 65535
* soft nofile 65535
* hard nofile 65535

elasticsearch

准备目录

mkdir -p /home/ELKStack/elasticsearch-data
chown -R 1000:1000 /home/ELKStack

elasticsearch配置

node1
cat elasticsearch.yml

cluster.name: elasticsearch
node.name: vnecaaselks001
network.host: 100.65.36.15
http.port: 9200
node.master: true
node.data: true
node.ingest: false
network.bind_host: 0.0.0.0
network.publish_host: 100.65.36.15
bootstrap.memory_lock: true
transport.tcp.port: 9300
http.cors.enabled: true
http.cors.allow-origin: "*"
transport.tcp.compress: true
discovery.zen.ping.unicast.hosts: ["100.65.36.15","100.65.36.16","100.65.36.17"]
discovery.zen.minimum_master_nodes: 1

node2
cat elasticsearch.yml

cluster.name: elasticsearch
node.name: vnecaaselks002
network.host: 100.65.36.16
http.port: 9200
node.ingest: false
node.master: true
node.data: true
transport.tcp.port: 9300
http.cors.enabled: true
http.cors.allow-origin: "*"
network.bind_host: 0.0.0.0
network.publish_host: 100.65.36.16
bootstrap.memory_lock: true
transport.tcp.compress: true
discovery.zen.ping.unicast.hosts: ["100.65.36.15","100.65.36.16","100.65.36.17"]
discovery.zen.minimum_master_nodes: 1

node3
cat elasticsearch.yml

cluster.name: elasticsearch
node.name: vnecaaselks003
network.host: 100.65.36.17
http.port: 9200
node.ingest: false
node.master: true
node.data: true
transport.tcp.port: 9300
http.cors.enabled: true
http.cors.allow-origin: "*"
network.bind_host: 0.0.0.0
network.publish_host: 100.65.36.17
bootstrap.memory_lock: true
transport.tcp.compress: true
discovery.zen.ping.unicast.hosts: ["100.65.36.15","100.65.36.16","100.65.36.17"]
discovery.zen.minimum_master_nodes: 1

docker-compose

每个节点都配置

cat docker-compose.yml

version: '2'
services:
  elasticsearch:
    image: docker.elastic.co/elasticsearch/elasticsearch:6.8.15
    container_name: elasticsearch
    environment:
      - cluster.name=elasticsearch
      - bootstrap.memory_lock=true
      - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
    ulimits:
      memlock:
        soft: -1
        hard: -1
    restart: always
    ports:
      - "9200:9200"
      - "9300:9300"
    volumes:
      - /home/ELKStack/elasticsearch-data:/usr/share/elasticsearch/data
      - /home/ELKStack/elasticsearch/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml

每个节点都启动

docker-compose up -d

验证

curl  -X GET http://localhost:9200/_cat/nodes

http://100.65.36.15:9200/_cat/nodes


kibana

https://www.elastic.co/guide/en/kibana/6.8/docker.html

准备目录

mkdir -p /home/ELKStack/kibana /home/ELKStack/kibana-data
chown -R 1000:1000 /home/ELKStack/kibana /home/ELKStack/kibana-data

配置

vim /home/ELKStack/kibana/kibana.yml

server.port: 5601
server.host: 0.0.0.0
elasticsearch.hosts: ["http://100.65.36.15:9200","http://100.65.36.16:9200","http://100.65.36.17:9200"]
xpack.security.enabled: false
kibana.index: ".kibana"
i18n.locale: "en"

docker-compose

vim docker-compose.yml

version: '2'
services:
  kibana:
    image: docker.elastic.co/kibana/kibana:6.8.15
    container_name: kibana
    restart: always
    ports:
      - "5601:5601"
    volumes:
       - /home/ELKStack/kibana/kibana.yml:/usr/share/kibana/config/kibana.yml
       - /home/ELKStack/kibana-data:/usr/share/kibana/data

启动

docker-compose up -d

验证
http://100.65.36.15:5601


filebeat

https://www.elastic.co/guide/en/beats/filebeat/6.8/filebeat-installation.html

下载

curl -L -O https://artifacts.elastic.co/downloads/beats/filebeat/filebeat-6.8.15-x86_64.rpm
rpm -ivh filebeat-6.8.15-x86_64.rpm

配置
vim /etc/filebeat/filebeat.yml

filebeat.inputs:
- type: log
  enabled: true
  paths:
    - /var/log/messages
  tags: ["messages"]
setup.template.settings:
  index.number_of_shards: 1
setup.kibana:
  host: "100.65.36.15:5601"
output.elasticsearch:
  hosts: ["100.65.36.15:9200","100.65.36.16:9200","100.65.36.17:9200"]
  indices:
    - index: "messages-%{+yyyy.MM.dd}"
      when.contains:
        tags: "messages"
setup.template.enabled: false
setup.template.overwrite: true
setup.ilm.enabled: false
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

wuxingge

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值