您的位置:首页 > 运维架构 > Linux

CentOS 7 安装 elasticsearch 7.5.1

2020-04-21 20:16 627 查看

CentOS 7 安装 elasticsearch 7.5.1

1.创建elsearch用户, 因为Elasticsearch不支持root用户运行

useradd elsearch

2.在根目录创建文件夹itcast,进入该目录,创建es目录

mkdir itcast
cd itcast
mkdir es

3.更改itcast目录所属的用户

chown elsearch:elsearch itcast/ -R

4.切换用户

su - elsearch

5.进入itcast目录

cd /itcast/

6.将下载的elsearch压缩包放到这里

7.解压安装包

tar -xvf elasticsearch-6.5.4.tar.gz -C /itcast/es/

8.进入config

cd /itcast/es/elasticsearch-7.5.1/config

9.修改配置文件

vim elasticsearch.yml
network.host: 0.0.0.0 #设置ip地址 ,任意网络均可访问

10.修改jvm启动参数

vim jvm.options
-Xms128m
-Xmx128m

11.切换到root用户:su root,设置一个进程在VMAS(虚拟内存区域)创建内存映射最大数量

vim /etc/sysctl.conf
vm.max_ map_count=655360
sysctl -p  #使配置生效

12.切换回elsearch用户:su - elsearch,启动es

cd bin
./elasticsearch 或 ./elasticsearch -d #后台系统

使用虚拟机IP:9200访问,若出现以下信息表示成功

{
"name" : "node-1",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "H2ye1sRGQK-vl1bcU3H7JQ",
"version" : {
"number" : "7.5.1",
"build_flavor" : "default",
"build_type" : "tar",
"build_hash" : "3ae9ac9a93c95bd0cdc054951cf95d88e1e18d96",
"build_date" : "2019-12-16T22:57:37.835892Z",
"build_snapshot" : false,
"lucene_version" : "8.3.0",
"minimum_wire_compatibility_version" : "6.8.0",
"minimum_index_compatibility_version" : "6.0.0-beta1"
},
"tagline" : "You Know, for Search"
}

报错解决

1: max file descriptors [4096] for elasticsearch process is too 1ow, increase to at least [65536]
#解决:切换到root用户。编辑limits.conf添加类似如下内容
vi /etc/security/limits.conf
添加如下内容:

* soft nofile 65536
* hard nofile 131072
* soft nproc 2048
* hard nproc 4096

CentOS 6 下处理2、3错误
2: max number of threads [1024] for user [elsearch] is too 1ow,increase to at least [4096]
#解决:切换到root用户,进入limits.d目录下修改配置文件。

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

#修改如下内容:

*soft nproc 1024

#修改为

soft nproc 4096

3: system call filters failed to install; check the logs and fix your configuration
or disable system cal1 filters at your own risk
#解决: Centos6不支持SecComp,而ES5.2。0默认bootstrap.system ca11. .filter为true

vim config/elasticsearch. yml

添加:

bootstrap.system_call_filter:false

4:the default discovery settings are unsuitable for production use; at least one of [discovery.seed_hosts, discovery.seed_providers, cluster.initial_master_nodes] must be configured
按照下文修改elasticsearch.yml文件配置

# ======================== Elasticsearch Configuration =========================
#
# NOTE: Elasticsearch comes with reasonable defaults for most settings.
#       Before you set out to tweak and tune the configuration, make sure you
#       understand what are you trying to accomplish and the consequences.
#
# The primary way of configuring a node is via this file. This template lists
# the most important settings you may want to configure for a production cluster.
#
# Please consult the documentation for further information on configuration options:
# https://www.elastic.co/guide/en/elasticsearch/reference/index.html
#
# ---------------------------------- Cluster -----------------------------------
#
# Use a descriptive name for your cluster:
#
#cluster.name: my-application
#
# ------------------------------------ Node ------------------------------------
#
# Use a descriptive name for the node:
#
node.name: node-1
#
# 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: /itcast/es/elasticsearch-7.5.1/data
#
# Path to log files:
#
path.logs: /itcast/es/elasticsearch-7.5.1/logs
#
# ----------------------------------- Memory -----------------------------------
#
# Lock the memory on startup:
#
#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
#
# 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]"]
#
#discovery.seed_hosts: ["host1", "host2"]
#
# Bootstrap the cluster using an initial set of master-eligible nodes:
#
#cluster.initial_master_nodes: ["node-1", "node-2"]
cluster.initial_master_nodes: ["node-1"]
#
# For more information, consult the discovery and cluster formation module documentation.
#
# ---------------------------------- Gateway -----------------------------------
#
# Block initial recovery after a full cluster restart until N nodes are started:
#
#gateway.recover_after_nodes: 3
#
# For more information, consult the gateway module documentation.
#
# ---------------------------------- Various -----------------------------------
#
# Require explicit names when deleting indices:
#
#action.destructive_requires_name: true
http.cors.enabled: true
http.cors.allow-origin: "*"

[5]:启动后内部命令访问测试成功:

curl -get localhost:9200

但是外部访问不到,是防火墙的原因,可以关闭防火墙:

systemctl stop firewalld.service

成功访问返回JSON格式数据:

{
"name" : "node-1",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "H2ye1sRGQK-vl1bcU3H7JQ",
"version" : {
"number" : "7.5.1",
"build_flavor" : "default",
"build_type" : "tar",
"build_hash" : "3ae9ac9a93c95bd0cdc054951cf95d88e1e18d96",
"build_date" : "2019-12-16T22:57:37.835892Z",
"build_snapshot" : false,
"lucene_version" : "8.3.0",
"minimum_wire_compatibility_version" : "6.8.0",
"minimum_index_compatibility_version" : "6.0.0-beta1"
},
"tagline" : "You Know, for Search"
}
  • 点赞
  • 收藏
  • 分享
  • 文章举报
qq_43626897 发布了2 篇原创文章 · 获赞 0 · 访问量 127 私信 关注
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: