CentOS7安装ElasticSearch7

CentOS7安装ElasticSearch7

  • 安装jdk8
  • 安装elasticsearch7.1.1

安装jdk8

查看 centos7 安装 jdk8

安装elasticsearch7.1.1

从https://www.elastic.co/cn/网站下载elasticsearch的安装包,将elasticsearch安装在/usr/local目录下。(7.11.2要求版本jdk11,刚开始没注意,下载错误。改成下载7.1.1

wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.1.1-linux-x86_64.tar.gz

CentOS7安装ElasticSearch7_第1张图片
解压文件,然后我们进入到elasticsearch的文件夹内

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

cd elasticsearch-7.1.1/

目录结构:

bin          //主要存放的是elasticsearch相关的脚本文件
config       // 存放的是elasticsearch的配置文件
jdk          //elasticsearch自带的jdk
logs         //elasticsearch存放日志
modules      //elasticsearch的功能模块
plugins      //elasticsearch的插件,我们安装的插件存放在此目录

配置

elasticsearch 不允许以 root 权限来运行!所以需要创建一个非root用户,以非root用户来启动es

#创建用户组es
groupadd es

#创建新用户es,设置用户组为es,密码es
useradd elasticsearch -g es -p elasticsearch

#授权,更改elasticsearch-7.1.1文件夹所属用户及用户组为es:es
chown -R elasticsearch:elasticsearch elasticsearch-7.1.1

#切换用户es
su elasticsearch

调整jvm内存大小,可以不调整

vi elasticsearch-7.1.1/config/jvm.options

#修改如下配置
-Xms512m
-Xmx512m

在这里我们需要对elasticsearch进行相关的配置,编辑config目录下的elasticsearch.yml文件,重点关注以下7个配置项:

# ======================== 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:
# !!!!!!配置项1: 集群名称
#
cluster.name: my-application-es1 
#
# ------------------------------------ Node ------------------------------------
#
# Use a descriptive name for the node:
# !!!!!!配置项2: 节点名称
#
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):
# !!!!!!配置项3: 数据目录
# 
path.data: /usr/local/elasticsearch-7.1.1/data  
#
# Path to log files:
# !!!!!!配置项4: log目录
#
path.logs: /usr/local/elasticsearch-7.1.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):
# !!!!!!配置项5: 部署的centos的ip地址
#
network.host: 0.0.0.0  
#
# Set a custom port for HTTP:
# !!!!!!配置项6: 默认端口
#
http.port: 9200   //-------------(6)---------------------
#
# 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:
# !!!!!!配置项7: 初始主节点
#
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

#启动命令

.elasticsearch-7.1.1/bin/elasticsearch

#后台启动命令
.elasticsearch-7.1.1/bin/elasticsearch -d
 
#设置开机自启动
systemctl enable elasticsearch.service

错误

 max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]

elasticsearch用户拥有的内存权限太小,至少需要262144。切换root用户下,使用vim /etc/sysctl.conf命令编辑sysctl.conf文件
添加以下内容

vm.max_map_count=262144

kibana安装

步骤1:下载(必须和你的es版本一致

ca kibana
wget https://artifacts.elastic.co/downloads/kibana/kibana-7.1.1-linux-x86_64.tar.gz

步骤2:解压

tar -zxvf kibana-7.1.1-linux-x86_64.tar.gz

步骤3:修改配置文件中的url

vim kibana-7.1.1/config/kibana.yml
./bin/kibana &
nohup bin/kibana >/dev/null 2>&1 &

开启x-pack

因为7.1.1版本已经内置了x-pack,开启x-pack

xpack.security.enabled: true
xpack.license.self_generated.type: basic
xpack.security.transport.ssl.enabled: true

设置密码

./../bin/elasticsearch-setup-passwords interactive

kibana 添加密码
修改配置

elasticsearch.username: "elastic"
elasticsearch.password: "xxxxxx"

你可能感兴趣的:(服务器,es,elasticsearch,centos,linux,nginx)