阿里云-云小站(无限量代金券发放中)
【腾讯云】云服务器、云数据库、COS、CDN、短信等热卖云产品特惠抢购

CentOS 7.3下安装部署Elasticsearch 6.3.2过程详解

177次阅读
没有评论

共计 3878 个字符,预计需要花费 10 分钟才能阅读完成。

elasticsearch 简介

ElasticSearch 是一个基于 Lucene 的搜索服务器。它提供了一个分布式多用户能力的全文检索引擎,基于 RESTful web 接口。Elasticsearch 是用 Java 开发的,并作为 Apache 许可条款下的开放源码发布,是当前流行的企业级搜索引擎。设计用于云计算中,能够达到实时搜索,稳定,可靠,快速,安装使用方便。

实验部署

1、实验所需组件及环境

1)JDK8 以上环境
2)CentOS7.3,IP 地址:192.168.144.112
3)elasticsearch6.3.2

  • es 最新软件软件包可在官方网站下载:https://www.elastic.co/downloads/elasticsearch

2、安装 jdk8 以上版本

yum install java -y
java -version 查看 java 版本

CentOS 7.3 下安装部署 Elasticsearch 6.3.2 过程详解

3、部署 elasticsearch6.3.2

  • 首先在官网当中下载 es 的软件包,本文采用压缩包解压缩安装方式启动服务。

  • 值得注意的是,在 es5.0 版本后不支持与 logstash 和 kibana2.x 版本的混用,且安全级别的提升,使得 es 在后续的版本中不允许使用 root 用户启动,因此我们需要创建另外独立账户专供 es 使用。并且需要在 root 权限下将该特定环境准备好。

tar zxvf elasticsearch-6.3.2.tar.gz -C /opt/

  • 创建独立用户与组(root 用户下创建设定)

groupadd ela 创建 ela 组
useradd -g ela ela 创建 ela 用户,并且加入 ela 组
passwd ela 为 ela 用户设定登录密码
visudo(或者 vim /etc/sudoers)

CentOS 7.3 下安装部署 Elasticsearch 6.3.2 过程详解

  • 为了让 ela 用户拥有对 elasticsearch 执行权限,在 root 用户权限下解压后,需要将软件包更改属主属组。

chown -R ela.ela /opt/elasticsearch-6.3.2/
ls -l /opt/elasticsearch-6.3.2/

CentOS 7.3 下安装部署 Elasticsearch 6.3.2 过程详解

  • 切换到 ela 用户,编辑配置文件,准备启动 es

su ela
[ela@localhost ~]$ cd /opt/elasticsearch-6.3.2/config/
[ela@localhost config]$ sudo vim elasticsearch.yml

# ———————————- Cluster ———————————–
#
# Use a descriptive name for your cluster:
#
cluster.name: abner  // 打开设定 es 群集名称
#
# ———————————— Node ————————————
#
# Use a descriptive name for the node:
#
node.name: node-1      //es 当前节点名称,用于区分不同节点
#
# Add custom attributes to the node:
#
#node.attr.rack: r1
#
# ———————————– Paths ————————————
#
# Path to directory where to store the data (separate multiple locations by comma):
#
path.data: /data/es-data    // 修改数据目录,此目录为自定义,需要在 root 用户下创建,且属主属组更改为 ela
#
# Path to log files:
#
path.logs: /var/log/elasticsearch  // 日志目录位置,需自己创建,方式同上
                                  //yum 安装则系统自定义,在软件版本或者系统升级时会被删除,所以建议修改
#
# ———————————– Memory ———————————–
#
# Lock the memory on startup:
#
bootstrap.memory_lock: true  //elasticsearch 官网建议生产环境需要设置 bootstrap.memory_lock: true
#
# Make sure that the heap size is set to about half the memory available
# on the system and that the owner of the process is allowed to use this
# limit.
#
# Elasticsearch performs poorly when the system is swapping the memory.
#
# ———————————- Network ———————————–
#
# Set the bind address to a specific IP (IPv4 or IPv6):
#
network.host: 0.0.0.0  // 监听访问地址为任意网段
#
# Set a custom port for HTTP:
#
http.port: 9200  // 服务监听端口
#

