zoukankan      html  css  js  c++  java
  • centos7 环境安装elasticsearch

    1、elasticserach官网下载对应的tar.gz 压缩包

     

    https://www.elastic.co/cn/downloads/elasticsearch

     

    2、下载成功后,解压到指定目录

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

    3、进入解压后目录,解压后目录结构如下:

      

    4、添加用户组和用户


    elastic 无法直接从root用户直接启动,所以先添加用户

    groupadd elsearch
    useradd elsearch -g elsearch -p es123456

    5、查看新创建的用户、组cat /etc/passwd

       

    6、#chown 用户名 目录名|文件名

    chown -R elsearch:elsearch elasticsearch-7.9.1

    Elasticsearch 目录、配置文件说明、注意点


    7、这里大概解答下各个目录、配置文件的作用:

    目录 配置文件 描述
    bin   放置脚本文件,如启动脚本elasticsearch,插件安装脚本等。
    config elasticsearch.yml elasticsearch配置文件,如集群配置、jvm配置等。
    jdk   Java运行环境
    data path.data 数据持久化文件
    lib   依赖相关类库
    logs path.log 日志文件
    modules   包含的所有ES模块
    plugins   包含的所有已安装

    注意点:

    • 有些童鞋的机器内存可能不够,就需要修改 JVM 参数,配置文件路径为 config/jvm.options,ES V7.1 版本默认为 1g, 老版本为2g, 你可以自行修改。

    • Xmx 和Xms 数值请设置相同;

    • Xmx 不要超过机器内存的 50%;

    内存总量不要超过 30GB, 参见官方文档 https://www.elastic.co/cn/blog/a-heap-of-trouble;

    8、-- 创建目录

    mkdir -p ./bigdata/es_work_space/elasticsearch-7.9.1/data

    9、#同时修改数据目录权限

    chown -R elsearch:elsearch bigdata

    cd config

    10、进入config目录、修改elasticsearch.yml配置文件

    vim elasticsearch.yml

    elasticsearch配置

    1、配置网络访问地址

    2、配置集群单节点模式

     

    注意:如果是集群"node-1" 必须唯一、找到  默认是有注释的,把注释去掉 后保存 

    11、切换用户、es只允许使用普通用户启动

    su elsearch

    ./elasticsearch -d

    查看后台运行日志

    tail -f logs/elasticsearch.log


    以下是常见错误的解决

    Elasticse报错-org.elasticsearch.bootstrap.BootstrapException: java.nio.file.AccessDeniedException

     1     Exception in thread "main" org.elasticsearch.bootstrap.BootstrapException: java.nio.file.AccessDeniedException: /usr/local/elasticsearch/elasticsearch-7.1.0/config/elasticsearch.keystore
     2 
     3     Likely root cause: java.nio.file.AccessDeniedException: /usr/local/elasticsearch/elasticsearch-7.1.0/config/elasticsearch.keystore
     4 
     5             at sun.nio.fs.UnixException.translateToIOException(UnixException.java:84)
     6 
     7             at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:102)
     8 
     9             at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:107)
    10 
    11             at sun.nio.fs.UnixFileSystemProvider.newByteChannel(UnixFileSystemProvider.java:214)
    12 
    13             at java.nio.file.Files.newByteChannel(Files.java:361)
    14 
    15             at java.nio.file.Files.newByteChannel(Files.java:407)
    16 
    17             at org.apache.lucene.store.SimpleFSDirectory.openInput(SimpleFSDirectory.java:77)
    18 
    19             at org.elasticsearch.common.settings.KeyStoreWrapper.load(KeyStoreWrapper.java:206)
    20 
    21             at org.elasticsearch.bootstrap.Bootstrap.loadSecureSettings(Bootstrap.java:224)
    22 
    23             at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:289)
    24 
    25             at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:159)
    26 
    27             at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:150)
    28 
    29             at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:86)
    30 
    31             at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:124)
    32 
    33             at org.elasticsearch.cli.Command.main(Command.java:90)
    34 
    35             at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:115)
    36 
    37             at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:92)
    38 
    39     Refer to the log for complete error details.

    解决办法:切换到root用户修改文件elasticsearch.keystore权限

    执行如下命令:

    chown -R elsearch:elsearch elasticsearch.keystore 

    问题描述:

    启动Elasticsearch 时报错如下:

    1     [3] bootstrap checks failed
    2 
    3     [1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65535]
    4 
    5     [2]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
    6 
    7     [3]: the default discovery settings are unsuitable for production use; at least one of [discovery.seed_hosts, discovery.seed_providers, cluster.initial_master_nodes] must be configured

    Elasticsearch 服务需要大量的虚拟内存支撑,系统默认的最大虚拟内存是 65530, 而 ES 至少需要 262144.

    解决办法:

    设置虚拟内存大小,此设置需要重启系统

    运行elasticsearch需要vm.max_map_count至少需要262144内存

    切换到root用户修改配置sysctl.conf

    vi /etc/sysctl.conf

    在尾行添加以下内容   

    vm.max_map_count=262144

    并执行命令

    sysctl -p

    12、Elasticsearch 报错如下:

    1 max file descriptors [4096] for elasticsearch process is too low, increase to at least [65535]    

      

    解决办法:

    13、编辑 /etc/security/limits.conf,追加以下内容

    // 文件句柄数

    * soft nofile 65536

       * hard nofile 65536

       

       

    此文件修改后需要退出用户,重新登录才会生效。

    14、登录后使用 ulimit -Hn 查看

      ulimit -Hn

      

    15、验证ES服务是否可用

    通过 jps 命令查看当前系统中运行的所有java 进程

      

    16、查看日志若出现如下信息则说明启动成功

      

    17、在浏览器中访问

      

     1 {
     2     "name": "node-1",
     3     "cluster_name": "elasticsearch",                # 当前集群的名称, 同一集群中要保证一致
     4     "cluster_uuid": "ZW0VDxesTN2EmJAjhMVYLw",
     5     "version": {
     6     "number": "7.9.1",                                # 当前运行的ES的版本号
     7     "build_flavor": "default",
     8     "build_type": "tar",
     9     "build_hash": "083627f112ba94dffc1232e8b42b73492789ef91",
    10     "build_date": "2020-09-01T21:22:21.964974Z",
    11     "build_snapshot": false,                        # 当前运行的版本是不是从源代码构建而来
    12     "lucene_version": "8.6.2",                        # 当前ES底层的Lucene的版本号
    13     "minimum_wire_compatibility_version": "6.8.0",
    14     "minimum_index_compatibility_version": "6.0.0-beta1"
    15     },
    16     "tagline": "You Know, for Search"
    17 }

    或者在命令窗口执行如下命令:

    curl -X GET http://ip:9200/

    健康状态检测

    http://ip:9200/_cat/health

    c

    18、关闭与重启服务

     

    19、查看索引

    http://ip:9200/_cat

  • 相关阅读:
    ubuntu 14.04下使用fcitx时将caps lock映射为ctrl
    php多进程、IPC和事件驱动
    [轉載]【京都动画统治世界】短篇科幻小说《2134动漫奇缘》
    [日语]每日笔记
    [转载]C++的顺序点(sequence point)和副作用(side effect)
    [转载]Best Practices for Speeding Up Your Web Site
    [系统]安装fedora 19
    阿里云服务上面部署redis + 本地Redis客户端连接方法 + 配置redis服务
    linux [Centos7]搭建PHP的RabbitMQ环境
    linux vim常用操作
  • 原文地址:https://www.cnblogs.com/lwx57280/p/13738230.html
Copyright © 2011-2022 走看看