ES7.4版本服务集群搭建记录

一、基础环境说明

1、系统说明:CentOS-7-x86_64-Minimal-1708

下载地址:Index of /centos-vault/7.4.1708/isos/x86_64/

或者在压缩包中上传

 

2、安装虚拟机

安装步骤:虚拟机CentoOS安装记录(用于Elasticsearch装机使用)由此点击获取教程 

3、Elasticsearch 下载地址 

官方网址Get Started with Elasticsearch, Kibana, and the Elastic Stack | Elastic

压缩包中也有,可以直接使用

二、基础环境配置

1、修改主机名

编辑集群中的各个节点主机名(本集群三个节点的主机名分别为   cdh-1.com   cdh-2.com   cdh-3com)

以  cdh-1.com  为例:

[root@localhost~]# hostnamectl set-hostname cdh-1.com

cdh-2.comcdh-3.com 略。

2、配置虚拟机网络,每台虚拟机均接入互联网(并设置静态IP)

   2.1网卡配置步骤:

        1、设置网络适配器,选择NAT模式(用于共享主机的IP地址)

        

        2、查看本地VMwear设置

         

        3、查看NAT设置(根据自己的业务需要修改IP段,此处我设置为“64”)设置静态IP

                注:此处子网网关为:192.168.64.10

          

        4、DHCP设置(根据自己的业务需要修改IP段,此处我设置为“64”,且ip动态自“10”开始)

         

        5、更改子网信息(根据自己的业务需要修改IP段,此处我设置为“64”)

        

        6、以上准备工作做完之后,启动虚拟机,并登陆系统。

         

   2.2虚拟机网络配置:

   此处以cdh-1.com节点为例(集群中其他节点配置参照本节点,注意 ip 唯一):                          

[root@cdh-1.com ~]# vi /etc/sysconfig/network-scripts/ifcfg-ens33

    

        cdh-1.com的IP是:   IPADDR=192.168.64.47

        cdh-2.com的IP是:   IPADDR=192.168.11.48

        cdh-3.com的IP是:   IPADDR=192.168.11.49

   说明:红框内为修改、增加的部分

   修改完毕后保存并退出  :wq

   集群中其他节点配置参照本节点。

3、修改完后重启network服务

[root@cdh-1.com ~]# service network restart

4、安装基本工具(各节点均要安装)

[root@cdh-1 ~]# yum install -y vim wget lrzsz tree zip unzip net-tools ntp

[root@cdh-1 ~]# yum update -y (可选)

5、(选装)集群各节点安装、配置JDK(es7.x 需要jdk11以上,安装包中自带了openjdk)

集群中各个节点均要安装JDK

6、配置防火墙

关闭防火墙,并设置开机禁止启动

关闭防火墙 : systemctl stop firewalld

查看状态     : systemctl status firewalld

开机禁用     : systemctl disable firewalld

7、配置host文件输入命令:vi /etc/hosts

此处以  cdh-1.com  节点为例,集群中其他节点和  cdh-1.com  相同:

8、配置节点间时间同步

以阿里时间服务器为准,阿里云时间服务器地址:ntp6.aliyun.com

说明:如有专用时间服务器,请更改时间服务器的主机名或者IP地址,主机名需要在etc/hosts文件中做好映射。

以  cdh-1.com  为例:

设置系统时区为东八区(上海时区)

        [root@cdh-1 ~]# timedatectl set-timezone Asia/Shanghai

关闭ntpd服务(一定要做这一步,否则自动同步时间会失效)

        [root@cdh-1 ~]# systemctl stop ntpd.service

设置ntpd服务禁止开机启动

        [root@cdh-1 ~]# systemctl disable ntpd

设置定时任务

        [root@cdh-1 ~]# crontab -e

写入以下内容(每10分钟同步一下阿里云时间服务器):

        0-59/10 * * * * /usr/sbin/ntpdate ntp6.aliyun.com

重启定时任务服务

        [root@cdh-1 ~]# /bin/systemctl restart crond.service

设置定时任务开机启动

        [root@node3 ~]# vi /etc/rc.local

加入以下内容后,保存并退出

        /bin/systemctl start crond.service

:wq

集群中其他各个节点同  cdh-1.com  节点。

9、配置系统环境为UTF8

以  cdh-1.com  为例:

        [root@cdh-1 ~]# echo "export LANG=zh_CN.UTF-8 " >> ~/.bashrc

        [root@cdh-1 ~]# source ~/.bashrc

集群中其他各个节点同  cdh-1.com  节点。

10、修改文件最大打开数(非生产环境,可不配置)

此处以  cdh-1.com  节点为例:

        [root@cdh-1 ~]# vi /etc/security/limits.conf

* soft nofile 204800

* hard nofile 204800

* soft nproc 204800

* hard nproc 204800

        [root@cdh-1 ~]# vi /etc/security/limits.d/20-nproc.conf

* soft nproc 204800

* hard nproc 204800

        [root@node3 ~]# vi /etc/pam.d/login

session    required     pam_limits.so

集群中其他节点配置和  cdh-1.com  相同

11、禁用SELinux(可选)

以  cdh-1.com  为例:

        [root@cdh-1 ~]# vim /etc/selinux/config

修改如下内容后,保存并退出

:wq

集群中其他节点配置和  cdh-1.com  相同。

12、禁用Transparent HugePages(可选)

以  cdh-1.com  为例:

查看

        [root@cdh-1 ~]# cat /sys/kernel/mm/transparent_hugepage/enabled

效果:

        

        [root@node3 ~]# vi /etc/rc.d/rc.local

if test -f /sys/kernel/mm/transparent_hugepage/enabled; then

 echo never > /sys/kernel/mm/transparent_hugepage/enabled

