当前位置:网站首页>02 es cluster construction
02 es cluster construction
2022-08-01 16:35:00 【blue wind 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. System configuration changes involved
编辑 /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=14. 切换到 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 Request query indexed data

完
边栏推荐
- Winform的消息提示框帮助类
- 比对软件-blastN结果详解
- AntDB数据库亮相24届高速展,助力智慧高速创新应用
- mysql源码分析——聚簇索引
- Good guy, the company server just crashed!
- Vulnhub靶机:HARRYPOTTER_ NAGINI
- 面试必问的HashCode技术内幕
- PHP security flaws: session hijacking, cross-site scripting, SQL injection and how to fix them
- 11 Publish a series as soon as it is released
- 月薪12K,蝶变向新勇往直前,我通过转行软件测试实现月薪翻倍...
猜你喜欢

ESP8266-Arduino programming example-GA1A12S202 logarithmic scale analog light sensor
MySQL INTERVAL 关键字指南

C#中关于DevExpress的常用操作和帮助类项目工程内容说明

参观首钢园

AntDB数据库亮相24届高速展,助力智慧高速创新应用

Ant discloses the open source layout of core basic software technology for the first time

珠海市生物安全P3实验室主体结构封顶

14年测试人最近的面试经历,值得借鉴√

指针进阶(二)

阿里官方 Redis 开发规范
随机推荐
03 gp 集群搭建
面试必问的HashCode技术内幕
PAT 甲级 A1003 Emergency
Go 单元测试
5年测试,只会功能要求17K,功能测试都敢要求这么高薪资了?
软测面试如何介绍项目?要做哪些技术准备?
14年测试人最近的面试经历,值得借鉴√
ESP8266-Arduino编程实例-74HC595位移寄存驱动
05 doris 集群搭建
2022 Strong Net Cup CTF---Strong Net Pioneer ASR wp
Winform的UI帮助类——部分组件会使用到DevExpress组件
月薪12K,蝶变向新勇往直前,我通过转行软件测试实现月薪翻倍...
js邯郸市地图网页源码下载
11 一发布就发布一系列系列
我的新书销量1万册了!
Complete knapsack problem to find the number of combinations and permutations
如何防止重复下单?
ESP8266-Arduino programming example-GA1A12S202 logarithmic scale analog light sensor
测试技术|白盒测试以及代码覆盖率实践
显示为弹出窗口是什么意思(电脑总是弹出广告)