今天我们尝试一下在AlmaLinux 9 安装Oracle GraalVM Enterprise Edition 21.3.x。
GraalVM Enterprise 21 是一个 Long-Term-Support (LTS) 版本。
注意:下载Oracle GraalVM Enterprise Edition需要有Oracle账户,如果没有,可以通过访问创建您的 Oracle 帐户进行创建。
step0. 支持的功能
适用于Linux(AMD64)平台的GraalVM企业版的基本发行版包括启用了GraalVM编译器的Oracle JDK、LLVM和JavaScript运行模块。基本安装可以扩展为,
Step1. 下载安装文件
访问https://www.oracle.com/downloads/graalvm-downloads.html,下载,
- Oracle GraalVM Enterprise Edition Core (Oracle GraalVM企业版的核心组件。不包括Native Image和可选语言包。)
- Oracle GraalVM Enterprise Edition Native Image (GraalVM Enterprise Native Image是一个ahead-of-time编译器)
- GraalVM LLVM Toolchain Plugin (GraalVM组件包含LLVM工具链10.0.0)
- Oracle GraalVM Enterprise Edition Node.js Runtime Plugin (使用GraalVM企业版实现JavaScript的Node.js版本)
Step2. 安装Oracle GraalVM Enterprise Edition Core
编译native-image依赖于本地工具链。使用你的操作系统上的软件包管理器安装glibc-devel、zlib-devel(C库和zlib的头文件)和gcc。一些Linux发行版可能还需要libstdc+±static。(注意:这里不太确定libstdc+±static是否在AlmaLinux 9是否必须安装,暂时先安装上,后续继续观察)
sudo dnf --enablerepo=crb install -y libstdc++-static gcc glibc-devel zlib-devel
接下来,开始正式安装,解压文件,
tar -xzf graalvm-ee-java17-linux-amd64-21.3.5.tar.gz
设置环境变量,
export JAVA_HOME=<your_graalvm_ee_path>
export PATH=$JAVA_HOME/bin:$PATH
查看,
java --version
输出示例,
java 17.0.6 2023-01-17 LTS
Java(TM) SE Runtime Environment GraalVM EE 21.3.5 (build 17.0.6+9-LTS-jvmci-21.3-b27)
Java HotSpot(TM) 64-Bit Server VM GraalVM EE 21.3.5 (build 17.0.6+9-LTS-jvmci-21.3-b27, mixed mode, sharing)
Step3. 安装Oracle GraalVM Enterprise Edition Native Image
安装,
gu -L install native-image-installable-svm-svmee-java17-linux-amd64-21.3.5.jar
输出示例,
Processing Component archive: native-image-installable-svm-svmee-java17-linux-amd64-21.3.5.jar
Installing new component: Native Image (org.graalvm.native-image, version 21.3.5)
查看,
gu list
输出示例,
ComponentId Version Component name Stability Origin
---------------------------------------------------------------------------------------------------------------------------------
graalvm 21.3.5 GraalVM Core Supported
js 21.3.5 Graal.js Supported
native-image 21.3.5 Native Image Early adopter
(Optional)卸载,
gu remove native-image
(Optional)升级,
gu upgrade --edition ee
Step4. 安装GraalVM LLVM Toolchain Plugin
安装,
gu -L install llvm-toolchain-installable-java17-linux-amd64-21.3.5.jar
输出示例,
Processing Component archive: llvm-toolchain-installable-java17-linux-amd64-21.3.5.jar
Installing new component: LLVM.org toolchain (org.graalvm.llvm-toolchain, version 21.3.5)
查看,
gu list
输出示例,
ComponentId Version Component name Stability Origin
---------------------------------------------------------------------------------------------------------------------------------
graalvm 21.3.5 GraalVM Core Supported
js 21.3.5 Graal.js Supported
llvm-toolchain 21.3.5 LLVM.org toolchain Supported
native-image 21.3.5 Native Image Early adopter
(Optional)卸载,
gu remove llvm-toolchain
(Optional)升级,
gu upgrade --edition ee
Step5. 安装Oracle GraalVM Enterprise Edition Node.js Runtime Plugin
安装,
gu -L install nodejs-installable-svm-svmee-java17-linux-amd64-21.3.5.jar
输出示例,
Processing Component archive: nodejs-installable-svm-svmee-java17-linux-amd64-21.3.5.jar
Installing new component: Graal.nodejs (org.graalvm.nodejs, version 21.3.5)
IMPORTANT NOTE:
---------------
Set of GraalVM components that provide language implementations have changed. The Polyglot native image and polyglot native C library may be out of sync:
- new languages may not be accessible
- removed languages may cause the native binary to fail on missing resources or libraries.
To rebuild and refresh the native binaries, use the following command:
/u01/apps/java/graalvm-ee-java17-21.3.5/bin/gu rebuild-images
注意:这里的IMPORTANT NOTE
的影响不得而知,后续继续观察。
查看,
gu list
输出示例,
ComponentId Version Component name Stability Origin
---------------------------------------------------------------------------------------------------------------------------------
graalvm 21.3.5 GraalVM Core Supported
js 21.3.5 Graal.js Supported
llvm-toolchain 21.3.5 LLVM.org toolchain Supported
native-image 21.3.5 Native Image Early adopter
nodejs 21.3.5 Graal.nodejs Supported
(Optional)卸载,
gu remove nodejs
(Optional)升级,
gu upgrade --edition ee
参考文档
- https://docs.oracle.com/en/graalvm/enterprise/21/docs/getting-started/installation-linux/
- https://docs.oracle.com/en/graalvm/enterprise/21/docs/reference-manual/graalvm-updater/