How to set memory limit for Java 11 inside Docker? - docker

What is the process to set memory limit for Java 11 inside Docker?
Which JDK to use for production environment?
Thanks

As java 11 (10+) can automatically detect the container's memory you can set memory limit on your container and it should WAI:
docker run -m 512 ....
As for the choice of JDK, you can either use oracle JDK which is licensed or open source OpenJDK.
More details in this article: https://www.docker.com/blog/improved-docker-container-integration-with-java-10/

You can set the maximum heap size using the hotspot JVM -Xmx option (see java 11 options)
You may use AdoptOpenJDK for production as they are kept up tp date.

Related

How to limit memory usage when I run Memgraph Platform within Docker?

I've been running Memgraph for a few days now and everything is working as expected. This is the first time that I'm using Docker.
I've noticed that when I shut down the Memgraph Platform my RAM is still used. I need to restart my computer to free up my RAM. Is there some switch that I can use to limit the memory that Memgraph Platform uses? Is there some way to release the memory after I shut it down?
If it is important, my OS is Windows 10 Professional and I have a 6 years old laptop with 8GB of RAM.
The issue you are experiencing is not related to Memgraph, but Docker or to WSL2 to be more precise. You say that you use Windows 10 so I presume your Docker is configured to use WSL2.
You didn't write which exact build of Windows 10 you are using, but depending on it WSL can use up to 80% of your RAM if you don't limit it.
When you run the Docker image you will see a process called vmmem. When you shutdown running Docker image this process will still occupy your RAM. Restarting your computer frees up the RAM, which is what you are experiencing.
The solution is not to change the configuration of your Memgraph, but to configure Docker. You need to limit the amount of memory that WSL2 can use. But be careful; this is a change that will affect all of your WSL2 instances, not just the Docker ones.
The exact steps that you need to do are:
Shutdown all of the WSL instances with wsl --shutdown
Edit the .wslconfig file (it is located in your user profile folder)
Add the following lines to it:
[wsl2]
memory=3GB
This will limit the RAM usage of WSL to 3GB. I hope that this will help you.

How to monitor JBoss EAP with Prometheus jmx-exporter

