ElasticSearch | centos7 上安裝ES

0 參考博客文章(感謝!!!)

 

 

1.安裝jdk

  1.1 執行命令下面命令查看可安裝java版本
    yum -y list java*
  1.2 選擇一個java版本進行安裝,
    yum install -y java-1.8.0-openjdk-devel.x86_64

      這裏有個地方要注意,要選擇 要帶有-devel的安裝,由於這個安裝的是jdk,而那個不帶-devel的安裝完了實際上是jre。html

  1.3 輸入java -version查看已安裝的jdk版本,當出現以下輸出表示安裝成功。
  1.4 jdk 的安裝目錄
    /usr/lib/jvm 
  1.5 配置環境變量,編輯/etc/profile文件:

    vi /etc/profilejava

  1.6 在文件尾部添加以下配置:
    export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.181-3.b13.el6_10.x86_64
    export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
    export PATH=$PATH:$JAVA_HOME/bin

  1.7 :wq退出vim編輯器,而後使用命令更新配置
    source /etc/profile

 

2. 安裝ES

  2.1 依次執行命令
  wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.3.2.zip
  wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.3.2.zip.sha512
  shasum -a 512 -c elasticsearch-6.3.2.zip.sha512
  unzip elasticsearch-6.3.2.zip
  cd elasticsearch-6.3.2/
    遇到錯誤1
      -bash: shasum: command not found
    解決方案:在CentOS上,「shasum」被稱爲「sha1sum」,運行下面命令修復此問題
      ln -s /usr/bin/sha1sum /usr/bin/shasum
    遇到錯誤2
      sha1sum: invalid option -- 'a'
    解決方案:
      yum install -y perl-Digest-SHA
    遇到報錯3
      OpenJDK 64-Bit Server VM warning: If the number of processors is expected to increase from one, then you should configure the number of parallel GC threads appropriately using -XX:ParallelGCThreads=N
      OpenJDK 64-Bit Server VM warning: INFO: os::commit_memory(0x00000000c5330000, 986513408, 0) failed; error='Cannot allocate memory' (errno=12)
    解決方案:調小啓動內存,若是512m仍是不行的話,就得要再往下調了
      [root@iZwz9ahuk6xeihs1n3gqy5Z elasticsearch-6.3.2]# vi config/jvm.options

        #-Xms2g
        #-Xmx2g
        -Xms512m
        -Xmx512m
    遇到報錯4:沒法以root權限啓動
        org.elasticsearch.bootstrap.StartupException: java.lang.RuntimeException: can not run elasticsearch as root
    解決方案:建立一個非root用戶並賦予目錄該用戶權限,再啓動
        #root身份
        groupadd es
        useradd es -g es -p es
        chown es:es ${elasticsearch_HOME}/ #存放elasticsearch的目錄
        su - es  #切換到es用戶下
        ${elasticsearch_HOME}/bin/elasticsearch #啓動elasticsearch
    遇到報錯5
      ERROR: [4] bootstrap checks failed
      [1]: max file descriptors [65535] for elasticsearch process is too low, increase to at least [65536]
      [2]: max number of threads [1024] for user [e] is too low, increase to at least [4096]
      [3]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
      [4]: system call filters failed to install; check the logs and fix your configuration or disable system call filters at your own risk
    解決方案:

    【5.1】【5.2】linux

      #root身份
        vi /etc/security/limits.conf  
      #文件末尾添加內容(*也是要加上去)
        * soft nofile 65536  
        * hard nofile 131072  
        * soft nproc 4096  
        * hard nproc 4096  

    【5.3】git

 

    #root身份
      sysctl -w vm.max_map_count=262144
       vim /etc/sysctl.conf     #讓配置永久生效
    #文件末尾添加內容
      vm.max_map_count=262144

  【5.4】github

    Centos6不支持SecComp,而ES6默認bootstrap.system_call_filter爲trueweb

      vim config/elasticsearch.yml 

      禁用:在elasticsearch.yml中配置bootstrap.system_call_filter爲false,注意要在Memory下面:       取消bootstrap.memory_lock的註釋,添加bootstrap.system_call_filter 配置bootstrap

      #注意在":"後面須要空格
        bootstrap.memory_lock: false  
        bootstrap.system_call_filter: false
相關文章
相關標籤/搜索