ElasticSearch7.11 Linux 搭建

ElasticSearch7.11 Linux 搭建

环境准备:

  • 云服务器
  • CentOS7
  • jdk8
  • 开放9200端口,开放9200端口防火墙

开始安装

一、使用 wget 命令下载压缩文件,并解压文件
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.11.0-linux-x86_64.tar.gz

tar -zxvf elasticsearch-7.11.0-linux-x86_64.tar.gz

注意:es7版本对应使用的jdk8, 若要使用高版本的es, 需要升级jdk 【因为es8的启动配置文件中,jvm配置使用的是java8以上的,若版本不对应则无法启动,抛出版本异常,具体这里不做展开】

二、修改jvm.options配置文件
# 进入解压后的es目录中的config目录下
cd elasticsearch-7.11.0/config
# 找到jvm.options文件
vim jvm.options
jvm.options文件 部分
################################################################
## IMPORTANT: JVM heap size
################################################################
##
## The heap size is automatically configured by Elasticsearch
## based on the available memory in your system and the roles
## each node is configured to fulfill. If specifying heap is
## required, it should be done through a file in jvm.options.d,
## and the min and max should be set to the same value. For
## example, to set the heap to 4 GB, create a new file in the
## jvm.options.d directory containing these lines:
##
#  根据你的服务器配置将此处的jvm内存大小调整成适应大小
-Xms340m
-Xmx340m
##
## See https://www.elastic.co/guide/en/elasticsearch/reference/current/heap-size.html
## for more information
##
################################################################
三、修改elasticsearch.yml配置文件
# 仍然在config目录下
vim elasticsearch.yml
elasticsearch.yml文件 部分
# ---------------------------------- Network -----------------------------------
#
# Set the bind address to a specific IP (IPv4 or IPv6):
# 若你只想要在本机访问,可以设置为 127.0.0.1 ,若想要公网能访问 配置为如下
network.host: 0.0.0.0
#
# Set a custom port for HTTP:
#
#http.port: 9200
#
# For more information, consult the network module documentation.
#
# --------------------------------- Discovery ----------------------------------
#
# Pass an initial list of hosts to perform discovery when this node is started:
# The default list of hosts is ["127.0.0.1", "[::1]"]
# Network设置为 0.0.0.0 时,需要将一下配置 修改成如下,若使用127.0.0.1 则可以不配置,使用默认方式
discovery.seed_hosts: ["0.0.0.0"]
#
# Bootstrap the cluster using an initial set of master-eligible nodes:
# Network设置为 0.0.0.0 时,需要将一下配置 修改成如下,若使用127.0.0.1 则可以不配置,使用默认方式
cluster.initial_master_nodes: ["node-1"]
#
# For more information, consult the discovery and cluster formation module documentation.
#
四、启动es
# 进入es的bin目录
cd elasticsearch-7.11.0/bin
# 启动es
./elasticsearch
若启动时遇到如下错误
ERROR: [1] bootstrap checks failed
[1]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
修改 /etc/sysctl.conf
# 进入sysctl.conf  注意修改子文件需要root权限
vim /etc/sysctl.conf
# 在文件尾部追加如下配置
vm.max_map_count=262144
# wq保存退出后 执行如下命令
sysctl -p
重新启动es
# 启动es -d 参数表示后台启动
./elasticsearch -d
五、检查es是否可用
# curl 调用接口
curl -X GET "http://127.0.0.1:9200"
# 成功返回  表示启动成功 内网访问也成功
{
  "name" : "VM-8-6-centos",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : "2ENmFV4eSsOVUSO-akIqiA",
  "version" : {
    "number" : "7.11.0",
    "build_flavor" : "default",
    "build_type" : "tar",
    "build_hash" : "8ced7813d6f16d2ef30792e2fcde3e755795ee04",
    "build_date" : "2021-02-08T22:44:01.320463Z",
    "build_snapshot" : false,
    "lucene_version" : "8.7.0",
    "minimum_wire_compatibility_version" : "6.8.0",
    "minimum_index_compatibility_version" : "6.0.0-beta1"
  },
  "tagline" : "You Know, for Search"
}

curl -X GET "http://你的公网ip:9200"
# 若仍返回上述json 则表示公网配置也成功
# 若失败请检查方向:
# 1 你的9200端口是否开放了防火墙 ,可以 在其他服务器 使用 nc -vz ip port 命令探测端口是否畅通
# 2 检查elasticsearch.yml 配置文件 是否完成第三步中的elasticsearch.yml配置
  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值