Linux系统Elasticsearch安装与运行(yum)

当前环境:Linux liuns 3.10.0-957.5.1.el7.x86_64 #1 SMP Fri Feb 1 14:54:57 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

  1. Elashticseach依赖java,所有需要先安装java。
    [root@liuns ~]# yum install java
    [root@liuns ~]# java -version
    openjdk version "1.8.0_232"
    OpenJDK Runtime Environment (build 1.8.0_232-b09)
    OpenJDK 64-Bit Server VM (build 25.232-b09, mixed mode)
    
    //源码安装参考:https://www.java.com/en/download/help/linux_x64_install.xml
  2. 导入Elasticsearch PGP Key。
    [root@liuns ~]# rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch
  3. 在/etc/yum.repos.d/目录下新建elasticsearch.repo源文件。

    [root@liuns ~]# vim /etc/yum.repos.d/elasticsearch.repo
    插入如下内容:
    [elasticsearch]
    name=Elasticsearch repository for 7.x packages
    baseurl=https://artifacts.elastic.co/packages/7.x/yum
    gpgcheck=1
    gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch
    enabled=0
    autorefresh=1
    type=rpm-md
    
  4. 执行安装即启动

    //执行安装
    [root@liuns ~]# yum install --enablerepo=elasticsearch elasticsearch -y
    
    //加入系统自启动
    [root@liuns ~]# sudo systemctl daemon-reload
    [root@liuns ~]# sudo systemctl enable elasticsearch.service
    
    //启动/关闭服务
    [root@liuns ~]# sudo service elasticsearch start
    [root@liuns ~]# sudo service elasticsearch stop
    
    //如果启动失败可以通过以下命令查看系统日志定位问题
    [root@liuns ~]# sudo journalctl -f
  5. 可通过访问http://localhost:9200检查Elasticsearch是否正常运行访问

    [root@liuns ~]# curl http://localhost:9200
    {
      "name" : "liuns",
      "cluster_name" : "elasticsearch",
      "cluster_uuid" : "r49F7tEOTXugFfRgAbLmYw",
      "version" : {
        "number" : "7.5.0",
        "build_flavor" : "default",
        "build_type" : "rpm",
        "build_hash" : "e9ccaed468e2fac2275a3761849cbee64b39519f",
        "build_date" : "2019-11-26T01:06:52.518245Z",
        "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"
    }

     

  6. Elasticsearch相关目录结构布局。

    TypeDescriptionDefault LocationSetting

    home

    Elasticsearch home directory or $ES_HOME

    /usr/share/elasticsearch

     

    bin

    Binary scripts including elasticsearch to start a node and elasticsearch-plugin to install plugins

    /usr/share/elasticsearch/bin

     

    conf

    Configuration files including elasticsearch.yml

    /etc/elasticsearch

    ES_PATH_CONF 

    conf

    Environment variables including heap size, file descriptors.

    /etc/sysconfig/elasticsearch

     

    data

    The location of the data files of each index / shard allocated on the node. Can hold multiple locations.

    /var/lib/elasticsearch

    path.data

    jdk

    The bundled Java Development Kit used to run Elasticsearch. Can be overriden by setting the JAVA_HOME environment variable in /etc/sysconfig/elasticsearch.

    /usr/share/elasticsearch/jdk

     

    logs

    Log files location.

    /var/log/elasticsearch

    path.logs

    plugins

    Plugin files location. Each plugin will be contained in a subdirectory.

    /usr/share/elasticsearch/plugins

     

    repo

    Shared file system repository locations. Can hold multiple locations. A file system repository can be placed in to any subdirectory of any directory specified here.

    Not configured

    path.repo

  7. 系统配置文件 /etc/sysconfig/elasticsearch 运行时相关配置项。

    JAVA_HOME

    Set a custom Java path to be used.

    MAX_OPEN_FILES

    Maximum number of open files, defaults to 65535.

    MAX_LOCKED_MEMORY

    Maximum locked memory size. Set to unlimited if you use the bootstrap.memory_lock option in elasticsearch.yml.

    MAX_MAP_COUNT

    Maximum number of memory map areas a process may have. If you use mmapfs as index store type, make sure this is set to a high value. For more information, check the linux kernel documentation about max_map_count. This is set via sysctl before starting Elasticsearch. Defaults to 262144.

    ES_PATH_CONF

    Configuration file directory (which needs to include elasticsearch.ymljvm.options, and log4j2.properties files); defaults to /etc/elasticsearch.

    ES_JAVA_OPTS

    Any additional JVM system properties you may want to apply.

    RESTART_ON_UPGRADE

    Configure restart on package upgrade, defaults to false. This means you will have to restart your Elasticsearch instance after installing a package manually. The reason for this is to ensure, that upgrades in a cluster do not result in a continuous shard reallocation resulting in high network traffic and reducing the response times of your cluster.

  8. Elasticsearch的3个主要配置文件。

    elasticsearch.yml

    for configuring Elasticsearch.

    jvm.options

    for configuring Elasticsearch JVM settings.

    log4j2.properties

    for configuring Elasticsearch logging.

 

参考资料:

https://www.elastic.co/guide/en/elasticsearch/reference/7.5/rpm.html

https://www.elastic.co/guide/en/elasticsearch/reference/7.5/settings.html 

 ​​​​

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值