【IDC从入门到跑路】使用Proxmox开KVM VPS

个人开VPS我还是推荐Proxmox,因为使用起来方便,而且功能也比较全。
商家也可以使用Proxmox配合virtualizor进行自动化操作。


Proxmox的安装

使用控制面板自动安装

如果您的独立服务器支持安装Proxmox,这就是最好选择。

使用官方ISO挂载安装

如果您的服务器供应商支持iso挂载,可以选择挂载官方iso进行安装。(较为繁琐)

使用Debian9/10安装(推荐)

如果服务器供应商无法自动安装Proxmox,则可以让服务器安装Debian系统进行安装Proxmox

首选 Debian 10(buster)

在Debian 10 Buster 上安装Proxmox VE


网络配置相关

可选步骤是为了防止配置文件设置错误,导致服务器失联。

可选步骤在无控制面板和无KVM的情况下推荐使用

(可选)备份网卡文件

cp /etc/network/interfaces /etc/network/interfaces.old

编辑网卡配置文件

#如果您之前使用的多为centos系统,请安装vim编辑器

#apt update

#apt install -y vim

#vim /etc/network/interfaces

vi /etc/network/interfaces

配置文件无坑版

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
source /etc/network/interfaces.d/*

#设置本地回环
auto lo
iface lo inet loopback
iface lo inet6 loopback

#设置网卡接口,修改eth0为您本机网卡接口名
auto eth0
iface eth0 inet manual
iface eth0 inet6 manual

 

###设置外网网卡
auto vmbr0
iface vmbr0 inet static
#设置网络配置address为主机ipv4地址,netmask为子网掩码,gateway为网关地址。
address xxx.xxx.xxx.xxx
netmask xxx.xxx.xxx.xxx
gateway xxx.xxx.xxx.xxx
#设置桥接,修改eth0为您本机网卡接口名
bridge_ports eth0
bridge_stp off
bridge_fd 0
bridge_maxwait 0

#如果无IPV6地址请删除或注释。
#配置IPV6,address为主机ipv6地址,netmask为子网掩码,gateway为网关地址。
iface vmbr0 inet6 static
address 0000:0000:0000:0000:0000:0000:0000:0000
netmask 64
gateway fe80::1
#设置桥接,修改eth0为您本机网卡接口名
bridge_ports eth0
bridge_stp off
bridge_fd 0

 

### 内网网卡
auto vmbr1
iface vmbr1 inet static
#设置内网网关,address为内网网关地址,netmask为子网掩码。一般情况无需修改
address 192.168.0.1
netmask 255.255.255.0
bridge_ports none
bridge_stp off
bridge_fd 0
###解决垃圾网卡断流(可选,需要安装ethtool)修改eth0为您本机网卡接口名
#post-up /sbin/ethtool -K eth0 tx off rx off

(可选)检查备份的网络配置:

#vim /etc/network/interfaces.old

vi /etc/network/interfaces.old

示例:

auto lo
iface lo inet loopback

#ens33为本机网络接口

#如果没有auto ens33的命令需要手动添加

#看情况而定

auto ens33

iface ens33 inet manual

auto vmbr0
iface vmbr0 inet static
address 192.168.1.129/24
gateway 192.168.1.2
bridge_ports ens33
bridge_stp off
bridge_fd 0

(可选)设置网络配置文件开启自动还原

配置rc.local开机自启

Debian9/10 添加开机自启动方法 rc.local

编辑rc.local文件

#vim /etc/rc.local

vi /etc/rc.local

方法1 shell脚本判断(自己糊的,测试正常)

在exit 0之前添加命令

bash /root/proxmox_networking_reset.sh

创建脚本

cat > /root/proxmox_networking_reset.sh <<EOF
#!/bin/bash
sleep 10
#检测网络链接畅通
curl 1.1.1.1 > /dev/null 2>&1
if [ \$? -eq 0 ];then
echo "检测网络正常"
else
echo "检测网络连接异常"
cp /etc/network/interfaces.old /etc/network/interfaces
sleep 5
service networking restart
fi

EOF

方法2 无任何判断 绝对不会出错

在exit 0之前添加命令

cp /etc/network/interfaces.old /etc/network/interfaces
sleep 5
service networking restart

添加自动重启

#打开crontab配置文件

crontab -e

#添加每十分钟重启一次命令

*/10 * * * * /sbin/reboot

#注意下时间,别在下一秒内重启了

#示例12:19分添加保存文件,会在12:20分重启

 

重启网络(尽人事听天命)

service networking restart

如果一切正常,并且您进行了可选步骤,请删除或者注释在 /etc/rc.local文件、crontab文件,添加的命令。

如果服务器失联,并进行了可选步骤,请等待每个10分的自动重启并还原配置文件。

如果您服务器提供vKvm,ipmi等服务,请自行检查网络文件的错误。


创建VPS

 

 

未经允许不得转载:VPSBOOM!!! » 【IDC从入门到跑路】使用Proxmox开KVM VPS

赞 (7)

评论