最新消息
一键虚拟化项目
一键虚拟化项目
7个月前 4 阅读
  • 首页
  • /
  • 默认
  • /
  • 正文
  • 一键虚拟化项目
    本文主要参考:https://www.spiritlhl.net/guide/dashboard.html
    一、准备工作
    本文档将以VPS作为范例,且该VPS纯净,无原生环境问题,如有必要请重装系统保证初始环境的纯净
    1、PVE:https://github.com/spiritLHLS/pve
    可开设KVM虚拟化的虚拟机、LXC虚拟化的容器
    2、incus:https://github.com/oneclickvirt/incus
    可开设LXC虚拟化的容器
    3、Docker:https://github.com/spiritLHLS/docker
    可开设Docker虚拟化的容器
    4、LXD:https://github.com/oneclickvirt/lxd
    可开设LXC虚拟化的容器

    二、各种要求
    建议debian在使用前尽量使用最新的稳定版本的系统, 不要在动态IP的服务器上使用本套脚本(重启机器后自动切换本机IP的服务器暂不支持,重启机器后IP不自动切换的支持)
    本项目的一键安装脚本只适配Debian系统,非Debian无法通过APT源安装,官方只给了Debian的镜像,其他系统只能使用ISO安装,或使用自定义分区和常见问题分区中的其他方式解决问题。

    开设虚拟内存(SWAP)
    单位换算:输入 1024 产生 1G SWAP-虚拟内存,虚拟内存占用硬盘空间,当实际内存不够用时将自动使用虚拟内存做内存使用,但随之带来IO高占用以及CPU性能占用

    建议只开实际内存大小两倍大小的虚拟内存
    国际:

    国内:

    curl -L https://cdn.spiritlhl.net/https://raw.githubusercontent.com/spiritLHLS/addswap/main/addswap.sh -o addswap.sh && chmod +x addswap.sh && bash addswap.sh

    检测环境
    本项目相关脚本执行前务必执行本脚本检测环境,如果不符合安装PVE的要求则无法使用后续的脚本
    检测本机IPV6的网络配置情况(有无IPV6都可安装,只是查询一下罢了)
    检测硬件配置是否满足最低要求
    检测硬件环境是否可嵌套虚拟化KVM类型的服务器
    检测系统环境是否可嵌套虚拟化KVM类型的服务器
    不可嵌套虚拟化KVM类型的服务器也可以开LXC虚拟化的服务器,但不推荐安装PVE,不如使用LXD
    国际:

    bash <(wget -qO- --no-check-certificate https://raw.githubusercontent.com/spiritLHLS/pve/main/scripts/check_kernal.sh)

    国内:

    bash <(wget -qO- --no-check-certificate https://cdn.spiritlhl.net/https://raw.githubusercontent.com/spiritLHLS/pve/main/scripts/check_kernal.sh)

    如果你需要更新IPV6信息再查询,那么执行以下命令后再查询

    rm -rf /usr/local/bin/pve_ipv6*
    rm -rf /usr/local/bin/pve_check_ipv6*
    rm -rf /usr/local/bin/pve_last_ipv6*

    三、主体安装
    安装过程中遇到选项不会选的可无脑按回车,本项目所有脚本内置国内外IP自动判断,使用的是不同的安装源与配置文件,有使用CDN加速镜像下载

    1、一键安装PVE
    国际:

    curl -L https://raw.githubusercontent.com/spiritLHLS/pve/main/scripts/install_pve.sh -o install_pve.sh && chmod +x install_pve.sh && bash install_pve.sh

    国内:

    curl -L https://cdn.spiritlhl.net/https://raw.githubusercontent.com/spiritLHLS/pve/main/scripts/install_pve.sh -o install_pve.sh && chmod +x install_pve.sh && bash install_pve.sh

    安装成功后打开网页可能提示不安全,点击高级或更多选项,坚持访问即可,登录的信息是你SSH的账户和密码

    2、预配置环境
    国际:

    bash <(wget -qO- --no-check-certificate https://raw.githubusercontent.com/spiritLHLS/pve/main/scripts/build_backend.sh)

    国内:

    bash <(wget -qO- --no-check-certificate https://cdn.spiritlhl.net/https://raw.githubusercontent.com/spiritLHLS/pve/main/scripts/build_backend.sh)

    3、自动配置宿主机的网关
    国际:

    bash <(wget -qO- --no-check-certificate https://raw.githubusercontent.com/spiritLHLS/pve/main/scripts/build_nat_network.sh)

    国内:

    bash <(wget -qO- --no-check-certificate https://cdn.spiritlhl.net/https://raw.githubusercontent.com/spiritLHLS/pve/main/scripts/build_nat_network.sh)

    这一步是可能需要你执行成功几分钟后重启系统,详见脚本最后执行完毕的提示,但重启可以保证部分隐藏设置加载成功,有条件务必重启一次服务器

    四、LXC虚拟化
    单独开设LXC虚拟化的CT,开设前请使用screen挂起执行,避免批量开设时间过长,SSH不稳定导致中间执行中断
    国际:

    curl -L https://raw.githubusercontent.com/spiritLHLS/pve/main/scripts/buildct.sh -o buildct.sh && chmod +x buildct.sh

    国内:

    curl -L https://cdn.spiritlhl.net/https://raw.githubusercontent.com/spiritLHLS/pve/main/scripts/buildct.sh -o buildct.sh && chmod +x buildct.sh

    所有系统的CT默认用户名是root
    各参数含义
    ./buildct.sh CTID 密码 CPU核数 内存 硬盘 SSH端口 80端口 443端口 外网端口起 外网端口止 系统 存储盘 独立IPV6(默认为N)
    测试示例

    ./buildct.sh 102 oneclick123 1 512 5 20001 20002 20003 30000 30025 debian11 local N

    以下为开设的示例CT的信息:
    01

    删除指定容器
    国际:

    curl -L https://raw.githubusercontent.com/spiritLHLS/pve/main/scripts/pve_delete.sh -o pve_delete.sh && chmod +x pve_delete.sh

    国内:

    curl -L https://cdn.spiritlhl.net/https://raw.githubusercontent.com/spiritLHLS/pve/main/scripts/pve_delete.sh -o pve_delete.sh && chmod +x pve_delete.sh

    可以删除对应CTID的容器,这里用上文中的示例102做演示

    ./pve_delete.sh 102

    批量开设NAT的LXC虚拟化的CT
    国际:

    curl -L https://raw.githubusercontent.com/spiritLHLS/pve/main/scripts/create_ct.sh -o create_ct.sh && chmod +x create_ct.sh && bash create_ct.sh` 
    国内: `curl -L https://cdn.spiritlhl.net/https://raw.githubusercontent.com/spiritLHLS/pve/main/scripts/create_ct.sh -o create_ct.sh && chmod +x create_ct.sh && bash create_ct.sh

    删除所有CT

    pct list | awk 'NR>1{print $1}' | xargs -I {} sh -c 'pct stop {}; pct destroy {}'
    rm -rf ct*
    iptables -t nat -F
    iptables -t filter -F
    service networking restart
    systemctl restart networking.service
    systemctl restart ndpresponder.service
    iptables-save | awk '{if($1=="COMMIT"){delete x}}$1=="-A"?!x[$0]++:1' | iptables-restore
    iptables-save > /etc/iptables/rules.v4

    开设纯IPV6地址的虚拟机(略)

    0

    评语 (0)

    取消
    您是第 24027 位访客