Linux基于Docker搭建Elasticsearch-7.12.0集群亲测可用

news/2024/7/7 5:52:35 标签: elasticsearch, docker

前言

提示:上文我们已经安装了elasticsearch:7.12.0和kibana:7.12.0


一、设置Elasticsearch挂载目录

设置文件夹

#存放配置文件的文件夹
mkdir -p /home/elasticsearch-7.12.0/esnode-1/config
mkdir -p /home/elasticsearch-7.12.0/esnode-2/config
mkdir -p /home/elasticsearch-7.12.0/esnode-3/config
#存放数据的文件夹
mkdir -p /home/elasticsearch-7.12.0/esnode-1/data
mkdir -p /home/elasticsearch-7.12.0/esnode-2/data
mkdir -p /home/elasticsearch-7.12.0/esnode-3/data
#存放运行日志的文件夹
mkdir -p /home/elasticsearch-7.12.0/esnode-1/log
mkdir -p /home/elasticsearch-7.12.0/esnode-2/log
mkdir -p /home/elasticsearch-7.12.0/esnode-3/log
#存放IK分词插件的文件夹
mkdir -p /home/elasticsearch-7.12.0/esnode-1/plugins
mkdir -p /home/elasticsearch-7.12.0/esnode-2/plugins
mkdir -p /home/elasticsearch-7.12.0/esnode-3/plugins

对文件加设置开放权限

chmod 777 /home/elasticsearch-7.12.0/esnode-1/data
chmod 777 /home/elasticsearch-7.12.0/esnode-2/data
chmod 777 /home/elasticsearch-7.12.0/esnode-3/data
chmod 777 /home/elasticsearch-7.12.0/esnode-1/plugins
chmod 777 /home/elasticsearch-7.12.0/esnode-2/plugins
chmod 777 /home/elasticsearch-7.12.0/esnode-3/plugins
chmod 777 /home/elasticsearch-7.12.0/esnode-1/log
chmod 777 /home/elasticsearch-7.12.0/esnode-2/log
chmod 777 /home/elasticsearch-7.12.0/esnode-3/log
chmod 777 /home/elasticsearch-7.12.0/esnode-1/config
chmod 777 /home/elasticsearch-7.12.0/esnode-3/config
chmod 777 /home/elasticsearch-7.12.0/esnode-2/config

二、创建多个yml到data目录

在每个节点的config下创建elasticsearch.yml文件

cd /home/elasticsearch-7.12.0/esnode-1/config
vim elasticsearch.yml

elasticsearch.yml文件内容

cluster.name: my-es
node.name: node-1
node.master: true
node.data: true
node.max_local_storage_nodes: 4
path.data: /usr/share/elasticsearch/data
path.logs: /usr/share/elasticsearch/log
network.host: 0.0.0.0
network.publish_host: 192.168.28.129
http.port: 9201
transport.tcp.port: 9301
discovery.seed_hosts: ["192.168.28.129:9301","192.168.28.129:9302","192.168.28.129:9303"]
cluster.initial_master_nodes: ["node-1","node-2","node-3"]
gateway.recover_after_nodes: 3
cd /home/elasticsearch-7.12.0/esnode-2/config
vim elasticsearch.yml

elasticsearch.yml文件内容

cluster.name: my-es
node.name: node-2
node.master: true
node.data: true
node.max_local_storage_nodes: 4
path.data: /usr/share/elasticsearch/data
path.logs: /usr/share/elasticsearch/log
network.host: 0.0.0.0
network.publish_host: 192.168.28.129
http.port: 9202
transport.tcp.port: 9302
discovery.seed_hosts: ["192.168.28.129:9301","192.168.28.129:9302","192.168.28.129:9303"]
cluster.initial_master_nodes: ["node-1","node-2","node-3"]
gateway.recover_after_nodes: 2
cd /home/elasticsearch-7.12.0/esnode-3/config
vim elasticsearch.yml

