Elasticsearch集群搭建实战
来源:互联网 发布:上海财经大学知乎 编辑:程序博客网 时间:2024/05/02 00:34
1. 基础配置与安装
1.1 基础环境
node110.202.20.191
node210.202.20.192
node310.202.20.193
node410.202.20.194
node510.202.20.195
node610.202.20.196
node710.202.20.197
node810.202.20.198
以上服务器基于现在的云平台(32核,96G内存),OS:centos6.6
1.1.1 安装JAVA
yum -y installjdk-8u51-linux-x64.rpm
rm /usr/bin/java
ln -s /usr/java/jdk1.8.0_51/bin/java/usr/bin/java
1.1.2 OS环境配置
在/etc/sysctl.conf中添加以下三行:
vm.zone_reclaim_mode=0
vm.max_map_count = 262144
vm.swappiness = 1
执行sysctl –p让配置生效
在/etc/security/limits.conf 中添加以下四行:
* soft nofile 65536
* hard nofile 65536
* soft nproc 65536
* hard nproc 65536
在/etc/hosts加入以下信息:
10.202.20.191 ras1.novalocal
10.202.20.192 ras2.novalocal
10.202.20.193 ras3.novalocal
10.202.20.194 ras4.novalocal
10.202.20.195 ras5.novalocal
10.202.20.196 ras6.novalocal
10.202.20.197 ras7.novalocal
10.202.20.198 ras8.novalocal
1.1.3 添加用户
useradd elastic
在/home/elastic/.bash_profile中添加
export JAVA_HOME=/usr/java/jdk1.8.0_51
修改path
PATH=$PATH:$HOME/bin:/opt/elasticsearch/bin
1.1.4 配置存储
mkdir /data1
mkdir /data2
mount /dev/vdb1 /data1
mount /dev/vdc1 /data2
chmod 777 /data1
chmod 777 /data2
1.2 Elasticsearch安装
1.2.1 安装
https://www.elastic.co/downloads/elasticsearch下载对应的版本
tar xvf elasticsearch-1.7.5.tar.gz -C /opt
mv /opt/elasticsearch-1.7.5 /opt/elasticsearch
chown -R elastic.elastic /opt/elasticsearch
1.2.2 配置
su – elastic
cd /opt/elasticsearch/config/
准备几个目录,用于存放数据文件,建议使用SSD,如果是硬盘,建议用raid0
mkdir -p /data1/elastic/data1file
mkdir -p /data2/elastic/data2file
配置参数文件,在配置前,做个备份
cp elasticsearch.yml elasticsearch.yml.bak
修改参数文件
集群名称:
cluster.name: FVP-RAS
节点名称:
node.name:"node1"
数据复制份数:
index.number_of_replicas: 2
数据文件:
如果存放位置多个地方,用逗号分开每个目录
path.data: /data1/elastic/data1file,/data2/elastic/data2file
内存锁定:
bootstrap.mlockall: true
通讯地址:
network.publish_host: 10.202.20.191
恢复相关:
能执行恢复最小节点数:
gateway.recover_after_nodes:6
6个节点起来后,等10分钟才执行恢复
gateway.recover_after_time:10m
已有7个节点起来,马上执行恢复
gateway.expected_nodes:7
定义发现相关:
定义发现主节点数:
discovery.zen.minimum_master_nodes: 5
注意:这里设定为N/2+1,8节点为8/2+1=5
关闭自动发现节点:
discovery.zen.ping.multicast.enabled: false
定义发现的节点:
discovery.zen.ping.unicast.hosts: ["ras1.novalocal","ras2.novalocal","ras3.novalocal","ras4.novalocal","ras5.novalocal","ras6.novalocal","ras7.novalocal","ras8.novalocal"]
cd/opt/elasticsearch/bin
Heap内存大小:
elasticsearch.in.sh 第四行添加ES_HEAP_SIZE=31232m
2. 操作
2.1 启动
/opt/elasticsearch/bin/elasticsearch -d
默认是在前台运行,如果想在后台运行,请使加–d参数
启动后可以通地/opt/elasticsearch/logs/FVP-RAS.log来查看相关信息,动态查看命令如下:
tail -f /opt/elasticsearch/logs/FVP-RAS.log
也可以使用标准的查询结口查询:
curl -XGET"http://$(hostname):9200/_cluster/health?pretty=true"
2.2 停止
curl -XPOST "http:// $(hostname):9200/_shutdown"
确定是否已停:
ps -ef|grepelasticsearch
2.3 监控
2.
2.1
2.2
2.3
2.3.1 集群健康度
curl$(hostname):9200/_cluster/health?pretty
2.3.2 集群状态
curl$(hostname):9200/_cluster/stats?pretty
2.3.3 节点状态
curl$(hostname):9200/_nodes/process?pretty
curl $(hostname):9200/_nodes/node1/process?pretty
2.4 null
null
2.5 null
null
2.6 null
null
- Elasticsearch集群搭建实战
- elasticsearch 集群搭建步骤
- ElasticSearch — 集群搭建
- Elasticsearch集群搭建
- elasticsearch集群搭建
- ElasticSearch集群搭建实例
- elasticsearch 集群搭建
- elasticsearch 集群的搭建
- 搭建Elasticsearch分布式集群
- elasticsearch 集群搭建
- Elasticsearch集群环境搭建
- elasticsearch 集群搭建
- Elasticsearch集群搭建
- 使用elasticsearch搭建集群
- ElasticSearch集群搭建
- Elasticsearch集群搭建
- ElasticSearch集群搭建
- ElasticSearch集群搭建
- Windows服务 开机自动运行
- 剑指offer-001
- IOS Dev Intro - UIControlEvent
- 向量中断和非向量中断
- EhLib 7.0.133,有关DbGridEh的使用的一些细节
- Elasticsearch集群搭建实战
- UITableView学习笔记
- 第二天 关于XML语言
- 剑指offer-面试题12:打印1到最大的n位数
- Install SharePoint2016 RTM - Hardware and Software Requirements
- Go语言概览——《Java程序员学习Go》之一
- 剑指offer----矩形覆盖问题的解析与实现
- DDD架构图
- android studio 插件