把測試環境的Elasticsearch升級到1.5.1版本,啓動的時候報錯:html
[root@node2 elasticsearch-1.5.1]# bin/service/elasticsearch start
Starting Elasticsearch…
Waiting for Elasticsearch……
WARNING: Elasticsearch may have failed to start.java
到日誌裏看,發現這樣的異常:node
[ERROR][bootstrap ] Exception
java.lang.RuntimeException: Java version: 1.7.0_51 suffers from critical bug
https://bugs.openjdk.java.net/browse/JDK-8024830 which can cause data corruption. Please upgrade the JVM, see http://www.elastic.co/guide/en/elasticsearch/reference/current/_installation.html for current recommendations.
If you absolutely cannot upgrade, please add -XX:-UseSuperWord to the JVM_OPTS environment variable.
Upgrading is preferred, this workaround will result in degraded performance.
at org.elasticsearch.bootstrap.JVMCheck.check(JVMCheck.java:121)
at org.elasticsearch.bootstrap.Bootstrap.main(Bootstrap.java:211)
at org.elasticsearch.bootstrap.ElasticsearchF.main(ElasticsearchF.java:34)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.tanukisoftware.wrapper.WrapperSimpleApp.run(WrapperSimpleApp.java:290)bootstrap
測試環境的jdk使用的是1.7.0_51版本,這個版本有個bug,可能引發Lucene崩潰,形成seg文件或者index文件損壞。Elasticsearch建議升級jdk的版本,或者在啓動命令中設置-XX:-UseSuperWord,關閉UseSuperWord功能,能夠避免這個bug。架構
因而修改Elasticsearch的啓動設置,打開bin/service/elasticsearch.conf, 增長下面的設置:app
wrapper.java.additional.10=-XX:-UseSuperWordless
而後啓動:jvm
[root@node2 elasticsearch-1.5.1]# bin/service/elasticsearch start
Starting Elasticsearch…
Waiting for Elasticsearch……
running: PID:3283elasticsearch
好了啓動起來了。看一下jvm進程的狀態:ide
[root@node2 elasticsearch-1.5.1]# jinfo 3285
Attaching to process ID 3285, please wait…
Debugger attached successfully. Server compiler detected. JVM version is 24.51-b03
…memes….
-Delasticsearch-service -Des.path.home=/server/elasticsearch-1.5.1 -Xss256k -XX:+UseParNewGC
-XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=75 -XX:+UseCMSInitiatingOccupancyOnly
-XX:+HeapDumpOnOutOfMemoryError -Djava.awt.headless=true -XX:-UseSuperWord -Xms1024m -Xmx1024m
-Djava.library.path=/server/elasticsearch-1.5.1/bin/service/lib -Dwrapper.key=7w8xGTzSEUve1FvC
-Dwrapper.port=32000 -Dwrapper.jvm.port.min=31000 -Dwrapper.jvm.port.max=31999
-Dwrapper.disable_console_input=TRUE -Dwrapper.pid=3283 -Dwrapper.version=3.5.14
-Dwrapper.native_library=wrapper -Dwrapper.service=TRUE -Dwrapper.cpu.timeout=10
-Dwrapper.jvmid=1
能夠看到-XX:-UseSuperWord指令已經生效了,Elasticsearch已經啓動成功了。但是去掉UseSuperWord特性有沒有負面的影響呢?查了一下,UseSuperWord的功能是這樣的:
http://search-lucene.com/m/l6pAi13MPrt1BjCmN1&subj=Crazy+Solr+startup+params+please+review
摘要以下:
「-XX:-UseSuperWord If you have a Haswell CPU, all other improvements in these command line settings are eaten up by this flag! If you have 7u55 at minimum, you should never disable this. Things like BooleanFilter and other bitset operations are up to 2 times faster with Java 7u55 on Haswell CPUs and later!!! This setting only makes sense if you have one of those buggy JDKs (7u40 to 7u51). In all other cases this slows down enormous! In addition, enabling this option may break JDKs before 7u40 (this option was added in 7u40), so breaks:
It would be good, if we could fix the startup scripts not not have options, which may also break with JDK 8 or later!」
大概是這樣的意思:UseSuperWord會在字節運算時啓用布隆過濾器之類的特性,能在haswell架構的cpu上提升2倍以上的速度。看來這個功能仍是開啓的好。最好的方式仍是升級jdk的版本到1.7.0_51以上。