1

I install Elasticsearch 7.17.7 on my local machine Linux Ubuntu 22.04.1 LTS ( not using virtual machine )

To start elasticsearch I run this command in terminal

sudo systemctl start elasticsearch.service

After it successfully start and run I notice it utilize up to 8.1GB of ram which is too huge from what I see, my machine only have 16GB of utilizeable ram

Attached is the elasticsearch info and the stacer output

enter image description here

enter image description here

enter image description here

From time to time I will check to see whether the elasticsearch is running or not because I realize when I am using my laptop doing work and everything, opening tools such as google chrome, vs code and smartgit, at one point my device becomes really slow, then I try to run certain command needed for work and it return error

Elasticsearch\Common\Exceptions\NoNodesAvailableException: No alive nodes found in your cluster

I check and found the error happen because elasticsearch suddenly stop working

I am able to restart elasticsearch using

sudo systemctl restart elasticsearch.service or sudo service elasticsearch restart

but sometimes an error come out causing elasticsearch unable to restart, if this happen, I just restart my laptop, which I wanted to avoid as it is disturbing my work

I am unable to reproduce back the error log but I will update this question once I found the log

Please provide any tips or experience if anyone have encountered this issue

I have tried installing different version of elasticsearch which is 7.16 but still same issue happen

I have tried reinstall elasticsearch but still same

Update : Elasticsearch finally crash and I am unable to restart the service, refer below image for detail and log

Elasticsearch service failed

enter image description here

Error during restart

enter image description here

enter image description here

Update : below is the log I able to receive when starting the elasticsearch

==> /var/log/syslog <==
Dec  8 14:26:37 farhan-Yoga-6-13ALC6 systemd[1]: Starting Elasticsearch...

==> /var/log/kern.log <==
Dec  8 14:26:47 farhan-Yoga-6-13ALC6 kernel: [16726.683629] [UFW BLOCK] IN=wlp2s0 OUT= MAC=01:00:5e:00:00:01:64:3a:ea:e9:0a:4e:08:00 SRC=0.0.0.0 DST=224.0.0.1 LEN=36 TOS=0x00 PREC=0xC0 TTL=1 ID=14037 PROTO=2 

==> /var/log/syslog <==
Dec  8 14:26:47 farhan-Yoga-6-13ALC6 kernel: [16726.683629] [UFW BLOCK] IN=wlp2s0 OUT= MAC=01:00:5e:00:00:01:64:3a:ea:e9:0a:4e:08:00 SRC=0.0.0.0 DST=224.0.0.1 LEN=36 TOS=0x00 PREC=0xC0 TTL=1 ID=14037 PROTO=2 

==> /var/log/ufw.log <==
Dec  8 14:26:47 farhan-Yoga-6-13ALC6 kernel: [16726.683629] [UFW BLOCK] IN=wlp2s0 OUT= MAC=01:00:5e:00:00:01:64:3a:ea:e9:0a:4e:08:00 SRC=0.0.0.0 DST=224.0.0.1 LEN=36 TOS=0x00 PREC=0xC0 TTL=1 ID=14037 PROTO=2 

==> /var/log/auth.log <==
Dec  8 14:26:49 farhan-Yoga-6-13ALC6 sudo: pam_unix(sudo:session): session closed for user root
Dec  8 14:26:49 farhan-Yoga-6-13ALC6 sudo:   farhan : TTY=pts/3 ; PWD=/var/log ; USER=root ; COMMAND=/usr/sbin/service elasticsearch restart
Dec  8 14:26:49 farhan-Yoga-6-13ALC6 sudo: pam_unix(sudo:session): session opened for user root(uid=0) by (uid=1000)

