有事没事领个红包

elasticsearch7 docker集群部署

背景

在日志分析中常用中间件 ELK,工作中需要部署一套 elastic 7 集群用于存储数据。搭建过程如下。

镜像版本
elasticsearch:7.16.2
kibana:7.16.2

部署地址:192.168.20.20/192.168.20.21/192.168.20.22

创建目录

sudo mkdir -p /app/server/elasticsearch/temp/config
sudo mkdir -p /app/server/elasticsearch/temp/data
sudo mkdir -p /app/server/elasticsearch/temp/logs

修改权限

sudo chmod 777 /app/server/elasticsearch/temp/config
sudo chmod 777 /app/server/elasticsearch/temp/data
sudo chmod 777 /app/server/elasticsearch/temp/logs

在config目录新增配置文件, elasticsearch.yml

sudo vi /app/server/elasticsearch/temp/config/elasticsearch.yml

cluster.name: test
node.name: 192.168.20.20 //当前主机名
node.master: true
node.data: true
network.host: 0.0.0.0
http.port: 19200 //外部监听端口
transport.port: 19300 //集群内部通信端口
discovery.seed_hosts: ["192.168.20.21:19300","192.168.20.22:19300"] //候选 master
cluster.initial_master_nodes: ["192.168.20.21","192.168.20.22"] //初始化 master
http.cors.enabled: true
http.cors.allow-origin: "*"

容器启动配置。磁盘挂载

/app/server/elasticsearch/temp/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml
/app/server/elasticsearch/temp/data:/usr/share/elasticsearch/data
/app/server/elasticsearch/temp/logs:/usr/share/elasticsearch/logs

启动好后进行验证

curl -l http://192.168.20.20:19200
查看集群状态
curl -X GET "192.168.20.20:19200/_cat/health?v"
查看节点
curl -X GET "192.168.20.20:19200/_cat/nodes?v&pretty"
查看所有索引
curl -XGET "http://192.168.20.20:19200/_cat/indices?v&pretty"

可视化工具安装

####### kibana 安装

1 创建文件夹
sudo mkdir -p /app/server/elasticsearch/kibana/config

2 配置文件,kibana.yml
sudo vi /app/server/elasticsearch/kibana/config/kibana.yml

server.port: 9901
server.name: kibana
server.host: "0"
elasticsearch.hosts: ["http://192.168.20.20:19200"]
xpack.monitoring.ui.container.elasticsearch.enabled: true

3 启动配置
/app/server/elasticsearch/kibana/config/kibana.yml:/usr/share/kibana/config/kibana.yml


######## elasticsearch-hq 安装

docker run -d -p 9900:5000 elastichq/elasticsearch-hq:release-v3.5.12
posted @ 2022-01-25 14:32  crazyCodeLove  阅读(332)  评论(0编辑  收藏  举报