当前位置:   article > 正文

Elasticsearch安装笔记_openjdk 64-bit server vm warning: options -xverify

openjdk 64-bit server vm warning: options -xverify:none and -noverify were d

第一次接触Elasticsearch,这里记录一下本地Ubuntu Linux环境的安装。过程中遇到不少报错,其中很多都是可以避免的,那就是安装时一定要切换到普通用户(非root账号)

①检查依赖

Elasticsearch依赖于Java,所以本地一定要有Java环境。

  1. root@ubuntu:~# java -version
  2. openjdk version "10.0.2" 2018-07-17
  3. OpenJDK Runtime Environment (build 10.0.2+13-Ubuntu-1ubuntu0.18.04.4)
  4. OpenJDK 64-Bit Server VM (build 10.0.2+13-Ubuntu-1ubuntu0.18.04.4, mixed mode)
  5. root@ubuntu:~# which java
  6. /usr/bin/java

②下载解压

  1. root@ubuntu:~# wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.5.4.tar.gz
  2. root@ubuntu:~# tar -xvf elasticsearch-6.5.4.tar.gz

③root运行

  1. root@ubuntu:~# cd elasticsearch-6.5.4/bin
  2. root@ubuntu:~/elasticsearch-6.5.4/bin# bash elasticsearch
  3. OpenJDK 64-Bit Server VM warning: Option UseConcMarkSweepGC was deprecated in version 9.0 and will likely be removed in a future release.
  4. [2019-01-09T10:43:22,092][WARN ][o.e.b.ElasticsearchUncaughtExceptionHandler] [unknown] uncaught exception in thread [main]
  5. org.elasticsearch.bootstrap.StartupException: java.lang.RuntimeException: can not run elasticsearch as root
  6. at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:140) ~[elasticsearch-6.5.4.jar:6.5.4]
  7. at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:127) ~[elasticsearch-6.5.4.jar:6.5.4]
  8. at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:86) ~[elasticsearch-6.5.4.jar:6.5.4]
  9. at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:124) ~[elasticsearch-cli-6.5.4.jar:6.5.4]
  10. at org.elasticsearch.cli.Command.main(Command.java:90) ~[elasticsearch-cli-6.5.4.jar:6.5.4]
  11. at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:93) ~[elasticsearch-6.5.4.jar:6.5.4]
  12. at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:86) ~[elasticsearch-6.5.4.jar:6.5.4]
  13. Caused by: java.lang.RuntimeException: can not run elasticsearch as root
  14. at org.elasticsearch.bootstrap.Bootstrap.initializeNatives(Bootstrap.java:103) ~[elasticsearch-6.5.4.jar:6.5.4]
  15. at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:170) ~[elasticsearch-6.5.4.jar:6.5.4]
  16. at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:333) ~[elasticsearch-6.5.4.jar:6.5.4]
  17. at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:136) ~[elasticsearch-6.5.4.jar:6.5.4]
  18. ... 6 more

报错很明显“can not run elasticsearch as root”,所以切换到普通用户重新来吧。

④普通账户运行

  1. root@ubuntu:~/elasticsearch-6.5.4/bin# cd
  2. root@ubuntu:~# mv elasticsearch-6.5.4 /home/ubuntu/
  3. root@ubuntu:~# su ubuntu
  4. ubuntu@ubuntu:/root$ cd
  5. ubuntu@ubuntu:~$ cd elasticsearch-6.5.4/bin/
  6. ubuntu@ubuntu:~/elasticsearch-6.5.4/bin$ bash elasticsearch
  7. Exception in thread "main" java.nio.file.AccessDeniedException: /home/ubuntu/elasticsearch-6.5.4/config/jvm.options
  8. at java.base/sun.nio.fs.UnixException.translateToIOException(UnixException.java:90)
  9. at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:111)
  10. at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:116)
  11. at java.base/sun.nio.fs.UnixFileSystemProvider.newByteChannel(UnixFileSystemProvider.java:215)
  12. at java.base/java.nio.file.Files.newByteChannel(Files.java:369)
  13. at java.base/java.nio.file.Files.newByteChannel(Files.java:415)
  14. at java.base/java.nio.file.spi.FileSystemProvider.newInputStream(FileSystemProvider.java:384)
  15. at java.base/java.nio.file.Files.newInputStream(Files.java:154)
  16. at org.elasticsearch.tools.launchers.JvmOptionsParser.main(JvmOptionsParser.java:60)
  17. ubuntu@ubuntu:~/elasticsearch-6.5.4/bin$ sudo chown -R ubuntu ~/elasticsearch-6.5.4/
  18. ubuntu@ubuntu:~/elasticsearch-6.5.4/bin$ sudo chgrp -R ubuntu ~/elasticsearch-6.5.4/

