在线教育网站项目第四步:deepseek骗我, WSL2不能创建两个独立的Ubuntu,但我们能实现实例互访及外部访问

一、说明

上一章折腾了半天,搞出不少问题,今天我们在deepseek的帮助下,完成多个独立ubuntu24.04实例的安装,并完成固定ip,实践证明,deepseek不靠谱,浪费我2个小时时间,我们将在下面实现,其实网上有很多信息比较旧

计划安装实例已经端口IP分配表

服务器配置表
服务器顺序服务器名IP地址端口主机名说明
1mysql192.168.1.15

3306; ssh:2221

mysql关系型数据库
2redis6379; ssh:2222非关系型数据库
3kkfileview8012; ssh:2223kkfileview

在线文件预览

4elasticsearch9200; ssh:2224elasticsearch搜索和数据分析模型
4kibana5601; ssh:2224kibanaKibana 是为Elasticsearch设计的开源分析和可视化平台
5minio

服务端口:9000

控制台:9001

; ssh:2225

minio对象存储
6nacos

注册中心:8848

控制台:9848

; ssh:2226

nacos动态服务发现、配置管理和服务管理平台
7xxl-job-admin8080; ssh:2227xxl-job-admin分布式任务调平台
8

seata

; ssh:2228seata分布式事务
9roncoo-education-gateway7700; ssh:2229roncoo-education-gateway在线教育网关服务
9roncoo-education-system7710; ssh:2229roncoo-education-system在线教育系统服务
9roncoo-education-user7720; ssh:2229roncoo-education-user在线教育用户服务
9roncoo-education-course
7730; ssh:2229
roncoo-education-course在线教育课程服务
一共9台服务器

推荐使用WSLMan 管理工具

Release v0.1.1.0 · jet2jet/WSLMan

二、安装Ubuntu-24.04

1、建立配置文件.wslconfig

在宿主机win11的登录用户目录下,建立文件.wslconfig,添加内容:

[experimental]
autoMemoryReclaim=gradual  
networkingMode=mirrored
dnsTunneling=true
firewall=true
autoProxy=true

[boot]
systemd=true

2、选择安装新的分发

3、选择ubuntu24.04 

4、安装

安装过程 

 安装完成

5、启动,添加用户密码

ip地址很有意思,192.168.1.15 是我主机的ip,也就是win11的地址,我们在上一篇文章中可不是这样的, 刚才我们建立的9台虚拟机ip地址都是一样,据说宿主机可以通过localhost访问所有的机器,这个就是添加了全局的.wslconfig有的效果,具体配置可以查资料,上面我们已经添加了

6、安装ssh

修改默认登录用户为x58win
sudo vi /etc/wsl.conf
添加内容
[user]
default=x58win
[boot]
systemd=true

 重启wsl

 

# 安装
sudo apt-get update
sudo apt-get install openssh-server##有错误,ssh.socket 是 systemd 的套接字单元,用于按需启动 SSH 服务(当有连接时启动)
Could not execute systemctl:  at /usr/bin/deb-systemd-invoke line 148.
dpkg: error processing package openssh-server (--configure):installed openssh-server package post-installation script subprocess returned error exit status 1##解决方案
sudo systemctl stop ssh.socket      # 停止套接字
sudo systemctl disable ssh.socket   # 禁用开机启动## 修改端口
sudo vi /etc/ssh/sshd_config
#Port 22 改为
Port 2220sudo systemctl start ssh
sudo systemctl status ssh
sudo systemctl enable ssh

x58win@x58:~$ sudo vi /etc/ssh/sshd_config
x58win@x58:~$
x58win@x58:~$ sudo systemctl start ssh
x58win@x58:~$ sudo systemctl status ssh
● ssh.service - OpenBSD Secure Shell server
     Loaded: loaded (/usr/lib/systemd/system/ssh.service; enabled; preset: enabled)
     Active: active (running) since Wed 2025-03-19 18:19:16 CST; 10s ago
       Docs: man:sshd(8)
             man:sshd_config(5)
    Process: 409 ExecStartPre=/usr/sbin/sshd -t (code=exited, status=0/SUCCESS)
   Main PID: 411 (sshd)
      Tasks: 1 (limit: 9510)
     Memory: 1.2M (peak: 1.6M)
        CPU: 48ms
     CGroup: /system.slice/ssh.service
             └─411 "sshd: /usr/sbin/sshd -D [listener] 0 of 10-100 startups"

