zoukankan      html  css  js  c++  java
  • linux下安装elasticsearch5.6.3

    1.准备工作

    确保系统已经安装jdk1.8及以上版本

    2.下载es

    下载地址:wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.0.0.tar.gz

    3.解压安装

    添加用户

    useradd elasticsearch

    解压

    tar xf elasticsearch-5.6.3.tar.gz -C /usr/local

    cd /usr/local

    设置软链
    ln -sv elasticsearch-5.6.3 elasticsearch
     
    mkdir -pv /data/elasticsearch/{data,logs}
    chown -R elasticsearch.elasticsearch /data/elasticsearch
     
    注意:在安装过程中,不建这2个文件夹,启动时会报错,找不到这两个路径。
    mkdir -p /usr/local/elasticsearch/plugins
    mkdir -p /usr/local/elasticsearch/config/scripts
     
    4.修改配置文件
    /usr/local/elasticsearch/config/elasticsearch.yml
    配置文件中新增内容如下
    # 换个集群的名字,免得跟别人的集群混在一起
    cluster.name: wlt-es5.0-application   
    # 换个节点名字
    node.name: node-1
         
    path.data: /data/elasticsearch/data
    path.logs: /data/elasticsearch/logs
    
    # 修改一下ES的监听地址,这样别的机器也可以访问
    network.host: 0.0.0.0
    # 默认的就好
    
    http.port: 9200
    # 增加新的参数,这样head插件可以访问es
    #http.cors.enabled: true
    #http.cors.allow-origin: “*"
    

    5.修改系统参数

    编辑limit.conf文件  /etc/security/limits.conf

    内容如下

    *               soft    nproc           65536
    
    *               hard    nproc           65536
    
    *               soft    nofile          65536
    
    *               hard    nofile          65536
    

    继续编辑sysctl.conf文件  /etc/sysctl.conf

    内容如下

    vm.max_map_count= 262144

    编辑完成后执行指令 sysctl -p 使配置生效

    :如果遇到limit.conf文件没有生效的情况下,可执行命令 ulimit -n 65536 临时添加limit.conf中最大打开文件数配置

    6.启动es服务

    进入/usr/local 路径下,切换至上面添加的elasticsearch用户

    指令如下

    cd /usr/local

    su elasticsearch

    启动es

    cd /elasticsearch/bin

    ./elasticsearch

    启动完成

    启动可能会遇到的问题:

    1.elasticsearch安装目录权限不对

    遇到启动elasticsearch失败,使用的是专门的用户elasticsearch来启动的,启动日志提示不能加载配置文件:

    [elasticsearch@docker bin]$ ./elasticsearch
    Exception in thread "main" 2018-06-03 17:36:23,881 main ERROR No log4j2 configuration file found. Using default configuration: logging only errors to the console. Set system property ‘log4j2.debug‘ to show Log4j2 internal initialization logging.
    2018-06-03 17:36:24,113 main ERROR Could not register mbeans java.security.AccessControlException: access denied ("javax.management.MBeanTrustPermission" "register")
            at java.security.AccessControlContext.checkPermission(AccessControlContext.java:472)
            at java.lang.SecurityManager.checkPermission(SecurityManager.java:585)
            at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.checkMBeanTrustPermission(DefaultMBeanServerInterceptor.java:1848)
            at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerMBean(DefaultMBeanServerInterceptor.java:322)
            at com.sun.jmx.mbeanserver.JmxMBeanServer.registerMBean(JmxMBeanServer.java:522)
            at org.apache.logging.log4j.core.jmx.Server.register(Server.java:389)
            at org.apache.logging.log4j.core.jmx.Server.reregisterMBeansAfterReconfigure(Server.java:167)
            at org.apache.logging.log4j.core.jmx.Server.reregisterMBeansAfterReconfigure(Server.java:140)
            at org.apache.logging.log4j.core.LoggerContext.setConfiguration(LoggerContext.java:556)
            at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:617)
            at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:634)
            at org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:229)
            at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:242)
            at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:45)
            at org.apache.logging.log4j.LogManager.getContext(LogManager.java:174)
            at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:618)
            at org.elasticsearch.common.logging.ESLoggerFactory.getLogger(ESLoggerFactory.java:54)
            at org.elasticsearch.common.logging.ESLoggerFactory.getLogger(ESLoggerFactory.java:62)
            at org.elasticsearch.common.logging.Loggers.getLogger(Loggers.java:101)
            at org.elasticsearch.ExceptionsHelper.<clinit>(ExceptionsHelper.java:42)
            at org.elasticsearch.ElasticsearchException.toString(ElasticsearchException.java:663)
            at java.lang.String.valueOf(String.java:2994)
            at java.io.PrintStream.println(PrintStream.java:821)
            at java.lang.Throwable$WrappedPrintStream.println(Throwable.java:748)
            at java.lang.Throwable.printStackTrace(Throwable.java:655)
            at java.lang.Throwable.printStackTrace(Throwable.java:643)
            at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:1061)
            at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:1052)
            at java.lang.Thread.dispatchUncaughtException(Thread.java:1959)
    
    SettingsException[Failed to load settings from /usr/local/elasticsearch-5.6.0/config/elasticsearch.yml]; nested: AccessDeniedException[/usr/local/elasticsearch-5.6.0/config/elasticsearch.yml];
            at org.elasticsearch.node.InternalSettingsPreparer.prepareEnvironment(InternalSettingsPreparer.java:102)
            at org.elasticsearch.cli.EnvironmentAwareCommand.createEnv(EnvironmentAwareCommand.java:72)
            at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:67)
            at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:134)
            at org.elasticsearch.cli.Command.main(Command.java:90)
            at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:91)
            at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:84)
    Caused by: java.nio.file.AccessDeniedException: /usr/local/elasticsearch-5.6.0/config/elasticsearch.yml
            at sun.nio.fs.UnixException.translateToIOException(UnixException.java:84)
            at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:102)
            at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:107)
            at sun.nio.fs.UnixFileSystemProvider.newByteChannel(UnixFileSystemProvider.java:214)
            at java.nio.file.Files.newByteChannel(Files.java:361)
            at java.nio.file.Files.newByteChannel(Files.java:407)
            at java.nio.file.spi.FileSystemProvider.newInputStream(FileSystemProvider.java:384)
            at java.nio.file.Files.newInputStream(Files.java:152)
            at org.elasticsearch.common.settings.Settings$Builder.loadFromPath(Settings.java:1032)
            at org.elasticsearch.node.InternalSettingsPreparer.prepareEnvironment(InternalSettingsPreparer.java:100)
            ... 6 more
    

    解决方案

    看到“Caused by: java.nio.file.AccessDeniedException: /usr/local/elasticsearch-5.6.3/config/elasticsearch.yml”的提示,

    就去检查目录的权限,果然是root:root权限,

    使用elasticsearch用户去启动,就报错了。

    将目录的权限改成elasticsearch:elasticsearch就好了。

    [root@docker ~]# ll /usr/local/
    drwxr-xr-x  7 root root       123 9月   7 2017 elasticsearch-5.6.3
    
    [root@docker local]#  chown  -R elasticsearch: elasticsearch elasticsearch-5.6.3
    [root@docker local]# ll
    drwxr-xr-x  7 elasticsearch  elasticsearch        123 9月   7 2017 elasticsearch-5.6.3
    

      

    head插件安装教程  https://www.cnblogs.com/vicF/p/9718430.html

    文末小福利免费视频资源网站:www.sousuohou.com
  • 相关阅读:
    《生命3.0—在亿年的尺度下审视生命的演进》阅读笔记3
    软件杯赛题周总结(2)
    《生命3.0—在亿年的尺度下审视生命的演进》阅读笔记2
    记一次阅读源码的小经历
    11
    解决在 CSS 中,如何实现动态吸顶的样式/效果 ?
    Angular 初始化项目后,如何把默认的 .css 文件修改为 .scss 文件?
    解决 Angular 项目中,添加 <router-outlet> 标签后,报错: ‘router-outlet’ is not a known element 的问题。
    在 Angular 项目中,如何为项目单独创建路由文件?
    [NOIP2013 提高组] 《火柴排队》
  • 原文地址:https://www.cnblogs.com/vicF/p/9713830.html
Copyright © 2011-2022 走看看