Centos7部署Elasticsearch7.8.0

一、安装准备
1、elasticsearch简介
ElasticSearch是一个基于Lucene的搜索服务器。它提供了一个分布式多用户能力的全文检索引擎,基于RESTful web接口。Elasticsearch是用Java开发的,并作为Apache许可条款下的开放源码发布,是当前流行的企业级搜索引擎。设计用于云计算中,能够达到实时搜索,稳定,可靠,快速,安装使用方便。
2、搭建环境
es最新软件软件包可在官方网站下载:https://www.elastic.co/downloads/elasticsearch
1)JDK11环境
2)CentOS7 IP地址:192.168.112.139
3)elasticsearch7.8.0
3、准备环境

关闭防火墙
systemctl stop firewalld
systemctl disable firewalld

二、安装部署(单节点)
1、安装jdk

[root@prometheus opt]# rpm -ivh jdk-11.0.12_linux-x64_bin.rpm

2、查看版本

[root@prometheus opt]# java -version
java version "11.0.12" 2021-07-20 LTS
Java(TM) SE Runtime Environment 18.9 (build 11.0.12+8-LTS-237)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.12+8-LTS-237, mixed mode)

3、部署elasticsearch7.8.0
首先在官网当中下载es的软件包,本文采用rpm包安装方式。
注意:在es5.0版本后不支持与logstash和kibana2.x版本的混用,且安全级别的提升,使得es在后续的版本中不允许使用root用户启动,因此我们需要创建另外独立账户专供es使用。并且需要在root权限下将该特定环境准备好。

[root@prometheus opt]# rpm -ivh elasticsearch-7.8.0-x86_64.rpm
[root@client1 opt]# mkdir /data/elasticsearch/{data,logs} -p
[root@client1 opt]# chown -R elasticsearch:elasticsearch /data/elasticsearch/

4、修改配置文件(单机版)

vim /etc/elasticsearch/elasticsearch.yml
#设置集群名字
cluster.name: my-cluster
#设置节点名字
node.name: prometheus
#向节点添加自定义属性
node.attr.rack: r1
#设置数据存放路径
path.data: /data/elasticsearch/data
#设置logs存放路径
path.logs: /data/elasticsearch/logs
#设置允许其他主机连接得IP
network.host: 192.168.112.139
#设置服务监听端口号
http.port: 9200
transport.tcp.port: 9300
cluster.initial_master_nodes: 192.168.112.139

5、安装分词器

[root@prometheus opt]# yum install -y unzip
[root@prometheus opt]# mkdir /usr/share/elasticsearch/plugins/ik
[root@prometheus opt]# unzip -d /usr/share/elasticsearch/plugins/ik elasticsearch-analysis-ik-7.8.0.zip
[root@prometheus opt]# chown -R elasticsearch:elasticsearch /usr/share/elasticsearch/plugins/ik/

6、启动elasticsearch

systemctl start elasticsearch
systemctl enable elasticsearch

三、可视化查看
1、推荐一款很棒的UI查询elasticsearch的插件
它是Edge 浏览器的一个插件,功能很强大,可以查询,删除,备份,快照,导出数据等。
安装方式很简单:Edge 浏览器输入:https://microsoftedge.microsoft.com/addons/search/idm
搜索:elasticsearch

安装Elasticvue

插件效果展示

节点数

节点数

四、优化参数
1、修改默认的堆内存参数

vim /etc/elasticsearch/jvm.options
-Xms1g
-Xmx1g
根据主机配置,业务需求来修改
-Xms5g
-Xmx5g

五、安装部署集群
1、准备环境:

elasticsearch集群至少需要三个节点
192.168.112.138
192.168.112.139
192.168.112.141
做好hosts解析
vim /etc/hosts
192.168.112.138    client1
192.168.112.139    client2
192.168.112.141    client3
关闭防火墙
systemctl stop firewalld
systemctl disable firewalld

2、安装jdk

[root@client1 opt]# rpm -ivh jdk-11.0.12_linux-x64_bin.rpm