Mar 19 18:19:16 x58 systemd[1]: Starting ssh.service - OpenBSD Secure Shell server...
Mar 19 18:19:16 x58 sshd[411]: Server listening on 0.0.0.0 port 2220.
Mar 19 18:19:16 x58 sshd[411]: Server listening on :: port 2220.
Mar 19 18:19:16 x58 systemd[1]: Started ssh.service - OpenBSD Secure Shell server.
x58win@x58:~$ sudo systemctl enable ssh
Synchronizing state of ssh.service with SysV service script with /usr/lib/systemd/systemd-sysv-install.
Executing: /usr/lib/systemd/systemd-sysv-install enable ssh
x58win@x58:~$

x58win@x58:~$ sudo ss -tulpn | grep ':2220'
tcp   LISTEN 0      128           0.0.0.0:2220      0.0.0.0:*    users:(("sshd",pid=411,fd=3))
tcp   LISTEN 0      128              [::]:2220         [::]:*    users:(("sshd",pid=411,fd=4))

测试 

在win11 测试

ssh x58win@localhost -p 2220

PS C:\Windows\system32> ssh x58win@localhost -p 2220
The authenticity of host '[localhost]:2220 ([127.0.0.1]:2220)' can't be established.
ED25519 key fingerprint is SHA256:OvWuU6KZCq7AyIGzUwvNGsBwbnr3MlmnQ6knrTs9lwE.
This key is not known by any other names.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '[localhost]:2220' (ED25519) to the list of known hosts.
x58win@localhost's password:
Welcome to Ubuntu 24.04.2 LTS (GNU/Linux 6.6.75.1-microsoft-standard-WSL2 x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/pro

 System information as of Wed Mar 19 18:23:50 CST 2025

  System load:  0.0                 Processes:             29
  Usage of /:   0.1% of 1006.85GB   Users logged in:       1
  Memory usage: 5%                  IPv4 address for eth0: 192.168.1.15
  Swap usage:   0%

 * Strictly confined Kubernetes makes edge and IoT secure. Learn how MicroK8s
   just raised the bar for easy, resilient and secure K8s cluster deployment.

   https://ubuntu.com/engage/secure-kubernetes-at-the-edge
x58win@x58:~$ ls

在其它局域网,非宿主机win11

ssh x58win@192.168.1.15 -p 2220
# 就这样是不能连接的,有防火墙打开2220转发
New-NetFirewallRule -DisplayName "WSL2 x58 ssh" -Direction Inbound -LocalPort 2220 -Action Allow -Protocol TCP
netsh interface portproxy show v4tov4

C:\Users\x230win10>ssh x58win@192.168.1.15 -p 2220
The authenticity of host '[192.168.1.15]:2220 ([192.168.1.15]:2220)' can't be established.
ED25519 key fingerprint is SHA256:OvWuU6KZCq7AyIGzUwvNGsBwbnr3MlmnQ6knrTs9lwE.
This key is not known by any other names.
Are you sure you want to continue connecting (yes/no/[fingerprint])? y
Please type 'yes', 'no' or the fingerprint: yes
Warning: Permanently added '[192.168.1.15]:2220' (ED25519) to the list of known hosts.
x58win@192.168.1.15's password:
Welcome to Ubuntu 24.04.2 LTS (GNU/Linux 6.6.75.1-microsoft-standard-WSL2 x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/pro

 System information as of Wed Mar 19 18:36:44 CST 2025

  System load:  0.03                Processes:             34
  Usage of /:   0.1% of 1006.85GB   Users logged in:       1
  Memory usage: 5%                  IPv4 address for eth0: 192.168.1.15
  Swap usage:   0%

 * Strictly confined Kubernetes makes edge and IoT secure. Learn how MicroK8s
   just raised the bar for easy, resilient and secure K8s cluster deployment.

   https://ubuntu.com/engage/secure-kubernetes-at-the-edge
Last login: Wed Mar 19 18:23:51 2025 from 127.0.0.1
x58win@x58:~$

 好,OK,搞了不少时间,那个ssh.socket的错误,在ubuntu 22上直接显示是这个错误,而ubuntu24上没有指名,ssh是必须安装的所以我们先装了

7、安装docker和docker-compose

按照前面的文章安装就行

在线教育网站项目第二步 :学习Vue3 + Nuxt3+springcloud,服务器为ubuntu24.04-CSDN博客https://blog.csdn.net/jiangkp/article/details/145995259

8、导出发行版

先expert出来,然后再import

选个目录,如果启动了,需要shutdown WSL 

点击ok开始expert ,abort是停止运行

 最后变为close,直接关闭即可

9、注销Ubuntu-24.04

注销掉就都没了,可以回去看看那个appdata目录下的东西都没有

原来安装的发行版没有了 

目录下了也没有东西了

二、安装9台的服务器

mysql
redis
kkfileview
elasticsearch
minio
nacos
xxl-job-admin
seata
roncoo-education

选择上面导出的虚拟机,分发名字自己要安装虚拟机名字,自己要安装的地址

 开始安装

 完成

  

 下面再建立8个,完全为了测试

三、配置各个实例

1、进入实例

先选下用户

比方说进入redis,看下面

2、查点想查的东西 

x58win@x58:~$ docker --version
Docker version 28.0.1, build 068a01e
x58win@x58:~$ docker-compose --version
Docker Compose version v2.33.1
x58win@x58:~$ sudo systemctl status ssh
[sudo] password for x58win:
● ssh.service - OpenBSD Secure Shell server
     Loaded: loaded (/usr/lib/systemd/system/ssh.service; enabled; preset: enabled)
     Active: active (running) since Wed 2025-03-19 19:16:44 CST; 49s ago
       Docs: man:sshd(8)
             man:sshd_config(5)
    Process: 198 ExecStartPre=/usr/sbin/sshd -t (code=exited, status=0/SUCCESS)
   Main PID: 214 (sshd)
      Tasks: 1 (limit: 9510)
     Memory: 2.1M (peak: 2.5M)
        CPU: 91ms
     CGroup: /system.slice/ssh.service
             └─214 "sshd: /usr/sbin/sshd -D [listener] 0 of 10-100 startups"

Mar 19 19:16:44 x58 systemd[1]: Starting ssh.service - OpenBSD Secure Shell server...
Mar 19 19:16:44 x58 sshd[214]: Server listening on 0.0.0.0 port 2220.
Mar 19 19:16:44 x58 sshd[214]: Server listening on :: port 2220.
Mar 19 19:16:44 x58 systemd[1]: Started ssh.service - OpenBSD Secure Shell server.

3、修改主机名

sudo vi /etc/wsl.conf[network]
hostname = mysql  # 替换为你想要的主机名
generateHosts = false           # 阻止 WSL 自动生成 hosts 文件

更新 /etc/hosts 添加互相解析

sudo vi /etc/hosts

将x58 改为mysql

4、修改ssh端口


sudo sed -i 's/Port 2220/Port 2221/' /etc/ssh/sshd_config对应端口在这里,22开头的就是ssh地址
"mysql8" = 2221,3306
"redis" = 2222,6379
"kkfileview" = 2223,8012
"elasticsearch" = 2224,9200,5601
"minio" = 2225,9000,9001
"nacos" = 2226,8848,9848
"xxl-job-admin" = 2227,8080
"seata" = 2228,8091
"roncoo-education" = 2229,7700,7710,7720,7730

重启 

PS C:\Windows\system32> ssh x58win@192.168.1.15 -p 2221
The authenticity of host '[192.168.1.15]:2221 ([192.168.1.15]:2221)' can't be established.
ED25519 key fingerprint is SHA256:OvWuU6KZCq7AyIGzUwvNGsBwbnr3MlmnQ6knrTs9lwE.
This host key is known by the following other names/addresses:
    C:\Users\x230win10/.ssh/known_hosts:1: [192.168.1.15]:2220
Are you sure you want to continue connecting (yes/no/[fingerprint])? y
Please type 'yes', 'no' or the fingerprint: yes
Warning: Permanently added '[192.168.1.15]:2221' (ED25519) to the list of known hosts.
x58win@192.168.1.15's password:
Welcome to Ubuntu 24.04.2 LTS (GNU/Linux 6.6.75.1-microsoft-standard-WSL2 x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/pro

 System information as of Wed Mar 19 19:55:45 CST 2025

  System load:  0.23                Processes:             31
  Usage of /:   0.2% of 1006.85GB   Users logged in:       1
  Memory usage: 5%                  IPv4 address for eth0: 192.168.1.15
  Swap usage:   0%

 * Strictly confined Kubernetes makes edge and IoT secure. Learn how MicroK8s
   just raised the bar for easy, resilient and secure K8s cluster deployment.

   https://ubuntu.com/engage/secure-kubernetes-at-the-edge
Last login: Wed Mar 19 18:51:19 2025 from 192.168.1.8
x58win@mysql:~$ hostname
mysql

5、每个ubuntu24.04实例都要来一遍 

四、配置Windows防火墙和端口转发

创建脚本 MakeWslPort.ps1

# powershell.exe -ExecutionPolicy Bypass -File "D:\wsl\Script\MakeWslPort.ps1"# 脚本功能:为WSL实例分配固定IP并配置端口转发
$wslInstances = @("mysql", "redis","kkfileview","elasticsearch","minio","nacos","xxl-job-admin","seata","roncoo-education")
$ports = 80,443,2221,2222,2223,2224,2225,2226,2227,2228,2229,3306,6379,8012,9200,5601,9000,9001,8848,9848,8080,7700,7710,7720,7730netsh interface portproxy reset # 清除所有端口转发规则# 这里不需要添加
#foreach ($port in $ports) {
#	echo $port
#	netsh interface portproxy add v4tov4 listenaddress=0.0.0.0 listenport=$port #connectaddress= 192.168.1.15 connectport=$port # netsh interface portproxy add v4tov4 listenaddress=0.0.0.0 listenport=443 #connectaddress=192.168.1.100 connectport=443
}# 开放 TCP 端口 
New-NetFirewallRule -DisplayName "WebServer" -Direction Inbound -Protocol TCP -LocalPort 80,443,2221-2229,3306,6379,8012,9200,5601,9000,9001,8848,9848,8080,7700,7710,7720,7730 -Action Allownetsh interface portproxy show v4tov4

# 在win11 管理员ps命令行下 

powershell.exe -ExecutionPolicy Bypass -File "D:\wsl\Script\MakeWslPort.ps1"

    本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.rhkb.cn/news/36587.html

    如若内容造成侵权/违法违规/事实不符,请联系长河编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

    相关文章

    Apache Paimon 在抖音集团多场景中的优化实践

    资料来源:火山引擎-开发者社区 本文将基于抖音集团内部两大业务的典型实时数仓场景,介绍Paimon在抖音集团内部的生产实践。 作者:李明、苏兴、文杰 抖音集团大数据工程师 目前抖音集团内部主要使用 Lambda 架构进行实时数仓建设,其…

    PDF Reader Pro for Mac v4.9.0 PDF编辑/批注/OCR/转换工具 支持M、Intel芯片

    PDF Reader Pro 是一款用户必备的集管理、编辑、转换、阅读功能于一体的专业的全能PDF阅读专家。快速、易用、强大,让您出色完成 PDF 工作。 应用介绍 PDF Reader Pro,一款功能齐全且强大的PDF阅读和编辑软件。支持PDF阅读、批注、PDF编辑、PDF格式转换…

    HTML5与CSS3新特性详解

    一、HTML5新特性 1.概述 HTML5 的新增特性主要是针对于以前的不足,增加了一些新的标签、新的表单和新的表单属性等。 这些新特性都有兼容性问题,基本是 IE9 以上版本的浏览器才支持,如果不考虑兼容性问题,可以大量使用这些新特…

    shell 脚本搭建apache

    #!/bin/bash # Set Apache version to install ## author: yuan# 检查外网连接 echo "检查外网连接..." ping www.baidu.com -c 3 > /dev/null 2>&1 if [ $? -eq 0 ]; thenecho "外网通讯良好!" elseecho "网络连接失败&#x…

    Linux环境使用jmeter做性能测试

    一、安装JDK,版本jdk1.8 1、下载压缩包到/jdk目录下解压 cd /jdk tar -zxvf jdk-8u241-linux-64.tar.gz 2、配置环境变量 在profile文件中末尾新增信息如下所示 vim /etc/profile export JAVA_HOME/usr/local/java/jdk/jdk1.8.0_221 export PATH$PATH:$JAVA_HOM…

    巧用符号链接搬移C盘中的软件数据目录到其他盘

    #工作记录 我们知道,在Windows11系统,有些软件是不能指定安装目录的,有些软件即使指定了安装目录可是在更新版本之后还是会安装到默认的C盘目录中(比如剪映),而且每次安装某些软件之后,这些软件…

    Mysql的安装配置

    目录 MySQL 简介 MySQL 的下载安装 mysql配置【默认以及下载好】 (1)配置环境变量 (2)修改配置文件 (3)以管理员身份运行cmd(一定要用管理员身份运行,不然权限不够) …

    登山第二十梯:无人机实时自主探索——我是一只小小小鸟

    文章目录 一 摘要 二 资源 三 内容 一 摘要 自主探索是无人机 (UAV) 各种应用的基本问题。最近,基于 LiDAR 的探索因其能够生成大规模环境的高精度点云地图而受到广泛关注。虽然点云本身就为导航提供了信息,但许多现有的勘探方…

    基于FPGA轨道交通6U机箱CPCI脉冲板板卡

    板卡简介: 本板为脉冲板,脉冲板主要执行CPU下达的指令,通过实现各种控制算法来调节PWM,然后输出光纤PWM信号来驱动变频器功率模块以达到控制电机的目的。 性能规格: 电源:DC5V;15V FPGA&…

    一键批量txt转DWG,DWG转txt——插件实现 CAD c#二次开发

    如下图,我们有大量dwg需要转为txt格式,或txt格式坐标需要转为dwg格式,此插件可一键完成一个文件夹下所有文件的转换。 插件使用方式 命令行输入: netload 加载此dll插件, 输入: dwg2txt 可将dwg转为t…

    【Unity基础】Unity中角色动画的三种实现方式

    在Unity中,角色动画有三种不同的实现方式:逐帧动画(Frame-by-Frame)、剪裁动画(Cutout)和骨骼动画(Skeletal),各自适用于不同的场景和需求。以下是它们的核心区别及特点&…

    Flutter中Align的使用说明

    又失业了,作为一个高龄Android程序员今年找工作真难呀。现在Flutter是必需技能了,所以最近在自学。所用书籍叫《Flutter实战》,如下 如今已看了100多页,发现这本书写得……有点赶吧,好几处讲得不清不楚,而关…

    leetcode hot100(五)

    11. 盛最多水的容器 给定一个长度为 n 的整数数组 height 。有 n 条垂线,第 i 条线的两个端点是 (i, 0) 和 (i, height[i]) 。 找出其中的两条线,使得它们与 x 轴共同构成的容器可以容纳最多的水。 返回容器可以储存的最大水量。 说明:你…

    echarts+Vue2 自动轮播饼图

    1、首先下载echarts,并且全局引入echarts 方法:从 npm 安装 npm install echarts 在 main.js 文件中全局引入 然后创建一个vue文件,名字随便起,比如 pieChart.vue,话不多说,直接上才艺:&…

    自学软硬件第755 docker容器虚拟化技术

    见字如面, 这里是AIGC创意人_竹相左边, 正在通过AI自学软硬件工程师,目标手搓可回收火箭玩具。 我很喜欢 《流浪地球 2》中 ,马兆:没有硬件支撑,你破解个屁。 写作背景 今天在剪视频,然后看…

    单片机自学总结

    自从工作以来,一直努力耕耘单片机,至今,颇有收获。从51单片机,PIC单片机,直到STM32,以及RTOS和Linux,几乎天天在搞:51单片机,STM8S207单片机,PY32F003单片机,…

    模拟String基本函数/深浅拷贝/柔性数组

    1.首先我们先关注一下ASCII&#xff1a; 记住常用每一个字符对应的ascii码值&#xff01; 2.string函数的相关操作函数代码&#xff1a; 大多数小疑问都已经写在注释里面&#xff01; #pragma once #define _CRT_SECURE_NO_WARNINGS #include<iostream> #include<a…

    论文分享:PL-ALF框架实现无人机低纹理环境自主飞行

    在室内仓库、地下隧道等低纹理复杂场景中&#xff0c;无人机依赖视觉传感器进行自主飞行时&#xff0c;往往会遇到定位精度低、路径规划不稳定等难题。针对这一问题&#xff0c;重庆邮电大学计算机学院雷大江教授团队在IEEE Trans期刊上提出了一种新型自主飞行框架&#xff1a;…

    文档搜索引擎

    实现的搜索功能 首先获取很多的网页,然后根据用户输入的查询词,在这些网页中进行查找 用户输入查询词之后,如何让查询词和当前的网站进行匹配? 首先获取很多网页(爬虫->一个http客户端,发送http请求获取http响应结果(就是网站))(批量化的获取很多的页面), 再根据用户输入…

    自然语言处理入门4——RNN

    一般来说&#xff0c;提到自然语言处理&#xff0c;我们都会涉及到循环神经网络&#xff08;RNN&#xff09;&#xff0c;这是因为自然语言可以被看作是一个时间序列&#xff0c;这个时间序列中的元素是一个个的token。传统的前馈神经网络结构简单&#xff0c;但是不能很好的处…