WebLogic Startup Slow
After long WebLogic installation, I found that every time I startup WebLogic Server, it looked stuck and took about 10 to 15 minutes to complete. Which is unbearable and unacceptable for a production environment.
Rationale
This is because JVM library used for random number generation relies on /dev/random by default for UNIX platforms. This can potentially slow down the startup before returning a result.
Although /dev/random is more secure, using /dev/urandom instead if the startup is slow. So next, we should make a comparison test on the response time of /dev/random and /dev/urandom in this machine. Please note that, the comparison test should be done at least twice.
[oracle@admin ~]$ time head -1 /dev/random
...
real 4m41.002s
user 0m0.000s
sys 0m0.010s
[oracle@admin ~]$ time head -1 /dev/urandom
...
real 0m0.005s
user 0m0.000s
sys 0m0.004s
As we can see, /dev/urandom returned the result immediately, whereas /dev/random took almost 5 minutes. Apparently, we should use /dev/urandom.
Solutions
For various scopes, here are some treatments that can speed up the startup of a WebLogic server.
Java Scope
Please modify the setting in java.security of the default JVM.
[root@admin ~]$ vi /usr/java/default/jre/lib/security/java.security
...
securerandom.source=file:/dev/urandom
Session Scope
Alternatively, we can add a JAVA_OPTIONS environment variable for every logon session of the user.
[oracle@admin ~]$ vi .bash_profile
...
export JAVA_OPTIONS=-Djava.security.egd=file:/dev/./urandom
...
[oracle@admin ~]$ . .bash_profile
Domain Scope
Although we can set JAVA_OPTIONS in the session scope, adding it to the scripts is a more selective way to do it, no matter where we execute them. For example, exporting JAVA_OPTIONS in the beginning of startWebLogic.sh:
[oracle@admin ~]$ vi $DOMAIN_HOME/bin/startWebLogic.sh
#!/bin/sh
export JAVA_OPTIONS=-Djava.security.egd=file:/dev/./urandom
...
Consequently, the startup is back to normal, it can be done in one minute.
Not only starting up, but installing and configuring a new domain of WebLogic are also affected by the slow random number generator. Even though, They all can be resolved by the above solutions.