当前位置:网站首页>02 es 集群搭建
02 es 集群搭建
2022-08-01 16:19:00 【蓝风9】
前言
呵呵 最近有一系列环境搭建的相关需求
记录一下
es 三个节点 : 192.168.110.150, 192.168.110.151, 192.168.110.152
150 为 master, 151 为 slave01, 152 为 slave02
三台机器都做了 trusted shell
es 单节点 docker 搭建
创建 docker-compose.yml 如下, 然后 docker-compose up -d 启动 es 即可使用
version: '3'
services:
es:
image: elasticsearch:7.7.0
container_name: es
environment:
- "cluster.name=es"
- "discovery.type=single-node"
- "ES_JAVA_OPTS=-Xms1024m -Xmx1024m"
volumes:
# - ./es/plugins:/usr/share/elasticsearch/plugins
- ./es/data:/usr/share/elasticsearch/data
- ./es/config:/usr/share/elasticsearch/config
ports:
- 9200:9200
- 9300:9300
kibana:
image: kibana:7.7.0
container_name: kibana
depends_on:
- es
environment:
- "elasticsearch.hosts=http://es:9200"
volumes:
- ./kibana/config:/usr/share/kibana/config
ports:
- 5601:5601
es 集群搭建
es 三个节点 : 192.168.110.150, 192.168.110.151, 192.168.110.152
1. 基础环境准备
192.168.110.150, 192.168.110.151, 192.168.110.152 上面安装 jdk, 上传 es 的安装包
es 7.17 至少需要 jdk11
安装包来自于 Download Elasticsearch | Elastic
2. es 配置调整
更新 master, slave01, slave02 的 elasticsearch.yml 的配置文件如下
cluster.name: es_cluster
cluster.initial_master_nodes: ["master_1"]
node.master: true
node.max_local_storage_nodes: 3
node.name: master_1
node.data: false
path.data: /data/es/data/master_1
path.logs: /data/es/log/master_1
bootstrap.memory_lock: true
network.host: master
http.port: 9210
transport.tcp.port: 9310
discovery.zen.ping.unicast.hosts: ["master:9310"]
discovery.zen.minimum_master_nodes: 1
gateway.recover_after_nodes: 1
action.destructive_requires_name: true
discovery.zen.ping_timeout: 10s
node.attr.size: medium
cluster.name: es_cluster
cluster.initial_master_nodes: ["master_1"]
node.master: false
node.max_local_storage_nodes: 3
node.name: slave_1
node.data: true
path.data: /data/es/data/slave_1
path.logs: /data/es/log/slave_1
bootstrap.memory_lock: true
network.host: slave01
http.port: 9210
transport.tcp.port: 9310
discovery.zen.ping.unicast.hosts: ["master:9310"]
discovery.zen.minimum_master_nodes: 1
gateway.recover_after_nodes: 1
action.destructive_requires_name: true
discovery.zen.ping_timeout: 10s
node.attr.size: medium
cluster.name: es_cluster
cluster.initial_master_nodes: ["master_1"]
node.master: false
node.max_local_storage_nodes: 3
node.name: slave_2
node.data: true
path.data: /data/es/data/slave_2
path.logs: /data/es/log/slave_2
bootstrap.memory_lock: true
network.host: slave02
http.port: 9210
transport.tcp.port: 9310
discovery.zen.ping.unicast.hosts: ["master:9310"]
discovery.zen.minimum_master_nodes: 1
gateway.recover_after_nodes: 1
action.destructive_requires_name: true
discovery.zen.ping_timeout: 10s
node.attr.size: medium
三台机器分别创建 数据目录, 日志目录
mkdir -p /data/es/data/master_1
mkdir -p /data/es/log/master_1
mkdir -p /data/es/data/slave_1
mkdir -p /data/es/log/slave_1
mkdir -p /data/es/data/slave_2
mkdir -p /data/es/log/slave_2
新增 es 用户, 并增加相关配置
groupadd es
useradd -g es es
chown -R es:es /usr/local/ProgramFiles/elasticsearch-7.17/
chown -R es:es /data/es
passwd es
3. 修改涉及的系统配置
编辑 /etc/security/limits.conf, 新增如下配置
* soft nofile 300000
* hard nofile 300000
* soft nofile 65536
* hard nofile 65536
* hard memlock unlimited
* soft memlock unlimited
编辑 /etc/sysctl.conf 配置文件, 新增如下配置, 并使用 sysctl -p 重启
vm.max_map_count=262144
vm.swappiness=1
4. 切换到 es 用户, 启动集群
三台机器 分别切换到 es 用户
并启动集群, 注意 es 7.17 需要 jdk11
./bin/elasticsearch -d
测试集群
基于 curl 的测试
[email protected]:/usr/local/ProgramFiles/kafka_2.12-2.8.1# curl -XPUT -H 'content-Type:application/json' -d '{"mappings":{"properties":{"title":{"type":"text"},"description":{"type":"text"},"price":{"type":"double"},"onSale":{"type":"boolean"},"type":{"type":"integer"},"createDate":{"type":"date"}}}}' http://192.168.110.150:9210/position/?pretty
{
"acknowledged" : true,
"shards_acknowledged" : true,
"index" : "position"
}
[email protected]:/usr/local/ProgramFiles/kafka_2.12-2.8.1# curl -XPOST -H 'content-Type:application/json' -d '{"id":"5","title":"chinese","description":"chinese","price":5000}' http://192.168.110.150:9210/position/_doc
{"_index":"position","_type":"_doc","_id":"E23qwoABZqbSMddNmV3L","_version":1,"result":"created","_shards":{"total":2,"successful":2,"failed":0},"_seq_no":0,"_primary_term":1}
[email protected]:/usr/local/ProgramFiles/kafka_2.12-2.8.1# curl -XPOST -H 'content-Type:application/json' -d '{"id":"6","title":"math","description":"math","price":2000}' http://192.168.110.150:9210/position/_doc
{"_index":"position","_type":"_doc","_id":"FG3qwoABZqbSMddNml1j","_version":1,"result":"created","_shards":{"total":2,"successful":2,"failed":0},"_seq_no":1,"_primary_term":1}
[email protected]:/usr/local/ProgramFiles/kafka_2.12-2.8.1# curl -XPOST -H 'content-Type:application/json' -d '{"id":"6","title":"english","description":"english","price":3000}' http://192.168.110.150:9210/position/_doc
{"_index":"position","_type":"_doc","_id":"FW3qwoABZqbSMddNml2k","_version":1,"result":"created","_shards":{"total":2,"successful":2,"failed":0},"_seq_no":2,"_primary_term":1}
[email protected]:/usr/local/ProgramFiles/kafka_2.12-2.8.1# curl http://192.168.110.150:9210/position/_search
{"took":896,"timed_out":false,"_shards":{"total":1,"successful":1,"skipped":0,"failed":0},"hits":{"total":{"value":3,"relation":"eq"},"max_score":1.0,"hits":[{"_index":"position","_type":"_doc","_id":"E23qwoABZqbSMddNmV3L","_score":1.0,"_source":{"id":"5","title":"chinese","description":"chinese","price":5000}},{"_index":"position","_type":"_doc","_id":"FG3qwoABZqbSMddNml1j","_score":1.0,"_source":{"id":"6","title":"math","description":"math","price":2000}},{"_index":"position","_type":"_doc","_id":"FW3qwoABZqbSMddNml2k","_score":1.0,"_source":{"id":"6","title":"english","description":"english","price":3000}}]}}
[email protected]:/usr/local/ProgramFiles/kafka_2.12-2.8.1#
浏览器中 get 请求查询索引的数据
完
边栏推荐
猜你喜欢
随机推荐
便携烙铁开源系统IronOS,支持多款便携DC, QC, PD供电烙铁,支持所有智能烙铁标准功能
BPM是什么意思?BPM的优势及好处有哪些?
如何防止重复下单?
How to Efficiently Develop Jmix Extension Components
kubelet node pressure eviction
Zhaoqi Science and Technology Innovation Platform attracts talents and attracts talents, and attracts high-level talents at home and abroad
canvas粒子雨动画js特效
DOM series of touch screen events
uwsgi配置文件启动
ESP8266-Arduino编程实例-MLX90614红外测温传感器驱动
蚂蚁首次披露核心基础软件技术开源版图
【建议收藏】技术面必考题:多线程、多进程
显示为弹出窗口是什么意思(电脑总是弹出广告)
Kernel pwn 入门 (6)
PHP 安全漏洞:会话劫持、跨站点脚本、SQL 注入以及如何修复它们
AI艺术‘美丑’不可控?试试 AI 美学评分器~
全网最全音视频媒体流
IronOS, an open source system for portable soldering irons, supports a variety of portable DC, QC, PD powered soldering irons, and supports all standard functions of smart soldering irons
shell 基础之函数编写
2.8K 120Hz touch dual-screen blessing Lingyao X dual-screen Pro 2022 makes the office without fear of imagination