Elasticsearch6.3.1 tar包离线集群安装手册

前提准备
jdk安装包
elasticsearch安装包
1、在/app下创建es文件夹 创建/app/es/eslogs文件夹(每台机器)

传入相关压缩文件解压后 elasticsearch-6.3.1  jdk1.8.0_181
安装用户为es

2、安装jdk(每台机器)

配置环境变量
vi ~/.bash_profile

JAVA_HOME=/app/es/jdk1.8.0_181
JRE_HOME=${JAVA_HOME}/jre
CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
PATH=${JAVA_HOME}/bin:$PATH
export JAVA_HOME JRE_HOME CLASSPATH PATH
保存退出
source ~/.bash_profile

3、修改系统参数(每台机器;需root管理员)

vi /etc/sysctl.conf
es vm.max_map_count=262144
执行  sysctl -p 生效
vi /etc/security/limits.conf
es hard nofile 65536
vi /etc/security/limits.conf
es soft memlock unlimited
es hard memlock unlimited 
重新登录生效

4、data节点硬盘挂载(data节点操作)
相关运维人员完成T级别磁盘挂载
5、修改elasticsearch-6.3.1/config/jvm.options和elasticsearch-6.3.1/config/elasticsearch.yml

## JVM configuration

################################################################
## IMPORTANT: JVM heap size
################################################################
##
## You should always set the min and max JVM heap
## size to the same value. For example, to set
## the heap to 4 GB, set:
##
## -Xms1g
## -Xmx1g
##
## See https://www.elastic.co/guide/en/elasticsearch/reference/current/heap-size.html
## for more information
##
################################################################

# Xms represents the initial size of total heap space
# Xmx represents the maximum size of total heap space

-Xms31g
-Xmx31g
(1)master节点 三台机器分别是
cluster.name: pass-es
node.name: master-1
node.data: false
node.master: true
path.logs: /app/es/eslogs
bootstrap.memory_lock: true
network.host: 134.108.0.98
http.port: 9200
discovery.zen.ping.unicast.hosts: ["134.108.0.98", "134.108.0.99", "134.108.0.100","134.108.0.101","134.108.0.102","134.108.0.103","134.108.0.104","134.108.0.105","134.108.0.106"]
discovery.zen.minimum_master_nodes: 2

cluster.name: pass-es
node.name: master-2
node.data: false
node.master: true
path.logs: /app/es/eslogs
bootstrap.memory_lock: true
network.host: 134.108.0.99
http.port: 9200
discovery.zen.ping.unicast.hosts: ["134.108.0.98", "134.108.0.99", "134.108.0.100","134.108.0.101","134.108.0.102","134.108.0.103","134.108.0.104","134.108.0.105","134.108.0.106"]
discovery.zen.minimum_master_nodes: 2

cluster.name: pass-es
node.name: master-3
node.data: false
node.master: true
path.logs: /app/es/eslogs
bootstrap.memory_lock: true
network.host: 134.108.0.100
http.port: 9200
discovery.zen.ping.unicast.hosts: ["134.108.0.98", "134.108.0.99", "134.108.0.100","134.108.0.101","134.108.0.102","134.108.0.103","134.108.0.104","134.108.0.105","134.108.0.106"]
discovery.zen.minimum_master_nodes: 2

(2)client节点 三台机器分别是
cluster.name: pass-es
node.name: client-1
node.data: false
node.master: false
path.logs: /app/es/eslogs
bootstrap.memory_lock: true
network.host: 134.108.0.102
http.port: 9200
discovery.zen.ping.unicast.hosts: ["134.108.0.98", "134.108.0.99", "134.108.0.100","134.108.0.101","134.108.0.102","134.108.0.103","134.108.0.104","134.108.0.105","134.108.0.106"]
discovery.zen.minimum_master_nodes: 2

cluster.name: pass-es
node.name: client-1
node.data: false
node.master: false
path.logs: /app/es/eslogs
bootstrap.memory_lock: true
network.host: 134.108.0.101
http.port: 9200
discovery.zen.ping.unicast.hosts: ["134.108.0.98", "134.108.0.99", "134.108.0.100","134.108.0.101","134.108.0.102","134.108.0.103","134.108.0.104","134.108.0.105","134.108.0.106"]
discovery.zen.minimum_master_nodes: 2

cluster.name: pass-es
node.name: client-1
node.data: false
node.master: false
path.logs: /app/es/eslogs
bootstrap.memory_lock: true
network.host: 134.108.0.103
http.port: 9200
discovery.zen.ping.unicast.hosts: ["134.108.0.98", "134.108.0.99", "134.108.0.100","134.108.0.101","134.108.0.102","134.108.0.103","134.108.0.104","134.108.0.105","134.108.0.106"]
discovery.zen.minimum_master_nodes: 2