可以看到切换到普通账户运行的时候报了“AccessDeniedException”,这是因为前面是以root账户下载和解压的elasticsearch,其ower和group都属于root,所以后面需要修改一下文件归属。修改完成后就可以启动了。

⑤修改配置

ubuntu@ubuntu:~/elasticsearch-6.5.4/bin$ vim ../config/elasticsearch.yml

刚开始安装试用,所以简单修改以下几项(取消注释然后修改对应值):

  1. cluster.name: Zoo
  2. node.name: Zoo-node-1
  3. network.host: 0.0.0.0
  4. http.port: 9200

“cluster.name”和“node.name”自定义即可,“network.host”的设置是为了开启外网访问。

⑥修改配置后试运行

  1. ubuntu@ubuntu:~/elasticsearch-6.5.4/bin$ bash elasticsearch
  2. …… omitted ……
  3. [2019-01-09T18:44:37,429][INFO ][o.e.b.BootstrapChecks ] [80tiwtn] bound or publishing to a non-loopback address, enforcing bootstrap checks
  4. ERROR: [1] bootstrap checks failed
  5. [1]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
  6. …… omitted ……

因为修改了配置开启了外网访问,又报了系统级别的ERROR和WARNING,切回root修改一下系统配置。

  1. ubuntu@ubuntu:~/elasticsearch-6.5.4/bin$ su root
  2. Password:
  3. root@ubuntu:/home/ubuntu/elasticsearch-6.5.4/bin# vim /etc/security/limits.conf

添加以下内容:

  1. # Elasticsearch Relevant
  2. elasticsearch soft nofile 65536
  3. elasticsearch hard nofile 65536
  4. elasticsearch soft nproc 4096
  5. elasticsearch hard nproc 4096
root@ubuntu:/home/ubuntu/elasticsearch-6.5.4/bin# vim /etc/sysctl.conf

添加以下内容:

vm.max_map_count=262144

load一下sysctl修改。

  1. root@ubuntu:/home/ubuntu/elasticsearch-6.5.4/bin# sysctl -p
  2. vm.max_map_count = 262144

⑦静默模式执行

命令行添加-d参数启动daemon运行模式,-p参数将进程ID写入指定文件。

  1. ubuntu@ubuntu:~/elasticsearch-6.5.4/bin$ bash elasticsearch -d -p Zoo.pid
  2. OpenJDK 64-Bit Server VM warning: Option UseConcMarkSweepGC was deprecated in version 9.0 and will likely be removed in a future release.

这个时候elasticsearch已经在后台运行了,尝试再启动的话就会报错了。

  1. ubuntu@ubuntu:~/elasticsearch-6.5.4/bin$ bash elasticsearch
  2. OpenJDK 64-Bit Server VM warning: Option UseConcMarkSweepGC was deprecated in version 9.0 and will likely be removed in a future release.
  3. [2019-01-09T19:04:59,829][WARN ][o.e.b.ElasticsearchUncaughtExceptionHandler] [unknown] uncaught exception in thread [main]
  4. org.elasticsearch.bootstrap.StartupException: java.lang.IllegalStateException: failed to obtain node locks, tried [[/home/ubuntu/elasticsearch-6.5.4/data/Zoo]] with lock id [0]; maybe these locations are not writable or multiple nodes were started without increasing [node.max_local_storage_nodes] (was [1])? at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:140) ~[elasticsearch-6.5.4.jar:6.5.4]
  5. at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:127) ~[elasticsearch-6.5.4.jar:6.5.4]
  6. at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:86) ~[elasticsearch-6.5.4.jar:6.5.4]
  7. at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:124) ~[elasticsearch-cli-6.5.4.jar:6.5.4]
  8. at org.elasticsearch.cli.Command.main(Command.java:90) ~[elasticsearch-cli-6.5.4.jar:6.5.4]
  9. at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:93) ~[elasticsearch-6.5.4.jar:6.5.4]
  10. at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:86) ~[elasticsearch-6.5.4.jar:6.5.4]
  11. Caused by: java.lang.IllegalStateException: failed to obtain node locks, tried [[/home/ubuntu/elasticsearch-6.5.4/data/Zoo]] with lock id [0]; maybe these locations are not writable or multiple nodes were started without increasing [node.max_local_storage_nodes] (was [1])? at org.elasticsearch.env.NodeEnvironment.<init>(NodeEnvironment.java:297) ~[elasticsearch-6.5.4.jar:6.5.4]
  12. at org.elasticsearch.node.Node.<init>(Node.java:296) ~[elasticsearch-6.5.4.jar:6.5.4]
  13. at org.elasticsearch.node.Node.<init>(Node.java:265) ~[elasticsearch-6.5.4.jar:6.5.4]
  14. at org.elasticsearch.bootstrap.Bootstrap$5.<init>(Bootstrap.java:212) ~[elasticsearch-6.5.4.jar:6.5.4]
  15. at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:212) ~[elasticsearch-6.5.4.jar:6.5.4]
  16. at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:333) ~[elasticsearch-6.5.4.jar:6.5.4]
  17. at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:136) ~[elasticsearch-6.5.4.jar:6.5.4]
  18. ... 6 more

