1. 程式人生 > >快速安裝ElasticSearch以及安裝常見問題

快速安裝ElasticSearch以及安裝常見問題

1.安裝jdk1.8

linux下使用wget下載jdk8:

         進到目錄/usr/local/software

                   wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/8u141-b15/336fa29ff2bb4ef291e347e091f7f4a7/jdk-8u141-linux-x64.tar.gz"

  

  vim /etc/profile

                   加入        

                    export JAVA_HOME=/usr/local/software/jdk8

                    export PATH=$JAVA_HOME/bin:$PATH

儲存後,要執行 source/etc/profile 讓修改的檔案生效

使用wget 下載elasticsearch安裝包

                   wget  https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.2.2.tar.gz

  或者登陸es官網(https://www.elastic.co/products/elasticsearch)下載tar包,傳輸到伺服器上

 解壓

                   tar -zxvf elasticsearch-6.2.2.tar.gz

配置es出現相關問題處理:

1、問題一

                            Java HotSpot(TM) 64-Bit Server VM warning: INFO: os::commit_memory(0x00000000c5330000, 986513408, 0) failed; error='Cannot allocate memory' (errno=12)

                            #

                            # There is insufficient memory for the Java Runtime Environment to continue.

                            # Native memory allocation (mmap) failed to map 986513408 bytes for committing reserved memory.

                            # An error report file with more information is saved as:

                            # /usr/local/software/temp/elasticsearch-6.2.2/hs_err_pid1912.log

                   解決:elasticsearch使用java的jvm預設是使用1G的記憶體的,這裡我們修改一下記憶體,直接把記憶體改到200m

   

[[email protected] elasticsearch-6.2.2]# vim ./config/jvm.options
#修改內容
-Xms200m
-Xmx200m

 

2、問題二

                            [[email protected] bin]# ./elasticsearch

                            [2018-02-22T20:14:04,870][WARN ][o.e.b.ElasticsearchUncaughtExceptionHandler] [] uncaught exception in thread [main]

                            org.elasticsearch.bootstrap.StartupException: java.lang.RuntimeException: can not run elasticsearch as root

                            at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:125) ~[elasticsearch-6.2.2.jar:6.2.2]

                            at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:112) ~[elasticsearch-6.2.2.jar:6.2.2]

                            at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:86) ~[elasticsearch-6.2.2.jar:6.2.2]

                            at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:124) ~[elasticsearch-cli-6.2.2.jar:6.2.2]

                   解決:用非root使用者

                            新增使用者:useradd -m 使用者名稱  然後設定密碼  passwd 使用者名稱

 

3、問題三

                            ./elasticsearch

                            Exception in thread "main" java.nio.file.AccessDeniedException: /usr/local/software/temp/elasticsearch-6.2.2/config/jvm.options

                      解決:許可權不夠 chmod 777 -R 當前es目錄

 

                   常見配置問題資料:https://www.jianshu.com/p/c5d6ec0f35e0

 

4、

         could not find java; set JAVA_HOME or ensure java is in PATH

        解決:在新建的使用者下配置java環境變數即可

 

   最後啟動

  

 

,測試 curl localhost:9200

 

                   常見配置問題資料:https://www.jianshu.com/p/c5d6ec0f35e0