今天我们尝试一下在AlmaLinux 9 安装Oracle GraalVM Enterprise Edition 22.3.x。
GraalVM Enterprise 22是包含新功能的最新版本,但不是Long-Term-Support (LTS) 版本。
注意:下载Oracle GraalVM Enterprise Edition需要有Oracle账户,如果没有,可以通过访问创建您的 Oracle 帐户进行创建。
step0. 支持的功能
用于Linux平台的64位GraalVM企业版包括启用了GraalVM编译器的Oracle JDK、GraalVM Updater、gu utility和一些开发工具(如基于Chrome inspector的调试器、Profiler)。对Native Image、JavaScript、Node.js、LLVM和WebAssembly运行时的支持可以用gu安装。Python、FastR和Ruby语言的运行时在这个发行版中还不可用。
GraalVM Enterprise for Linux的基本版本包括启用了GraalVM编译器的Oracle JDK。基本安装可以额外扩展。
Step1. 下载安装文件
访问https://www.oracle.com/downloads/graalvm-downloads.html,下载,
- Oracle GraalVM Enterprise Edition Core (Oracle GraalVM企业版的核心组件。不包括Native Image和可选语言包。)
其他安装文件无需下载,需要时可以使用gu
命令行工具安装。
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-22.3.1.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 22.3.1 (build 17.0.6+9-LTS-jvmci-22.3-b11)
Java HotSpot(TM) 64-Bit Server VM GraalVM EE 22.3.1 (build 17.0.6+9-LTS-jvmci-22.3-b11, mixed mode, sharing)
Step3. 安装Oracle GraalVM Enterprise Edition Native Image
运行gu available
,列出你所安装的GraalVM企业版的可用组件,
gu available
输出示例,
Downloading: Artifacts catalog from gds.oracle.com
Downloading: Release index file from oca.opensource.oracle.com
Downloading: Component catalog for GraalVM Enterprise Edition 22.3.1 on jdk17 from oca.opensource.oracle.com
Skipping ULN EE channels, no username provided.
Downloading: Component catalog from www.graalvm.org
ComponentId Version Component name Stability Origin
---------------------------------------------------------------------------------------------------------------------------------
espresso 22.3.1 Java on Truffle Supported gds.oracle.com
espresso-llvm 22.3.1 Java on Truffle LLVM Java librSupported gds.oracle.com
js 22.3.1 Graal.js Supported gds.oracle.com
llvm 22.3.1 LLVM Runtime Core Supported gds.oracle.com
llvm-toolchain 22.3.1 LLVM.org toolchain Supported gds.oracle.com
native-image 22.3.1 Native Image Early adopter gds.oracle.com
native-image-llvm-backend22.3.1 Native Image LLVM Backend Early adopter (experimental) gds.oracle.com
nodejs 22.3.1 Graal.nodejs Supported gds.oracle.com
python 22.3.1 GraalVM Python Experimental gds.oracle.com
ruby 22.3.1 TruffleRuby Experimental gds.oracle.com
visualvm 22.3.1 VisualVM Experimental gds.oracle.com
wasm 22.3.1 GraalWasm Experimental gds.oracle.com
安装native-image,需要输入ENTER
,然后输入Oracle账号的邮箱,查看"Oracle Technology Network License Agreement | GraalVM Enterprise Edition" license的邮件,并且接受该许可后,再次输入ENTER
。
gu install native-image
输出示例,
Downloading: Artifacts catalog from gds.oracle.com
Downloading: Release index file from oca.opensource.oracle.com
Downloading: Component catalog for GraalVM Enterprise Edition 22.3.1 on jdk17 from oca.opensource.oracle.com
Skipping ULN EE channels, no username provided.
Downloading: Component catalog from www.graalvm.org
Processing Component: Native Image
Enter your download token and press ENTER, or press ENTER to generate a new download token.
Enter a valid download token:
Please provide an email address. Please review Oracles Privacy Policy (https://www.oracle.com/legal/privacy/privacy-policy.html).
Enter a valid email address: <your_email>
Obtained download token "RjI0NURBQkU3ODgwNDNFN0UqzxvfgNjE4MDAwQUQyQTc6NjFkNWZiODBkMTBiZTQ4MTIxNjI0YmQ2NTMwNzdmMTllNGU0NmE0OQ".
The license has been sent to <your_email>. Accept it and then press ENTER to continue.
Downloading: Component native-image: Native Image from gds.oracle.com
Installing new component: Native Image (org.graalvm.native-image, version 22.3.1)
查看,
gu list
输出示例,
ComponentId Version Component name Stability Origin
---------------------------------------------------------------------------------------------------------------------------------
graalvm 22.3.1 GraalVM Core Supported
native-image 22.3.1 Native Image Early adopter gds.oracle.com
(Optional)卸载,
gu remove native-image
(Optional)升级,
gu upgrade --edition ee
参考文档
- https://docs.oracle.com/en/graalvm/enterprise/22/docs/getting-started/installation-linux/
- https://docs.oracle.com/en/graalvm/enterprise/22/docs/reference-manual/graalvm-updater/