centos7.0中安装单机版es6.2.3

一 介绍

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

二 说明

1.说明:

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

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

2.jdk1.8的安装:

https://blog.****.net/u011066470/article/details/89282422

3.es的安装:

#3.1 解压压缩包,在root用户权限下解压

[[email protected] softpackagebyjurf] tar   -zxvf   elasticsearch-6.3.2.tar.gz

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

[[email protected] softpackagebyjurf]# groupadd elagroup      #创建用户组elagroup

[[email protected] softpackagebyjurf]# useradd -g elagroup elauser  #创建用户elauser并将其添加到elagroup组中

[[email protected] softpackagebyjurf]# passwd   elauser    #为elauser设置密码

#3.3设定密码后,编辑文件,使elauser用户具有执行权限

[[email protected] softpackagebyjurf]# vim /etc/sudoers

centos7.0中安装单机版es6.2.3

#3.4为了让elauser用户拥有对elasticsearch执行权限需要将软件包更改属主属组

[[email protected] softpackagebyjurf]# chown -R elauser:elagroup  /opt/softpackagebyjurf/elasticsearch-6.3.2/           #注意为用户名:用户组的格式

centos7.0中安装单机版es6.2.3

#3.5切换到elauser,修改elasticsearch.yml的配置文件

[[email protected] elasticsearch-6.3.2]# su elauser

#3.6进入到config目录下

[[email protected] config]$ vim 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-meboth

#

# ------------------------------------ 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/es-data

#

# Path to log files:

#

path.logs: /var/log/elasticsearch

#

# ----------------------------------- 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 new node is started:

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

#

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

#

# 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

 

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

[[email protected] config]$ sudo  mkdir -p /data/es-data

[[email protected] config]$ sudo  mkdir -p /var/log/elasticsearch

[[email protected] config]$ sudo chown -R elauser.elagroup /data

[[email protected] config]$ sudo chown -R elauser.elagroup /var/log/elasticsearch/

 

4.es的启动:(切换到elauser用户)

进入bin目录下执行: ./elasticsearch 后面可以跟上-d后台执行

centos7.0中安装单机版es6.2.3

 

centos7.0中安装单机版es6.2.3

5.es的启动异常的处理:

centos7.0中安装单机版es6.2.3

 

解决办法:切换到root用户

#修改sysctl.conf文件

[[email protected] bin]# vim /etc/sysctl.conf

vm.max_map_count = 655365   //文件中添加这一行

[[email protected] bin]# sysctl -p     #执行生效命令

vm.max_map_count = 655365

#修改limits.conf文件

[[email protected] bin]# vim /etc/security/limits.conf

centos7.0中安装单机版es6.2.3

#切换到elauser用户

[[email protected] bin]# su elauser

 

 

6.es的启动端口判定:

[[email protected] ~]# jps

3401 Jps

3163 Elasticsearch

[[email protected] ~]# netstat -nlap|grep 9200

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

[[email protected] ~]# netstat -nlap|grep 9500

[[email protected] ~]#

7.es的后台启动执行:

[[email protected] bin]$ ./elasticsearch -d

[[email protected] bin]$ jps

3573 Jps

3548 Elasticsearch

[[email protected] bin]$ netstat -nlap|grep 9200

(Not all processes could be identified, non-owned process info

 will not be shown, you would have to be root to see it all.)

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

[[email protected] bin]$ ^C

8.页面访问:

centos7.0中安装单机版es6.2.3

 

https://www.linuxidc.com/Linux/2018-08/153718.htm