{"id":809,"date":"2021-10-24T11:35:32","date_gmt":"2021-10-24T05:35:32","guid":{"rendered":"https:\/\/mellowhost.com\/blog\/?p=809"},"modified":"2021-10-24T11:36:19","modified_gmt":"2021-10-24T05:36:19","slug":"install-elasticsearch-in-cpanel-centos-java-lang-noclassdeffounderror-could-not-initialize-class-com-sun-jna-native","status":"publish","type":"post","link":"https:\/\/mellowhost.com\/blog\/install-elasticsearch-in-cpanel-centos-java-lang-noclassdeffounderror-could-not-initialize-class-com-sun-jna-native.html","title":{"rendered":"Install Elasticsearch in Cpanel &#8211; CentOS \/ java.lang.NoClassDefFoundError: Could not initialize class com.sun.jna.Native"},"content":{"rendered":"\n<p>If you are trying to install the Elasticsearch 7.* in CentOS and Cpanel, you are probably seeing your Elasticsearch is installed, but not starting with an error like the following:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">java.lang.NoClassDefFoundError: Could not initialize class com.sun.jna.Native\n        at org.elasticsearch.systemd.Libsystemd.lambda$static$0(Libsystemd.java:23) ~[?:?]\n        at java.security.AccessController.doPrivileged(AccessController.java:318) ~[?:?]\n        at org.elasticsearch.systemd.Libsystemd.&lt;clinit>(Libsystemd.java:22) ~[?:?]\n        at org.elasticsearch.systemd.SystemdPlugin.sd_notify(SystemdPlugin.java:115) ~[?:?]\n        at org.elasticsearch.systemd.SystemdPlugin.onNodeStarted(SystemdPlugin.java:126) ~[?:?]\n        at java.util.ArrayList.forEach(ArrayList.java:1511) ~[?:?]\n        at org.elasticsearch.node.Node.start(Node.java:998) ~[elasticsearch-7.15.1.jar:7.15.1]\n        at org.elasticsearch.bootstrap.Bootstrap.start(Bootstrap.java:313) ~[elasticsearch-7.15.1.jar:7.15.1]\n        at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:408) ~[elasticsearch-7.15.1.jar:7.15.1]\n        at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:167) ~[elasticsearch-7.15.1.jar:7.15.1]\n        at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:158) ~[elasticsearch-7.15.1.jar:7.15.1]\n        at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:75) ~[elasticsearch-7.15.1.jar:7.15.1]\n        at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:114) ~[elasticsearch-cli-7.15.1.jar:7.15.1]\n        at org.elasticsearch.cli.Command.main(Command.java:79) ~[elasticsearch-cli-7.15.1.jar:7.15.1]\n        at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:123) ~[elasticsearch-7.15.1.jar:7.15.1]\n        at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:81) ~[elasticsearch-7.15.1.jar:7.15.1]\n<\/pre>\n\n\n\n<p>The error appears if your tmp directory is not writable and executable by Elasticsearch. You need to make two changes, to make Elasticsearch start for you.<\/p>\n\n\n\n<p>First, edit the elasticsearch sysconfig file:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">nano \/etc\/sysconfig\/elasticsearch<\/pre>\n\n\n\n<p>and add the following line:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">ES_TMPDIR=\/tmp<\/pre>\n\n\n\n<p>Next, you need to mount \/tmp with exec permission, which is normally mounted with noexec permission in Cpanel:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">mount -o remount,exec \/tmp<\/pre>\n\n\n\n<p>You should be done now, you may start your Elasticsearch:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">service elasticsearch start<\/pre>\n\n\n\n<p>Please also remember, Elasticsearch needs at least 3GB of RAM to start. If you have lower RAM than that, you are probably hitting OOM killer of the system. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you are trying to install the Elasticsearch 7.* in CentOS and Cpanel, you are probably seeing your Elasticsearch is installed, but not starting with an error like the following: The error appears if your tmp directory is not writable and executable by Elasticsearch. You need to make two changes, to make Elasticsearch start for &hellip; <a href=\"https:\/\/mellowhost.com\/blog\/install-elasticsearch-in-cpanel-centos-java-lang-noclassdeffounderror-could-not-initialize-class-com-sun-jna-native.html\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Install Elasticsearch in Cpanel &#8211; CentOS \/ java.lang.NoClassDefFoundError: Could not initialize class com.sun.jna.Native&#8221;<\/span><\/a><\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[411],"tags":[220,46,413],"_links":{"self":[{"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/posts\/809"}],"collection":[{"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/comments?post=809"}],"version-history":[{"count":2,"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/posts\/809\/revisions"}],"predecessor-version":[{"id":811,"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/posts\/809\/revisions\/811"}],"wp:attachment":[{"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/media?parent=809"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/categories?post=809"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/tags?post=809"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}