(3)data节点 三台机器分别是
cluster.name: pass-es
node.name: datanode-1
node.data: true
node.master: false
path.logs: /app/es/eslogs
path.data: /data01,/data02,/data03,/data04,/data05,/data06,/data07,/data08,/data09,/data10,/data11,/data12
bootstrap.memory_lock: true
network.host: 134.108.0.104
http.port: 9200
discovery.zen.ping.unicast.hosts: ["134.108.0.98", "134.108.0.99", "134.108.0.100","134.108.0.101","134.108.0.102","134.108.0.103","134.108.0.104","134.108.0.105","134.108.0.106"]
discovery.zen.minimum_master_nodes: 2

cluster.name: pass-es
node.name: datanode-2
node.data: true
node.master: false
path.logs: /app/es/eslogs
path.data: /data01,/data02,/data03,/data04,/data05,/data06,/data07,/data08,/data09,/data10,/data11,/data12
bootstrap.memory_lock: true
network.host: 134.108.0.105
http.port: 9200
discovery.zen.ping.unicast.hosts: ["134.108.0.98", "134.108.0.99", "134.108.0.100","134.108.0.101","134.108.0.102","134.108.0.103","134.108.0.104","134.108.0.105","134.108.0.106"]
discovery.zen.minimum_master_nodes: 2

cluster.name: pass-es
node.name: datanode-3
node.data: true
node.master: false
path.logs: /app/es/eslogs
path.data: /data01,/data02,/data03,/data04,/data05,/data06,/data07,/data08,/data09,/data10,/data11,/data12
bootstrap.memory_lock: true
network.host: 134.108.0.106
http.port: 9200
discovery.zen.ping.unicast.hosts: ["134.108.0.98", "134.108.0.99", "134.108.0.100","134.108.0.101","134.108.0.102","134.108.0.103","134.108.0.104","134.108.0.105","134.108.0.106"]
discovery.zen.minimum_master_nodes: 2

6、启动脚本(每台机器;需root管理员)
在/etc/init.d目录下新建文件elasticsearch


#!/bin/sh
#chkconfig: 2345 80 05
#description: elasticsearch
 
export JAVA_HOME=/usr/java/jdk1.8.0_112
export JAVA_BIN=/usr/java/jdk1.8.0_112/bin
export PATH=$PATH:$JAVA_HOME/bin
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export JAVA_HOME JAVA_BIN PATH CLASSPATH

case "$1" in
start)
    su es<<!
    cd /home/elasticsearch
    ./bin/elasticsearch -d
!
    echo "elasticsearch startup"
    ;;  
stop)
    es_pid=`ps aux|grep elasticsearch | grep -v 'grep elasticsearch' | awk '{print $2}'`
    kill -9 $es_pid
    echo "elasticsearch stopped"
    ;;  
restart)
    es_pid=`ps aux|grep elasticsearch | grep -v 'grep elasticsearch' | awk '{print $2}'`
    kill -9 $es_pid
    echo "elasticsearch stopped"
    su es<<!
    cd /home/elasticsearch
    ./bin/elasticsearch -d
!
    echo "elasticsearch startup"
    ;;  
*)
    echo "start|stop|restart"
    ;;  
esac

exit $?

保存退出,赋予执行权限
chmod +x elasticsearch
添加到开机启动任务
chkconfig -add elasticsearch
使用service elasticsearch start/stop/restart来操作
下面是填坑了,一些复制我脚本的发现重启没效果或者在使用 service tomcat start 可能会遇到该错误
“env: /etc/init.d/elasticsearch: No such file or directory)”
这是为甚呢,因为你在windows下保存了该脚本文件,其中的换行符被改变了,windows中换行符为/r/n
而linux中是/n 所以这边需要把脚本做个转换,我们使用dos2unix,一般大家可能都没装该工具
yum install dos2unix
安装完成后直接执行既可
dos2unix /etc/init.d/tomcat
再使用service elasticsearch start 就没问题啦

7、在一台client上安装监控工具cerebro
cerebro下载安装地址:
http://github.com/lmenezes/cerebro
ip:9000端口启动
Elasticsearch6.3.1 tar包离线集群安装手册_第1张图片
Elasticsearch6.3.1 tar包离线集群安装手册_第2张图片
8、压测工具rally
https://github.com/elastic/rally

9、建议

建议集群中设置三台以上的节点作为master节点,这些节点只负责成为主节点,维护整个集群的状态。
node.master: true
node.data: false
再根据数据量设置一批data节点,这些节点只负责存储数据。
node.master: false
node.data: true
后期提供建立索引和查询索引的服务,这样的话如果用户请求比较频繁,这些节点的压力也会比较大所以在集群中建议再设置一批client节点。这些节点只负责处理用户请求,实现请求转发,负载均衡等功能。
node.master: false
node.data: true
配置
master节点:普通服务器即可(CPU 内存 消耗一般)
data节点: 主要消耗磁盘,内存
client节点:普通服务器即可(如果要进行分组聚合操作的话,建议这个节点内存也分配多一点)

我们集群之所以调高所有内存即是为了扩容方便(毕竟是向公司申请的;先占住为妙嘛)。

你可能感兴趣的:(ElasticSearch博文)