【ES实战】ES6.7的tar包离线安装帮助手册

Elasticsearch6.7部署帮助手册

校验时间:2023年12月19日

文章目录

  • Elasticsearch6.7部署帮助手册
    • 安装前准备
      • 安装包
      • 安装要求
        • 锁定内存,修改最大文件描述符,最大线程数
        • 内核参数
      • 部署规划
      • 端口规划
      • 用户规划
      • 目录规划
    • 安装步骤
      • 每个服务器配置JDK
      • 配置文件
        • master角色
        • node角色
    • 启动与停止
      • 启动
        • 首次启动
      • 检查
      • 停止

安装前准备

安装包

  • elasticsearch-6.7.2.tar.gz
  • elasticsearch-analysis-dynamic-synonym-6.7.2.zip
  • elasticsearch-analysis-ik-6.7.2.zip
  • elasticsearch-analysis-pinyin-6.7.2.zip
  • jdk1.8.0_161.tgz

插件安装参考:ES插件安装帮助说明

安装要求

命令netstat -lntp 2>/dev/null|grep LISTEN|awk '{print $4}'|awk -F':' '{print $NF}'|sort|uniq查询已经占用的端口

机器要求与大数据机器模板相同

以下是补充:

锁定内存,修改最大文件描述符,最大线程数

vim /etc/security/limits.d/90-nproc.conf

确保:

nproc >= 20480
nofile >= 65536

增加:

* - memlock unlimited
内核参数

vim /etc/sysctl.conf

确保增加以下参数配置:

vm.zone_reclaim_mode = 0
net.ipv4.ip_local_reserved_ports=9500-9702
net.ipv4.ip_local_port_range = 10000 65000
net.ipv4.tcp_tw_recycle = 1
net.ipv4.tcp_tw_reuse = 1
vm.swappiness=0
vm.overcommit_memory=1
vm.zone_reclaim_mode=0
vm.max_map_count=262144

更改内核后完成后执行命令:sysctl -p生效

部署规划

采用master与data分离部署方式

集群A

服务器Host master data Cluster
es01 yes yes A
es02 yes yes A
es03 yes yes A

集群B

服务器Host master data Cluster
es04 yes yes B
es05 yes yes B
es06 yes yes B

端口规划

纯master角色节点:TCP端口:9201,HTTP端口:9200

纯data角色节点:TCP端口:9301,HTTP端口:9300

用户规划

groupadd -g 750 es;
useradd -u 750 -g 750 es;

目录规划

将空间大的目录软链接到home的子目录下,比如/opt或者/data。此文档采用/data目录为例:

  • 用户目录

    /home/es/software 链接至 /data/elasticsearch/software

  • 数据目录

    /home/es/data链接至 /data/elasticsearch/data

  • 日志目录

    /home/es/logs链接至 /data/elasticsearch/logs

安装步骤

在操作之前安装包已经分发到各个服务器的/data/install_package目录。权限为755

root命令执行命令

chmod 755 -R /data/install_package/
# 1.新建用户与用户组
groupadd -g 750 es;
useradd -u 750 -g 750 es;
# 2.准备目录
mkdir -p /data/elasticsearch;
chown -R es:es /data/elasticsearch/;

以下开始使用es用户执行命令

su - es;
mkdir -p /data/elasticsearch/software;
mkdir -p /data/elasticsearch/logs;
mkdir -p /data/elasticsearch/data;
# master的元数据存储目录
mkdir -p /data/elasticsearch/masterdata;
ln -snf /data/elasticsearch/software /home/es/software;
ln -snf /data/elasticsearch/logs /home/es/logs;
ln -snf /data/elasticsearch/masterdata /home/es/masterdata;
# master角色节点的配置文件目录
mkdir -p /home/es/software/config-master;
# node角色节点的配置文件目录
mkdir -p /home/es/software/config-dnode0;

# 3.将安装包解压至software目录并配置软链接
tar -zxf /data/install_package/jdk1.8.0_161.tgz -C /home/es/software/;
tar -zxf /data/install_package/elasticsearch-6.7.2.tar.gz -C /home/es/software/;
ln -snf /home/es/software/jdk1.8.0_161 /home/es/software/java;
ln -snf /home/es/software/elasticsearch-6.7.2 /home/es/software/elasticsearch;

每个服务器配置JDK

su - es;
vim /home/es/.bashrc;
# 在.bashrc文件中追加以下内容
export JAVA_HOME=/home/es/software/java
export PATH=$JAVA_HOME/bin:$PATH

# 配置生效
source /home/es/.bashrc;
# 检查jdk
java -version;

配置文件

master角色
ssh [email protected] "su - es -c 'cp  /home/es/software/elasticsearch-6.7.2/config/* /home/es/software/config-master/'";
ssh [email protected] "su - es -c 'cp  /home/es/software/elasticsearch-6.7.2/config/* /home/es/software/config-master/'";
ssh [email protected] "su - es -c 'cp  /home/es/software/elasticsearch-6.7.2/config/* /home/es/software/config-master/'";

修改配置文件

vim config-master/elasticsearch.yml

