当前位置:网站首页>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

完
边栏推荐
- PHP security flaws: session hijacking, cross-site scripting, SQL injection and how to fix them
- PAT 甲级 A1003 Emergency
- 第一次改开源中间件keycloak总个结
- 实习日报-2022-7-29
- 参观首钢园
- 网站备案后没有找到站点 您没有将此域名或IP绑定到对应站点! 配置文件未生效!
- Meeting OA project (6) --- (to-be-opened meeting, historical meeting, all meetings)
- 蚂蚁首次披露核心基础软件技术开源版图
- The untiy Resources directory dynamically loads resources
- DOM series of touch screen events
猜你喜欢

5年测试,只会功能要求17K,功能测试都敢要求这么高薪资了?

月薪12K,蝶变向新勇往直前,我通过转行软件测试实现月薪翻倍...

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

指针进阶(三)之指针与数组笔试题

08 spark 集群搭建

Vulnhub target drone: HARRYPOTTER_ NAGINI

【黑马早报】胡军代言悟空理财涉嫌欺诈,疑似涉及390亿元;涪陵榨菜回应榨菜吃出脚指甲; 鸿星尔克再捐1个亿;腾讯控股股价跌回5年前...

DOM系列之classList属性

shell 基础之函数编写

mysql 面试题
随机推荐
显示为弹出窗口是什么意思(电脑总是弹出广告)
TiFlash 存储层概览
MUI as a mobile phone to return to the action bar
Chapter 13 Manually create a REST service (1)
Vulnhub靶机:HARRYPOTTER_ NAGINI
MySQL locking case analysis
The untiy Resources directory dynamically loads resources
C # Excel helper classes
2022强网杯CTF---强网先锋 ASR wp
美国弗吉尼亚大学、微软 | Active Data Pattern Extraction Attacks on Generative Language Models(对生成语言模型的主动数据模式提取攻击)
完全背包问题求组合数和排列数
MySQL INTERVAL 关键字指南
Winform message prompt box helper class
【黑马早报】胡军代言悟空理财涉嫌欺诈,疑似涉及390亿元;涪陵榨菜回应榨菜吃出脚指甲; 鸿星尔克再捐1个亿;腾讯控股股价跌回5年前...
UI helper class for Winform - some components will use DevExpress components
Complete knapsack problem to find the number of combinations and permutations
ESP8266-Arduino编程实例-GA1A12S202对数刻度模拟光传感器
04 flink 集群搭建
Spark: Cluster Computing with Working Sets
C#的FTP帮助类