WSL2 Ubuntu 20.04 并不是很稳定,又或者由于其它的原因需要重置子系统,已经安装配置好的应用又要重新安装配置,已经踩过的坑又要重新踩一遍。所以有了这篇作为总结和备忘,以后再重新配置直接抄作业就行,不用再重新 debug 已经被 debug 多次的问题。不过新系统每个应用都要重新配置毕竟不是长久之道,早点升级机器配置安装 CDH 之类的集成环境才是正解(现在的机器内存就这么几个 G 你还要装 CDH 它能装吗? 装不了,没这个能力知道吧 ╮(╯_╰)╭)。
WSL2 Ubuntu 重置
Windows - 设置 - 应用 - 应用和功能 - 应用列表 - Ubuntu on Windows - 高级设置 - 重置
WSL2 Ubuntu 移动到 D 盘
下载 LxRunOffline
查看子系统列表 LxRunOffline l:
| 1 | Ubuntu | 
将 Ubuntu 从默认位置移动到 D:\Virtual Machines\WSL\Ubuntu:
| 1 | LxRunOffline m -n Ubuntu -d "D:\Virtual Machines\WSL\Ubuntu" | 
查看子系统安装位置验证是否迁移成功:
| 1 | LxRunOffline di -n Ubuntu | 
设置默认 WSL2 子系统发行版
| 1 | wsl --setdefault Ubuntu | 
apt 换源、更新、手动安装 ca-certificates
| 1 | sudo vim /etc/apt/sources.list | 
SSH
| 1 | ssh-keygen | 
/run/nologin 导致的 SSH 启动失败问题
sudo vim /etc/pam.d/sshd 注释掉 account    required     pam_nologin.so
配置 systemd
安装 daemonize : sudo apt install daemonize
安装 systemd:ubuntu-wsl2-systemd-script
解决 nsenter: cannot open /proc/10867/ns/time: No such file or directory 报错
nsenter: cannot open /proc/320/ns/time: No such file or directory
测试是否安装成功:systemctl
子系统内屏蔽 Windows 环境变量
新建 /etc/wsl.conf 文件并添加以下内容:
| 1 | [interop] | 
上述操作后无法执行 code . 来打开主系统的 VS Code, 所以需要把主系统 VS Code 的安装路径添加到子系统环境变量中:
| 1 | ## VS Code | 
重启子系统
Python 软连接、PIP 安装、pip 换源
| 1 | sudo ln -s /usr/bin/python3.8 /usr/bin/python | 
Conda 环境
| 1 | wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh | 
Jupyter 环境
PIP 安装 Jupyter:
| 1 | pip install jupyterlab jupyterlab-language-pack-zh-CN jupyterlab-execute-time | 
Jupyter 环境变量:export PATH=$PATH:~/.local/bin
Jupyter 笔记本设置:
| 1 | {"codeCellConfig": | 
Java 环境
安装 Java 8 :sudo apt-get install openjdk-8-jdk
Java 环境变量:
| 1 | ## JAVA | 
MySQL
在 WSL2 Ubuntu 20.04 上安装 MySQL 并配置账户SQL Server
在 Windows 中配置端口 1433 入站规则:打开 Windows 防火墙的端口以进行 TCP 访问
在 WSL2 Ubuntu 20.04 上安装 SQL Server 并用 Sqoop 将数据导入 HDFSHadoop
在 WSL2 Ubuntu 20.04 上安装 Hadoop 并写一个 WordCountSpark
| 1 | ## SPARK |