centos7 - elasticsearch 6.8部署

简介

ElasticSearch是一个基于Lucene的搜索服务器。它提供了一个分布式多用户能力的全文搜索引擎,基于RESTful web接口。

centos7 - elasticsearch 6.8部署


下载

下载页面:

https://www.elastic.co/cn/downloads/past-releases#elasticsearch

可以找到目前6版本最新是6.8.2

https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.8.2.tar.gz


centos7 - elasticsearch 6.8部署

修改内核参数

echo vm.max_map_count=262144 >> /etc/sysctl.conf
sysct -p

centos7 - elasticsearch 6.8部署


修改句柄限制

echo "* soft nofile 65536" >> /etc/security/limits.conf

echo "* hard nofile 131072" >> /etc/security/limits.conf

(需要重新登录终端即可)

centos7 - elasticsearch 6.8部署


创建执行用户

useradd es
passwd es

(设置密码,方便登录操作,如果习惯用key,直接做免密码登录比较安全方便)


安装jdk

tar zcvf jdk-8u202-linux-x64.tar.gz -C /opt/
cd /opt
ln -s jdk1.8.0_202 jdk

添加环境变量

vim /etc/profile

export JAVA_HOME=/opt/jdk
export PATH=${JAVA_HOME}/bin:$PATH

安装elasticesarch

tar zxvf elasticsearch-6.8.2.tar.gz -C /opt/
cd /opt/
ln -s elasticsearch-6.8.2 elasticsearch

创建数据目录和日志目录

mkdir -p /data/elasticsearch/data 
mkdir -p /data/elasticsearch/logs

修改权限

chown es.es /opt/elasticsearch /opt/elasticsearch-6.8.2 /data/elasticsearch -R

配置elasticsearch

为了防止权限出现问题,需要切换到es用户进行操作

su - es

配置文件目录

/opt/elasticsearch/config

目录里面的默认文件:

elasticsearch.yml jvm.options log4j2.properties role_mapping.yml roles.yml users users_roles

jvm.options : 设置jvm相关参数的,可以根据实际情况修改对应的参数,从默认配置里面可以看到默认是启用gc的,日志是在logs/gc.log,这个路径是跟elasticsearch默认路径是一致的,如果需要修改gc日志路径需要在这个里面修改,例如:8:-Xloggc:/data/elasticsearch/logs/gc.log

log4j2.properties : 日志相关参数的配置文件

role_mapping.yml roles.yml users users_roles:这几个是验证相关的配置文件

elasticsearch.yml:主要的配置文件

centos7 - elasticsearch 6.8部署


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-es

#

# ------------------------------------ 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: /data/elasticsearch/data

#

# Path to log files:

#日志文件路径

path.logs: /data/elasticsearch/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):

#需要绑定监听的IP,多个IP可以使用,分隔

network.host: 192.168.57.102,127.0.0.1

#

# Set a custom port for HTTP:

#http端口

http.port: 9200

#

# For more information, consult the network module documentation.

#

# --------------------------------- Discovery ----------------------------------

#

# Pass an initial list of hosts to perform discovery when new node is started:

# The default list of hosts is ["127.0.0.1", "[::1]"]

#

#discovery.zen.ping.unicast.hosts: ["host1", "host2"]

#启动时自动发现集群的节点

discovery.zen.ping.unicast.hosts: ["127.0.0.1", "192.168.57.102"]

#

# Prevent the "split brain" by configuring the majority of nodes (total number of master-eligible nodes / 2 + 1):

#

#discovery.zen.minimum_master_nodes:

#

# For more information, consult the zen discovery 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


启动

/opt/elasticsearch/bin/elasticsearch -d

centos7 - elasticsearch 6.8部署


测试

curl http://192.168.57.102:9200/_cat/indices?v

相关推荐