如何在 Windows 11 的 wsl2 ubuntu 上安装 apache flink

如何在 Windows 11 的 wsl2 ubuntu 上安装 apache flink

下面是我在 Windows 11 的 wsl2 ubuntu 上安装 Apache Flink 的过程。

一、openjdk-11的安装

$ sudo apt update
$ sudo apt upgrade
$ sudo apt install openjdk-11-jdk

systemd 安装,

$ sudo nano /etc/wsl.conf
    
[boot]
systemd=true

下载并解压 flink-1.18.1 并建立 flink-1.18.1 的链接

$ ln -s flink-1.18.1 flink
$ pwd 
/home/jhwang
$ ls
flink flink-1.18.1

在 /usr/lib/systemd/system 上创建 flink.service

$ nano /usr/lib/systemd/system/flink.service
    
[Unit]
Description=Flink Service
    
[Service]
Type=simple
User=jhwang
Group=jhwang
Environment=JAVA_HOME=/usr/lib/jvm/jdk
ExecStart=/home/jhwang/flink/bin/start-cluster.sh
ExecStop=/home/jhwang/flink/bin/stop-cluster.sh
    
    
Restart=always
    
[Install]
WantedBy=multi-user.target

然后我执行flink的systemctl,

$ sudo systemctl enable flink
$ sudo systemctl start flink

但flink系统守护进程立即被停用。

● flink.service - Flink Service
     Loaded: loaded (/lib/systemd/system/flink.service; enabled; vendor preset: enabled)
     Active: deactivating (stop) since Fri 2024-02-16 08:33:03 KST; 2s ago
    Process: 248179 ExecStart=/home/jhwang/flink/bin/start-cluster.sh (code=exited, status=0/SUCCESS)
   Main PID: 248179 (code=exited, status=0/SUCCESS); Control PID: 248868 (bash)
      Tasks: 67 (limit: 19187)
     Memory: 257.8M
     CGroup: /system.slice/flink.service
             ├─248563 /usr/lib/jvm/jdk/bin/java -Xmx1073741824 -Xms1073741824 -XX:MaxMetaspaceSize=268435456 -XX:+Ignor>             ├─248868 bash /home/jhwang/flink/bin/stop-cluster.sh
             ├─249273 bash /home/jhwang/flink-1.18.1/bin/jobmanager.sh stop
             ├─249382 bash /home/jhwang/flink-1.18.1/bin/flink-daemon.sh stop standalonesession
             ├─249513 timeout 10 tail --pid=248563 -f /dev/null
             └─249515 tail --pid=248563 -f /dev/null

Feb 16 08:33:01 DESKTOP-7MNP0L0 systemd[1]: Started Flink Service.
Feb 16 08:33:01 DESKTOP-7MNP0L0 start-cluster.sh[248179]: Starting cluster.
Feb 16 08:33:02 DESKTOP-7MNP0L0 start-cluster.sh[248449]: Starting standalonesession daemon on host DESKTOP-7MNP0L0.
Feb 16 08:33:03 DESKTOP-7MNP0L0 start-cluster.sh[248751]: Starting taskexecutor daemon on host DESKTOP-7MNP0L0.
Feb 16 08:33:03 DESKTOP-7MNP0L0 stop-cluster.sh[249116]: Stopping taskexecutor daemon (pid: 248865) on host DESKTOP-7MN>Feb 16 08:33:05 DESKTOP-7MNP0L0 stop-cluster.sh[249382]: Stopping standalonesession daemon (pid: 248563) on host DESKTO>lines 1-21/21 (END)...skipping...
● flink.service - Flink Service
     Loaded: loaded (/lib/systemd/system/flink.service; enabled; vendor preset: enabled)
     Active: deactivating (stop) since Fri 2024-02-16 08:33:03 KST; 2s ago
    Process: 248179 ExecStart=/home/jhwang/flink/bin/start-cluster.sh (code=exited, status=0/SUCCESS)
   Main PID: 248179 (code=exited, status=0/SUCCESS); Control PID: 248868 (bash)
      Tasks: 67 (limit: 19187)
     Memory: 257.8M
     CGroup: /system.slice/flink.service
             ├─248563 /usr/lib/jvm/jdk/bin/java -Xmx1073741824 -Xms1073741824 -XX:MaxMetaspaceSize=268435456 -XX:+IgnoreUnrecognizedVMOptions --add-exports=java.base/sun.net.util=ALL-UNNAMED --add-exports=java.rmi/sun.rmi.registry=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tool>             ├─248868 bash /home/jhwang/flink/bin/stop-cluster.sh
             ├─249273 bash /home/jhwang/flink-1.18.1/bin/jobmanager.sh stop
             ├─249382 bash /home/jhwang/flink-1.18.1/bin/flink-daemon.sh stop standalonesession
             ├─249513 timeout 10 tail --pid=248563 -f /dev/null
             └─249515 tail --pid=248563 -f /dev/null

Feb 16 08:33:01 DESKTOP-7MNP0L0 systemd[1]: Started Flink Service.
Feb 16 08:33:01 DESKTOP-7MNP0L0 start-cluster.sh[248179]: Starting cluster.
Feb 16 08:33:02 DESKTOP-7MNP0L0 start-cluster.sh[248449]: Starting standalonesession daemon on host DESKTOP-7MNP0L0.
Feb 16 08:33:03 DESKTOP-7MNP0L0 start-cluster.sh[248751]: Starting taskexecutor daemon on host DESKTOP-7MNP0L0.
Feb 16 08:33:03 DESKTOP-7MNP0L0 stop-cluster.sh[249116]: Stopping taskexecutor daemon (pid: 248865) on host DESKTOP-7MNP0L0.

此安装过程是否包含错误命令或遗漏了某些内容?请告知我如何在 wsl2 ubuntu 上安装 apache flink。此致

相关内容