I want to monitor some JBoss EAP 7 servers with Prometheus/Grafana (as well as some Wildfly).
I understand I have to use jmx_exporter.
Should I use it as embedded (agent) or side-car (http)?
Which configuration file?
I was able to scrape the metrices using this config
Add the below config to your startup script or standalone.conf
JAVA_OPTS="$JAVA_OPTS -Djboss.modules.system.pkgs=org.jboss.byteman,org.jboss.logmanager -Djava.util.logging.manager=org.jboss.logmanager.LogManager -Dorg.jboss.logging.Logger.pluginClass=org.jboss.logging.logmanager.LoggerPluginImpl"
JAVA_OPTS="$JAVA_OPTS -Xbootclasspath/p:$JBOSS_HOME/modules/system/layers/base/org/jboss/logmanager/main/jboss-logmanager-2.0.3.Final-redhat-1.jar"
JAVA_OPTS="$JAVA_OPTS -javaagent:/path/to/exporter/jmx_exporter.jar=10001:/path/to/config/config.yaml"
It's recommended to use jmx-exporter embedded in the Java JVM virtual machine (use -javaagent). That's easier, more robust and gives better insights.
The configuration file depends on the version (JBoss use undertow... that's a different mBeans to collect than JBoss 6).
The jmx-exporter project provides an example configuration file for WildFly 10 example_configs/wildfly-10.yaml.
However, if you use "JBoss EAP for Openshift" containers images, the jmx-exporter agent is already embedded in the containers (set variables: AB_PROMETHEUS_ENABLE=true and sometimes this one too JAVA_OPTS_APPEND=-Dwildfly.statistics-enabled=true)
If you don't use Red Hat's container images, you can still use the ssame jmx-exporter configuration files. Those files (jmx-exporter-config.yaml) are open-source and available on github:
on master branch JBoss 7.3
on older branches JBoss 6.4 (and 7.1 and 7.2)

jenkins installation in Solaris server

How to install the jenkins on a solaris server? i found articles that this cannot be done as jenkins has discontinued support for solaris.
Even though official IPS repositories for Solaris are discontinued, you can still run Jenkins in Solaris via the jenkins webapp (jenkins.war). To quote from Jenkins installation doc:
Solaris, OmniOS, SmartOS, and other siblings
Generally it should
suffice to install Java 8 and download the jenkins.war and run it as a
standalone process or under an application server such as Apache
Tomcat.
Some caveats apply:
Headless JVM and fonts: For OpenJDK builds on minimalized-footprint
systems, there may be issues running the headless JVM, because Jenkins
needs some fonts to render certain pages.
ZFS-related JVM crashes: When Jenkins runs on a system detected as a
SunOS, it tries to load integration for advanced ZFS features using
the bundled libzfs.jar which maps calls from Java to native libzfs.so
routines provided by the host OS. Unfortunately, that library was made
for binary utilities built and bundled by the OS along with it at the
same time, and was never intended as a stable interface exposed to
consumers. As the forks of Solaris legacy, including ZFS and later the
OpenZFS initiative evolved, many different binary function signatures
were provided by different host operating systems - and when Jenkins
libzfs.jar invoked the wrong signature, the whole JVM process crashed.
A solution was proposed and integrated in jenkins.war since weekly
release 2.55 (and not yet in any LTS to date) which enables the
administrator to configure which function signatures should be used
for each function known to have different variants, apply it to their
application server initialization options and then run and update the
generic jenkins.war without further workarounds. See the libzfs4j Git
repository for more details, including a script to try and "lock-pick"
the configuration needed for your particular distribution (in
particular if your kernel updates bring a new incompatible libzfs.so).
Also note that forks of the OpenZFS initiative may provide ZFS on
various BSD, Linux, and macOS distributions. Once Jenkins supports
detecting ZFS capabilities, rather than relying on the SunOS check,
the above caveats for ZFS integration with Jenkins should be
considered.

After starting hadoop, i cannot start mahout ..!

When Starting Mahout i got an error message like this
root#fazil-VPCEB45FG:/usr/local/mahout/bin# ./mahout
hadoop binary is not in PATH,HADOOP_HOME/bin,HADOOP_PREFIX/bin, running locally
Error occurred during initialization of VM
Could not reserve enough space for object heap
Could not create the Java virtual machine.
i have installed openjdk0.6, Whether openjdk is supported by mahout
There's no OpenJDK 0.6 -- you mean 1.6. Yes Java 6 is supported, as you see in the project documentation. This does not seem to have anything to do with Mahout as it's an error from the JVM itself. The error itself says the problem: you requested a heap that's too large. So, I'd go see what heap you requested in Hadoop config and check it. This is the kind of info you should post in a question.
It's exactly what is says in the error message
Could not reserve enough space for object heap
check your your hadoop config files: hadoop-env.sh and
mapred-site.xml for any properties where you have allocated memory to JVM through the Xmx parameter and lower the values if you don't have enough physical memory.
If you have plenty of ram and you run java on 64-bit OS you need to add a -d64 java option to enforce 64-bit mode (it's not done by default in some cases)
Edit: for stand alone mode (your case) just use a proper Xmx value and -d64 if it is 64bits OS
JAVA_HEAP_MAX parameter in mahout file you're running should be lowered. It was 3GB in the mahout version I downloaded.

Neo4j unsupported Java runtime. use JDK 6. ubuntu 12.04

I am a new user to Neo4j usage and my OS is 32bit Ubuntu12.04. You need to start the server from Terminal by entering into the directory of Neo and then type
bin/neo4j start
which is all set and correct was until yesterday, there is some problem now and I get this
WARNING: Max 1024 open files allowed, minimum of 40 000 recommended.
See the Neo4j manual.WARNING! You are using an unsupported Java runtime.
Please use JDK 6.Neo4j Server already running with pid 3527
I am clueless to why this error occured suddenly.
When I run
localhost:7474
on my browser it doesn't recognise it any more.I tried to update my version following Install JDK6 on Ubuntu 12.04 link, but doesn't seem to work.Still gives the same error.
After checking for the version from terminal
java -version
I recieve
java version "1.6.0_27"
OpenJDK Runtime Environment (IcedTea6 1.12.3) (6b27-1.12.3-0ubuntu1~12.04.1)
OpenJDK Server VM (build 20.0-b12, mixed mode)
How do make localhost:7474 work on my machine?
Thanks.
For some licensing issues, Ubuntu does no longer ship Oracle/Sun JDKs directly, blame Oracle for that!
There is https://github.com/flexiondotorg/oab-java6 which automatically fetches Oracle/Sun JDKs, build local deb packages from them and puts them in a local apt repository.
Using update-java-alternatives you can set your system's default jdk.
Regarding the "open file" warning see http://docs.neo4j.org/chunked/stable/configuration-linux-notes.html#_setting_the_number_of_open_files.
We are using Ubuntu 12.04 as well. We use OpenJDK 1.6.0_24.
We ran into similar problems when we initially used Neo4j. Here are the instructions to get pass those hurdles.
You need to be able to open more files.
Edit /etc/security/limits.conf and add these two lines:
root soft nofile 40000
root hard nofile 40000
Edit /etc/pam.d/su and uncomment or add the following line:
session required pam_limits.so
Finally check that limit was changed. You might need to reboot.
ulimit -n
Returns 40000
Next in order to be able to use the webadmin on Ubuntu. You need to change one of the properties files inside neo4j. It works without this change on a Mac, I know.
Edit the neo4j-server.properties file:
cd [neo4j installation]/conf/
vim neo4-server.properties
Change this line
org.neo4j.server.webserver.address=0.0.0.0
The default is set to only listen for connections from localhost (that's why it works on a Mac). This way you can access the webadmin from anywhere. This can be a security problem though.
Hope this helps.
This seems to be a bug in neo4j about detection of running instance. By the reported pid there was some script about gnome and proxy, which after being killed (including parent lens script) let me start neo4j with OpenJDK. I guess they made it too smart.

Resources