elasticsearch.yml文件内容

cluster.name: my-es
node.name: node-3
node.master: true
node.data: true
node.max_local_storage_nodes: 4
path.data: /usr/share/elasticsearch/data
path.logs: /usr/share/elasticsearch/log
network.host: 0.0.0.0
network.publish_host: 192.168.28.129
http.port: 9203
transport.tcp.port: 9303
discovery.seed_hosts: ["192.168.28.129:9301","192.168.28.129:9302","192.168.28.129:9303"]
cluster.initial_master_nodes: ["node-1","node-2","node-3"]
gateway.recover_after_nodes: 2

三、放行端口

  • 放行相关端口
firewall-cmd --zone=public --add-port=9200/tcp --permanent
firewall-cmd --zone=public --add-port=9201/tcp --permanent
firewall-cmd --zone=public --add-port=9202/tcp --permanent
firewall-cmd --zone=public --add-port=9300/tcp --permanent
firewall-cmd --zone=public --add-port=9301/tcp --permanent
firewall-cmd --zone=public --add-port=9302/tcp --permanent
#这个是kibana端口,等会会用到
firewall-cmd --zone=public --add-port=5601/tcp --permanent

  • 更新防火墙规则
firewall-cmd --complete-reload
  • 查看当前所开放的端口
firewall-cmd --zone=public --list-ports

三、安装并启动es节点

docker run -e ES_JAVA_OPTS="-Xms256m -Xmx256m" -d -p 9201:9201 -p 9301:9301 -v /home/elasticsearch-7.12.0/esnode-1/config/elasticsearch-7.12.0.yml:/usr/share/elasticsearch-7.12.0/config/elasticsearch-7.12.0.yml -v /home/elasticsearch-7.12.0/esnode-1/plugins:/usr/share/elasticsearch-7.12.0/plugins -v /home/elasticsearch-7.12.0/esnode-1/data:/usr/share/elasticsearch-7.12.0/data -v /home/elasticsearch-7.12.0/esnode-1/log:/usr/share/elasticsearch-7.12.0/log --name es-esnode-1 elasticsearch-7.12.0:7.12.0

docker run -e ES_JAVA_OPTS="-Xms256m -Xmx256m" -d -p 9202:9202 -p 9302:9302 -v /home/elasticsearch-7.12.0/esnode-2/config/elasticsearch-7.12.0.yml:/usr/share/elasticsearch-7.12.0/config/elasticsearch-7.12.0.yml -v /home/elasticsearch-7.12.0/esnode-2/plugins:/usr/share/elasticsearch-7.12.0/plugins -v /home/elasticsearch-7.12.0/esnode-2/data:/usr/share/elasticsearch-7.12.0/data -v /home/elasticsearch-7.12.0/esnode-2/log:/usr/share/elasticsearch-7.12.0/log --name es-esnode-2 elasticsearch-7.12.0:7.12.0

docker run -e ES_JAVA_OPTS="-Xms256m -Xmx256m" -d -p 9203:9203 -p 9303:9303 -v /home/elasticsearch-7.12.0/esnode-3/config/elasticsearch-7.12.0.yml:/usr/share/elasticsearch-7.12.0/config/elasticsearch-7.12.0.yml -v /home/elasticsearch-7.12.0/esnode-3/plugins:/usr/share/elasticsearch-7.12.0/plugins -v /home/elasticsearch-7.12.0/esnode-3/data:/usr/share/elasticsearch-7.12.0/data -v /home/elasticsearch-7.12.0/esnode-3/log:/usr/share/elasticsearch-7.12.0/log --name es-esnode-3 elasticsearch-7.12.0:7.12.0

三、检测集群是否的搭建成功

打开浏览器,输入地址http://192.168.28.129:9201/_cat/nodes?pretty

http://192.168.28.129:9201/_cat/nodes?pretty

搭建成功会出现
在这里插入图片描述