3、查看版本

[root@client1 opt]# java -version
java version "11.0.12" 2021-07-20 LTS
Java(TM) SE Runtime Environment 18.9 (build 11.0.12+8-LTS-237)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.12+8-LTS-237, mixed mode)

4、部署elasticsearch7.8.0
首先在官网当中下载es的软件包,本文采用rpm包安装方式。
注意:在es5.0版本后不支持与logstash和kibana2.x版本的混用,且安全级别的提升,使得es在后续的版本中不允许使用root用户启动,因此我们需要创建另外独立账户专供es使用。并且需要在root权限下将该特定环境准备好。

[root@client1 opt]# rpm -ivh elasticsearch-7.8.0-x86_64.rpm
[root@client1 opt]# mkdir /data/elasticsearch/{data,logs} -p
[root@client1 opt]# chown -R elasticsearch:elasticsearch /data/elasticsearch/

5、修改配置文件(集群版)

vim /etc/elasticsearch/elasticsearch.yml
# ----------------------------------- Paths --------------------------------
path.data: /data/elasticsearch/data
path.logs: /data/elasticsearch/logs
path.repo: /data/elasticsearch/kuaizhao
# ---------------------------------- Cluster -------------------------------
cluster.name: esxi-cluster 
# ------------------------------------ Node ------------------------------
node.name: client1                            #根据各节点主机名更改
node.attr.rack: r1
# ---------------------------------- Network -----------------------------
network.host: 192.168.112.138                 #根据各节点ip地址更改
http.port: 9200
transport.tcp.port: 9300
#discovery.zen.ping.unicast.hosts: [{"192.168.112.138","192.168.112.139","192.168.112.141"}]
discovery.seed_hosts: ["192.168.112.138", "192.168.112.139","192.168.112.141"]
cluster.initial_master_nodes: ["192.168.112.138", "192.168.112.139","192.168.112.141"]

discovery.zen.minimum_master_nodes: 2
transport.tcp.compress: true            #设置是否压缩tcp传输时的数据,默认为false,不压缩。
node.data: true                         #指定该节点是否存储索引数据,默认为true。
node.master: true                       #指定该节点是否有资格被选举成为node(注意这里只是设置成有资格, 不代表该node一定就是master)>,默认是true。
discovery.zen.ping_timeout: 6s          #es选举master的超时时间

6、安装分词器

[root@client1 opt]# yum install -y unzip
[root@client1 opt]# mkdir /usr/share/elasticsearch/plugins/ik
[root@client1 opt]# unzip -d /usr/share/elasticsearch/plugins/ik elasticsearch-analysis-ik-7.8.0.zip
[root@client1 opt]# chown -R elasticsearch:elasticsearch /usr/share/elasticsearch/plugins/ik/

7、启动elasticsearch

systemctl start elasticsearch
systemctl enable elasticsearch

8、检查集群状态

[root@client1 ~]# curl http://192.168.112.138:9200
{
  "name" : "client1",
  "cluster_name" : "esxi-cluster",
  "cluster_uuid" : "D8RsqB_5TrWv7Zp0Wncc4g",             ##一定要这里是随机字符串,才算正常
  "version" : {
    "number" : "7.8.0",
    "build_flavor" : "default",
    "build_type" : "rpm",
    "build_hash" : "757314695644ea9a1dc2fecd26d1a43856725e65",
    "build_date" : "2020-06-14T19:35:50.234439Z",
    "build_snapshot" : false,
    "lucene_version" : "8.5.1",
    "minimum_wire_compatibility_version" : "6.8.0",
    "minimum_index_compatibility_version" : "6.0.0-beta1"
  },
  "tagline" : "You Know, for Search"
}
[root@client1 ~]# curl -XGET http://192.168.112.138:9200/_cat/health?v

es

© 版权声明
THE END
喜欢就支持一下吧
点赞0 分享
评论 抢沙发
头像
欢迎您留下宝贵的见解!
提交
头像

昵称

取消
昵称表情代码图片

    暂无评论内容