==> /var/log/syslog <==
Dec  8 14:26:49 farhan-Yoga-6-13ALC6 systemd[1]: Started Elasticsearch.
Dec  8 14:26:49 farhan-Yoga-6-13ALC6 systemd[1]: Stopping Elasticsearch...
Dec  8 14:26:49 farhan-Yoga-6-13ALC6 systemd-entrypoint[46384]: uncaught exception in thread [process reaper (pid 46606)]
Dec  8 14:26:49 farhan-Yoga-6-13ALC6 systemd-entrypoint[46384]: java.security.AccessControlException: access denied ("java.lang.RuntimePermission" "modifyThread")
Dec  8 14:26:49 farhan-Yoga-6-13ALC6 systemd-entrypoint[46384]: #011at java.base/java.security.AccessControlContext.checkPermission(AccessControlContext.java:485)
Dec  8 14:26:49 farhan-Yoga-6-13ALC6 systemd-entrypoint[46384]: #011at java.base/java.security.AccessController.checkPermission(AccessController.java:1068)
Dec  8 14:26:49 farhan-Yoga-6-13ALC6 systemd-entrypoint[46384]: #011at java.base/java.lang.SecurityManager.checkPermission(SecurityManager.java:411)
Dec  8 14:26:49 farhan-Yoga-6-13ALC6 systemd-entrypoint[46384]: #011at org.elasticsearch.secure_sm.SecureSM.checkThreadAccess(SecureSM.java:160)
Dec  8 14:26:49 farhan-Yoga-6-13ALC6 systemd-entrypoint[46384]: #011at org.elasticsearch.secure_sm.SecureSM.checkAccess(SecureSM.java:120)
Dec  8 14:26:49 farhan-Yoga-6-13ALC6 systemd-entrypoint[46384]: #011at java.base/java.lang.Thread.checkAccess(Thread.java:2360)
Dec  8 14:26:49 farhan-Yoga-6-13ALC6 systemd-entrypoint[46384]: #011at java.base/java.lang.Thread.setDaemon(Thread.java:2308)
Dec  8 14:26:49 farhan-Yoga-6-13ALC6 systemd-entrypoint[46384]: #011at java.base/java.lang.ProcessHandleImpl.lambda$static$0(ProcessHandleImpl.java:103)
Dec  8 14:26:49 farhan-Yoga-6-13ALC6 systemd-entrypoint[46384]: #011at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.<init>(ThreadPoolExecutor.java:637)
Dec  8 14:26:49 farhan-Yoga-6-13ALC6 systemd-entrypoint[46384]: #011at java.base/java.util.concurrent.ThreadPoolExecutor.addWorker(ThreadPoolExecutor.java:928)
Dec  8 14:26:49 farhan-Yoga-6-13ALC6 systemd-entrypoint[46384]: #011at java.base/java.util.concurrent.ThreadPoolExecutor.processWorkerExit(ThreadPoolExecutor.java:1021)
Dec  8 14:26:49 farhan-Yoga-6-13ALC6 systemd-entrypoint[46384]: #011at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1158)
Dec  8 14:26:49 farhan-Yoga-6-13ALC6 systemd-entrypoint[46384]: #011at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
Dec  8 14:26:49 farhan-Yoga-6-13ALC6 systemd-entrypoint[46384]: #011at java.base/java.lang.Thread.run(Thread.java:1589)
Dec  8 14:26:49 farhan-Yoga-6-13ALC6 systemd-entrypoint[46384]: #011at java.base/jdk.internal.misc.InnocuousThread.run(InnocuousThread.java:186)
Dec  8 14:26:49 farhan-Yoga-6-13ALC6 systemd[1]: elasticsearch.service: Deactivated successfully.
Dec  8 14:26:49 farhan-Yoga-6-13ALC6 systemd[1]: Stopped Elasticsearch.
Dec  8 14:26:49 farhan-Yoga-6-13ALC6 systemd[1]: elasticsearch.service: Consumed 42.311s CPU time.
Dec  8 14:26:49 farhan-Yoga-6-13ALC6 systemd[1]: Starting Elasticsearch...

==> /var/log/auth.log <==
Dec  8 14:27:00 farhan-Yoga-6-13ALC6 sudo: pam_unix(sudo:session): session closed for user root

==> /var/log/syslog <==
Dec  8 14:27:00 farhan-Yoga-6-13ALC6 systemd[1]: Started Elasticsearch.

Update : Able to find out the log that's causing the elasticsearch to stop working, apparently its because the ram usage is too high causing ubuntu to stop the process

Dec  8 14:30:43 farhan-Yoga-6-13ALC6 kernel: [16962.195555] oom-kill:constraint=CONSTRAINT_NONE,nodemask=(null),cpuset=/,mems_allowed=0,global_oom,task_memcg=/system.slice/elasticsearch.service,task=java,pid=46712,uid=128
Dec  8 14:30:43 farhan-Yoga-6-13ALC6 kernel: [16962.195728] Out of memory: Killed process 46712 (java) total-vm:16570600kB, anon-rss:8393480kB, file-rss:0kB, shmem-rss:0kB, UID:128 pgtables:17344kB oom_score_adj:0

==> /var/log/syslog <==
Dec  8 14:30:43 farhan-Yoga-6-13ALC6 kernel: [16962.194794] Monitor Deflati invoked oom-killer: gfp_mask=0x1100cca(GFP_HIGHUSER_MOVABLE), order=0, oom_score_adj=0

Still unable to figure out how to make the elasticsearch use less ram

1 Answers1

0

You can also run an elastic search via docker with the -e ES_JAVA_OPTS="-Xmx512m" option.

Example:

docker network create elastic
docker pull docker.elastic.co/elasticsearch/elasticsearch:8.6.1
docker run --name elasticsearch --net elastic -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" -e ES_JAVA_OPTS="-Xmx512m" -t docker.elastic.co/elasticsearch/elasticsearch:8.6.1
Igor Micev
  • 1,514
  • 1
  • 17
  • 23