四、创建Kibana的YML文件

前面我们已经创建过Kibana的yml文件,目录是
/data/elk7/kibana/config/kibana.yml,如果还未创建,可自行创建

vim /data/elk7/kibana/config/kibana.yml
erver.port: 5601
server.host: "0.0.0.0"
server.name: "kibana-192.168.28.129"
elasticsearch.hosts: ["http://192.168.28.129:9201","http://192.168.28.129:9202","http://192.168.28.129:9203"]
i18n.locale: "zh-CN"
xpack.monitoring.ui.container.elasticsearch.enabled: true

五、安装并启动Kibana容器

输入命令,指定network网络

docker run -d -p 5601:5601 -v /home/kibana/config/kibana.yml:/usr/share/kibana/config/kibana.yml --network es-net  --name kibana1 kibana:7.12.0

六、登录网址进行验证

http://192.168.28.129:5601

在这里插入图片描述


http://www.niftyadmin.cn/n/874216.html

相关文章

django手机访问_Django的认证系统

点击上方“Python Web与Django大咖之路”关注我!Django自带的用户认证我们在开发一个网站的时候,无可避免的需要设计实现网站的用户系统。此时我们需要实现包括用户注册、用户登录、用户认证、注销、修改密码等功能,这还真是个麻烦的事情呢。Django作为一…

Elasticsearch尚硅谷学习笔记(三)进阶详解

1、核心概念 1.1 索引(Index) 一个索引就是一个拥有几分相似特征的文档的集合。比如说,你可以有一个客户数据的索引,另一个产品目录的索引,还有一个订单数据的索引。一个索引由一个名字来标识(必须全部是…

microsoft office visio 科学图形包_Visio——入门教程

Visio搞起工作中,我们难免会遇到需要制作各种图形的时候,思维导图、流程图、甘特图、韦恩图、组织结构图……你以为一个SmartArt就能搞定了吗?那咋办? 不能够!今天小编就给大家带来一款非常好用的绘制流程图和矢量图形…

python提取txt内容写入新word_读取word文档并提取和写入数据(基于python 3.6)

#!/usr/bin/python3 # -*- coding: utf-8 -*- # File : delete_file # Author : moucong # Date : 2018/4/1 16:33 # Software: PyCharm #读取docx中的文本代码示例 import docx import re #获取文档 filedocx.Document("E:\\python_word\\word.docx") print("段…

Plugin [analysis-ik] was built for Elasticsearch version 7.4.1 but version 7.4.2 is running

CentOs8安装ik分词器,发现Elasticsearch不运行了 通过查看日志发现,ik分词器版本是7.4.1,es版本是7.4.2,版本不一致导致的 进入es启动挂载的目录内,修改plugin-descriptor.properties配置文件的版本号 最后一步重启…

H5实现一键复制功能ios不兼容问题

上文使用的代码经过多个系统版本ios测试还是不生效,网上的方法都试过,ios手机还是不生效,就算demo生效,但是由于实际业务代码一些样式等影响或者其他原因,业务功能复制链接在ios手机还是显示不兼容,ios估计…

python 条形图 stack_python用matplotlib画条形图初探‘单变量,双变量堆叠

一、包 python]view plain copy import numpy as np import matplotlib.pyplot as plt 二、单变量(垂直) [python]view plain copy y [5, 10, 15, 20, 25] index np.arange(len(y)) plt.bar(leftindex, heighty, colorr, width0.5) # 水平对应left&…

SpringBoot项目H5界面手机拍照调用腾讯云OCR卡证识别接口完整例子

最近一个微信端项目的功能涉及一个手机拍照上传身份证识别身份证信息回显的功能,调用的接口是腾讯云OCR的卡证识别功能。看了腾讯云的api通俗易懂,本地写好了demo测试可用。H5界面手机拍照调用后台方法保存身份证照片进行识别也可用,难度就在…