快速安装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环境变量即可

 

   最后启动

  快速安装ElasticSearch以及安装常见问题

 

快速安装ElasticSearch以及安装常见问题

,测试 curl localhost:9200

快速安装ElasticSearch以及安装常见问题

 

                   常见配置问题资料:https://www.jianshu.com/p/c5d6ec0f35e0