CentOS安装OracleJDK
实践证明,OracleJDK比OpenJDK快不止一星半点,换了之后立马从满负载降到个位数负载。
1、卸载openjdk
# rpm -qa | grep -E '^(java|jdk)'
# yum remove -y java-1.8.0-openjdk java-1.8.0-openjdk-headless
2、上oracle官网下载rpm包,这里要注意cookie,不能直接下载
# wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/8u144-b01/090f390dda5b47b9b721c7dfaa008135/jdk-8u144-linux-x64.rpm"
3、安装jdk
# yum install -y jdk-8u144-linux-x64.rpm
4、导出环境变量
# vim /etc/profile.d/java.sh
export JAVA_HOME=/usr/java/latest
export PATH=$JAVA_HOME/bin:$PATH
# source /etc/profile.d/java.sh
5、验证
# java -version
java version "1.8.0_144"
Java(TM) SE Runtime Environment (build 1.8.0_144-b01)
Java HotSpot(TM) 64-Bit Server VM (build 25.144-b01, mixed mode)
参考:
https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html