zoukankan      html  css  js  c++  java
  • elasticsearch摸石头过河——基本安装应用(三)

       

        首先从官网下载elasticsearch:https://www.elastic.co/downloads/elasticsearch

        需要jdk版本1.8:https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html

        1.先解压安装 JDK(如果已有可忽略)

           tar  -zxvf  jdk-8u131-linux-x64.tar.gz

        2.yum安装各种需要的命令插件(如果已有可忽略)

          yum -y install nodejs npm git wget vim

        安装npm出现过问题

        npm install
        出现license问题
        npm WARN elasticsearch-head@0.0.0 license should be a valid SPDX license expression
        进入 package.json文件,修改
        Apache 改为:Apache-2.0

        3.配置JDK环境变量

         添加环境变量 etc/profile

           export JAVA_HOME=/usr/java/jdk1.8.0_131
           export JRE_HOME=${JAVA_HOME}/jre
                     export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib:$CLASSPATH
                     export JAVA_PATH=${JAVA_HOME}/bin:${JRE_HOME}/bin
                     export PATH=$PATH:${JAVA_PATH}

          让环境变量立即生效需要执行如下命令:
          source /etc/profile

        4.解压 并启动elasticsearch

           由于不能使用root用户启动,创建用户
         adduser es1
         passwd 12345678
            授权root用户组
                      usermod -g root es1
         添加:与root相同的权限

           所有用户 目录授权:chmod -R 777 目录PATH

           切换用户:su es1

         切换到elasticsearch目录,nohup./bin/elasticsearch& 后台启动

         遇到错误:   max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]

          修改文件:

          

    [root@localhost ~]# cp /etc/security/limits.conf /etc/security/limits.conf.bak
    [root@localhost ~]# cat /etc/security/limits.conf | grep -v "es1" > /tmp/system_limits.conf
    [root@localhost ~]# echo "es1 hard nofile 65536" >> /tmp/system_limits.conf 
    [root@localhost ~]# echo "es1 soft nofile 65536" >> /tmp/system_limits.conf 
    [root@localhost ~]# mv /tmp/system_limits.conf /etc/security/limits.conf

          一定要重新登录用户才会生效

         再次启动:

         遇到错误:       max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]

        或者:

    1 解决:切换到root用户,编辑limits.conf 添加类似如下内容
    2 vi /etc/security/limits.conf 
    3 添加如下内容:
    4 * soft nofile 65536
    5 * hard nofile 131072
    6 * soft nproc 2048
    7 * hard nproc 4096
    1 sudo gedit /etc/sysctl.conf
    2 在该文件任意地方加入:vm.max_map_count=655360
    3 sudo sysctl -p
     然后重启ES

      es会默认分配1G或者2G内存,可以在config/jvm.options 中修改内存大小

    ################################################################
    ## IMPORTANT: JVM heap size
    ################################################################
    ##
    ## You should always set the min and max JVM heap
    ## size to the same value. For example, to set
    ## the heap to 4 GB, set:
    ##
    ## -Xms4g
    ## -Xmx4g
    ##
    ## See https://www.elastic.co/guide/en/elasticsearch/reference/current/heap-size.html
    ## for more information
    ##
    ################################################################
    
    # Xms represents the initial size of total heap space
    # Xmx represents the maximum size of total heap space
    
    -Xms3g
    -Xmx3g
    
    ################################################################
    ## Expert settings
    ################################################################
    ##
    ## All settings below this section are considered
    ## expert settings. Don't tamper with them unless

    5.安装elasticsearch-head(前端控制)

      下载:

      git clone git://github.com/mobz/elasticsearch-head.git

      elasticsearch-head 依赖nodejs,

    修改:
    elasticsearch-head/_site/app.js
    this.base_uri = this.config.base_uri || this.prefs.get("app-base_uri") || "http://localhost:9200";
    将其中的"http://localhost:9200"; 改为"http://公网IP:9200";
    这样其他都可以访问

     npm run start 启动elasticsearch-head

       然后输入:http://xxx.xxx.x.xx:9100/ 就可呈现

     

  • 相关阅读:
    p1373【奶牛的卧室】
    p1248【交错匹配】(DP)
    QBXT模拟赛T3
    NOIP冲刺班的考试总结
    欧拉回路的一些东西
    一道dp题目
    Blocks
    玩具取名
    Y的积木
    游荡的奶牛
  • 原文地址:https://www.cnblogs.com/10fly/p/9945341.html
Copyright © 2011-2022 走看看