可以查看一下进程列表。

  1. ubuntu@ubuntu:~/elasticsearch-6.5.4/bin$ ps aux | grep elasticsearch
  2. ubuntu 2933 10.6 15.7 3736144 1282148 pts/0 Sl 19:04 0:19 /usr/bin/java -Xms1g -Xmx1g -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=75 -XX:+UseCMSInitiatingOccupancyOnly -XX:+AlwaysPreTouch -Xss1m -Djava.awt.headless=true -Dfile.encoding=UTF-8 -Djna.nosys=true -XX:-OmitStackTraceInFastThrow -Dio.netty.noUnsafe=true -Dio.netty.noKeySetOptimization=true -Dio.netty.recycler.maxCapacityPerThread=0 -Dlog4j.shutdownHookEnabled=false -Dlog4j2.disable.jmx=true -Djava.io.tmpdir=/tmp/elasticsearch.khIDF3OL -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=data -XX:ErrorFile=logs/hs_err_pid%p.log -Xlog:gc*,gc+age=trace,safepoint:file=logs/gc.log:utctime,pid,tags:filecount=32,filesize=64m -Djava.locale.providers=COMPAT -XX:UseAVX=2 -Des.path.home=/home/ubuntu/elasticsearch-6.5.4 -Des.path.conf=/home/ubuntu/elasticsearch-6.5.4/config -Des.distribution.flavor=default -Des.distribution.type=tar -cp /home/ubuntu/elasticsearch-6.5.4/lib/* org.elasticsearch.bootstrap.Elasticsearch -d -p Zoo.pid
  3. ubuntu 2949 0.0 0.0 136508 7252 pts/0 Sl 19:04 0:00 /home/ubuntu/elasticsearch-6.5.4/modules/x-pack-ml/platform/linux-x86_64/bin/controller
  4. ubuntu 3070 0.0 0.0 21536 1000 pts/0 S+ 19:07 0:00 grep --color=auto elasticsearch

pid文件默认会写在elasticsearch的主目录。

  1. ubuntu@ubuntu:~/elasticsearch-6.5.4/bin$ ls ..
  2. bin config data lib LICENSE.txt logs modules NOTICE.txt plugins README.textile Zoo.pid

打开浏览器输入“http://localhost:9200/?pretty”可以测试elasticsearch是否成功运行。

⑧关闭程序

以守护进程模式运行,因为将进程ID写入了pid文件,所以要结束运行的话,kill掉进程即可。

ubuntu@ubuntu:~/elasticsearch-6.5.4/bin$ kill -9 $(cat ../Zoo.pid)

运行日子记录在elasticsearch主目录的logs子目录下。

  1. ubuntu@ubuntu:~/elasticsearch-6.5.4/bin$ ls ../logs/
  2. elasticsearch_access.log elasticsearch_index_indexing_slowlog.log gc.log Zoo_deprecation.log Zoo.log
  3. elasticsearch_audit.log elasticsearch_index_search_slowlog.log Zoo_access.log Zoo_index_indexing_slowlog.log
  4. elasticsearch_deprecation.log elasticsearch.log

 

 

参考:

https://www.elastic.co/guide/en/elasticsearch/reference/current/getting-started-install.html

https://www.elastic.co/guide/en/elasticsearch/reference/6.5/zip-targz.html#setup-installation-daemon

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/你好赵伟/article/detail/212286
推荐阅读
相关标签
  

闽ICP备14008679号