fi

if test -f /sys/kernel/mm/transparent_hugepage/defrag; then

 echo never > /sys/kernel/mm/transparent_hugepage/defrag

fi

效果:

重启系统后,永久生效。

        [root@cdh-1 ~]# chmod +x /etc/rc.d/rc.local

重启系统后查看
        [root@cdh-1 ~]# cat /sys/kernel/mm/transparent_hugepage/enabled

效果:   

always madvise [never]

集群中其他节点配置和  cdh-1.com  相同。

13、配置内存 /etc/sysctl.conf

        [root@cdh-1 ~]# vi /etc/sysctl.conf

写入(根据自身硬件条件而定,其它节点于此相同)

        vm.max_map_count=262144

三、Elasticsearch 集群部署、配置

1、每个节点创建文件夹  /opt/elasticsearch/  

[root@cdh-1 ~]# mkdir /opt/elasticsearch/

2、上传文件rz

把官网上的压缩包(elasticsearch-7.4.0-linux-x86_64.tar.gz)下载到本地,再用  rz 或者其他第三方ftp工具把安装包上传至节点  cdh-1.com  的指定目录下(网络允许的条件下,也可直接使用 wget 直接下载)

[root@cdh-1 elasticsearch]# rz

上传完毕后,解压缩压缩包

[root@cdh-1 elasticsearch]# tar zxvf elasticsearch-7.4.0-linux-x86_64.tar.gz

3、修改配置文件  elasticsearch.yml

[root@cdh-1 ~]# vi /opt/elasticsearch/elasticsearch-7.0.0/config/elasticsearch.yml

文件内容如下(将文本框中内容添加到elasticsearch.yml结尾):

cluster.name: es-cluster
node.name: cdh-1.com 
node.master: true
node.data: true
path.data: /opt/elasticsearch/elasticsearch-7.4.0/data
path.logs: /opt/elasticsearch/elasticsearch-7.4.0/logs
network.host: 0.0.0.0
http.port: 9200
cluster.initial_master_nodes: ["cdh-1.com", "cdh-2.com","cdh-3.com"]
discovery.zen.ping.unicast.hosts: ["198.168.64.xx", "198.168.64.xx","198.168.64.xx"]
discovery.zen.minimum_master_nodes: 2
http.cors.enabled:  true
http.cors.allow-origin:  "*"

修改配置文件  elasticsearch-env

[root@node3 ~]# vi /opt/elasticsearch/elasticsearch-7.4.0/bin/elasticsearch-env

复制以下内容到该文件elasticsearch-env中

        JAVA_HOME="/opt/elasticsearch/elasticsearch-7.4.0/jdk"

4、分发文件

把节点 cdh-1上已经配置好的es所有文件发送给集群的所有节点的相同目录  (会提示输入各自节点的 root 用户的密码)

[root@cdh-1 ~]# scp -r /opt/elasticsearch/elasticsearch-7.4.0 cdh-2.com:/opt/elasticsearch/  

[root@cdh-1 ~]# scp -r /opt/elasticsearch/elasticsearch-7.4.0 cdh-3.com:/opt/elasticsearch/

分别在  cdh-2、cdh-3上编辑文件   elasticsearch.yml

修改各自的  node.name  (注意区分 node.name   保证集群中node.name唯一

[root@node4 ~]# vim /opt/elasticsearch/elasticsearch-7.4.0/config/elasticsearch.yml

[root@node5 ~]# vim /opt/elasticsearch/elasticsearch-7.4.0/config/elasticsearch.yml

保存后退出  :wq

5、创建用户组及用户信息

        [root@cdh-1 ~]# groupadd es

        [root@cdh-1 ~]# useradd es -g es

        [root@cdh-1 ~]# chown -R es:es /opt/elasticsearch/*

集群中其他各节点操作同 cdh-1节点。

6、启动服务

切换用户

        [root@cdh-1 ~]# su es

        [es@cdh-1 ~]$ /opt/elasticsearch/elasticsearch-7.4.0/bin/elasticsearch -d

启动成功效果:

其他各节点操作同 cdh-1节点。

7、查看启动情况

        [root@cdh-1 ~]$ jps

 

亦可在其他节点查看服务启动情况。

8、在浏览器查看启动结果

在浏览器输入
        http://192.168.64.xx:9200/

        http://192.168.64.xx:9200/

        http://192.168.64.xx:9200/

效果如下:

        

至此,Centos7.4 手动搭建 Elasticsearch 7 集群 操作完毕。

四、IK分词插件安装:

使用IK分词器可以实现对中文分词的效果有两种分词模式:ik_max_word和ik_smart模式。

1、ik_max_word会将文本做最细粒度的拆分,比如会将“中华人民共和国人民大会堂”拆分为“中华人民共和国、中华人民、中华、华人、人民共和国、人民、共和国、大会堂、大会、会堂等词语。

2、ik_smart会做最粗粒度的拆分,比如会将“中华人民共和国人民大会堂”拆分为中华人民共和国、人民大会堂。

1.使用用第三方工具将解压后的ik文件上传到elasticsearch-7.4.0/plugins目录下

(注:压缩包不可存在在plugins目录下) 

 2.自定义词库(可选)

iK分词器自带的main.dic的文件为扩展词典,stopword.dic为停用词典。

3.自定义词库配置(可选)

至此,分词插件安装完成!

五、Kibana搭建步骤:

        参照该文章进行安装 : Kibana7.4版本安装启动       由此点击获取教程 

至此,该文章记录完结,欢迎各位码友一起学习探讨,后期还会更新这些工具的使用及使用过程中遇到的问题处理方法。

                文章类型说明:该文章部分内容有参考其他博主,如有侵权请与本人私信说明

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值