cluster.name: demo-ccr-1
node.name: 192.168.1.1-master
node.master: true
node.data: false
node.max_local_storage_nodes: 3
path.data: /home/es/masterdata
path.logs: /home/es/logs/es
bootstrap.memory_lock: true
bootstrap.system_call_filter: false
network.host: 192.168.1.1
http.port: 9200
transport.tcp.port: 9201
discovery.zen.ping.unicast.hosts: ["192.168.1.1:9201","192.168.1.2:9201","192.168.1.:9201"]
discovery.zen.minimum_master_nodes: 2
discovery.zen.fd.connect_on_network_disconnect: true
discovery.zen.ping_timeout: 30s
discovery.zen.fd.ping_timeout: 120s
discovery.zen.fd.ping_retries: 6
discovery.zen.fd.ping_interval: 5s
gateway.expected_nodes: 3
gateway.expected_master_nodes: 3
gateway.expected_data_nodes: 3
gateway.recover_after_time: 5m
gateway.recover_after_nodes: 2
gateway.recover_after_master_nodes: 2
gateway.recover_after_data_nodes: 2
action.destructive_requires_name: true

vim config-master/jvm.options

sed -i "s|\${role_name}|master|g" software/config-master/jvm.options &>> tt.log
#SIT环境
-Xms4g
-Xmx4g
# PRD环境
-Xms31g
-Xmx31g

vim config-master/log4j2.properties

sed -i "s|\${role_name}|master|g" software/config-master/log4j2.properties &>> tt.log
rm -f tt.log
node角色
ssh [email protected] "su - es -c 'cp  /home/es/software/elasticsearch/config/* /home/es/software/config-dnode0/'";
ssh [email protected] "su - es -c 'cp  /home/es/software/elasticsearch/config/* /home/es/software/config-dnode0/'";
ssh [email protected] "su - es -c 'cp  /home/es/software/elasticsearch/config/* /home/es/software/config-dnode0/'";

修改配置文件

vim config-dnode0/elasticsearch.yml

cluster.name: demo-ccr-1
node.name: 192.168.1.1-dnode0
node.master: false
node.data: true
node.max_local_storage_nodes: 3
path.data: /data/elasticsearch/data/dnode0
path.logs: /home/es/logs/es
bootstrap.memory_lock: true
bootstrap.system_call_filter: false
network.host: 192.168.1.1
http.port: 9300
transport.tcp.port: 9301
discovery.zen.ping.unicast.hosts: ["192.168.1.1:9201","192.168.1.2:9201","192.168.1.:9201"]
discovery.zen.minimum_master_nodes: 2
discovery.zen.fd.connect_on_network_disconnect: true
discovery.zen.ping_timeout: 30s
discovery.zen.fd.ping_timeout: 120s
discovery.zen.fd.ping_retries: 6
discovery.zen.fd.ping_interval: 5s
gateway.expected_nodes: 3
gateway.expected_master_nodes: 3
gateway.expected_data_nodes: 3
gateway.recover_after_time: 5m
gateway.recover_after_nodes: 2
gateway.recover_after_master_nodes: 2
gateway.recover_after_data_nodes: 2
action.destructive_requires_name: true

vim config-dnode0/jvm.options

sed -i "s|\${role_name}|dnode0|g" config-dnode0/jvm.options &>> tt.log
#SIT环境
-Xms4g
-Xmx4g
# PRD环境
-Xms31g
-Xmx31g

vim config-dnode0/log4j2.properties

sed -i "s|\${role_name}|dnode0|g" config-dnode0/log4j2.properties &>> tt.log
rm -f tt.log

启动与停止

es-daemon.sh并非官网脚本。

启动

首次启动

先启动所有的master,在启动dnode1

su - es;
cd /home/es/software/elasticsearch/bin/;
sh es-daemon.sh start master;


su - es;
cd /home/es/software/elasticsearch/bin/;
sh es-daemon.sh start dnode0

检查

查询节点是否正常

curl 'http://ip:http端口'
curl 'http://192.168.1.1:9200'

如果返回

{
  "name" : "192.168.1.1-dnode0",
  "cluster_name" : "demo-ccr-1",
  "cluster_uuid" : "CjcavbOjQPeymec-GOJgVA",
  "version" : {
    "number" : "6.7.2",
    "build_flavor" : "default",
    "build_type" : "tar",
    "build_hash" : "Unknown",
    "build_date" : "Unknown",
    "build_snapshot" : true,
    "lucene_version" : "7.7.0",
    "minimum_wire_compatibility_version" : "5.6.0",
    "minimum_index_compatibility_version" : "5.0.0"
  },
  "tagline" : "You Know, for Search"
}

则表示启动成功,其余情况,则可能存在问题。

查询集群整体健康

curl 'http://192.168.1.1:9200/_cat/health?v'

如果返回值中:status值为green,则表示启动成功,其余情况,则可能存在问题

停止

su - es;
cd /home/es/software/elasticsearch/bin/;
sh es-daemon.sh stop master

su - es;
cd /home/es/software/elasticsearch/bin/;
sh es-daemon.sh stop dnode1

你可能感兴趣的:(Elastic实战,elasticsearch,大数据)