编辑完成配置文件后,数据目录以及日志文件目录需要创建

sudo mkdir -p /data/es-data
sudo mkdir -p /var/log/elasticsearch
sudo chown -R ela.ela /data/
sudo chown -R ela.ela /var/log/elasticsearch

  • 准备工作完成,启动 es

[ela@localhost /]$ cd /opt/elasticsearch-6.3.2/bin/
[ela@localhost bin]$ ./elasticsearch 后面可以跟上 - d 后台执行

CentOS 7.3 下安装部署 Elasticsearch 6.3.2 过程详解

4、启动发现异常情况以及处理方式

CentOS 7.3 下安装部署 Elasticsearch 6.3.2 过程详解

- 当发现如上图无法分配内存错误等,可执行如下操作。(需要在 root 用户权限下)

vim /etc/security/limits.conf

CentOS 7.3 下安装部署 Elasticsearch 6.3.2 过程详解

* soft nofile 65536
* hard nofile 131072
ela soft memlock unlimited
ela hard memlock unlimited

  • 当发现 ERROR: [1] bootstrap checks failed 错误时,解决方式如下 (root 用户状态下)

CentOS 7.3 下安装部署 Elasticsearch 6.3.2 过程详解

vim /etc/sysctl.conf

vm.max_map_count = 655360 // 添加

sysctl -p

  • 切换到 ela 用户,执行启动程序

[ela@localhost abc]$ cd /opt/elasticsearch-6.3.2/bin/
[ela@localhost bin]$ ./elasticsearch

CentOS 7.3 下安装部署 Elasticsearch 6.3.2 过程详解

  • 新建终端,以 root 用户查看 9200 端口是否开启

netstat -ntap | grep 9200

tcp6      0      0 :::9200                :::*                    LISTEN      2095/java

  • 打开浏览器访问验证,出现如下界面即安装成功,访问时记得关闭防火墙!!!

CentOS 7.3 下安装部署 Elasticsearch 6.3.2 过程详解

Elasticsearch 教程系列文章

Linux 上安装部署 ElasticSearch 全程记录  https://www.linuxidc.com/Linux/2015-09/123241.htm
Linux 下 Elasticsearch 1.7.0 安装配置 https://www.linuxidc.com/Linux/2017-05/144215.htm
在 Ubuntu 16.04 中安装 Elasticsearch 5.4 分析引擎  https://www.linuxidc.com/Linux/2017-07/145588.htm
Elasticsearch1.7 升级到 2.3 实践总结  https://www.linuxidc.com/Linux/2016-11/137282.htm
Ubuntu 14.04 中 Elasticsearch 集群配置  https://www.linuxidc.com/Linux/2017-01/139460.htm
Elasticsearch-5.0.0 移植到 Ubuntu 16.04 https://www.linuxidc.com/Linux/2017-01/139505.htm
ElasticSearch 5.2.2 集群环境的搭建  https://www.linuxidc.com/Linux/2017-04/143136.htm
Linux 下安装搜索引擎 Elasticsearch  https://www.linuxidc.com/Linux/2017-05/144105.htm
CentOS 上安装 ElasticSearch 详解  https://www.linuxidc.com/Linux/2017-05/143766.htm
Elasticsearch5.3 安装插件 head  https://www.linuxidc.com/Linux/2017-09/147008.htm

Linux 上安装 Elasticsearch https://www.linuxidc.com/Linux/2018-08/153391.htm

ElasticSearch 的详细介绍 :请点这里
ElasticSearch 的下载地址 :请点这里

正文完
星哥说事-微信公众号
post-qrcode
 
星锅
版权声明:本站原创文章,由 星锅 2022-01-21发表,共计3878字。
转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。
【腾讯云】推广者专属福利,新客户无门槛领取总价值高达2860元代金券,每种代金券限量500张,先到先得。
阿里云-最新活动爆款每日限量供应
评论(没有评论)
验证码
【腾讯云】云服务器、云数据库、COS、CDN、短信等云产品特惠热卖中