ElasticSearch的部署

一 Linux环境部署

首先到官网下载ElasticSearch安装包:下载地址:https://www.elastic.co/cn/downloads/elasticsearch, 该页面有各个平台下载链接,其中Linux平台有.tar.rpm两种格式
这里我们以.tar格式为例,首先登陆Linux系统

  • 执行命令cd /opt 进入opt目录,再执行命令mkdir elk创建新的文件夹
  • 执行命令cd elk进入到elk目录,再执行命令wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.3.1.tar.gz下载文件,也可以通过
    windows下载好后上传到该目录,等待下载完成
  • 执行命令tar -zxvf elasticsearch-6.3.1.tar.gz 解压下载的文件
  • 执行命令ll查看文件夹内容,发现多了elasticsearch-6.3.1目录,使用cd elasticsearch-6.3.1进入目录
  • 执行命令./bin/elasticsearch,等待启动完成(elasticsearch不能使用root用户启动,所以需要新增用户启动)
  • elasticsearch是基于java写的,所以要运行elasticsearch.必须先安装java环境
1. 下载jdk安装包,下载地址:
2.  使用 tar -zxvf jdk1.8.0_171 命令解压安装jdk
3.  配置jdk环境变量
     3.1  vi  /etc/profile  -- 编辑profile文件,新增一下内容 
            #java setting 
            #JAVA_HOME的地址为解压后的jdk目录
            export JAVA_HOME=/opt/downloads/jdk1.8.0_171
            export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
            export PATH=$JAVA_HOME/bin:$PATH
      3.2  执行source /etc/profile 命令,是文件生效
      3.3  执行 java -version 命令,输出如下,则表明java环境配置成功
             java version "1.8.0_171"
             Java(TM) SE Runtime Environment (build 1.8.0_171-b11)
             Java HotSpot(TM) 64-Bit Server VM (build 25.171-b11, mixed mode)

再浏览器中输入http://serverip:9200,回车访问
启动的过程中可能会出现以下错误

错误1 max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]
错误2 max number of threads [1024] for user [lish] likely too low, increase to at least [2048]
错误3 max virtual memory areas vm.max_map_count [65530] likely too low, increase to at least [262144]


浏览器输出一下字样,说明启动成功

{
  "name" : "Vjmx3nU",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : "CAnCsdxhQPe-DSlVg-D81g",
  "version" : {
    "number" : "6.3.1",
    "build_flavor" : "default",
    "build_type" : "tar",
    "build_hash" : "eb782d0",
    "build_date" : "2018-06-29T21:59:26.107521Z",
    "build_snapshot" : false,
    "lucene_version" : "7.3.1",
    "minimum_wire_compatibility_version" : "5.6.0",
    "minimum_index_compatibility_version" : "5.0.0"
  },
  "tagline" : "You Know, for Search"
}

安装过程可能会出现Linux相关的问题,例如权限等问题,不在此文章解决之列,接下来介绍下elasticsearch配置文件
elasticsearch配置文件,一下为默认的配置文件内容,注意看中文注释

# ======================== 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:
#集群名称,es会将该名字相同的同一网段的es服务器自动发现成为集群的节点
#cluster.name: my-application
#
# ------------------------------------ Node ------------------------------------
#
# Use a descriptive name for the node:
#该节点的名称
#node.name: node-3
#
# Add custom attributes to the node:
#集群的一些属性,比如master,data等
#node.attr.rack: r1
#node.master: true
#node.data: true
#
# ----------------------------------- Paths ------------------------------------
#
# Path to directory where to store the data (separate multiple locations by comma):
#节点数据保存位置
#path.data: /path/to/data
#
# Path to log files:
#日志文件位置
#path.logs: /path/to/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,如需外网访问,需要设置为0.0.0.0
#network.host: 192.168.0.1
#
# 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

基本上修改我注释的部分就可以作为进群的一个节点使用了

Windows的部署和Linux没差别,只需要下载对应的安装包,修改配置文件即可


种一棵树最好的时间是十年前,其次是现在.